KVM: x86: NOP emulation clears (incorrectly) the high 32-bits of RAX
authorNadav Amit <namit@cs.technion.ac.il>
Sun, 15 Jun 2014 13:13:01 +0000 (16:13 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 19 Jun 2014 10:52:10 +0000 (12:52 +0200)
On long-mode the current NOP (0x90) emulation still writes back to RAX.  As a
result, EAX is zero-extended and the high 32-bits of RAX are cleared.

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

index 6f09b2e555ef1ce797bc24a3c074bb95a22e24e2..84dc4ba0364dae1ed5d05ea8972bdb0e98b70f47 100644 (file)
@@ -4688,8 +4688,9 @@ special_insn:
                break;
        case 0x90 ... 0x97: /* nop / xchg reg, rax */
                if (ctxt->dst.addr.reg == reg_rmw(ctxt, VCPU_REGS_RAX))
-                       break;
-               rc = em_xchg(ctxt);
+                       ctxt->dst.type = OP_NONE;
+               else
+                       rc = em_xchg(ctxt);
                break;
        case 0x98: /* cbw/cwde/cdqe */
                switch (ctxt->op_bytes) {