Commit d9271123 authored by Gleb Natapov's avatar Gleb Natapov Committed by Avi Kivity

KVM: x86 emulator: during rep emulation decrement ECX only if emulation succeeded

Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent a682e354
...@@ -2411,13 +2411,13 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt, ...@@ -2411,13 +2411,13 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
} }
static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned long base, static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned long base,
int reg, unsigned long **ptr) int reg, struct operand *op)
{ {
struct decode_cache *c = &ctxt->decode; struct decode_cache *c = &ctxt->decode;
int df = (ctxt->eflags & EFLG_DF) ? -1 : 1; int df = (ctxt->eflags & EFLG_DF) ? -1 : 1;
register_address_increment(c, &c->regs[reg], df * c->src.bytes); register_address_increment(c, &c->regs[reg], df * op->bytes);
*ptr = (unsigned long *)register_address(c, base, c->regs[reg]); op->ptr = (unsigned long *)register_address(c, base, c->regs[reg]);
} }
int int
...@@ -2483,7 +2483,6 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -2483,7 +2483,6 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
goto done; goto done;
} }
} }
register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
c->eip = ctxt->eip; c->eip = ctxt->eip;
} }
...@@ -2936,11 +2935,13 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -2936,11 +2935,13 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
if ((c->d & SrcMask) == SrcSI) if ((c->d & SrcMask) == SrcSI)
string_addr_inc(ctxt, seg_override_base(ctxt, c), VCPU_REGS_RSI, string_addr_inc(ctxt, seg_override_base(ctxt, c), VCPU_REGS_RSI,
&c->src.ptr); &c->src);
if ((c->d & DstMask) == DstDI) if ((c->d & DstMask) == DstDI)
string_addr_inc(ctxt, es_base(ctxt), VCPU_REGS_RDI, string_addr_inc(ctxt, es_base(ctxt), VCPU_REGS_RDI, &c->dst);
&c->dst.ptr);
if (c->rep_prefix && (c->d & String))
register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
/* Commit shadow register state. */ /* Commit shadow register state. */
memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs); memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs);
......
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