Re: [PATCH v2 3/4] KVM: SEV: Drop page refcount early in VMSA reload
Michael Roth <[email protected]>
| Newsgroups | gmane.linux.kernel,gmane.comp.emulators.kvm.devel,gmane.linux.ports.arm.kernel |
|---|---|
| Message-ID | <thruecnqp72ii7bx3lfzlzhxs3u7pypfiu4hvkhwkpe2otnksg@vbaawawu3qo4> |
On Tue, Aug 18, 2026 at 09:15:54AM +0000, Ackerley Tng wrote: > When reloading the guest VMSA for an SEV-SNP vCPU, KVM retrieves the PFN > from guest_memfd. > > Drop the page reference immediately after retrieving the PFN instead of > holding it across MMU lock acquisition in preparation for a follow-up patch > to stop returning page pointers from guest_memfd PFN lookups. > > This is safe because the page's validity and presence are governed by KVM's > MMU invalidation protocol rather than the page reference. > > No functional change intended. > > Signed-off-by: Ackerley Tng <[email protected]> Reviewed-by: Michael Roth <[email protected]> > --- > arch/x86/kvm/svm/sev.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index b34b11d7f8fad..d3d620bc04dce 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -4062,6 +4062,7 @@ static void __sev_snp_reload_vmsa(struct kvm_vcpu *vcpu, gpa_t gpa) > */ > if (kvm_gmem_get_pfn(vcpu->kvm, slot, gfn, &pfn, &page, NULL)) > return; > + kvm_release_page_clean(page); > > read_lock(&kvm->mmu_lock); > /* > @@ -4076,8 +4077,6 @@ static void __sev_snp_reload_vmsa(struct kvm_vcpu *vcpu, gpa_t gpa) > else > svm->vmcb->control.vmsa_pa = pfn_to_hpa(pfn); > read_unlock(&kvm->mmu_lock); > - > - kvm_release_page_clean(page); > } > > /* > > -- > 2.55.0.699.gb54405d56f-goog >