x86/emul: Fix sarx emulation test
PATCH 1/1 x86/emul: Fix sarx emulation test
The emulation tests run sarx %edx,(%ecx),%ebx with 0xfedcba98 pointed at by %ecx, and 0xff13 in %rdx.
As the instruction uses a 32bit operand size, the expected result is 0x00000000ffffffdb in %rbx (rather than 0xffffffffffffffdb), due to normal usual zeroing of the upper half of the 64bit register.
The test harness was incorrectly sign extending from 32 bits to 64 bits rather than zero extending when checking the result of emulation, causing a false negative failure.
---
CC: Jan Beulich <[email protected]>
--- tools/tests/x86_emulator/test_x86_emulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tests/x86_emulator/test_x86_emulator.c +1 -1
@@ -1155,7 +1155,7 @@ int main(int argc, char **argv) regs.eflags =0xa43 ; rc =x86_emulate (&ctxt, &emulops);if ( (rc !=X86EMUL_OKAY ) || - regs.ebx != ((signed )*res >> (regs.edx &0x1f )) || + regs.ebx != (unsigned )(((signed )*res >> (regs.edx &0x1f ))) || regs.edx !=0xff13 || *res !=0xfedcba98 || regs.eflags !=0xa43 || !check_eip (sarx) ) goto fail;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Andrew Cooper <[email protected]> 02/24/17 7:14 PM >>>
The emulation tests run
sarx %edx,(%ecx),%ebxwith0xfedcba98pointed at by %ecx, and0xff13in %rdx.As the instruction uses a 32bit operand size, the expected result is
0x00000000ffffffdbin %rbx (rather than0xffffffffffffffdb), due to normal usual zeroing of the upper half of the 64bit register.
Quoted 5 lines
The test harness was incorrectly sign extending from 32 bits to 64 bits rather than zero extending when checking the result of emulation, causing a false negative failure.
Signed-off-by Andrew Cooper <[email protected]>
tools/tests/x86_emulator/test_x86_emulator.c int main(int argc, char **argv) · line 1158
Quoted 8 lines
tools/tests/x86_emulator/test_x86_emulator.c +0
-0@@ -1155,7 +1155,7 @@ int main(int argc, char **argv) regs.eflags =0xa43 ; rc =x86_emulate (&ctxt, &emulops);if ( (rc !=
X86EMUL_OKAY) ||tools/tests/x86_emulator/test_x86_emulator.c +1
-1- regs.ebx != ((signed)*res >> (regs.edx & 0x1f)) || + regs.ebx != (unsigned)(((signed)*res >> (regs.edx & 0x1f))) ||
If "ebx" was what its name says, there wouldn't have been a problem.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel