From: Julian Seward Date: Mon, 19 Mar 2007 14:34:08 +0000 (+0000) Subject: Followup to r6650: tidy up sys_sigreturn/sys_rt_sigreturn on ppc32/64-linux. X-Git-Tag: svn/VALGRIND_3_3_0~315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d31d0b60cdff7417b559ded0eb10be4a8ecc208;p=thirdparty%2Fvalgrind.git Followup to r6650: tidy up sys_sigreturn/sys_rt_sigreturn on ppc32/64-linux. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6651 --- diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index 9f61aad08b..335a112675 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -487,7 +487,7 @@ PRE(sys_rt_sigreturn) *flags |= SfNoWriteResult; SET_STATUS_Success(0); - /* Check to see if some any signals arose as a result of this. */ + /* Check to see if any signals arose as a result of this. */ *flags |= SfPollAfter; } diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index f7fd293ca8..ef865baa0c 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1024,8 +1024,11 @@ PRE(sys_clone) PRE(sys_sigreturn) { + /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for + an explanation of what follows. */ + ThreadState* tst; - PRINT("sigreturn ( )"); + PRINT("sys_sigreturn ( )"); vg_assert(VG_(is_valid_tid)(tid)); vg_assert(tid >= 1 && tid < VG_N_THREADS); @@ -1042,38 +1045,23 @@ PRE(sys_sigreturn) //ML_(fixup_guest_state_to_restart_syscall)(&tst->arch); // Should we do something equivalent on ppc32? Who knows. + /* Restore register state from frame and remove it */ VG_(sigframe_destroy)(tid, False); - /* For unclear reasons, it appears we need the syscall to return - without changing R3. Since R3 is the return value, and can - denote either success or failure, we must set up so that the - driver logic copies it back unchanged. Also, note R3 is of - the guest registers written by VG_(sigframe_destroy). */ - /* jrs 16 Nov 05: for some reason this occasionally causes the - is-this-a-sane-error-value sanity check to fail: - m_syswrap/syswrap-ppc32-linux.c:1037 - (vgSysWrap_ppc32_linux_sys_sigreturn_before): - Assertion 'wzz >= 0 && wzz < 10000' failed. - Hence use a sanity-check-free version. - Perhaps we should ignore CR0.S0 here? - In general I have no idea what this is for or if it is necessary. - It's a conceptual copy-n-paste from the x86 equivalent, but I'm - equally unclear as to whether it is needed there either. - */ - SET_STATUS_from_SysRes( - VG_(mk_SysRes_ppc32_linux)( - tst->arch.vex.guest_GPR3, - /* get CR0.SO */ - (LibVEX_GuestPPC32_get_CR( &tst->arch.vex ) >> 28) & 1 - ) - ); - - /* Check to see if some any signals arose as a result of this. */ + /* Tell the driver not to update the guest state with the "result", + and set a bogus result to keep it happy. */ + *flags |= SfNoWriteResult; + SET_STATUS_Success(0); + + /* Check to see if any signals arose as a result of this. */ *flags |= SfPollAfter; } PRE(sys_rt_sigreturn) { + /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for + an explanation of what follows. */ + ThreadState* tst; PRINT("rt_sigreturn ( )"); @@ -1092,18 +1080,15 @@ PRE(sys_rt_sigreturn) //ML_(fixup_guest_state_to_restart_syscall)(&tst->arch); // Should we do something equivalent on ppc32? Who knows. + /* Restore register state from frame and remove it */ VG_(sigframe_destroy)(tid, True); - /* See comments above in PRE(sys_sigreturn) about this. */ - SET_STATUS_from_SysRes( - VG_(mk_SysRes_ppc32_linux)( - tst->arch.vex.guest_GPR3, - /* get CR0.SO */ - (LibVEX_GuestPPC32_get_CR( &tst->arch.vex ) >> 28) & 1 - ) - ); + /* Tell the driver not to update the guest state with the "result", + and set a bogus result to keep it happy. */ + *flags |= SfNoWriteResult; + SET_STATUS_Success(0); - /* Check to see if some any signals arose as a result of this. */ + /* Check to see if any signals arose as a result of this. */ *flags |= SfPollAfter; } diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index 02e1fd33c8..427d3649fe 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1000,60 +1000,13 @@ PRE(sys_clone) } } -//zz PRE(sys_sigreturn) -//zz { -//zz ThreadState* tst; -//zz PRINT("sigreturn ( )"); -//zz -//zz vg_assert(VG_(is_valid_tid)(tid)); -//zz vg_assert(tid >= 1 && tid < VG_N_THREADS); -//zz vg_assert(VG_(is_running_thread)(tid)); -//zz -//zz ///* Adjust esp to point to start of frame; skip back up over -//zz // sigreturn sequence's "popl %eax" and handler ret addr */ -//zz tst = VG_(get_ThreadState)(tid); -//zz //tst->arch.vex.guest_ESP -= sizeof(Addr)+sizeof(Word); -//zz // Should we do something equivalent on ppc64? Who knows. -//zz -//zz ///* This is only so that the EIP is (might be) useful to report if -//zz // something goes wrong in the sigreturn */ -//zz //ML_(fixup_guest_state_to_restart_syscall)(&tst->arch); -//zz // Should we do something equivalent on ppc64? Who knows. -//zz -//zz VG_(sigframe_destroy)(tid, False); -//zz -//zz /* For unclear reasons, it appears we need the syscall to return -//zz without changing R3. Since R3 is the return value, and can -//zz denote either success or failure, we must set up so that the -//zz driver logic copies it back unchanged. Also, note R3 is of -//zz the guest registers written by VG_(sigframe_destroy). */ -//zz /* jrs 16 Nov 05: for some reason this occasionally causes the -//zz is-this-a-sane-error-value sanity check to fail: -//zz m_syswrap/syswrap-ppc64-linux.c:1037 -//zz (vgSysWrap_ppc64_linux_sys_sigreturn_before): -//zz Assertion 'wzz >= 0 && wzz < 10000' failed. -//zz Hence use a sanity-check-free version. -//zz Perhaps we should ignore CR0.S0 here? -//zz In general I have no idea what this is for or if it is necessary. -//zz It's a conceptual copy-n-paste from the x86 equivalent, but I'm -//zz equally unclear as to whether it is needed there either. -//zz */ -//zz SET_STATUS_from_SysRes_NO_SANITY_CHECK( -//zz VG_(mk_SysRes_ppc64_linux)( -//zz tst->arch.vex.guest_GPR3, -//zz /* get CR0.SO */ -//zz (LibVEX_GuestPPC32_get_CR( &tst->arch.vex ) >> 28) & 1 -//zz ) -//zz ); -//zz -//zz /* Check to see if some any signals arose as a result of this. */ -//zz *flags |= SfPollAfter; -//zz } - PRE(sys_rt_sigreturn) { + /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for + an explanation of what follows. */ + ThreadState* tst; - PRINT("rt_sigreturn ( )"); + PRINT("sys_rt_sigreturn ( )"); vg_assert(VG_(is_valid_tid)(tid)); vg_assert(tid >= 1 && tid < VG_N_THREADS); @@ -1063,25 +1016,22 @@ PRE(sys_rt_sigreturn) // ret addr */ tst = VG_(get_ThreadState)(tid); //tst->arch.vex.guest_ESP -= sizeof(Addr); - // Should we do something equivalent on ppc64? Who knows. + // Should we do something equivalent on ppc64-linux? Who knows. ///* This is only so that the EIP is (might be) useful to report if // something goes wrong in the sigreturn */ //ML_(fixup_guest_state_to_restart_syscall)(&tst->arch); // Should we do something equivalent on ppc64? Who knows. + /* Restore register state from frame and remove it */ VG_(sigframe_destroy)(tid, True); - /* See comments above in PRE(sys_sigreturn) about this. */ - SET_STATUS_from_SysRes( - VG_(mk_SysRes_ppc64_linux)( - tst->arch.vex.guest_GPR3, - /* get CR0.SO */ - (LibVEX_GuestPPC64_get_CR( &tst->arch.vex ) >> 28) & 1 - ) - ); + /* Tell the driver not to update the guest state with the "result", + and set a bogus result to keep it happy. */ + *flags |= SfNoWriteResult; + SET_STATUS_Success(0); - /* Check to see if some any signals arose as a result of this. */ + /* Check to see if any signals arose as a result of this. */ *flags |= SfPollAfter; } diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 4c7258accc..6a9486548d 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -963,7 +963,7 @@ PRE(sys_sigreturn) *flags |= SfNoWriteResult; SET_STATUS_Success(0); - /* Check to see if some any signals arose as a result of this. */ + /* Check to see if any signals arose as a result of this. */ *flags |= SfPollAfter; } @@ -997,7 +997,7 @@ PRE(sys_rt_sigreturn) *flags |= SfNoWriteResult; SET_STATUS_Success(0); - /* Check to see if some any signals arose as a result of this. */ + /* Check to see if any signals arose as a result of this. */ *flags |= SfPollAfter; }