From: Florian Krohm Date: Sun, 26 Feb 2012 17:51:28 +0000 (+0000) Subject: Tighten up initial guest/shodow state on s390x. X-Git-Tag: svn/VALGRIND_3_8_0~449 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f282be92523db37dbd321726e06a9740f54d6bd;p=thirdparty%2Fvalgrind.git Tighten up initial guest/shodow state on s390x. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12404 --- diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c index 1e1338e1a4..b752f01aad 100644 --- a/coregrind/m_initimg/initimg-linux.c +++ b/coregrind/m_initimg/initimg-linux.c @@ -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 /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 diff --git a/coregrind/pub_core_machine.h b/coregrind/pub_core_machine.h index ee65b977c4..6f15be5385 100644 --- a/coregrind/pub_core_machine.h +++ b/coregrind/pub_core_machine.h @@ -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)) //-------------------------------------------------------------