diff mbox

[v2,24/30] KVM: x86 emulator: during rep emulation decrement ECX only if emulation succeeded

Message ID 1268583675-3101-25-git-send-email-gleb@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gleb Natapov March 14, 2010, 4:21 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 12c630c..8f5e4c8 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2474,7 +2474,6 @@  x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
 				goto done;
 			}
 		}
-		register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
 		c->eip = ctxt->eip;
 	}
 
@@ -2943,6 +2942,9 @@  writeback:
 					 c->regs[VCPU_REGS_RDI]);
 	}
 
+	if (c->rep_prefix)
+		register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
+
 	/* Commit shadow register state. */
 	memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs);
 	kvm_rip_write(ctxt->vcpu, c->eip);