@@ -5636,8 +5636,13 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
int r, emulation_type = 0;
bool direct = vcpu->arch.mmu->direct_map;
- /* With shadow page tables, fault_address contains a GVA or nGPA. */
- if (vcpu->arch.mmu->direct_map) {
+ /*
+ * With shadow page tables, fault_address contains a GVA or nGPA.
+ * On a fetch fault, fault_address contains the instruction pointer.
+ */
+ if (vcpu->arch.mmu->direct_map &&
+ likely(!(error_code & PFERR_FETCH_MASK)) &&
+ (error_code & PFERR_GUEST_FINAL_MASK)) {
vcpu->arch.gpa_available = true;
vcpu->arch.gpa_val = cr2;
}