KVM: Unprotect a page if #PF happens during NMI injection.
authorGleb Natapov <gleb@redhat.com>
Mon, 11 May 2009 10:35:46 +0000 (13:35 +0300)
committerAvi Kivity <avi@redhat.com>
Wed, 10 Jun 2009 08:48:57 +0000 (11:48 +0300)
It is done for exception and interrupt already.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.h

index 8b5ffbd55c11e78c31914b91cc72b97106af163c..ac3d5ba48d61274cf1315d4a0c08c5deb303e045 100644 (file)
@@ -1122,8 +1122,7 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
        if (npt_enabled)
                svm_flush_tlb(&svm->vcpu);
        else {
-               if (svm->vcpu.arch.interrupt.pending ||
-                               svm->vcpu.arch.exception.pending)
+               if (kvm_event_needs_reinjection(&svm->vcpu))
                        kvm_mmu_unprotect_page_virt(&svm->vcpu, fault_address);
        }
        return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code);
index f3ab27b5a6b2c6d42b5ef9229cd8d195f9e8cb89..8981654ad061b16827c1a6236dfe7cd554f4ad35 100644 (file)
@@ -2615,7 +2615,7 @@ static int handle_exception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
                cr2 = vmcs_readl(EXIT_QUALIFICATION);
                KVMTRACE_3D(PAGE_FAULT, vcpu, error_code, (u32)cr2,
                            (u32)((u64)cr2 >> 32), handler);
-               if (vcpu->arch.interrupt.pending || vcpu->arch.exception.pending)
+               if (kvm_event_needs_reinjection(vcpu))
                        kvm_mmu_unprotect_page_virt(vcpu, cr2);
                return kvm_mmu_page_fault(vcpu, cr2, error_code);
        }
index 39350b25272582b0838f6de5e67d5767e53db66a..21203d4212763a3fff6f03309106edb1e8f7f2c6 100644 (file)
@@ -30,4 +30,10 @@ static inline u8 kvm_pop_irq(struct kvm_vcpu *vcpu)
                clear_bit(word_index, &vcpu->arch.irq_summary);
        return irq;
 }
+
+static inline bool kvm_event_needs_reinjection(struct kvm_vcpu *vcpu)
+{
+       return vcpu->arch.exception.pending || vcpu->arch.interrupt.pending ||
+               vcpu->arch.nmi_injected;
+}
 #endif