u32 vectoring_info = vmx->idt_vectoring_info;
KVMTRACE_3D(VMEXIT, vcpu, exit_reason, (u32)kvm_rip_read(vcpu),
-@@ -3512,6 +3550,14 @@ static void vmx_vcpu_run(struct kvm_vcpu
+@@ -3257,6 +3295,14 @@ static void vmx_complete_interrupts(stru
- intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
+ exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
+ vmx->exit_reason = vmcs_read32(VM_EXIT_REASON);
+
+ kvm_machine_check();
+
/* We need to handle NMIs before interrupts are enabled */
- if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR &&
- (intr_info & INTR_INFO_VALID_MASK)) {
+ if ((exit_intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR &&
+ (exit_intr_info & INTR_INFO_VALID_MASK)) {
--- /dev/null
+From 20f65983e30f222e5383f77206e3f571d1d64610 Mon Sep 17 00:00:00 2001
+From: Gleb Natapov <gleb@redhat.com>
+Date: Mon, 11 May 2009 13:35:55 +0300
+Subject: KVM: Move "exit due to NMI" handling into vmx_complete_interrupts()
+
+From: Gleb Natapov <gleb@redhat.com>
+
+commit 20f65983e30f222e5383f77206e3f571d1d64610 upstream.
+
+To save us one reading of VM_EXIT_INTR_INFO.
+
+Signed-off-by: Gleb Natapov <gleb@redhat.com>
+Signed-off-by: Avi Kivity <avi@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/x86/kvm/vmx.c | 21 ++++++++++-----------
+ 1 file changed, 10 insertions(+), 11 deletions(-)
+
+--- a/arch/x86/kvm/vmx.c
++++ b/arch/x86/kvm/vmx.c
+@@ -3255,8 +3255,17 @@ static void vmx_complete_interrupts(stru
+ bool idtv_info_valid;
+ u32 error;
+
+- idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK;
+ exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
++
++ /* We need to handle NMIs before interrupts are enabled */
++ if ((exit_intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR &&
++ (exit_intr_info & INTR_INFO_VALID_MASK)) {
++ KVMTRACE_0D(NMI, &vmx->vcpu, handler);
++ asm("int $2");
++ }
++
++ idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK;
++
+ if (cpu_has_virtual_nmis()) {
+ unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0;
+ vector = exit_intr_info & INTR_INFO_VECTOR_MASK;
+@@ -3386,7 +3395,6 @@ static void fixup_rmode_irq(struct vcpu_
+ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
+ {
+ struct vcpu_vmx *vmx = to_vmx(vcpu);
+- u32 intr_info;
+
+ /* Record the guest's net vcpu time for enforced NMI injections. */
+ if (unlikely(!cpu_has_virtual_nmis() && vmx->soft_vnmi_blocked))
+@@ -3515,15 +3523,6 @@ static void vmx_vcpu_run(struct kvm_vcpu
+ asm("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
+ vmx->launched = 1;
+
+- intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
+-
+- /* We need to handle NMIs before interrupts are enabled */
+- if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR &&
+- (intr_info & INTR_INFO_VALID_MASK)) {
+- KVMTRACE_0D(NMI, vcpu, handler);
+- asm("int $2");
+- }
+-
+ vmx_complete_interrupts(vmx);
+ }
+
--- /dev/null
+From 7b4a25cb296e2a73d2e87a4af65361d45d450a27 Mon Sep 17 00:00:00 2001
+From: Gleb Natapov <gleb@redhat.com>
+Date: Mon, 30 Mar 2009 16:03:08 +0300
+Subject: KVM: VMX: Fix handling of a fault during NMI unblocked due to IRET
+
+From: Gleb Natapov <gleb@redhat.com>
+
+commit 7b4a25cb296e2a73d2e87a4af65361d45d450a27 upstream.
+
+Bit 12 is undefined in any of the following cases:
+ If the VM exit sets the valid bit in the IDT-vectoring information field.
+ If the VM exit is due to a double fault.
+
+Signed-off-by: Gleb Natapov <gleb@redhat.com>
+Signed-off-by: Avi Kivity <avi@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ arch/x86/kvm/vmx.c | 17 +++++++++++------
+ 1 file changed, 11 insertions(+), 6 deletions(-)
+
+--- a/arch/x86/kvm/vmx.c
++++ b/arch/x86/kvm/vmx.c
+@@ -3248,36 +3248,41 @@ static void update_tpr_threshold(struct
+ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
+ {
+ u32 exit_intr_info;
+- u32 idt_vectoring_info;
++ u32 idt_vectoring_info = vmx->idt_vectoring_info;
+ bool unblock_nmi;
+ u8 vector;
+ int type;
+ bool idtv_info_valid;
+ u32 error;
+
++ idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK;
+ exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
+ if (cpu_has_virtual_nmis()) {
+ unblock_nmi = (exit_intr_info & INTR_INFO_UNBLOCK_NMI) != 0;
+ vector = exit_intr_info & INTR_INFO_VECTOR_MASK;
+ /*
+- * SDM 3: 25.7.1.2
++ * SDM 3: 27.7.1.2 (September 2008)
+ * Re-set bit "block by NMI" before VM entry if vmexit caused by
+ * a guest IRET fault.
++ * SDM 3: 23.2.2 (September 2008)
++ * Bit 12 is undefined in any of the following cases:
++ * If the VM exit sets the valid bit in the IDT-vectoring
++ * information field.
++ * If the VM exit is due to a double fault.
+ */
+- if (unblock_nmi && vector != DF_VECTOR)
++ if ((exit_intr_info & INTR_INFO_VALID_MASK) && unblock_nmi &&
++ vector != DF_VECTOR && !idtv_info_valid)
+ vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO,
+ GUEST_INTR_STATE_NMI);
+ } else if (unlikely(vmx->soft_vnmi_blocked))
+ vmx->vnmi_blocked_time +=
+ ktime_to_ns(ktime_sub(ktime_get(), vmx->entry_time));
+
+- idt_vectoring_info = vmx->idt_vectoring_info;
+- idtv_info_valid = idt_vectoring_info & VECTORING_INFO_VALID_MASK;
+ vector = idt_vectoring_info & VECTORING_INFO_VECTOR_MASK;
+ type = idt_vectoring_info & VECTORING_INFO_TYPE_MASK;
+ if (vmx->vcpu.arch.nmi_injected) {
+ /*
+- * SDM 3: 25.7.1.2
++ * SDM 3: 27.7.1.2 (September 2008)
+ * Clear bit "block by NMI" before VM entry if a NMI delivery
+ * faulted.
+ */
firmware_map-fix-hang-with-x86-32bit.patch
fs-remove-incorrect-i_new-warnings.patch
pci-disable-aspm-on-via-root-port-under-bridge-configurations.patch
+kvm-vmx-fix-handling-of-a-fault-during-nmi-unblocked-due-to-iret.patch
+kvm-move-exit-due-to-nmi-handling-into-vmx_complete_interrupts.patch
kvm-add-vt-x-machine-check-support.patch
kvm-disable-large-pages-on-misaligned-memory-slots.patch
kvm-prevent-overflow-in-largepages-calculation.patch