]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86/mmu: Put direct prefetched pages via kvm_release_page_clean()
authorSean Christopherson <seanjc@google.com>
Thu, 10 Oct 2024 18:23:40 +0000 (11:23 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Oct 2024 16:59:08 +0000 (12:59 -0400)
Use kvm_release_page_clean() to put prefeteched pages instead of calling
put_page() directly.  This will allow de-duplicating the prefetch code
between indirect and direct MMUs.

Note, there's a small functional change as kvm_release_page_clean() marks
the page/folio as accessed.  While it's not strictly guaranteed that the
guest will access the page, KVM won't intercept guest accesses, i.e. won't
mark the page accessed if it _is_ accessed by the guest (unless A/D bits
are disabled, but running without A/D bits is effectively limited to
pre-HSW Intel CPUs).

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-39-seanjc@google.com>

arch/x86/kvm/mmu/mmu.c

index 7dcd34628f49d92946f130cd2c9519e7523547f2..5e0c91f017f778bc32ff845263300750656f3221 100644 (file)
@@ -2972,7 +2972,7 @@ static int direct_pte_prefetch_many(struct kvm_vcpu *vcpu,
        for (i = 0; i < ret; i++, gfn++, start++) {
                mmu_set_spte(vcpu, slot, start, access, gfn,
                             page_to_pfn(pages[i]), NULL);
-               put_page(pages[i]);
+               kvm_release_page_clean(pages[i]);
        }
 
        return 0;