Commit 361cad2b authored by Avi Kivity's avatar Avi Kivity

KVM: x86 emulator: fix byte-sized MOVZX/MOVSX

Commit 2adb5ad9 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: default avatarAvi Kivity <avi@redhat.com>
parent 2dd7caa0
...@@ -4517,12 +4517,12 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -4517,12 +4517,12 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
break; break;
case 0xb6 ... 0xb7: /* movzx */ case 0xb6 ... 0xb7: /* movzx */
ctxt->dst.bytes = ctxt->op_bytes; 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; : (u16) ctxt->src.val;
break; break;
case 0xbe ... 0xbf: /* movsx */ case 0xbe ... 0xbf: /* movsx */
ctxt->dst.bytes = ctxt->op_bytes; 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; (s16) ctxt->src.val;
break; break;
case 0xc0 ... 0xc1: /* xadd */ case 0xc0 ... 0xc1: /* xadd */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment