diff mbox series

[11/19] nptl: alpha: Fix Race conditions in pthread cancellation (BZ#12683)

Message ID 1513019223-7603-12-git-send-email-adhemerval.zanella@linaro.org
State Superseded
Headers show
Series nptl: Fix Race conditions in pthread cancellation (BZ#12683) | expand

Commit Message

Adhemerval Zanella Netto Dec. 11, 2017, 7:06 p.m. UTC
This patch adds the alpha modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function

The default syscall_cancel.c should be fine for alpha and GCC 6.1
generates the following cod for syscall_cancel.os:

---
0000000000000000 <__GI___syscall_cancel_arch>:
   0:   00 00 bb 27     ldah    gp,0(t12)
   4:   00 00 bd 23     lda     gp,0(gp)
   8:   f0 ff de 23     lda     sp,-16(sp)
   c:   00 04 f1 47     mov     a1,v0
  10:   00 00 5e b7     stq     ra,0(sp)

0000000000000014 <__syscall_cancel_arch_start>:
  14:   00 00 30 a0     ldl     t0,0(a0)
  18:   01 00 e1 43     sextl   t0,t0
  1c:   01 90 20 44     and     t0,0x4,t0
  20:   0f 00 20 f4     bne     t0,60 <__syscall_cancel_arch_end+0x20>
  24:   10 04 f2 47     mov     a2,a0
  28:   11 04 f3 47     mov     a3,a1
  2c:   12 04 f4 47     mov     a4,a2
  30:   10 00 9e a6     ldq     a4,16(sp)
  34:   13 04 f5 47     mov     a5,a3
  38:   18 00 be a6     ldq     a5,24(sp)
  3c:   83 00 00 00     callsys

0000000000000040 <__syscall_cancel_arch_end>:
  40:   21 05 e0 43     negq    v0,t0
  44:   00 00 5e a7     ldq     ra,0(sp)
  48:   c0 04 61 46     cmovne  a3,t0,v0
  4c:   10 00 de 23     lda     sp,16(sp)
  50:   01 80 fa 6b     ret
  54:   00 00 fe 2f     unop
  58:   1f 04 ff 47     nop
  5c:   00 00 fe 2f     unop
  60:   00 00 7d a7     ldq     t12,0(gp)
  64:   00 40 5b 6b     jsr     ra,(t12),68 <__syscall_cancel_arch_end+0x28>
  68:   1f 04 ff 47     nop
  6c:   00 00 fe 2f     unop
---

Checked on alpha-linux-gnu, no regression found.

	* sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h (ucontext_get_pc):
	New function.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

---
 ChangeLog                                      |  4 ++++
 sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h | 13 +++++++++++++
 2 files changed, 17 insertions(+)

-- 
2.7.4
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h b/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h
index e8b74d5..a61c289 100644
--- a/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h
+++ b/sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h
@@ -15,6 +15,11 @@ 
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _SIGCONTEXTINFO_H
+#define _SIGCONTEXTINFO_H
+
+#include <stdint.h>
+
 #define SIGCONTEXT int _code, struct sigcontext *
 #define SIGCONTEXT_EXTRA_ARGS _code,
 #define GET_PC(ctx)	((void *) (ctx)->sc_pc)
@@ -22,3 +27,11 @@ 
 #define GET_STACK(ctx)	((void *) (ctx)->sc_regs[30])
 #define CALL_SIGHANDLER(handler, signo, ctx) \
   (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
+
+static inline uintptr_t
+ucontext_get_pc (const ucontext_t *uc)
+{
+  return uc->uc_mcontext.sc_pc;
+}
+
+#endif /* _SIGCONTEXTINFO_H  */