[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Fix up x86 emulator header docs and ensure callers use
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 07306e35a5fc3db72937dff75a0546540603dcbc # Parent 9efe7eb108e104d2f78daed2516ead08a33e7e81 Fix up x86 emulator header docs and ensure callers use the X86EMUL_MODE enumeration. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> diff -r 9efe7eb108e1 -r 07306e35a5fc tools/tests/test_x86_emulator.c --- a/tools/tests/test_x86_emulator.c Wed Jan 4 17:51:38 2006 +++ b/tools/tests/test_x86_emulator.c Thu Jan 5 11:19:12 2006 @@ -92,7 +92,7 @@ regs.ecx = 0x12345678; cr2 = (unsigned long)&res; res = 0x7FFFFFFF; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x92345677) || (regs.eflags != 0xa94) || @@ -110,7 +110,7 @@ regs.ecx = 0x12345678UL; #endif cr2 = (unsigned long)&res; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x92345677) || (regs.ecx != 0x8000000FUL) || @@ -125,7 +125,7 @@ regs.eax = 0x92345677UL; regs.ecx = 0xAA; cr2 = (unsigned long)&res; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x923456AA) || (regs.eflags != 0x244) || @@ -141,7 +141,7 @@ regs.eax = 0xAABBCC77UL; regs.ecx = 0xFF; cr2 = (unsigned long)&res; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x923456AA) || ((regs.eflags&0x240) != 0x200) || @@ -157,7 +157,7 @@ regs.eip = (unsigned long)&instr[0]; regs.ecx = 0x12345678; cr2 = (unsigned long)&res; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x12345678) || (regs.eflags != 0x200) || @@ -174,7 +174,7 @@ regs.eax = 0x923456AAUL; regs.ecx = 0xDDEEFF00L; cr2 = (unsigned long)&res; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0xDDEEFF00) || (regs.eflags != 0x244) || @@ -193,7 +193,7 @@ regs.edi = (unsigned long)&res + 2; regs.error_code = 0; /* read fault */ cr2 = regs.esi; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x44554455) || (regs.eflags != 0x200) || @@ -211,7 +211,7 @@ regs.eip = (unsigned long)&instr[0]; regs.edi = (unsigned long)&res; cr2 = regs.edi; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x2233445D) || ((regs.eflags&0x201) != 0x201) || @@ -229,7 +229,7 @@ regs.eip = (unsigned long)&instr[0]; regs.edi = (unsigned long)cmpxchg8b_res; cr2 = regs.edi; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (cmpxchg8b_res[0] != 0x9999AAAA) || (cmpxchg8b_res[1] != 0xCCCCFFFF) || @@ -243,7 +243,7 @@ regs.eip = (unsigned long)&instr[0]; regs.edi = (unsigned long)cmpxchg8b_res; cr2 = regs.edi; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (cmpxchg8b_res[0] != 0x9999AAAA) || (cmpxchg8b_res[1] != 0xCCCCFFFF) || @@ -260,7 +260,7 @@ regs.ecx = 0x12345678; cr2 = (unsigned long)&res; res = 0x82; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x82) || (regs.ecx != 0xFFFFFF82) || @@ -275,7 +275,7 @@ regs.ecx = 0x12345678; cr2 = (unsigned long)&res; res = 0x1234aa82; - rc = x86_emulate_memop(®s, cr2, &emulops, 4); + rc = x86_emulate_memop(®s, cr2, &emulops, X86EMUL_MODE_PROT32); if ( (rc != 0) || (res != 0x1234aa82) || (regs.ecx != 0xaa82) || diff -r 9efe7eb108e1 -r 07306e35a5fc xen/arch/x86/mm.c --- a/xen/arch/x86/mm.c Wed Jan 4 17:51:38 2006 +++ b/xen/arch/x86/mm.c Thu Jan 5 11:19:12 2006 @@ -3369,7 +3369,7 @@ emulate: if ( x86_emulate_memop(guest_cpu_user_regs(), addr, - &ptwr_mem_emulator, BITS_PER_LONG/8) ) + &ptwr_mem_emulator, X86EMUL_MODE_HOST) ) return 0; perfc_incrc(ptwr_emulations); return EXCRET_fault_fixed; diff -r 9efe7eb108e1 -r 07306e35a5fc xen/include/asm-x86/x86_emulate.h --- a/xen/include/asm-x86/x86_emulate.h Wed Jan 4 17:51:38 2006 +++ b/xen/include/asm-x86/x86_emulate.h Thu Jan 5 11:19:12 2006 @@ -18,10 +18,11 @@ * special treatment or emulation (*_emulated). * * The emulator assumes that an instruction accesses only one 'emulated memory' - * location, and that this is one of its data operands. Instruction fetches and + * location, that this location is the given linear faulting address (cr2), and + * that this is one of the instruction's data operands. Instruction fetches and * stack operations are assumed never to access emulated memory. The emulator * automatically deduces which operand of a string-move operation is accessing - * emulated memory, and requires that the other operand accesses normal memory. + * emulated memory, and assumes that the other operand accesses normal memory. * * NOTES: * 1. The emulator isn't very smart about emulated vs. standard memory. @@ -36,6 +37,7 @@ * then immediately bail. * 3. Valid access sizes are 1, 2, 4 and 8 bytes. On x86/32 systems only * cmpxchg8b_emulated need support 8-byte accesses. + * 4. The emulator cannot handle 64-bit mode emulation on an x86/32 system. */ /* Access completed successfully: continue emulation as normal. */ #define X86EMUL_CONTINUE 0 @@ -141,22 +143,27 @@ struct cpu_user_regs; -/* Current execution mode, passed to the emulator. */ -#define X86EMUL_MODE_REAL 0 -#define X86EMUL_MODE_PROT16 2 -#define X86EMUL_MODE_PROT32 4 -#define X86EMUL_MODE_PROT64 8 +/* Execution mode, passed to the emulator. */ +#define X86EMUL_MODE_REAL 0 /* Real mode. */ +#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */ +#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */ +#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */ + +/* Host execution mode. */ +#if defined(__i386__) +#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32 +#elif defined(__x86_64__) +#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64 +#endif /* * x86_emulate_memop: Emulate an instruction that faulted attempting to * read/write a 'special' memory area. * @regs: Register state at time of fault. - * @cr2: Linear faulting address. + * @cr2: Linear faulting address within an emulated/special memory area. * @ops: Interface to access special memory. - * @mode: Current execution mode, represented by the default size of memory - * addresses, in bytes. Valid values are 2, 4 and 8 (x86/64 only). - * Alternatively use the appropriate X86EMUL_MODE value (which also - * includes a value for emulating real mode). + * @mode: Emulated execution mode, represented by an X86EMUL_MODE value. + * Returns -1 on failure, 0 on success. */ extern int x86_emulate_memop( _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |