]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Don't fault-in APIC access page during initial allocation
authorSean Christopherson <seanjc@google.com>
Thu, 10 Oct 2024 18:23:38 +0000 (11:23 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Oct 2024 16:59:08 +0000 (12:59 -0400)
Drop the gfn_to_page() lookup when installing KVM's internal memslot for
the APIC access page, as KVM doesn't need to immediately fault-in the page
now that the page isn't pinned.  In the extremely unlikely event the
kernel can't allocate a 4KiB page, KVM can just as easily return -EFAULT
on the future page fault.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
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-37-seanjc@google.com>

arch/x86/kvm/lapic.c

index 20526e4d6c6257b4c73c4fe75bbbe90cbd49c60a..65412640cfc77f12d4ba3b562c9207bc517ad07a 100644 (file)
@@ -2647,7 +2647,6 @@ void kvm_apic_update_apicv(struct kvm_vcpu *vcpu)
 
 int kvm_alloc_apic_access_page(struct kvm *kvm)
 {
-       struct page *page;
        void __user *hva;
        int ret = 0;
 
@@ -2663,17 +2662,6 @@ int kvm_alloc_apic_access_page(struct kvm *kvm)
                goto out;
        }
 
-       page = gfn_to_page(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT);
-       if (!page) {
-               ret = -EFAULT;
-               goto out;
-       }
-
-       /*
-        * Do not pin the page in memory, so that memory hot-unplug
-        * is able to migrate it.
-        */
-       put_page(page);
        kvm->arch.apic_access_memslot_enabled = true;
 out:
        mutex_unlock(&kvm->slots_lock);