This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
[glibc] Deleted branch azanella/bz12683
- From: Adhemerval Zanella <azanella at sourceware dot org>
- To: glibc-cvs at sourceware dot org
- Date: 19 Aug 2019 20:14:54 -0000
- Subject: [glibc] Deleted branch azanella/bz12683
The branch 'azanella/bz12683' was deleted.
It previously pointed to:
2e8c8e9... nptl: Remove THREAD_ATOMIC_* macros
Diff:
!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
-------------------------------------------------------------------
2e8c8e9... nptl: Remove THREAD_ATOMIC_* macros
c905cdd... nptl: cancelhandling refactor
2212de8... nptl: Remove setxid bit from cancelhandling
f1b02e0... nptl: Move cancel state and type out cancelhandling
7102b56... nptl: riscv: Fix Race conditions in pthread cancellation (B
1092ac3... nptl: hppa: Fix Race conditions in pthread cancellation (BZ
f74aa23... nptl: mips: Fix Race conditions in pthread cancellation (BZ
7806615... nptl: sh: Fix Race conditions in pthread cancellation (BZ#1
02badc9... nptl: nios2: Fix Race conditions in pthread cancellation (B
a6ed517... nptl: sparc: Fix Race conditions in pthread cancellation (B
fbdf030... nptl: microblaze: Fix Race conditions in pthread cancellati
838fce2... nptl: m68k: Fix Race conditions in pthread cancellation (BZ
6da7532... nptl: alpha: Fix Race conditions in pthread cancellation (B
60eb1c5... nptl: ia64: Fix Race conditions in pthread cancellation (BZ
ee923ba... nptl: s390: Fix Race conditions in pthread cancellation (BZ
683a8f5... nptl: arm: Fix Race conditions in pthread cancellation (BZ#
0151ef6... nptl: aarch64: Fix Race conditions in pthread cancellation
996cfcb... nptl: powerpc: Fix Race conditions in pthread cancellation
2258ba7... nptl: i386: Fix Race conditions in pthread cancellation (BZ
f43adba... nptl: x32: Fix Race conditions in pthread cancellation (BZ#
299d22c... nptl: x86_64: Fix Race conditions in pthread cancellation (
6fe9935... nptl: Fix Race conditions in pthread cancellation (BZ#12683
590b6e0... nptl: Cleanup cancellation macros
323ab50... i386: Remove bogus THREAD_ATOMIC_* macros
b6838cd... x86: Remove wrong THREAD_ATOMIC_* macros
42794ba... nptl: Fix testcases for new pthread cancellation mechanism
00278aa... nptl: Remove tst-cancel-wrappers test and related macros
d6ed8a2... powerpc: Add CFI information on indirect syscall
commit 2e8c8e9622f0591fdffb7b5e79d1b6937af52e6a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Jan 24 21:05:56 2017 -0200
nptl: Remove THREAD_ATOMIC_* macros
This patch removes the ununsed THREAD_ATOMIC_* macros now that nptl
code is using C11 atomics.
Checked on x86_64-linux-gnu and i686-linux-gnu.
* manual/pattern.texi (THREAD_ATOMIC_BIT_SET): Remove.
(THREAD_ATOMIC_CMPXCHG_VAL): Likewise.
* nptl/pthreadP.h (THREAD_ATOMIC_CMPXCHG_VAL): Likewise.
(THREAD_ATOMIC_BIT_SET): Likewise.
* sysdeps/i386/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL): Likewise.
(THREAD_ATOMIC_AND): Likewise.
* sysdeps/x86_64/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL): Likewise.
(THREAD_ATOMIC_AND): Likewise.
commit c905cddb3868b5128b0460239e0cc5d609a7ef65
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Jan 24 09:17:37 2017 -0200
nptl: cancelhandling refactor
This patch basically uses glibc C11 atomic function to access and
modify struct pthread cancelhandling variable. All plain access
are handled using the atomic_load_* functions and THREAD_ATOMIC_BIT_SET
is replaced by atomic_fetch_or_acquire.
Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
* nptl/descr.h (CANCELED_BITMASK): Rename to THREAD_CANCELED.
(EXITING_BITMASK): Rename to THREAD_EXITING.
(TERMINATED_BITMARK): Rename to THREAD_TERMINATED.
* nptl/allocatestack.c (setxid_mark_thread): Use THREAD_* instead of
*_BITMASK and use glibc C11 atomic function to access pthread
cancelhandling.
* nptl/libc-cancellation.c (__syscall_cancel): Likewise.
* nptl/nptl-init.c (sigcancel_handler): Likewise.
* nptl/pthread_cancel.c (pthread_cancel): Likewise.
* nptl/pthread_create.c (__free_tcb): Likewise.
(START_THREAD_DEFN): Likewise.
(__pthread_create_2_1): Likewise.
* nptl/pthread_detach.c (pthread_detach): Likewise.
* nptl/pthread_exit.c (__pthread_exit): Likewise.
* nptl/pthread_join.c (pthread_join): Likewise.
* nptl_db/td_thr_get_info.c (td_thr_get_info): Likewise.
* nptl_db/td_thr_getfpregs.c (td_thr_getfpregs): Likewise.
* nptl_db/td_thr_getgregs.c (td_thr_getregs): Likewise.
* nptl_db/td_thr_setfpregs.c (td_thr_setfpregs): Likewise.
* nptl_db/td_thr_setgregs.c (td_thr_setgregs): Likewise.
* sysdeps/unix/sysv/linux/arm/syscall_cancel.S
(__syscall_cancel_arch): Change CANCELED_BITMASK to
THREAD_CANCELED in comment.
* sysdeps/unix/sysv/linux/syscall_cancel.c
(__syscall_cancel_arch): Likewise.
* sysdeps/x86_64/nptl/tcb-offsets.sym (TCB_CANCELED_BITMASK):
Remove.
(TCB_EXITING_BITMASK): Likewise.
(TCB_TERMINATED_BITMASK): Likewise.
* sysdeps/unix/sysv/linux/i386/syscall_cancel.S
(__syscall_cancel_arch): Likewise.
* sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S
(__syscall_cancel_arch): Likewise.
* sysdeps/unix/sysv/linux/sh/syscall_cancel.S
(__syscall_cancel_arch): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S
(__syscall_cancel_arch): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S
(__syscall_cancel_arch): Likewise.
commit 2212de8d6ffc4b29baf170422656d784caab4959
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Jul 18 16:33:41 2017 -0300
nptl: Remove setxid bit from cancelhandling
This patch removes the setxid signaling out of cancelhandling flag
and use its own member of pthread instead. The idea is simplify
setxid handling to not mix atomic operation with thread cancellation
since both are orthogonal, and to isolate cancelhandling variable to
only track thread cancel state.
It also uses glibc C11 atomic operation while accessing new setxid_op
field.
Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
* nptl/allocatestack.c (get_cached_stack): Set sexid_op on new
allocated stack.
(setxid_mark_thread): Use setxid_op to mark thread as executing
a sexid operation insteaf of using cancelhandling. Also adapt
algorithm to use C11 atomic analogous functions.
(setxid_unmark_thread): Likewise.
(setxid_signal_thread): Likewise.
* nptl/nptl-init.c (sighandler_setxid): Likewise.
* nptl/pthread_create.c (sighandler_setxid): Likewise.
* nptl/descr.h (SETXID_BIT): Remove define.
(SETXID_BITMASK): Likewise.
(setxid_op): New member.
commit f1b02e0cc90b72148e2755b55dff1faac3b9eb8b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri Jan 20 17:24:35 2017 -0200
nptl: Move cancel state and type out cancelhandling
This patch move both the cancel state (PTHREAD_CANCEL_ENABLE and
PTHREAD_CANCEL_DISABLE) and cancel type (PTHREAD_CANCEL_DEFERRED and
PTHREAD_CANCEL_ASYNCHRONOUS) out of cancelhandling member.
The idea is to simplify their access since for most cases there is
no concurrent access with cancellation mode:
* pthread_setcancel{type,state} and internal functions
__pthread_{un}register_cancel_defer (and its analogous compat
versions) only change the type/state of the calling thread.
* __syscall_cancel also only requires to check the state of
calling thread.
* sigcancel_handler is executed only for the thread about to be
potentially canceled.
* pthread_join deadlock checks only requires access the state for
the calling thread.
* Same behavior for pthread_testcancel.
With this change the cancelhandling member from pthread struct is
used solely for cancelation handling and setxid signaling.
Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
* nptl/allocatestack.c (get_cached_stack): Set both cancelstate
and canceltype on new stack allocation.
* nptl/cleanup_defer.c (__pthread_register_cancel_defer): Set
canceltype directly instead of using cancelhandling member.
(__pthread_unregister_cancel_restore): Likewise.
* nptl/cleanup_defer_compat.c (_pthread_cleanup_push_defer):
Likewise.
(_pthread_cleanup_pop_restore): Likewise.
* nptl/descr.h (CANCELSTATE_BIT): Remove flag.
(CANCELSTATE_BITMASK): Likewise.
(CANCELTYPE_BIT): Likewise.
(CANCELTYPE_BITMSK): Likewise.
(CANCEL_RESTMASK): Likewise.
(CANCEL_ENABLED_AND_CANCELED): Likewise.
(CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS): Likewise.
(cancelstate): New member.
(canceltype): Likewise.
* nptl/libc-cancellation.c (__syscall_cancel): Use cancelstate
instead of cancelhandling member.
* nptl/nptl-init.c (sigcancel_handler): Likewise.
* nptl/pthreadP.h (__do_cancel): Likewise.
(CANCELLATION_P): Likewise.
* nptl/pthread_join.c (pthread_join): Remove CANCELLATION_P
usage.
* nptl/pthread_testcancel.c (__pthread_testcancel): Likewise.
* nptl/pthread_setcancelstate.c (__pthread_setcancelstate):
Use cancelstate member instead of cancelhandling.
* nptl/pthread_setcanceltype.c (__pthread_setcanceltype): Use
canceltype member instead of canceltype.
* sysdeps/x86_64/nptl/tcb-offsets.sym (TCB_CANCELSTATE_BITMASK):
Remove.
(TCB_CANCELTYPE_BITMASK): Likewise.
(TCB_CANCEL_RETMASK): Likewise.
commit 7102b569bba27db931ae98460469796757709741
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Feb 26 16:24:15 2018 -0300
nptl: riscv: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the riscv modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function.
The default syscall_cancel.c should be as expected for RISCV. With
GCC 7.3.1 syscall_cancel.c generates the following code:
0000000000000000 <__GI___syscall_cancel_arch>:
0: 8346 mv t1,a7
0000000000000002 <__syscall_cancel_arch_start>:
2: 00052883 lw a7,0(a0)
6: 0048f893 andi a7,a7,4
a: 00089c63 bnez a7,22 <.L0 >
e: 88ae mv a7,a1
10: 8532 mv a0,a2
12: 85b6 mv a1,a3
14: 863a mv a2,a4
16: 86be mv a3,a5
18: 8742 mv a4,a6
1a: 879a mv a5,t1
1c: 00000073 ecall
0000000000000020 <__syscall_cancel_arch_end>:
20: 8082 ret
22: 1141 addi sp,sp,-16
24: e406 sd ra,8(sp)
26: 00000097 auipc ra,0x0
2a: 000080e7 jalr ra # 26 <.L0 >
Checked with a build for riscv64-linux-gnu with run-built-tests=no.
[BZ #12683]
* sysdeps/unix/sysv/linux/riscv/sigcontextinfo.h (ucontext_get_pc):
New fuction.
commit 1092ac32af74ddaa5ccfb63b8ef33b40b9befc8a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri Feb 3 21:07:07 2017 -0200
nptl: hppa: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the hppa modifications required for the BZ#12683.
It basically adds the required __pthread_get_pc function.
HPPA requires an arch-specific syscall_cancel because the
INTERNAL_SYSCALL_NCS adds some instruction to fetch the returned
syscalls value. The implementation were based on on default C
version built with GCC 6.1
Checked on hppa-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/hppa/sigcontextinfo.h: New file.
* sysdeps/unix/sysv/linux/hppa/syscall_cancel.S: Likewise.
commit f74aa232cde071899f8137920e84bbba3c8ed679
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:03:07 2017 -0200
nptl: mips: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the mips modifications required for the BZ#12683.
It adds the required ucontext_get_pc function, a mips32 cancellable
syscall wrapper and 7 argument cancellable syscall support.
To avoid code pessimization and add a requirement on all architectures
to support {INLINE,INTERNAL)_SYSCALL with 7 argument, its support is
added through a flag, HAVE_CANCELABLE_SYSCALL_WITH_7_ARGS, which changes
the signature and prototype of the requires macros and functions
(SYSCALL_CANCEL, __syscall_cancel and __syscall_cancel_arch). As
default 6 arguments cancellable syscalls are use.
MIPS o32 requires an arch-specific implementation because
INTERNAL_SYSCALL_NCS adds an 'addiu' just after the syscall
instruction which invalidates the checks on sigcancel_handler.
Checked against a build and make check run-built-tests=no for
mips-gnu-linux, mips64-linux-gnu, mips64-n32-linux-gnu. I also
ran some basic o32 and n64 cancellation tests on a simulated
mips64 qemu system.
[BZ #12683]
* nptl/libc-cancellation.c (__syscall_cancel): Define and use 7
argument syscall if architecture requires it.
* nptl/pthreadP.h (__syscall_cancel_arch): Likewise.
* sysdeps/unix/sysdep.h (__syscall_cancel, __SYSCALL_CANCEL*): Define
with 7 argument if architecture requires it.
(__SYSCALL_CANCEL7_ARG_DEF): New macro.
(__SYSCALL_CANCEL7_ARG): Likewise.
(__SYSCALL_CANCEL7_ARG7): Likewise.
* sysdeps/unix/sysv/linux/syscall_cancel.c (__syscall_cancel_arch):
Likewise.
* sysdeps/mips/nptl/tls.h (READ_THREAD_POINTER): Check __mips_isa_rev
existance for macro definition.
* sysdeps/unix/sysv/linux/mips/sigcontextinfo.h (ucontext_get_pc):
New function.
* sysdeps/unix/sysv/linux/mips/mips32/syscall_cancel.S: New file.
* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
(HAVE_CANCELABLE_SYSCALL_WITH_7_ARGS): Define.
commit 7806615561d4f40f4d53f3375536cfe08fe127e0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:03:03 2017 -0200
nptl: sh: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the sh modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function and a
cancellable syscall wrapper.
SH requires an arch-specific syscall_cancel because the
INTERNAL_SYSCALL_NCS adds the required or instruction to workaround
a hardware bug [1]. The implementation were based on on default C
version built with GCC 6.2.1.
Checked against a build and make check run-built-tests=no for
sh4-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/sh/syscall_cancel.S: New file.
* sysdeps/unix/sysv/linux/sh/sigcontextinfo.h (ucontext_get_pc):
New function.
[1] http://documentation.renesas.com/eng/products/mpumcu/tu/tnsh7456ae.pdf
commit 02badc9d7b0c5379bd46019546ed9d2d8acb6a4a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:02:53 2017 -0200
nptl: nios2: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the nios2 modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function.
The default syscall_cancel.c should be as expected for NIOS2. With
GCC 6.2.1 syscall_cancel.c generates the following code:
---
00000000 <__GI___syscall_cancel_arch>:
0: defffe04 addi sp,sp,-8
4: dd800015 stw r22,0(sp)
8: 002ce03a nextpc r22
c: 02000034 movhi r8,0
10: 42000004 addi r8,r8,0
14: dfc00115 stw ra,4(sp)
18: b22d883a add r22,r22,r8
0000001c <__syscall_cancel_arch_start>:
1c: 20c00017 ldw r3,0(r4)
20: 18c0010c andi r3,r3,4
24: 18000f1e bne r3,zero,64 <__syscall_cancel_arch_end+0x18>
28: 3015883a mov r10,r6
2c: 2805883a mov r2,r5
30: da400517 ldw r9,20(sp)
34: 380b883a mov r5,r7
38: da000417 ldw r8,16(sp)
3c: d9c00317 ldw r7,12(sp)
40: d9800217 ldw r6,8(sp)
44: 5009883a mov r4,r10
48: 003b683a trap 0
0000004c <__syscall_cancel_arch_end>:
4c: 38000126 beq r7,zero,54 <__syscall_cancel_arch_end+0x8>
50: 0085c83a sub r2,zero,r2
54: dfc00117 ldw ra,4(sp)
58: dd800017 ldw r22,0(sp)
5c: dec00204 addi sp,sp,8
60: f800283a ret
64: b0800017 ldw r2,0(r22)
68: 103ee83a callr r2
---
Checked against a build and make check run-built-tests=no for
nios2-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h (ucontext_get_pc):
New function.
commit a6ed5172ed96b96d6fe99bb1e83f0af8aec6bb97
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:02:36 2017 -0200
nptl: sparc: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the sparc modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function, cancellable
syscall wrappers, and a fix for pause.
Sparc requires arch-specific syscall_cancel implementation because
INLINE_SYSCALL_NCS uses the __SYSCALL_STRING (defined different
for sparc32 and sparc64) and it issues additional instructions
after the syscall one to check the resulting error code. When used
in the default syscall_cancel.c implementation the label
__syscall_cancel_arch_end is not placed just after the syscall as
expected. Both 32 and 64 bits version were based on default C version
built with GCC 6.1.
Also, different than other architectures, SPARC passes the sigcontext_t
struct pointer as third argument in the signal handler set with
SA_SIGINFO (some info at [1]) for 64 bits and the pt_regs in 32 bits.
From Linux code:
* arch/sparc/kernel/signal_64.c
428 /* 3. signal handler back-trampoline and parameters */
429 regs->u_regs[UREG_FP] = ((unsigned long) sf) - STACK_BIAS;
430 regs->u_regs[UREG_I0] = ksig->sig;
431 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
432
433 /* The sigcontext is passed in this way because of how it
434 * is defined in GLIBC's /usr/include/bits/sigcontext.h
435 * for sparc64. It includes the 128 bytes of siginfo_t.
436 */
437 regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
* arch/sparc/kernel/signal_32.c:
392 regs->u_regs[UREG_FP] = (unsigned long) sf;
393 regs->u_regs[UREG_I0] = ksig->sig;
394 regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
395 regs->u_regs[UREG_I2] = (unsigned long) &sf->regs;
396
397 regs->pc = (unsigned long) ksig->ka.sa.sa_handler;
398 regs->npc = (regs->pc + 4);
So to access the signal mask in the signal frame, a arch-specific
ucontext_get_mask is defined which obtain the sa_mask from the context.
Checked on a SPARC T5 for sparc64-linux-gnu and sparcv9-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/sparc/sparc32/sigcontextinfo.h
(ucontext_get_pc): New function.
* sysdeps/unix/sysv/linux/sparc/sparc64/sigcontextinfo.h
(ucontext_get_pc): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscall_cancel.S: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscall_cancel.S: Likwise.
* sysdeps/unix/sysv/linux/sparc/sparc64/pause.c: New file.
[1] https://www.spinics.net/lists/sparclinux/msg05037.html
commit fbdf0307b3e6b880a5c0effce603f441c1dce7ed
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:02:17 2017 -0200
nptl: microblaze: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the microblaze modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function.
Microblaze requires an arch specific assembly implementation because
the archicture INTERNAL_SYSCALL_NCS implementation adds a nop after
the brki instruction because the instruction expect a delay branch
slot. I based this implementation on generated assembly using GCC 6.1.
Checked against a build and make check run-built-tests=no for
microblaze-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S: New file.
* sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h
(ucontext_get_pc): New function.
commit 838fce23efc583cb8f016914fc374319b4b85f96
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:02:08 2017 -0200
nptl: m68k: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the m68k modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function
The default syscall_cancel.c should is as expected for m68k with
GCC 6.2.1. It generates the following code for syscall_cancel.os:
---
00000000 <__GI___syscall_cancel_arch>:
0: 4e56 0000 linkw %fp,#0
4: 48e7 3c00 moveml %d2-%d5,%sp@-
00000008 <__syscall_cancel_arch_start>:
8: 206e 0008 moveal %fp@(8),%a0
c: 2010 movel %a0@,%d0
e: 0800 0002 btst #2,%d0
12: 6628 bnes 3c <__syscall_cancel_arch_end+0xa>
14: 206e 0024 moveal %fp@(36),%a0
18: 2a2e 0020 movel %fp@(32),%d5
1c: 282e 001c movel %fp@(28),%d4
20: 262e 0018 movel %fp@(24),%d3
24: 242e 0014 movel %fp@(20),%d2
28: 222e 0010 movel %fp@(16),%d1
2c: 202e 000c movel %fp@(12),%d0
30: 4e40 trap #0
00000032 <__syscall_cancel_arch_end>:
32: 4cee 003c fff0 moveml %fp@(-16),%d2-%d5
38: 4e5e unlk %fp
3a: 4e75 rts
3c: 61ff 0000 0000 bsrl 3e <__syscall_cancel_arch_end+0xc>
---
Checked against a build and make check run-built-tests=no for
m68k-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/m68k/sigcontextinfo.h (ucontext_get_pc):
New function.
commit 6da7532402198c74e7c063ade4a1ea6c6906b82a
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:01:58 2017 -0200
nptl: alpha: Fix Race conditions in pthread cancellation (BZ#12683)
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.
[BZ #12683]
* sysdeps/unix/sysv/linux/alpha/sigcontextinfo.h (ucontext_get_pc):
New function.
commit 60eb1c51381fda4131058dffbd46f9d512cef59f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Jan 16 17:01:44 2017 -0200
nptl: ia64: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the s390 modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function. a workaround
for mismatched sigcontext::sa_flags defiition between kernel and
GLIBC (tracked by BZ#21634), and an arch specific syscall_cancel
implementation.
IA64 requires an arch-specific syscall_cancel implemetantion because
{INLINE,INTERNAL}_SYSCALL is implemented by branching to a gate
DSO (similar to i386) which renders the pointer comparison in
SIGCANCEL handler wrong. This incurs in performance penalty due the
use of a break instruction insteaf of a eds one, however
cancellable syscalls should potentially incur in syscalls blocking.
Checked with a ia64-linux-gnu build with run-tests-built=no.
[BZ #12683]
* sysdeps/unix/sysv/linux/ia64/sigcontextinfo.h (ucontext_get_pc,
ucontext_get_mask): New functions.
* sysdeps/unix/sysv/linux/ia64/syscall_cancel.S: New file.
commit ee923bad6397f393d8ae8d38b1ea95c8df0dcf74
Author: Adhemerval Zanella <adhemerval.zanella@linaro.com>
Date: Wed Aug 12 10:51:38 2015 -0300
nptl: s390: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the s390 modifications required for the BZ#12683 fix.
It basically adds the required ucontext_get_pc function.
The built cancelable syscall wrapper for s390 using GCC 7.2.1 and
default configuration flags shows the wrappers on expected corrected
places:
---
__GI___syscall_cancel_arch:
.LFB39:
.cfi_startproc
stm %r6,%r15,24(%r15)
.cfi_offset 6, -72
.cfi_offset 7, -68
.cfi_offset 8, -64
.cfi_offset 9, -60
.cfi_offset 10, -56
.cfi_offset 11, -52
.cfi_offset 12, -48
.cfi_offset 13, -44
.cfi_offset 14, -40
.cfi_offset 15, -36
ahi %r15,-96
.cfi_def_cfa_offset 192
.global __syscall_cancel_arch_start
.type __syscall_cancel_arch_start,@function
__syscall_cancel_arch_start:
l %r0,0(%r2)
tml %r0,4
jne .L5
lr %r1,%r3
lr %r2,%r4
lr %r3,%r5
lr %r4,%r6
l %r5,192(%r15)
l %r6,196(%r15)
l %r7,200(%r15)
svc 0
.global __syscall_cancel_arch_end
.type __syscall_cancel_arch_end,@function
__syscall_cancel_arch_end:
l %r4,152(%r15)
lm %r6,%r15,120(%r15)
.cfi_remember_state
.cfi_restore 15
.cfi_restore 14
.cfi_restore 13
.cfi_restore 12
.cfi_restore 11
.cfi_restore 10
.cfi_restore 9
.cfi_restore 8
.cfi_restore 7
.cfi_restore 6
.cfi_def_cfa_offset 96
br %r4
.L5:
.cfi_restore_state
brasl %r14,__syscall_do_cancel
.cfi_endproc
---
The s390x version also shows similar placement:
---
__GI___syscall_cancel_arch:
.cfi_startproc
stmg %r6,%r15,48(%r15)
.cfi_offset 6, -112
.cfi_offset 7, -104
.cfi_offset 8, -96
.cfi_offset 9, -88
.cfi_offset 10, -80
.cfi_offset 11, -72
.cfi_offset 12, -64
.cfi_offset 13, -56
.cfi_offset 14, -48
.cfi_offset 15, -40
aghi %r15,-160
.cfi_def_cfa_offset 320
.global __syscall_cancel_arch_start
.type __syscall_cancel_arch_start,@function
__syscall_cancel_arch_start:
l %r0,0(%r2)
tmll %r0,4
jne .L5
lgr %r1,%r3
lgr %r2,%r4
lgr %r3,%r5
lgr %r4,%r6
lg %r5,320(%r15)
lg %r6,328(%r15)
lg %r7,336(%r15)
svc 0
.global __syscall_cancel_arch_end
.type __syscall_cancel_arch_end,@function
__syscall_cancel_arch_end:
lg %r4,272(%r15)
lmg %r6,%r15,208(%r15)
.cfi_remember_state
.cfi_restore 15
.cfi_restore 14
.cfi_restore 13
.cfi_restore 12
.cfi_restore 11
.cfi_restore 10
.cfi_restore 9
.cfi_restore 8
.cfi_restore 7
.cfi_restore 6
.cfi_def_cfa_offset 160
br %r4
.L5:
.cfi_restore_state
brasl %r14,__syscall_do_cancel
.cfi_endproc
---
Checked on s390-linux-gnu and s390x-linux-gnu build with
run-tests-built=no.
[BZ #12683]
* sysdeps/unix/sysv/linux/s390/sigcontextinfo.h (ucontext_get_pc):
New function.
commit 683a8f59a9473e0ff6d6a3df26c0294948ddc8d8
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri May 8 17:12:31 2015 -0300
nptl: arm: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the ARM modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function and adjust
the generic syscall_cancel build.
For ARM we need to build syscall_cancel in ARM mode (-marm) to avoid
INTERNAL_SYSCALL to issue the syscall through the helper gate
__libc_do_syscall (which invalidates the mark checks on SIGCANCEL
handler).
Checked on arm-linux-gnueabihf.
[BZ #12683]
* sysdeps/unix/sysv/linux/arm/Makefile (CFLAGS-syscall_cancel.c): New
rule.
* sysdeps/unix/sysv/linux/arm/sigcontextinfo.h (ucontext_get_pc):
New function.
commit 0151ef6406a6e32c4601929bcbd3ea2b136f223b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed May 6 17:51:29 2015 -0300
nptl: aarch64: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the aarch64 modifications required for the BZ#12683.
It basically adds the required ucontext_get_pc function.
The built cancelable syscall wrapper for aarch64 using GCC 7.2.1 and
default configuration flags shows an expected optimized version:
---
__GI___syscall_cancel_arch:
.LFB38:
.cfi_startproc
.global __syscall_cancel_arch_start
.type __syscall_cancel_arch_start,@function
__syscall_cancel_arch_start:
ldr w9, [x0]
tbnz x9, 2, .L7
mov x8, x1
mov x0, x2
mov x1, x3
mov x2, x4
mov x3, x5
mov x4, x6
mov x5, x7
svc 0 // syscall nr
.global __syscall_cancel_arch_end
.type __syscall_cancel_arch_end,@function
__syscall_cancel_arch_end:
ret
---
A similar code is obtained with GCC 5.3.1, so I see to need to provide
an arch-specific syscall_cancel.S for aarch64.
Checked on aarch64-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h (PSEUDO): Redefine
to call __syscall_cancel function for cancellable syscalls.
(__pthread_get_ip): Add implementation.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h (SYSCALL_CANCEL_ERROR): Add
definition.
(SYSCALL_CANCEL_ERRNO): Likewise.
commit 996cfcbe41d1a7561a791ab20de2dab89bde529d
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri Sep 18 18:14:19 2015 -0300
nptl: powerpc: Fix Race conditions in pthread cancellation (BZ#12683)
This patches adds the powerpc64 modification required for the BZ#12683.
It basically adds the required __pthread_get_pc function and a arch
specific syscall_cancel implementation.
The powerpc requires an arch-specific syscall_cancel because
INTERNAL_SYSCALL_NCS adds a mfcr just after the sc instruction to get
the CR0.SO bit information from kernel (which signals the error
return status). So for cancelled syscalls with side effects,
__pthread_get_pc will point to mcfr and thus invalidating the checks
on sigcancel_handler.
Checked on powerpc64le-linux-gnu and powerpc-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/powerpc/sigcontextinfo.h (ucontext_get_pc):
New function.
* sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S: New file.
commit 2258ba74573f9265fea31606d2d1352514e9deb0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon May 4 16:30:13 2015 -0300
nptl: i386: Fix Race conditions in pthread cancellation (BZ#12683)
This patch adds the i386 modifications required for the BZ#12683.
It basically provides the required ucontext_get_pc symbol, add the
cancelable syscall wrapper and fix a thread atomic update macro.
On i386 an arch-specific cancellation implementation is required
because depending of the glibc configuration and underlying kernel
the syscall may be done using a vDSO symbol (__kernel_vsyscall).
By using the vDSO symbol the resulting PC value for an interrupted
syscall points to an adress outside the expected markers in
__syscall_cancel_arch. It has been discussed in LKML [1] on how
kernel could help userland to accomplish it, but afaik discussion
was stalled.
Also, since glibc supports i486, the old 'int 0x80' should be used
in the syscall wrapper. One option could make minimum default chip
to pentium II (which implements sysenter) or add a runtime check
on syscall_cancel.S to use 'int 0x80' or sysenter.
Checked on i686-linux-gnu.
[BZ #12683]
* sysdeps/i386/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL,
THREAD_ATOMIC_BIT_SET): Remove macro.
* sysdeps/unix/sysv/linux/i386/Makefile
[$(subdir) = elf] (sysdep-rtld_routines): Add libc-do-syscall object.
* sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_wait_tid): Use
cancellable futex syscall macro.
* sysdeps/unix/sysv/linux/i386/syscall_cancel.S: New file.
* sysdeps/unix/sysv/linux/i386/sigcontextinfo.h (ucontext_get_pc):
New function.
[1] https://lkml.org/lkml/2016/3/8/1105
commit f43adba514ff665338e6da714551d8c3f6b158ce
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Sat May 9 14:20:26 2015 -0300
nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683)
This patches adds the x32 modification required for the BZ#12683.
It basically adjust the syscall size used to pass the arguments to
the syscall cancel wrappers by zero extending pointers type while
preserting values for default types (such as off_t).
Checked on x86_64-linux-gnu-x32.
[BZ #12683]
* sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h (__syscall_arg_t):
Define type for x32.
(__SSC): Add platform specific macro.
* include/libc-pointer-arith.h (__integer_if_pointer_type_sub,
__integer_if_pointer_type, cast_to_integer): Parametrize integer type
cast.
(cast_to_uinteger): New macro.
commit 299d22ce112252b2a950e4395344dcf3791d73a9
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Sep 29 09:48:34 2014 -0300
nptl: x86_64: Fix Race conditions in pthread cancellation (BZ#12683)
This patches adds the x86_64 modification required for the BZ#12683.
It basically provide the required ucontext_get_pc symbol and remove
the arch-specific libc-cancellation implementations.
Checked on x86_64-linux-gnu.
[BZ #12683]
* sysdeps/unix/sysv/linux/x86_64/cancellation.S: Remove file.
* sysdeps/unix/sysv/linux/x86_64/libc-cancellation.S: Remove file.
* sysdeps/unix/sysv/linux/x86_64/librt-cancellation.S: Remove file.
* sysdeps/unix/sysv/linux/x86_64/sigcontextinfo.h (ucontext_get_pc):
New function.
* sysdeps/x86_64/nptl/tcb-offsets.sym (TCB_CANCELING_BITMASK):
Remove.
commit 6fe99352106cf8f244418f3708b3d5928e82e831
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri Sep 18 18:26:35 2015 -0300
nptl: Fix Race conditions in pthread cancellation (BZ#12683)
This patches fixes some race conditions in NPTL cancellation code by
redefining how cancellable syscalls are defined and handled. Current
approach is to enable asynchronous cancellation prior to making the syscall
and restore the previous cancellation type once the syscall returns.
As decribed in BZ#12683, this approach shows 2 important problems:
1. Cancellation can act after the syscall has returned from kernel, but
before userspace saves the return value. It might result in a resource
leak if the syscall allocated a resource or a side effect (partial
read/write), and there is no way to program handle it with cancellation
handlers.
2. If a signal is handled while the thread is blocked at a cancellable
syscall, the entire signal handler runs with asynchronous cancellation
enabled. This can lead to issues if the signal handler call functions
which are async-signal-safe but not async-cancel-safe.
For cancellation to work correctly, there are 5 points at which the
cancellation signal could arrive:
1. Before the final "testcancel" and before the syscall is made.
2. Between the "testcancel" and the syscall.
3. While the syscall is blocked and no side effects have yet taken place.
4. While the syscall is blocked but with some side effects already having
taken place (e.g. a partial read or write).
5. After the syscall has returned.
And GLIBC wants to act on cancellation in cases 1, 2, and 3 but not in case
4 or 5. The proposed solution follows:
* Handling case 1 is trivial: do a conditional branch based on whether the
thread has received a cancellation request;
* Case 2 can be caught by the signal handler determining that the saved
program counter (from the ucontext_t) is in some address range beginning
just before the "testcancel" and ending with the syscall instruction.
* In this case, except for certain syscalls that ALWAYS fail with EINTR
even for non-interrupting signals, the kernel will reset the program
counter to point at the syscall instruction during signal handling, so
that the syscall is restarted when the signal handler returns. So, from
the signal handler's standpoint, this looks the same as case 2, and thus
it's taken care of.
* In this case, the kernel cannot restart the syscall; when it's
interrupted by a signal, the kernel must cause the syscall to return
with whatever partial result it obtained (e.g. partial read or write).
* In this case, the saved program counter points just after the syscall
instruction, so the signal handler won't act on cancellation.
This one is equal to 4. since the program counter is past the syscall
instruction already.
Another case that needs handling is syscalls that fail with EINTR even
when the signal handler is non-interrupting. In this case, the syscall
wrapper code can just check the cancellation flag when the errno result
is EINTR, and act on cancellation if it's set.
The proposed GLIBC adjustments are:
1. Remove the enable_asynccancel/disable_asynccancel function usage in
syscall definition and instead make them call a common symbol that will
check if cancellation is enabled (__syscall_cancel at
nptl/libc-cancellation.c), call the arch-specific cancellable
entry-point (__syscall_cancel_arch) and cancel the thread when required.
2. Provide a arch-specific symbol that contains global markers. These
markers will be used in SIGCANCEL handler to check if the interruption
has been called in a valid syscall and if the syscalls has been
completed or not.
A default version is provided (sysdeps/unix/sysv/linux/syscall_cancel.c),
however the markers may not be set on correct expected places depeding
of how INTERNAL_SYSCALL_NCS is implemented by the underlying architecture.
In this case arch-specific implementation should be provided.
3. Rewrite SIGCANCEL asynchronous handler to check for both cancelling type
and if current IP from signal handler falls between the global markes
and act accordingly (sigcancel_handler at nptl/nptl-init.c).
4. Adjust nptl/pthread_cancel.c to send an signal instead of acting
directly. This avoid synchronization issues when updating the
cancellation status and also focus the logic on signal handler and
cancellation syscall code.
5. Adjust pthread code to replace CANCEL_ASYNC/CANCEL_RESET calls to
appropriated cancelable futex syscalls.
6. Adjust libc code to replace LIBC_CANCEL_ASYNC/LIBC_CANCEL_RESET to
appropriated cancelable syscalls.
7. Adjust 'lowlevellock-futex.h' arch-specific implementations to provide
cancelable futex calls (used in libpthread code).
This patch adds the proposed changes to NPTL. The code leaves all the ports
broken without further patches in the list.
[BZ #12683]
* manual/llio.texi: Adjust comments regarding
pthread_enable_asynccancel and pthread_disable_asynccancel.
* nptl/Makefile (routines): Add syscall_cancel object.
(libpthread-routines): Add pthread_kill_internal and remove
cancellation object.
(CFLAGS-cancellation.c): Remove rule.
(CFLAGS-syscall_cancel.c): New rule.
(tests): Add tst-cancel28.
* nptl/Versions [GLIBC_PRIVATE] (libc): Add __syscall_cancel,
__syscall_cancel_arch_start, and __syscall_cancel_arch_end.
* nptl/cancellation.c: Remove file.
* sysdeps/nptl/librt-cancellation.c: Likewise.
* nptl/descr.h (CANCELING_BIT, CANCELING_BITMASK): Remove define.
(CANCELED_BIT, EXITING_BIT, TERMINATED_BIT, SETXID_BIT,
CANCEL_RESTMASK): Adjust value with CANCELED_BIT removal.
* nptl/libc-cancellation.c (__syscall_cancel): New symbol: symbol
brigde for non-cancellable syscalls.
(__syscall_do_cancel): New symbol.
* nptl/nptl-init.c (sigcancel_handler): Rewrite function to avoid race
conditions.
(__pthread_initialize_minimal_internal): Add SA_RESTART to SIGCANCEL
handler.
(UCONTEXT_SIGMASK): New macro.
* nptl/pthreadP.h (__do_cancel): Rewrite to both disable asynchronous
cancellation and setting the thread as cancelled.
(__do_cancel_with_result): New macro.
(CANCEL_ASYNC, CANCEL_RESET, LIBC_CANCEL_ASYNC, LIBC_CANCEL_RESET,
LIBC_CANCEL_HANDLED): Remove macros.
(__syscall_cancel_arch, __syscall_do_cancel, __pthread_kill_internal):
New prototypes.
(__pthread_enable_asynccancel, __pthread_disable_asynccancel,
__libc_enable_asynccancel, __libc_disable_asynccancel,
__librt_enable_asynccancel, __librt_disable_asynccancel): Remove
prototypes.
* nptl/pthread_cancel.c (pthread_cancel): Rewrite to just set
CANCELLED_BIT and call __pthread_kill.
* nptl/pthread_create.c (START_THREAD_DEFN): Likewise.
* nptl/pthread_exit.c (__pthread_exit): Call __do_cancel_with_result.
* nptl/pthread_join_common.c (__pthread_timedjoin_ex): Likewise.
* nptl/pthread_kill.c (__pthread_kill): Check internal signals with
__is_internal_signal, tail call __pthread_kill_internal, and remove
stub_warning.
* nptl/pthread_kill_internal.c: New file.
* nptl/tst-cancel28.c: Likewise.
* rt/Makefile [CFLAGS-librt-cancellation.c]: Remove rule.
* support/temp_file.c (support_create_temp_fifo): New function.
* support/temp_file.h (support_create_temp_fifo): New prototype.
* sysdeps/generic/sigcontextinfo.h (ucontext_get_pc): Likewise.
* sysdeps/generic/sysdep-cancel.h (LIBC_CANCEL_ASYNC,
LIBC_CANCEL_RESET): Remove define.
* sysdeps/htl/pthreadP.h (__pthread_kill_internal): New prototype.
* sysdeps/nptl/Makefile [$(subdir) = rt] (librt-sysdep_routines):
Remove librt-cancellation object.
[$(subdir) = rt] (CFLAGS-librt-cancellation.c): Remove rule.
* nptl/lll_timedwait_tid.c (__lll_timedwait_tid): Use cancellable
futex operation.
* sysdeps/unix/sysdep.h (SYSCALL_CANCEL): Rewrite to call __syscall_cancel.
(INTERNAL_SYSCALL_NCS_CALL, __INTERNAL_SYSCALL_NCS*, __SYSCALL_CANCEL*):
New macros.
* sysdeps/unix/sysv/linux/futex-internal.h (fuex_wait_cancel,
futex_reltimed_wait_cancelable, futex_abstimed_wait_cancelable): Use
cancelable futex wrapper.
* sysdeps/unix/sysv/linux/lowlevellock-futex.h (lll_futex_syscall_cp,
lll_futex_wait_cancel, lll_futex_timed_wait_cancel,
lll_futex_timed_wait_bitset_cancel): New macros.
* sysdeps/unix/sysv/linux/pthread_kill_internal.c: New file.
* sysdeps/unix/sysv/linux/socketcall.h (SOCKETCALL): Use __SSC macros.
(SOCKETCALL_CANCEL): Use SYSCALL_CANCEL macros.
(__SOCKETCALL_CANCEL*): New macros.
* sysdeps/unix/sysv/linux/syscall_cancel.c: New file.
* sysdeps/unix/sysv/linux/sysdep.h (SYSCALL_CANCEL_RET): New macro.
commit 590b6e0aa785db2164870707244d4ae16a711277
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu May 10 17:24:56 2018 -0300
nptl: Cleanup cancellation macros
This patch wraps all uses of *_{enable,disable}_asynccancel and
and *_CANCEL_{ASYNC,RESET} in either already provided macros
(lll_futex_timed_wait_cancel) or creates new ones if the
functionality is not provided (SYSCALL_CANCEL_NCS, lll_futex_wait_cancel,
and lll_futex_timed_wait_cancel).
Also for some generic implementations, the direct call of the macros
are removed since the underlying symbols are suppose to provide
cancellation support.
This is a priliminary patch intended to simplify the work required
for BZ#12683 fix. It is a refactor change, no semantic changes are
expected.
Checked on x86_64-linux-gnu and i686-linux-gnu.
* nptl/pthread_join_common.c (__pthread_timedjoin_ex): Use
lll_wait_tid with timeout.
* nptl/sem_wait.c (__old_sem_wait): Use lll_futex_wait_cancel.
* sysdeps/nptl/aio_misc.h (AIO_MISC_WAIT): Use
futex_reltimed_wait_cancelable for cancelabla mode.
* sysdeps/nptl/gai_misc.h (GAI_MISC_WAIT): Likewise.
* sysdeps/posix/open64.c (__libc_open64): Do not call cancelation
macros.
* sysdeps/posix/sigwait.c (__sigwait): Likewise.
* sysdeps/posix/waitid.c (__sigwait): Likewise.
* sysdeps/unix/sysdep.h (__SYSCALL_CANCEL_CALL,
SYSCALL_CANCEL_NCS): New macro.
* sysdeps/nptl/lowlevellock.h (lll_wait_tid): Add timeout argument.
(lll_timedwait_tid): Remove macro.
* sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_wait_tid):
Likewise.
(lll_timedwait_tid): Likewise.
* sysdeps/unix/sysv/linux/sparc/lowlevellock.h (lll_wait_tid):
Likewise.
(lll_timedwait_tid): Likewise.
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_wait_tid):
Likewise.
(lll_timedwait_tid): Likewise.
* sysdeps/unix/sysv/linux/clock_nanosleep.c (__clock_nanosleep):
Use SYSCALL_CANCEL_NCS.
* sysdeps/unix/sysv/linux/futex-internal.h
(futex_reltimed_wait_cancelable): Use LIBC_CANCEL_{ASYNC,RESET}
instead of __pthread_{enable,disable}_asynccancel.
* sysdeps/unix/sysv/linux/lowlevellock-futex.h
(lll_futex_wait_cancel): New macro.
commit 323ab50e88231adaf93d3bdf42b15612f2795ce9
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed May 9 10:39:49 2018 -0300
i386: Remove bogus THREAD_ATOMIC_* macros
The x86 defines optimized THREAD_ATOMIC_* macros where reference always
the current thread instead of the one indicated by input 'descr' argument.
It work as long the input is the self thread pointer, however it generates
wrong code is the semantic is to set a bit atomicialy from another thread.
This is not an issue for current GLIBC usage, however the new cancellation
code expects that some synchronization code to atomically set bits from
different threads.
If some usage indeed proves to be a hotspot we can add an extra macro
with a more descriptive name (THREAD_ATOMIC_BIT_SET_SELF for instance)
where i386 might optimize it.
Checked on i686-linux-gnu.
* sysdeps/i686/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL,
THREAD_ATOMIC_AND, THREAD_ATOMIC_BIT_SET): Remove macros.
commit b6838cd772c01dca2cf49217d4af8bcfdbe8eeb8
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Wed May 9 10:32:25 2018 -0300
x86: Remove wrong THREAD_ATOMIC_* macros
The x86 defines optimized THREAD_ATOMIC_* macros where reference always
the current thread instead of the one indicated by input 'descr' argument.
It work as long the input is the self thread pointer, however it generates
wrong code is the semantic is to set a bit atomicialy from another thread.
This is not an issue for current GLIBC usage, however the new cancellation
code expects that some synchronization code to atomically set bits from
different threads.
The generic code generates an additional load to reference to TLS segment,
for instance the code:
THREAD_ATOMIC_BIT_SET (THREAD_SELF, cancelhandling, CANCELED_BIT);
Compiles to:
lock;orl $4, %fs:776
Where with patch changes it now compiles to:
mov %fs:16,%rax
lock;orl $4, 776(%rax)
If some usage indeed proves to be a hotspot we can add an extra macro
with a more descriptive name (THREAD_ATOMIC_BIT_SET_SELF for instance)
where x86_64 might optimize it.
Checked on x86_64-linux-gnu.
* sysdeps/x86_64/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL,
THREAD_ATOMIC_AND, THREAD_ATOMIC_BIT_SET): Remove macros.
commit 42794ba6346307769c5836e51c0b85b988b00732
Author: Adhemerval Zanella <adhemerval.zanella@linaro.com>
Date: Mon Sep 21 15:55:58 2015 -0700
nptl: Fix testcases for new pthread cancellation mechanism
With upcoming fix for BZ#12683, pthread cancellation does not act for:
1. If syscall is blocked but with some side effects already having
taken place (e.g. a partial read or write).
2. After the syscall has returned.
The main change is due the fact programs need to act in syscalls with
side-effects (for instance, to avoid leak of allocated resources or
handle partial read/write).
This patch changes the NPTL testcase that assumes the old behavior and
also remove the tst-cancel-wrappers.sh test (which checks for symbols
that will not exist anymore).
It also changes how to call the read syscall on tst-backtrace{5,6}
to use syscall instead of read cancelable syscall to avoid need to
handle the cancelable bridge function calls.
Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
aarch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu,
powerpc-linux-gnu, sparcv9-linux-gnu, and sparc64-linux-gnu.
* debug/tst-backtrace5.c (handle_signal): Check for syscall
instead of read.
(fn): Issue the read syscall instead of call the cancellable
syscall.
* nptl/tst-cancel4.c (tf_write): Handle cancelled syscall with
side-effects.
(tf_send): Likewise.
commit 00278aa8a3fffa4cb1d9a7b882b84e512aa09ae9
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue May 8 16:28:18 2018 -0300
nptl: Remove tst-cancel-wrappers test and related macros
With upcoming BZ#12683 fix, syscall cancellation is not more handled
by {libc,pthread,librt}_{enable,disable}_asynccancel symbols. This renders
both LIBC_CANCEL_HANDLED and empty declaration and tst-cancel-wrappers.sh
unrequired. This patch removes both the macro and the nptl test.
Checked on x86_64-linux-gnu.
* io/creat.c (LIBC_CANCEL_HANDLED): Remove macro.
* io/ppoll.c (LIBC_CANCEL_HANDLED): Likewise.
* misc/pselect.c (LIBC_CANCEL_HANDLED): Likewise.
* nptl/pthreadP.h (LIBC_CANCEL_HANDLED): Likewise.
* sysdeps/generic/sysdep-cancel.h (LIBC_CANCEL_HANDLED): Likewise.
* sysdeps/posix/pause.c (LIBC_CANCEL_HANDLED): Likewise.
* sysdeps/posix/sigpause.c (LIBC_CANCEL_HANDLED): Likewise.
* sysdeps/unix/sysv/linux/creat.c (LIBC_CANCEL_HANDLED): Likewise.
* sysdeps/unix/sysv/linux/creat64.c (LIBC_CANCEL_HANDLED): Likewise.
* sysdeps/unix/sysv/linux/sigwait.c (LIBC_CANCEL_HANDLED): Likewise.
* sysdeps/unix/sysv/linux/sigwaitinfo.c (LIBC_CANCEL_HANDLED):
Likewise.
* nptl/Makefile [$(run-built-tests) = yes] (tests-special): Remove
tst-cancel-wrappers.sh.
(generated): Remove tst-cancel-wrappers.out.
(tst-cancel-wrappers.out): Remove rule.
* nptl/tst-cancel-wrappers.sh: Remove file.
commit d6ed8a26a2b63f28721c4adfca00de8da83238ff
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon Feb 26 17:52:02 2018 -0300
powerpc: Add CFI information on indirect syscall
This patch the required CFI information on powerpc indirect syscall
so backtrace works correctly on signal handler.
Checked on powerpc-linux-gnu and powerpc64le-linux-gnu.
* sysdeps/unix/sysv/linux/powerpc/syscall.S (syscall): Add CFI
information.