KVM: x86: IRET emulation does not clear NMI masking
authorNadav Amit <namit@cs.technion.ac.il>
Mon, 26 Jan 2015 07:32:23 +0000 (09:32 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 26 Jan 2015 11:14:42 +0000 (12:14 +0100)
The IRET instruction should clear NMI masking, but the current implementation
does not do so.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_emulate.h
arch/x86/kvm/emulate.c
arch/x86/kvm/x86.c

index eb181178fe0b37dd00a5c0dc99c3162d1dbb817b..57a9d94fe160342036307f75e2f1f7b767b3cbf6 100644 (file)
@@ -208,6 +208,7 @@ struct x86_emulate_ops {
 
        void (*get_cpuid)(struct x86_emulate_ctxt *ctxt,
                          u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
+       void (*set_nmi_mask)(struct x86_emulate_ctxt *ctxt, bool masked);
 };
 
 typedef u32 __attribute__((vector_size(16))) sse128_t;
index dd7100481aac9b03c5fc865d02343b1e724c0cf8..fa3ca55a50c6227ec60a66fd0e845a218a9a632b 100644 (file)
@@ -2047,6 +2047,7 @@ static int emulate_iret_real(struct x86_emulate_ctxt *ctxt)
 
        ctxt->eflags &= ~EFLG_RESERVED_ZEROS_MASK; /* Clear reserved zeros */
        ctxt->eflags |= EFLG_RESERVED_ONE_MASK;
+       ctxt->ops->set_nmi_mask(ctxt, false);
 
        return rc;
 }
index afa0815bd38438bcb81b3b2ea462b4df46789dfa..cdd6606e4c543803c4b518bb4ed56d11f0a017a1 100644 (file)
@@ -4963,6 +4963,11 @@ static void emulator_write_gpr(struct x86_emulate_ctxt *ctxt, unsigned reg, ulon
        kvm_register_write(emul_to_vcpu(ctxt), reg, val);
 }
 
+static void emulator_set_nmi_mask(struct x86_emulate_ctxt *ctxt, bool masked)
+{
+       kvm_x86_ops->set_nmi_mask(emul_to_vcpu(ctxt), masked);
+}
+
 static const struct x86_emulate_ops emulate_ops = {
        .read_gpr            = emulator_read_gpr,
        .write_gpr           = emulator_write_gpr,
@@ -4998,6 +5003,7 @@ static const struct x86_emulate_ops emulate_ops = {
        .put_fpu             = emulator_put_fpu,
        .intercept           = emulator_intercept,
        .get_cpuid           = emulator_get_cpuid,
+       .set_nmi_mask        = emulator_set_nmi_mask,
 };
 
 static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)