aboutsummaryrefslogtreecommitdiffstats
path: root/tools/tests
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-23 18:38:08 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-23 18:38:08 +0100
commit55bfac8dfd0bde5dcf3e1f88ed5ed7a1bc9a9e4d (patch)
tree7e0d0ffebca6677fc66bbcb788c8f8e2e240765c /tools/tests
parentc4ea6f0c90c61234a69ce330b91f00854641af9f (diff)
downloadxen-55bfac8dfd0bde5dcf3e1f88ed5ed7a1bc9a9e4d.tar.gz
xen-55bfac8dfd0bde5dcf3e1f88ed5ed7a1bc9a9e4d.tar.bz2
xen-55bfac8dfd0bde5dcf3e1f88ed5ed7a1bc9a9e4d.zip
[XEN] Fix the x86 emulator to safely fail when it turns out the
faulting memory access was to/from an implicit memory operand (typically either an instruction fetch or stack access). Rationalise use of macros for page fault error code flags. This patch supercedes the fix in changeset 11242. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/tests')
-rw-r--r--tools/tests/test_x86_emulator.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/tests/test_x86_emulator.c b/tools/tests/test_x86_emulator.c
index 11755c3373..d3b7af0a7c 100644
--- a/tools/tests/test_x86_emulator.c
+++ b/tools/tests/test_x86_emulator.c
@@ -15,6 +15,8 @@ typedef int64_t s64;
#include <asm-x86/x86_emulate.h>
#include <sys/mman.h>
+#define PFEC_write_access (1U<<1)
+
static int read_any(
unsigned long addr,
unsigned long *val,
@@ -105,6 +107,7 @@ int main(int argc, char **argv)
regs.eflags = 0x200;
regs.eip = (unsigned long)&instr[0];
regs.ecx = 0x12345678;
+ regs.error_code = PFEC_write_access;
ctxt.cr2 = (unsigned long)res;
*res = 0x7FFFFFFF;
rc = x86_emulate_memop(&ctxt, &emulops);
@@ -125,6 +128,7 @@ int main(int argc, char **argv)
regs.ecx = 0x12345678UL;
#endif
ctxt.cr2 = (unsigned long)res;
+ regs.error_code = 0;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x92345677) ||
@@ -139,6 +143,7 @@ int main(int argc, char **argv)
regs.eip = (unsigned long)&instr[0];
regs.ecx = ~0UL;
ctxt.cr2 = (unsigned long)res;
+ regs.error_code = 0;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x92345677) ||
@@ -154,6 +159,7 @@ int main(int argc, char **argv)
regs.eax = 0x92345677UL;
regs.ecx = 0xAA;
ctxt.cr2 = (unsigned long)res;
+ regs.error_code = PFEC_write_access;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x923456AA) ||
@@ -170,6 +176,7 @@ int main(int argc, char **argv)
regs.eax = 0xAABBCC77UL;
regs.ecx = 0xFF;
ctxt.cr2 = (unsigned long)res;
+ regs.error_code = PFEC_write_access;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x923456AA) ||
@@ -186,6 +193,7 @@ int main(int argc, char **argv)
regs.eip = (unsigned long)&instr[0];
regs.ecx = 0x12345678;
ctxt.cr2 = (unsigned long)res;
+ regs.error_code = PFEC_write_access;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x12345678) ||
@@ -203,6 +211,7 @@ int main(int argc, char **argv)
regs.eax = 0x923456AAUL;
regs.ecx = 0xDDEEFF00L;
ctxt.cr2 = (unsigned long)res;
+ regs.error_code = PFEC_write_access;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0xDDEEFF00) ||
@@ -240,6 +249,7 @@ int main(int argc, char **argv)
regs.eip = (unsigned long)&instr[0];
regs.edi = (unsigned long)res;
ctxt.cr2 = regs.edi;
+ regs.error_code = PFEC_write_access;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x2233445D) ||
@@ -261,6 +271,7 @@ int main(int argc, char **argv)
regs.eip = (unsigned long)&instr[0];
regs.edi = (unsigned long)res;
ctxt.cr2 = regs.edi;
+ regs.error_code = PFEC_write_access;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(res[0] != 0x9999AAAA) ||
@@ -275,6 +286,7 @@ int main(int argc, char **argv)
regs.eip = (unsigned long)&instr[0];
regs.edi = (unsigned long)res;
ctxt.cr2 = regs.edi;
+ regs.error_code = PFEC_write_access;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(res[0] != 0x9999AAAA) ||
@@ -292,6 +304,7 @@ int main(int argc, char **argv)
regs.ecx = 0x12345678;
ctxt.cr2 = (unsigned long)res;
*res = 0x82;
+ regs.error_code = 0;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x82) ||
@@ -307,6 +320,7 @@ int main(int argc, char **argv)
regs.ecx = 0x12345678;
ctxt.cr2 = (unsigned long)res;
*res = 0x1234aa82;
+ regs.error_code = 0;
rc = x86_emulate_memop(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x1234aa82) ||