• Sean Christopherson's avatar
    KVM: x86/mmu: Move slot checks from __kvm_faultin_pfn() to kvm_faultin_pfn() · cd272fc4
    Sean Christopherson authored
    Move the checks related to the validity of an access to a memslot from the
    inner __kvm_faultin_pfn() to its sole caller, kvm_faultin_pfn().  This
    allows emulating accesses to the APIC access page, which don't need to
    resolve a pfn, even if there is a relevant in-progress mmu_notifier
    invalidation.  Ditto for accesses to KVM internal memslots from L2, which
    KVM also treats as emulated MMIO.
    
    More importantly, this will allow for future cleanup by having the
    "no memslot" case bail from kvm_faultin_pfn() very early on.
    
    Go to rather extreme and gross lengths to make the change a glorified
    nop, e.g. call into __kvm_faultin_pfn() even when there is no slot, as the
    related code is very subtle.  E.g. fault->slot can be nullified if it
    points at the APIC access page, some flows in KVM x86 expect fault->pfn
    to be KVM_PFN_NOSLOT, while others check only fault->slot, etc.
    
    No functional change intended.
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Reviewed-by: default avatarKai Huang <kai.huang@intel.com>
    Message-ID: <20240228024147.41573-13-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    cd272fc4
mmu.c 207 KB