[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d84d9853-d055-50b6-669f-de2f24304f15@redhat.com>
Date: Fri, 20 May 2022 17:24:51 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Lai Jiangshan <jiangshanlai@...il.com>,
David Woodhouse <dwmw@...zon.co.uk>,
Mingwei Zhang <mizhang@...gle.com>
Subject: Re: [PATCH v3 6/8] KVM: Fully serialize gfn=>pfn cache refresh via
mutex
On 4/29/22 23:00, Sean Christopherson wrote:
> diff --git a/virt/kvm/pfncache.c b/virt/kvm/pfncache.c
> index 05cb0bcbf662..eaef31462bbe 100644
> --- a/virt/kvm/pfncache.c
> +++ b/virt/kvm/pfncache.c
> @@ -157,6 +157,13 @@ int kvm_gfn_to_pfn_cache_refresh(struct kvm *kvm, struct gfn_to_pfn_cache *gpc,
> if (page_offset + len > PAGE_SIZE)
> return -EINVAL;
>
> + /*
> + * If another task is refreshing the cache, wait for it to complete.
> + * There is no guarantee that concurrent refreshes will see the same
> + * gpa, memslots generation, etc..., so they must be fully serialized.
> + */
> + mutex_lock(&gpc->refresh_lock);
> +
> write_lock_irq(&gpc->lock);
>
> old_pfn = gpc->pfn;
> @@ -248,6 +255,8 @@ int kvm_gfn_to_pfn_cache_refresh(struct kvm *kvm, struct gfn_to_pfn_cache *gpc,
> out:
> write_unlock_irq(&gpc->lock);
>
> + mutex_unlock(&gpc->refresh_lock);
> +
> gpc_release_pfn_and_khva(kvm, old_pfn, old_khva);
>
> return ret;
Does kvm_gfn_to_pfn_cache_unmap also need to take the mutex, to avoid
the WARN_ON(gpc->valid)?
Paolo
Powered by blists - more mailing lists