diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-12-20 15:16:13 +0000 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-12-20 15:16:13 +0000 |
commit | 0a967eccecfbdd4c5bf9d242ace21e30ff52b291 (patch) | |
tree | af8c0cf398b5b1d1ff22f0edaa4d17249c583613 /tools/tests | |
parent | c35c69faaeb4dda9a02ff1ce36a3de3dbbd39332 (diff) | |
download | xen-0a967eccecfbdd4c5bf9d242ace21e30ff52b291.tar.gz xen-0a967eccecfbdd4c5bf9d242ace21e30ff52b291.tar.bz2 xen-0a967eccecfbdd4c5bf9d242ace21e30ff52b291.zip |
[XEN] Emulator extensions to decode ModRM.MOD == 3.
This allows emulation of register-only instructions.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/tests')
-rw-r--r-- | tools/tests/test_x86_emulator.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/tools/tests/test_x86_emulator.c b/tools/tests/test_x86_emulator.c index 64797d3f81..bd7f1411ad 100644 --- a/tools/tests/test_x86_emulator.c +++ b/tools/tests/test_x86_emulator.c @@ -15,8 +15,6 @@ typedef int64_t s64; #include <asm-x86/x86_emulate.h> #include <sys/mman.h> -#define PFEC_write_access (1U<<1) - static int read( unsigned int seg, unsigned long offset, @@ -119,7 +117,6 @@ int main(int argc, char **argv) regs.eflags = 0x200; regs.eip = (unsigned long)&instr[0]; regs.ecx = 0x12345678; - regs.error_code = PFEC_write_access; regs.eax = (unsigned long)res; *res = 0x7FFFFFFF; rc = x86_emulate_memop(&ctxt, &emulops); @@ -130,6 +127,21 @@ int main(int argc, char **argv) goto fail; printf("okay\n"); + printf("%-40s", "Testing addl %%ecx,%%eax..."); + instr[0] = 0x01; instr[1] = 0xc8; + regs.eflags = 0x200; + regs.eip = (unsigned long)&instr[0]; + regs.ecx = 0x12345678; + regs.eax = 0x7FFFFFFF; + rc = x86_emulate_memop(&ctxt, &emulops); + if ( (rc != 0) || + (regs.ecx != 0x12345678) || + (regs.eax != 0x92345677) || + (regs.eflags != 0xa94) || + (regs.eip != (unsigned long)&instr[2]) ) + goto fail; + printf("okay\n"); + printf("%-40s", "Testing xorl (%%eax),%%ecx..."); instr[0] = 0x33; instr[1] = 0x08; regs.eflags = 0x200; @@ -140,7 +152,6 @@ int main(int argc, char **argv) regs.ecx = 0x12345678UL; #endif regs.eax = (unsigned long)res; - regs.error_code = 0; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x92345677) || @@ -155,7 +166,6 @@ int main(int argc, char **argv) regs.eip = (unsigned long)&instr[0]; regs.ecx = ~0UL; regs.eax = (unsigned long)res; - regs.error_code = 0; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x92345677) || @@ -171,7 +181,6 @@ int main(int argc, char **argv) regs.eax = 0x92345677UL; regs.ecx = 0xAA; regs.ebx = (unsigned long)res; - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x923456AA) || @@ -188,7 +197,6 @@ int main(int argc, char **argv) regs.eax = 0xAABBCC77UL; regs.ecx = 0xFF; regs.ebx = (unsigned long)res; - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x923456AA) || @@ -205,7 +213,6 @@ int main(int argc, char **argv) regs.eip = (unsigned long)&instr[0]; regs.ecx = 0x12345678; regs.eax = (unsigned long)res; - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x12345678) || @@ -223,7 +230,6 @@ int main(int argc, char **argv) regs.eax = 0x923456AAUL; regs.ecx = 0xDDEEFF00L; regs.ebx = (unsigned long)res; - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0xDDEEFF00) || @@ -241,7 +247,6 @@ int main(int argc, char **argv) regs.eip = (unsigned long)&instr[0]; regs.esi = (unsigned long)res + 0; regs.edi = (unsigned long)res + 2; - regs.error_code = 0; /* read fault */ rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x44554455) || @@ -259,9 +264,8 @@ int main(int argc, char **argv) regs.eflags = 0x200; regs.eip = (unsigned long)&instr[0]; regs.edi = (unsigned long)res; - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); - if ( (rc != 0) || + if ( (rc != 0) || (*res != 0x2233445D) || ((regs.eflags&0x201) != 0x201) || (regs.eip != (unsigned long)&instr[4]) ) @@ -275,9 +279,8 @@ int main(int argc, char **argv) regs.eip = (unsigned long)&instr[0]; regs.eax = -32; regs.edi = (unsigned long)(res+1); - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); - if ( (rc != 0) || + if ( (rc != 0) || (*res != 0x2233445E) || ((regs.eflags&0x201) != 0x201) || (regs.eip != (unsigned long)&instr[3]) ) @@ -296,9 +299,8 @@ int main(int argc, char **argv) regs.ecx = 0xCCCCFFFF; regs.eip = (unsigned long)&instr[0]; regs.edi = (unsigned long)res; - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); - if ( (rc != 0) || + if ( (rc != 0) || (res[0] != 0x9999AAAA) || (res[1] != 0xCCCCFFFF) || ((regs.eflags&0x240) != 0x240) || @@ -311,7 +313,6 @@ int main(int argc, char **argv) regs.eflags = 0x200; regs.eip = (unsigned long)&instr[0]; regs.edi = (unsigned long)res; - regs.error_code = PFEC_write_access; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (res[0] != 0x9999AAAA) || @@ -330,7 +331,6 @@ int main(int argc, char **argv) regs.ecx = 0x12345678; regs.eax = (unsigned long)res; *res = 0x82; - regs.error_code = 0; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x82) || @@ -347,7 +347,6 @@ int main(int argc, char **argv) regs.ecx = 0x12345678; regs.eax = (unsigned long)res; *res = 0x1234aa82; - regs.error_code = 0; rc = x86_emulate_memop(&ctxt, &emulops); if ( (rc != 0) || (*res != 0x1234aa82) || @@ -364,7 +363,6 @@ int main(int argc, char **argv) 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) || |