|
From: <sv...@va...> - 2005-08-07 14:48:11
|
Author: sewardj
Date: 2005-08-07 15:48:03 +0100 (Sun, 07 Aug 2005)
New Revision: 1320
Log:
A minimal implementation of the x86 sysenter instruction
(experimental). Limitations as commented in the code.
Modified:
trunk/priv/guest-x86/toIR.c
trunk/priv/host-x86/hdefs.c
trunk/priv/ir/irdefs.c
trunk/pub/libvex_ir.h
trunk/pub/libvex_trc_values.h
Modified: trunk/priv/guest-x86/toIR.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/guest-x86/toIR.c 2005-08-06 11:45:02 UTC (rev 1319)
+++ trunk/priv/guest-x86/toIR.c 2005-08-07 14:48:03 UTC (rev 1320)
@@ -88,6 +88,15 @@
happen. Programs that set it to 1 and then rely on the resulting
SIGBUSs to inform them of misaligned accesses will not work.
=20
+ Implementation sysenter is necessarily partial. sysenter is a kind
+ of system call entry. When doing a sysenter, the return address is
+ not known -- that is something that is beyond Vex's knowledge. So
+ the generated IR forces a return to the scheduler, which can do
+ what it likes to simulate the systemter, but it MUST set this
+ thread's guest_EIP field with the continuation address before
+ resuming execution. If that doesn't happen, the thread will jump
+ to address zero, which is probably fatal.
+
This module uses global variables and so is not MT-safe (if that
should ever become relevant).
=20
@@ -11974,6 +11983,26 @@
"%cl", False );
break;
=20
+ /* =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- SYSENTER -=3D-=3D-=3D-=3D-=
=3D-=3D-=3D-=3D-=3D-=3D */
+
+ case 0x34:
+ /* Simple implementation needing a long explaination.
+
+ sysenter is a kind of syscall entry. The key thing here
+ is that the return address is not known -- that is
+ something that is beyond Vex's knowledge. So this IR
+ forces a return to the scheduler, which can do what it
+ likes to simulate the systemter, but it MUST set this
+ thread's guest_EIP field with the continuation address
+ before resuming execution. If that doesn't happen, the
+ thread will jump to address zero, which is probably
+ fatal.=20
+ */=20
+ jmp_lit(Ijk_SysenterX86, 0/*bogus next EIP value*/);
+ dres.whatNext =3D Dis_StopHere;
+ DIP("sysenter");
+ break;
+
/* =3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- XADD -=3D-=3D-=3D-=3D-=3D-=
=3D-=3D-=3D-=3D-=3D */
=20
//-- case 0xC0: /* XADD Gb,Eb */
Modified: trunk/priv/host-x86/hdefs.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/host-x86/hdefs.c 2005-08-06 11:45:02 UTC (rev 1319)
+++ trunk/priv/host-x86/hdefs.c 2005-08-07 14:48:03 UTC (rev 1320)
@@ -2165,6 +2165,9 @@
case Ijk_TInval:
*p++ =3D 0xBD;
p =3D emit32(p, VEX_TRC_JMP_TINVAL); break;
+ case Ijk_SysenterX86:
+ *p++ =3D 0xBD;
+ p =3D emit32(p, VEX_TRC_JMP_SYSENTER_X86); break;
case Ijk_Ret:
case Ijk_Call:
case Ijk_Boring:
Modified: trunk/priv/ir/irdefs.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/priv/ir/irdefs.c 2005-08-06 11:45:02 UTC (rev 1319)
+++ trunk/priv/ir/irdefs.c 2005-08-07 14:48:03 UTC (rev 1320)
@@ -599,17 +599,18 @@
void ppIRJumpKind ( IRJumpKind kind )
{
switch (kind) {
- case Ijk_Boring: vex_printf("Boring"); break;
- case Ijk_Call: vex_printf("Call"); break;
- case Ijk_Ret: vex_printf("Return"); break;
- case Ijk_ClientReq: vex_printf("ClientReq"); break;
- case Ijk_Syscall: vex_printf("Syscall"); break;
- case Ijk_Yield: vex_printf("Yield"); break;
- case Ijk_EmWarn: vex_printf("EmWarn"); break;
- case Ijk_NoDecode: vex_printf("NoDecode"); break;
- case Ijk_MapFail: vex_printf("MapFail"); break;
- case Ijk_TInval: vex_printf("Invalidate"); break;
- default: vpanic("ppIRJumpKind");
+ case Ijk_Boring: vex_printf("Boring"); break;
+ case Ijk_Call: vex_printf("Call"); break;
+ case Ijk_Ret: vex_printf("Return"); break;
+ case Ijk_ClientReq: vex_printf("ClientReq"); break;
+ case Ijk_Syscall: vex_printf("Syscall"); break;
+ case Ijk_Yield: vex_printf("Yield"); break;
+ case Ijk_EmWarn: vex_printf("EmWarn"); break;
+ case Ijk_NoDecode: vex_printf("NoDecode"); break;
+ case Ijk_MapFail: vex_printf("MapFail"); break;
+ case Ijk_TInval: vex_printf("Invalidate"); break;
+ case Ijk_SysenterX86: vex_printf("SysenterX86"); break;
+ default: vpanic("ppIRJumpKind");
}
}
=20
Modified: trunk/pub/libvex_ir.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/pub/libvex_ir.h 2005-08-06 11:45:02 UTC (rev 1319)
+++ trunk/pub/libvex_ir.h 2005-08-07 14:48:03 UTC (rev 1320)
@@ -816,7 +816,9 @@
Ijk_EmWarn, /* report emulation warning before continuing =
*/
Ijk_NoDecode, /* next instruction cannot be decoded */
Ijk_MapFail, /* Vex-provided address translation failed */
- Ijk_TInval /* Invalidate translations before continuing. =
*/
+ Ijk_TInval, /* Invalidate translations before continuing. =
*/
+ Ijk_SysenterX86 /* X86 sysenter. guest_EIP becomes invalid
+ at the point this happens. */
}
IRJumpKind;
=20
Modified: trunk/pub/libvex_trc_values.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/pub/libvex_trc_values.h 2005-08-06 11:45:02 UTC (rev 1319)
+++ trunk/pub/libvex_trc_values.h 2005-08-07 14:48:03 UTC (rev 1320)
@@ -67,7 +67,10 @@
#define VEX_TRC_JMP_NODECODE 29 /* next instruction in not decodable =
*/
#define VEX_TRC_JMP_MAPFAIL 31 /* address translation failed */
=20
+#define VEX_TRC_JMP_SYSENTER_X86 9 /* simulate X86 sysenter before
+ continuing */
=20
+
#endif /* ndef __LIBVEX_TRC_VALUES_H */
=20
/*---------------------------------------------------------------*/
|