]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86/mmu: Convert page fault paths to kvm_faultin_pfn()
authorSean Christopherson <seanjc@google.com>
Thu, 10 Oct 2024 18:23:46 +0000 (11:23 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Oct 2024 17:00:47 +0000 (13:00 -0400)
Convert KVM x86 to use the recently introduced __kvm_faultin_pfn().
Opportunstically capture the refcounted_page grabbed by KVM for use in
future changes.

No functional change intended.

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

arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/mmu_internal.h

index 6058e7dbcd2be0c71832a6e0fb2e9186f71fb6b2..2bea2d20c57107829b3416186bddc5398c08fa2a 100644 (file)
@@ -4423,11 +4423,14 @@ static int kvm_mmu_faultin_pfn_private(struct kvm_vcpu *vcpu,
 static int __kvm_mmu_faultin_pfn(struct kvm_vcpu *vcpu,
                                 struct kvm_page_fault *fault)
 {
+       unsigned int foll = fault->write ? FOLL_WRITE : 0;
+
        if (fault->is_private)
                return kvm_mmu_faultin_pfn_private(vcpu, fault);
 
-       fault->pfn = __gfn_to_pfn_memslot(fault->slot, fault->gfn, false, true,
-                                         fault->write, &fault->map_writable);
+       foll |= FOLL_NOWAIT;
+       fault->pfn = __kvm_faultin_pfn(fault->slot, fault->gfn, foll,
+                                      &fault->map_writable, &fault->refcounted_page);
 
        /*
         * If resolving the page failed because I/O is needed to fault-in the
@@ -4454,8 +4457,11 @@ static int __kvm_mmu_faultin_pfn(struct kvm_vcpu *vcpu,
         * to wait for IO.  Note, gup always bails if it is unable to quickly
         * get a page and a fatal signal, i.e. SIGKILL, is pending.
         */
-       fault->pfn = __gfn_to_pfn_memslot(fault->slot, fault->gfn, true, true,
-                                         fault->write, &fault->map_writable);
+       foll |= FOLL_INTERRUPTIBLE;
+       foll &= ~FOLL_NOWAIT;
+       fault->pfn = __kvm_faultin_pfn(fault->slot, fault->gfn, foll,
+                                      &fault->map_writable, &fault->refcounted_page);
+
        return RET_PF_CONTINUE;
 }
 
index 59e600f6ff9df9acf75fa952f29a1b0ef9d30bec..fabbea504a690c68b9ef43938744b87eeffba1f6 100644 (file)
@@ -238,6 +238,7 @@ struct kvm_page_fault {
        /* Outputs of kvm_mmu_faultin_pfn().  */
        unsigned long mmu_seq;
        kvm_pfn_t pfn;
+       struct page *refcounted_page;
        bool map_writable;
 
        /*