|
From: <sv...@va...> - 2012-02-26 17:56:01
|
Author: florian
Date: 2012-02-26 17:51:28 +0000 (Sun, 26 Feb 2012)
New Revision: 12404
Log:
Tighten up initial guest/shodow state on s390x.
Modified:
trunk/coregrind/m_initimg/initimg-linux.c
trunk/coregrind/pub_core_machine.h
Modified: trunk/coregrind/m_initimg/initimg-linux.c
===================================================================
--- trunk/coregrind/m_initimg/initimg-linux.c 2012-02-26 17:01:22 UTC (rev 12403)
+++ trunk/coregrind/m_initimg/initimg-linux.c 2012-02-26 17:51:28 UTC (rev 12404)
@@ -1061,14 +1061,26 @@
is also done by the kernel for the fpc during execve. */
LibVEX_GuestS390X_initialise(&arch->vex);
- /* Zero out the shadow area. */
- VG_(memset)(&arch->vex_shadow1, 0, sizeof(VexGuestS390XState));
- VG_(memset)(&arch->vex_shadow2, 0, sizeof(VexGuestS390XState));
+ /* Mark all registers as undefined ... */
+ VG_(memset)(&arch->vex_shadow1, 0xFF, sizeof(VexGuestS390XState));
+ VG_(memset)(&arch->vex_shadow2, 0x00, sizeof(VexGuestS390XState));
+ /* ... except SP, FPC, and IA */
+ VG_(memset)((UChar *)&arch->vex_shadow1 + VG_O_STACK_PTR, 0x00, 8);
+ VG_(memset)((UChar *)&arch->vex_shadow1 + VG_O_FPC_REG, 0x00, 4);
+ VG_(memset)((UChar *)&arch->vex_shadow1 + VG_O_INSTR_PTR, 0x00, 8);
/* Put essential stuff into the new state. */
arch->vex.guest_SP = iifii.initial_client_SP;
arch->vex.guest_IA = iifii.initial_client_IP;
+ /* See sys_execve in <linux>/arch/s390/kernel/process.c */
+ arch->vex.guest_fpc = 0;
+ /* Tell the tool about the registers we just wrote */
+ VG_TRACK(post_reg_write, Vg_CoreStartup, /*tid*/1, VG_O_STACK_PTR, 8);
+ VG_TRACK(post_reg_write, Vg_CoreStartup, /*tid*/1, VG_O_FPC_REG, 4);
+ VG_TRACK(post_reg_write, Vg_CoreStartup, /*tid*/1, VG_O_INSTR_PTR, 8);
+ return;
+
# else
# error Unknown platform
# endif
Modified: trunk/coregrind/pub_core_machine.h
===================================================================
--- trunk/coregrind/pub_core_machine.h 2012-02-26 17:01:22 UTC (rev 12403)
+++ trunk/coregrind/pub_core_machine.h 2012-02-26 17:51:28 UTC (rev 12404)
@@ -103,6 +103,7 @@
# define VG_INSTR_PTR guest_IA
# define VG_STACK_PTR guest_SP
# define VG_FRAME_PTR guest_FP
+# define VG_FPC_REG guest_fpc
#else
# error Unknown arch
#endif
@@ -111,6 +112,7 @@
// Offsets for the Vex state
#define VG_O_STACK_PTR (offsetof(VexGuestArchState, VG_STACK_PTR))
#define VG_O_INSTR_PTR (offsetof(VexGuestArchState, VG_INSTR_PTR))
+#define VG_O_FPC_REG (offsetof(VexGuestArchState, VG_FPC_REG))
//-------------------------------------------------------------
|
|
From: Christian B. <bor...@de...> - 2012-02-26 19:35:25
|
> + /* ... except SP, FPC, and IA */ R14 seems also be defined. See ELF_PLAT_INIT. |
|
From: Florian K. <br...@ac...> - 2012-02-26 20:37:07
|
On 02/26/2012 02:35 PM, Christian Borntraeger wrote:
>> + /* ... except SP, FPC, and IA */
>
> R14 seems also be defined. See ELF_PLAT_INIT.
>
Not according to the ABI document.
Florian
|