KVM: x86/mmu: Exit to userspace on make_mmu_pages_available() error
authorSean Christopherson <sean.j.christopherson@intel.com>
Tue, 23 Jun 2020 19:35:42 +0000 (12:35 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Jul 2020 20:21:52 +0000 (16:21 -0400)
Propagate any error returned by make_mmu_pages_available() out to
userspace instead of resuming the guest if the error occurs while
handling a page fault.  Now that zapping the oldest MMU pages skips
active roots, i.e. fails if and only if there are no zappable pages,
there is no chance for a false positive, i.e. no chance of returning a
spurious error to userspace.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20200623193542.7554-5-sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/paging_tmpl.h

index 8083ec3..53d6bd0 100644 (file)
@@ -4148,7 +4148,8 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
        spin_lock(&vcpu->kvm->mmu_lock);
        if (mmu_notifier_retry(vcpu->kvm, mmu_seq))
                goto out_unlock;
-       if (make_mmu_pages_available(vcpu) < 0)
+       r = make_mmu_pages_available(vcpu);
+       if (r)
                goto out_unlock;
        r = __direct_map(vcpu, gpa, write, map_writable, max_level, pfn,
                         prefault, is_tdp && lpage_disallowed);
index 7e370d8..4ec044a 100644 (file)
@@ -866,7 +866,8 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code,
                goto out_unlock;
 
        kvm_mmu_audit(vcpu, AUDIT_PRE_PAGE_FAULT);
-       if (make_mmu_pages_available(vcpu) < 0)
+       r = make_mmu_pages_available(vcpu);
+       if (r)
                goto out_unlock;
        r = FNAME(fetch)(vcpu, addr, &walker, write_fault, max_level, pfn,
                         map_writable, prefault, lpage_disallowed);