KVM: x86/mmu: Skip mmu_notifier check when handling MMIO page fault
authorSean Christopherson <seanjc@google.com>
Mon, 22 Feb 2021 02:45:21 +0000 (11:45 +0900)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 22 Feb 2021 18:13:30 +0000 (13:13 -0500)
Don't retry a page fault due to an mmu_notifier invalidation when
handling a page fault for a GPA that did not resolve to a memslot, i.e.
an MMIO page fault.  Invalidations from the mmu_notifier signal a change
in a host virtual address (HVA) mapping; without a memslot, there is no
HVA and thus no possibility that the invalidation is relevant to the
page fault being handled.

Note, the MMIO vs. memslot generation checks handle the case where a
pending memslot will create a memslot overlapping the faulting GPA.  The
mmu_notifier checks are orthogonal to memslot updates.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210222024522.1751719-2-stevensd@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/paging_tmpl.h

index 6e78d8e51aa2c569484b3c00934a6fa41c169d36..752b4b7ab01b49791a61fde18b3e6e6cf090e640 100644 (file)
@@ -3712,7 +3712,7 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
        else
                write_lock(&vcpu->kvm->mmu_lock);
 
-       if (mmu_notifier_retry(vcpu->kvm, mmu_seq))
+       if (!is_noslot_pfn(pfn) && mmu_notifier_retry(vcpu->kvm, mmu_seq))
                goto out_unlock;
        r = make_mmu_pages_available(vcpu);
        if (r)
index d9f66cc459e84993b08752529d45c514f0435e8d..5844d3979bb8cd6f67dd7733fad22bd23518459c 100644 (file)
@@ -869,7 +869,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code,
 
        r = RET_PF_RETRY;
        write_lock(&vcpu->kvm->mmu_lock);
-       if (mmu_notifier_retry(vcpu->kvm, mmu_seq))
+       if (!is_noslot_pfn(pfn) && mmu_notifier_retry(vcpu->kvm, mmu_seq))
                goto out_unlock;
 
        kvm_mmu_audit(vcpu, AUDIT_PRE_PAGE_FAULT);