]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Tighten up initial guest/shodow state on s390x.
authorFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Feb 2012 17:51:28 +0000 (17:51 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Feb 2012 17:51:28 +0000 (17:51 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12404

coregrind/m_initimg/initimg-linux.c
coregrind/pub_core_machine.h

index 1e1338e1a436b322ab6b21094b7203b189a7c741..b752f01aad23ad746abeff67372485a40ebedb14 100644 (file)
@@ -1061,13 +1061,25 @@ void VG_(ii_finalise_image)( IIFinaliseImageInfo iifii )
       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
index ee65b977c45975310c276f26e99f1a71c480d4b9..6f15be5385c235f28abc68d57868a506085b257e 100644 (file)
 #  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
 // 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))
 
 
 //-------------------------------------------------------------