KVM: x86: smsw emulation is incorrect in 64-bit mode
authorNadav Amit <namit@cs.technion.ac.il>
Mon, 2 Jun 2014 15:34:11 +0000 (18:34 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 18 Jun 2014 15:46:19 +0000 (17:46 +0200)
In 64-bit mode, when the destination is a register, the assignment is done
according to the operand size. Otherwise (memory operand or no 64-bit mode), a
16-bit assignment is performed.

Currently, 16-bit assignment is always done to the destination.

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

index a151f8d24a1df11296614c95604f24941a5b82c2..9b5d97db7631393f5aa645eb55fbf0ff0576135f 100644 (file)
@@ -3235,7 +3235,8 @@ static int em_lidt(struct x86_emulate_ctxt *ctxt)
 
 static int em_smsw(struct x86_emulate_ctxt *ctxt)
 {
-       ctxt->dst.bytes = 2;
+       if (ctxt->dst.type == OP_MEM)
+               ctxt->dst.bytes = 2;
        ctxt->dst.val = ctxt->ops->get_cr(ctxt, 0);
        return X86EMUL_CONTINUE;
 }