KVM: x86 emulator: fix byte-sized MOVZX/MOVSX
authorAvi Kivity <avi@redhat.com>
Mon, 11 Jun 2012 16:40:15 +0000 (19:40 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 9 Jul 2012 11:19:03 +0000 (14:19 +0300)
Commit 2adb5ad9fe1 removed ByteOp from MOVZX/MOVSX, replacing them by
SrcMem8, but neglected to fix the dependency in the emulation code
on ByteOp.  This caused the instruction not to have any effect in
some circumstances.

Fix by replacing the check for ByteOp with the equivalent src.op_bytes == 1.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/emulate.c

index 90b549ed89970742995bdf51761a2650433316cb..30f4912c6a6779ca935a28ff3b46c649c8f27c0e 100644 (file)
@@ -4517,12 +4517,12 @@ twobyte_insn:
                break;
        case 0xb6 ... 0xb7:     /* movzx */
                ctxt->dst.bytes = ctxt->op_bytes;
-               ctxt->dst.val = (ctxt->d & ByteOp) ? (u8) ctxt->src.val
+               ctxt->dst.val = (ctxt->src.bytes == 1) ? (u8) ctxt->src.val
                                                       : (u16) ctxt->src.val;
                break;
        case 0xbe ... 0xbf:     /* movsx */
                ctxt->dst.bytes = ctxt->op_bytes;
-               ctxt->dst.val = (ctxt->d & ByteOp) ? (s8) ctxt->src.val :
+               ctxt->dst.val = (ctxt->src.bytes == 1) ? (s8) ctxt->src.val :
                                                        (s16) ctxt->src.val;
                break;
        case 0xc0 ... 0xc1:     /* xadd */
This page took 0.027805 seconds and 5 git commands to generate.