]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Deal with somewhat dubious numbers showing up from the kernel for the
authorJulian Seward <jseward@acm.org>
Thu, 19 Jan 2006 03:44:10 +0000 (03:44 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 19 Jan 2006 03:44:10 +0000 (03:44 +0000)
r3 (syscall return) value in the ucontext for a signal interrupting a
syscall.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5554

coregrind/m_signals.c

index fe91614ec6d21a2b368a471a4cde07b86c545488..9198482b85ed343c595f7b9202fcaa275156f0f3 100644 (file)
@@ -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