aboutsummaryrefslogtreecommitdiffstats
path: root/tools/tests
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-12-01 13:57:46 +0000
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-12-01 13:57:46 +0000
commit2aba25fee2273946a15c8766cb252808c6f60f99 (patch)
tree6f6c2c73bcb63880be7aabcc5d93b37c288bf715 /tools/tests
parentea1248436a8ebe048ac70c5967a6904d4c78073d (diff)
downloadxen-2aba25fee2273946a15c8766cb252808c6f60f99.tar.gz
xen-2aba25fee2273946a15c8766cb252808c6f60f99.tar.bz2
xen-2aba25fee2273946a15c8766cb252808c6f60f99.zip
[XEN] Emulate XADD instruction.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/tests')
-rw-r--r--tools/tests/test_x86_emulator.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/tests/test_x86_emulator.c b/tools/tests/test_x86_emulator.c
index 31f1abcb02..e22e342ce2 100644
--- a/tools/tests/test_x86_emulator.c
+++ b/tools/tests/test_x86_emulator.c
@@ -304,6 +304,7 @@ int main(int argc, char **argv)
printf("%-40s", "Testing cmpxchg8b (%edi) [failing]...");
instr[0] = 0x0f; instr[1] = 0xc7; instr[2] = 0x0f;
+ regs.eflags = 0x200;
regs.eip = (unsigned long)&instr[0];
regs.edi = (unsigned long)res;
regs.error_code = PFEC_write_access;
@@ -320,6 +321,7 @@ int main(int argc, char **argv)
printf("%-40s", "Testing movsxbd (%%eax),%%ecx...");
instr[0] = 0x0f; instr[1] = 0xbe; instr[2] = 0x08;
+ regs.eflags = 0x200;
regs.eip = (unsigned long)&instr[0];
regs.ecx = 0x12345678;
regs.eax = (unsigned long)res;
@@ -336,6 +338,7 @@ int main(int argc, char **argv)
printf("%-40s", "Testing movzxwd (%%eax),%%ecx...");
instr[0] = 0x0f; instr[1] = 0xb7; instr[2] = 0x08;
+ regs.eflags = 0x200;
regs.eip = (unsigned long)&instr[0];
regs.ecx = 0x12345678;
regs.eax = (unsigned long)res;
@@ -350,6 +353,23 @@ int main(int argc, char **argv)
goto fail;
printf("okay\n");
+ printf("%-40s", "Testing xadd %%ax,(%%ecx)...");
+ instr[0] = 0x66; instr[1] = 0x0f; instr[2] = 0xc1; instr[3] = 0x01;
+ regs.eflags = 0x200;
+ regs.eip = (unsigned long)&instr[0];
+ regs.ecx = (unsigned long)res;
+ regs.eax = 0x12345678;
+ *res = 0x11111111;
+ regs.error_code = 0;
+ rc = x86_emulate_memop(&ctxt, &emulops);
+ if ( (rc != 0) ||
+ (*res != 0x11116789) ||
+ (regs.eax != 0x12341111) ||
+ ((regs.eflags&0x240) != 0x200) ||
+ (regs.eip != (unsigned long)&instr[4]) )
+ goto fail;
+ printf("okay\n");
+
return 0;
fail: