KVM: x86/mmu: Set kvm_page_fault.hva to KVM_HVA_ERR_BAD for "no slot" faults
authorSean Christopherson <seanjc@google.com>
Wed, 28 Feb 2024 02:41:45 +0000 (18:41 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 7 May 2024 15:59:23 +0000 (11:59 -0400)
Explicitly set fault->hva to KVM_HVA_ERR_BAD when handling a "no slot"
fault to ensure that KVM doesn't use a bogus virtual address, e.g. if
there *was* a slot but it's unusable (APIC access page), or if there
really was no slot, in which case fault->hva will be '0' (which is a
legal address for x86).

Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Message-ID: <20240228024147.41573-15-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c

index 8c7927d10d8e89a053aebdabba2037c8ebe7b9f8..f5e13f8a67c0caf19a6b0ce395e5eae5f7c496d6 100644 (file)
@@ -3272,6 +3272,7 @@ static int kvm_handle_noslot_fault(struct kvm_vcpu *vcpu,
        fault->slot = NULL;
        fault->pfn = KVM_PFN_NOSLOT;
        fault->map_writable = false;
+       fault->hva = KVM_HVA_ERR_BAD;
 
        /*
         * If MMIO caching is disabled, emulate immediately without