From: Julian Seward Date: Thu, 19 Jan 2006 03:44:10 +0000 (+0000) Subject: Deal with somewhat dubious numbers showing up from the kernel for the X-Git-Tag: svn/VALGRIND_3_2_0~357 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4936ed62d736a8ad08bc370d9be1f75ca943aeb1;p=thirdparty%2Fvalgrind.git Deal with somewhat dubious numbers showing up from the kernel for the r3 (syscall return) value in the ucontext for a signal interrupting a syscall. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5554 --- diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index fe91614ec6..9198482b85 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -212,12 +212,29 @@ typedef struct SigQueue { # define VG_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.gp_regs[VKI_PT_R1]) # define VG_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.gp_regs[VKI_PT_R1]) # define VG_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.gp_regs[VKI_PT_R0]) +#if 0 # define VG_UCONTEXT_SYSCALL_SYSRES(uc) \ /* Convert the values in uc_mcontext r3,cr into a SysRes. */ \ VG_(mk_SysRes_ppc64_linux)( \ (uc)->uc_mcontext.gp_regs[VKI_PT_R3], \ (((uc)->uc_mcontext.gp_regs[VKI_PT_CCR] >> 28) & 1) \ ) +#else + /* Dubious hack: if there is an error, only consider the lowest 8 + bits of r3. memcheck/tests/post-syscall shows a case where an + interrupted syscall should have produced a ucontext with 0x4 + (VKI_EINTR) in r3 but is in fact producing 0x204. */ + /* Awaiting clarification from PaulM. Evidently 0x204 is + ERESTART_RESTARTBLOCK, which shouldn't have made it into user + space. */ + static inline SysRes VG_UCONTEXT_SYSCALL_SYSRES( struct vki_ucontext* uc ) + { + ULong err = (uc->uc_mcontext.gp_regs[VKI_PT_CCR] >> 28) & 1; + ULong r3 = uc->uc_mcontext.gp_regs[VKI_PT_R3]; + if (err) r3 &= 0xFF; + return VG_(mk_SysRes_ppc64_linux)( r3, err ); + } +#endif # define VG_UCONTEXT_LINK_REG(uc) ((uc)->uc_mcontext.gp_regs[VKI_PT_LNK]) #else