]> xenbits.xensource.com Git - xen.git/commitdiff
x86_emulate: fix EFLAGS setting of CMPXCHG emulation
authorEugene Korenevsky <ekorenevsky@gmail.com>
Mon, 4 May 2015 09:55:41 +0000 (11:55 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 4 May 2015 09:55:41 +0000 (11:55 +0200)
CMPXCHG sets CF, PF, AF, SF, and OF flags according to the results of the
comparison the rAX with the operand of the instruction.
rAX must be the first argument of the comparison (a minuend), the operand
must be the second one (a subtrahend).

Due to improper order of comparison arguments, CF, PF, AF, SF and OF flags were
set incorrectly in the case of inequality. Need to swap them.

Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
xen/arch/x86/x86_emulate/x86_emulate.c

index ae32c82d2f1def733099e5b63b647e807e5e4bd8..6c6c58a8ea0292fc52a188663e0d9dd17e83e89f 100644 (file)
@@ -4343,7 +4343,8 @@ x86_emulate(
         /* Save real source value, then compare EAX against destination. */
         src.orig_val = src.val;
         src.val = _regs.eax;
-        emulate_2op_SrcV("cmp", src, dst, _regs.eflags);
+        /* cmp: %%eax - dst ==> dst and src swapped for macro invocation */
+        emulate_2op_SrcV("cmp", dst, src, _regs.eflags);
         if ( _regs.eflags & EFLG_ZF )
         {
             /* Success: write back to memory. */