summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2024-10-10 20:23:49 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2024-10-25 19:00:47 +0200
commit8dd861cc07e238c1474bb0903caf8cd3b5b5e2b4 (patch)
treea27718ef6b4c4eb45f98c69de768efaf12203051 /arch
parentKVM: guest_memfd: Provide "struct page" as output from kvm_gmem_get_pfn() (diff)
downloadlinux-8dd861cc07e238c1474bb0903caf8cd3b5b5e2b4.tar.xz
linux-8dd861cc07e238c1474bb0903caf8cd3b5b5e2b4.zip
KVM: x86/mmu: Put refcounted pages instead of blindly releasing pfns
Now that all x86 page fault paths precisely track refcounted pages, use Use kvm_page_fault.refcounted_page to put references to struct page memory when finishing page faults. This is a baby step towards eliminating kvm_pfn_to_refcounted_page(). Tested-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Sean Christopherson <seanjc@google.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20241010182427.1434605-48-seanjc@google.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/mmu/mmu.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index c657c3c449c8..fe3f3bc0bb79 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -4380,6 +4380,9 @@ static void kvm_mmu_finish_page_fault(struct kvm_vcpu *vcpu,
lockdep_assert_once(lockdep_is_held(&vcpu->kvm->mmu_lock) ||
r == RET_PF_RETRY);
+ if (!fault->refcounted_page)
+ return;
+
/*
* If the page that KVM got from the *primary MMU* is writable, and KVM
* installed or reused a SPTE, mark the page/folio dirty. Note, this
@@ -4391,9 +4394,9 @@ static void kvm_mmu_finish_page_fault(struct kvm_vcpu *vcpu,
* folio dirty if KVM could locklessly make the SPTE writable.
*/
if (!fault->map_writable || r == RET_PF_RETRY)
- kvm_release_pfn_clean(fault->pfn);
+ kvm_release_page_clean(fault->refcounted_page);
else
- kvm_release_pfn_dirty(fault->pfn);
+ kvm_release_page_dirty(fault->refcounted_page);
}
static int kvm_mmu_faultin_pfn_private(struct kvm_vcpu *vcpu,