]> git.karo-electronics.de Git - linux-beck.git/commitdiff
KVM: x86 emulator: fix RCX access during rep emulation
authorGleb Natapov <gleb@redhat.com>
Mon, 15 Mar 2010 14:38:29 +0000 (16:38 +0200)
committerAvi Kivity <avi@redhat.com>
Mon, 17 May 2010 09:15:47 +0000 (12:15 +0300)
During rep emulation access length to RCX depends on current address
mode.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/emulate.c

index 0b70a364f0f402455e0bd5925cfd30c6e1336cc2..4dce80560d264dddb31d57f0fc5d835de5521124 100644 (file)
@@ -1852,7 +1852,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
 
        if (c->rep_prefix && (c->d & String)) {
                /* All REP prefixes have the same first termination condition */
-               if (c->regs[VCPU_REGS_RCX] == 0) {
+               if (address_mask(c, c->regs[VCPU_REGS_RCX]) == 0) {
                        kvm_rip_write(ctxt->vcpu, c->eip);
                        goto done;
                }
@@ -1876,7 +1876,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
                                goto done;
                        }
                }
-               c->regs[VCPU_REGS_RCX]--;
+               register_address_increment(c, &c->regs[VCPU_REGS_RCX], -1);
                c->eip = kvm_rip_read(ctxt->vcpu);
        }