From: Andrew Cooper Date: Fri, 24 Feb 2017 18:12:19 +0000 (+0000) Subject: x86/emul: Fix sarx emulation test X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~2681 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4f888208147432d6f7cc0a1f8d5445c927549d7b;p=xen.git 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 usual behaviour of 32bit operations on 64bit registers. 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 Reviewed-by: Jan Beulich --- diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c index 71e3b969c2..37d00f1f44 100644 --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -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;