]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
KVM: x86: Fix update RCX/RDI/RSI on REP-string
authorNadav Amit <namit@cs.technion.ac.il>
Tue, 28 Apr 2015 10:06:00 +0000 (13:06 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 19 May 2015 18:52:35 +0000 (20:52 +0200)
When REP-string instruction is preceded with an address-size prefix,
ECX/EDI/ESI are used as the operation counter and pointers.  When they are
updated, the high 32-bits of RCX/RDI/RSI are cleared, similarly to the way they
are updated on every 32-bit register operation.  Fix it.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/emulate.c

index b32a38e6e287c8588ca60aea73583b485f282a0b..e8c03be83e48a335dbeed56b4cdbaa3e5d81b40e 100644 (file)
@@ -524,13 +524,9 @@ static void masked_increment(ulong *reg, ulong mask, int inc)
 static inline void
 register_address_increment(struct x86_emulate_ctxt *ctxt, int reg, int inc)
 {
-       ulong mask;
+       ulong *preg = reg_rmw(ctxt, reg);
 
-       if (ctxt->ad_bytes == sizeof(unsigned long))
-               mask = ~0UL;
-       else
-               mask = ad_mask(ctxt);
-       masked_increment(reg_rmw(ctxt, reg), mask, inc);
+       assign_register(preg, *preg + inc, ctxt->ad_bytes);
 }
 
 static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc)