diff options
author | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-03-22 20:04:01 +0000 |
---|---|---|
committer | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-03-22 20:04:01 +0000 |
commit | 02d0c9fb149b22a67a6d0f0a0a4f3a757c901f16 (patch) | |
tree | 041845b33a197fa5cdae95b93c70fce5ba40096e /tools/tests | |
parent | 2ad15d851f8c1e543cb43901adbbcb649ea7ef74 (diff) | |
download | xen-02d0c9fb149b22a67a6d0f0a0a4f3a757c901f16.tar.gz xen-02d0c9fb149b22a67a6d0f0a0a4f3a757c901f16.tar.bz2 xen-02d0c9fb149b22a67a6d0f0a0a4f3a757c901f16.zip |
bitkeeper revision 1.1236.1.114 (42407a31Nf9p7AkNdYSNJUqcXa7-NA)
Fix XCHG instruction emulation.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/tests')
-rw-r--r-- | tools/tests/test_x86_emulator.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/tools/tests/test_x86_emulator.c b/tools/tests/test_x86_emulator.c index 4347727488..e6df8092bc 100644 --- a/tools/tests/test_x86_emulator.c +++ b/tools/tests/test_x86_emulator.c @@ -134,9 +134,42 @@ int main(int argc, char **argv) goto fail; printf("okay\n"); + printf("%-40s", "Testing lock cmpxchgb %%cl,(%%eax)..."); + instr[0] = 0xf0; instr[1] = 0x0f; instr[2] = 0xb0; instr[3] = 0x08; + regs.eflags = 0x200; + regs.eip = (unsigned long)&instr[0]; + regs.eax = 0xAABBCC77UL; + regs.ecx = 0xFF; + cr2 = (unsigned long)&res; + rc = x86_emulate_memop(®s, cr2, &emulops, 4); + if ( (rc != 0) || + (res != 0x923456AA) || + ((regs.eflags&0x240) != 0x200) || + (regs.eax != 0xAABBCCAA) || + (regs.ecx != 0xFF) || + (regs.eip != (unsigned long)&instr[4]) ) + goto fail; + printf("okay\n"); + + printf("%-40s", "Testing xchgl %%ecx,(%%eax)..."); + instr[0] = 0x87; instr[1] = 0x08; + regs.eflags = 0x200; + regs.eip = (unsigned long)&instr[0]; + regs.ecx = 0x12345678; + cr2 = (unsigned long)&res; + rc = x86_emulate_memop(®s, cr2, &emulops, 4); + if ( (rc != 0) || + (res != 0x12345678) || + (regs.eflags != 0x200) || + (regs.ecx != 0x923456AA) || + (regs.eip != (unsigned long)&instr[2]) ) + goto fail; + printf("okay\n"); + printf("%-40s", "Testing lock cmpxchgl %%ecx,(%%eax)..."); instr[0] = 0xf0; instr[1] = 0x0f; instr[2] = 0xb1; instr[3] = 0x08; regs.eflags = 0x200; + res = 0x923456AA; regs.eip = (unsigned long)&instr[0]; regs.eax = 0x923456AAUL; regs.ecx = 0xDDEEFF00L; @@ -186,7 +219,7 @@ int main(int argc, char **argv) goto fail; printf("okay\n"); - printf("%-40s", "Testing cmpxchg (%edi) [succeeding]..."); + printf("%-40s", "Testing cmpxchg8b (%edi) [succeeding]..."); instr[0] = 0x0f; instr[1] = 0xc7; instr[2] = 0x0f; regs.eflags = 0x200; regs.eax = cmpxchg8b_res[0]; @@ -205,7 +238,7 @@ int main(int argc, char **argv) goto fail; printf("okay\n"); - printf("%-40s", "Testing cmpxchg (%edi) [failing]..."); + printf("%-40s", "Testing cmpxchg8b (%edi) [failing]..."); instr[0] = 0x0f; instr[1] = 0xc7; instr[2] = 0x0f; regs.eip = (unsigned long)&instr[0]; regs.edi = (unsigned long)cmpxchg8b_res; |