diff options
Diffstat (limited to 'nptl/sysdeps')
5 files changed, 65 insertions, 8 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S index 6761c136e5..884987cf50 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S @@ -649,10 +649,24 @@ __condvar_tw_cleanup: movl $0x7fffffff, %edx ENTER_KERNEL + /* Lock the mutex only if we don't own it already. This only happens + in case of PI mutexes, if we got cancelled after a successful + return of the futex syscall and before disabling async + cancellation. */ 5: movl 24+FRAME_SIZE(%esp), %eax - call __pthread_mutex_cond_lock + movl MUTEX_KIND(%eax), %ebx + andl $(ROBUST_BIT|PI_BIT), %ebx + cmpl $PI_BIT, %ebx + jne 8f + + movl (%eax), %ebx + andl $TID_MASK, %ebx + cmpl %ebx, %gs:TID + je 9f + +8: call __pthread_mutex_cond_lock - movl %esi, (%esp) +9: movl %esi, (%esp) .LcallUR: call _Unwind_Resume hlt diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S index 0af06acad4..bf1e5fe788 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S @@ -566,10 +566,24 @@ __condvar_w_cleanup: movl $0x7fffffff, %edx ENTER_KERNEL + /* Lock the mutex only if we don't own it already. This only happens + in case of PI mutexes, if we got cancelled after a successful + return of the futex syscall and before disabling async + cancellation. */ 5: movl 24+FRAME_SIZE(%esp), %eax - call __pthread_mutex_cond_lock + movl MUTEX_KIND(%eax), %ebx + andl $(ROBUST_BIT|PI_BIT), %ebx + cmpl $PI_BIT, %ebx + jne 8f + + movl (%eax), %ebx + andl $TID_MASK, %ebx + cmpl %ebx, %gs:TID + je 9f + +8: call __pthread_mutex_cond_lock - movl %esi, (%esp) +9: movl %esi, (%esp) .LcallUR: call _Unwind_Resume hlt diff --git a/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym b/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym index 46fbd0de74..0ac51dba98 100644 --- a/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym +++ b/nptl/sysdeps/unix/sysv/linux/pthread-pi-defines.sym @@ -6,3 +6,4 @@ MUTEX_KIND offsetof (pthread_mutex_t, __data.__kind) ROBUST_BIT PTHREAD_MUTEX_ROBUST_NORMAL_NP PI_BIT PTHREAD_MUTEX_PRIO_INHERIT_NP PS_BIT PTHREAD_MUTEX_PSHARED_BIT +TID_MASK FUTEX_TID_MASK diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S index b669abb573..eb133266c6 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S @@ -771,10 +771,24 @@ __condvar_cleanup2: movl $SYS_futex, %eax syscall + /* Lock the mutex only if we don't own it already. This only happens + in case of PI mutexes, if we got cancelled after a successful + return of the futex syscall and before disabling async + cancellation. */ 5: movq 16(%rsp), %rdi - callq __pthread_mutex_cond_lock + movl MUTEX_KIND(%rdi), %eax + andl $(ROBUST_BIT|PI_BIT), %eax + cmpl $PI_BIT, %eax + jne 7f + + movl (%rdi), %eax + andl $TID_MASK, %eax + cmpl %eax, %fs:TID + je 8f + +7: callq __pthread_mutex_cond_lock - movq 24(%rsp), %rdi +8: movq 24(%rsp), %rdi movq FRAME_SIZE(%rsp), %r15 movq FRAME_SIZE+8(%rsp), %r14 movq FRAME_SIZE+16(%rsp), %r13 diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S index ec403cd9b8..6c6dc0e74d 100644 --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S @@ -495,10 +495,24 @@ __condvar_cleanup1: movl $SYS_futex, %eax syscall + /* Lock the mutex only if we don't own it already. This only happens + in case of PI mutexes, if we got cancelled after a successful + return of the futex syscall and before disabling async + cancellation. */ 5: movq 16(%rsp), %rdi - callq __pthread_mutex_cond_lock + movl MUTEX_KIND(%rdi), %eax + andl $(ROBUST_BIT|PI_BIT), %eax + cmpl $PI_BIT, %eax + jne 7f + + movl (%rdi), %eax + andl $TID_MASK, %eax + cmpl %eax, %fs:TID + je 8f + +7: callq __pthread_mutex_cond_lock - movq 24(%rsp), %rdi +8: movq 24(%rsp), %rdi .LcallUR: call _Unwind_Resume@PLT hlt |