Commit 575e7c14 authored by Takuya Yoshikawa's avatar Takuya Yoshikawa Committed by Avi Kivity

KVM: x86 emulator: Disable writeback for CMP emulation

This stops "CMP r/m, reg" to write back the data into memory.
Pointed out by Avi.

The writeback suppression now covers CMP, CMPS, SCAS.
Signed-off-by: default avatarTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent be6d05cf
...@@ -3671,6 +3671,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -3671,6 +3671,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
break; break;
case 0x38 ... 0x3d: case 0x38 ... 0x3d:
cmp: /* cmp */ cmp: /* cmp */
c->dst.type = OP_NONE; /* Disable writeback. */
emulate_2op_SrcV("cmp", c->src, c->dst, ctxt->eflags); emulate_2op_SrcV("cmp", c->src, c->dst, ctxt->eflags);
break; break;
case 0x40 ... 0x47: /* inc r16/r32 */ case 0x40 ... 0x47: /* inc r16/r32 */
...@@ -3797,7 +3798,6 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ...@@ -3797,7 +3798,6 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
rc = emulate_popf(ctxt, ops, &c->dst.val, c->op_bytes); rc = emulate_popf(ctxt, ops, &c->dst.val, c->op_bytes);
break; break;
case 0xa6 ... 0xa7: /* cmps */ case 0xa6 ... 0xa7: /* cmps */
c->dst.type = OP_NONE; /* Disable writeback. */
goto cmp; goto cmp;
case 0xa8 ... 0xa9: /* test ax, imm */ case 0xa8 ... 0xa9: /* test ax, imm */
goto test; goto test;
......
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