Unwire set/get_robust_list
PATCH 1/1 Unwire set/get_robust_list
The syscalls set/get_robust_list must not be wired up until futex_atomic_cmpxchg_inatomic is implemented. Otherwise the kernel will hang in handle_futex_death.
include/asm-powerpc/systbl.h +2 -2
@@ -302,5 +302,5 @@ SYSCALL_SPU(symlinkat) SYSCALL_SPU(readlinkat) SYSCALL_SPU(fchmodat) SYSCALL_SPU(faccessat) -COMPAT_SYS_SPU(get_robust_list) -COMPAT_SYS_SPU(set_robust_list) +SYSCALL(ni_syscall) +SYSCALL(ni_syscall)
include/asm-powerpc/unistd.h +2 -2
@@ -321,8 +321,8 @@#define __NR_readlinkat 296#define __NR_fchmodat 297#define __NR_faccessat 298 -#define __NR_get_robust_list 299 -#define __NR_set_robust_list 300 +/* Number 299 reserved for get_robust_list */ +/* Number 300 reserved for set_robust_list */ #ifdef __KERNEL__
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 3 lines · Andreas Schwab
The syscalls set/get_robust_list must not be wired up until
futex_atomic_cmpxchg_inatomicis implemented. Otherwise the kernel will hang inhandle_futex_death.
Something like this?
include/asm-powerpc/futex.h +24 -1
@@ -84,7 +84,30 @@ static inline int futex_atomic_op_inuserstatic inline int futex_atomic_cmpxchg_inatomic (int __user *uaddr,int oldval,int newval) { -return -ENOSYS ; +int prev; + + __asm__ __volatile__ ( +LWSYNC_ON_SMP +"1: lwarx %0,0,%2 # futex_atomic_cmpxchg_inatomic\n\ +cmpw 0,%0,%3\n\ +bne- 3f\n" + PPC405_ERR77(0,%2) +"2: stwcx. %4,0,%2\n\ +bne- 1b\n" +ISYNC_ON_SMP +"3: .section .fixup,\"ax\"\n\ +4: li %0,%5\n\ +b 3b\n\ +.previous\n\ +.section __ex_table,\"a\"\n\ +.align 3\n\ +" PPC_LONG "1b,4b,2b,4b\n\ +.previous" \ + : "=&r" (prev), "+m" (*uaddr) + : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) + : "cc", "memory"); + + return prev; }#endif /* __KERNEL__ */
Signature · 1 line
dwmw2
Quoted 8 lines · David Woodhouse
Quoted 3 lines · Andreas Schwab
The syscalls set/get_robust_list must not be wired up until
futex_atomic_cmpxchg_inatomicis implemented. Otherwise the kernel will hang inhandle_futex_death.Something like this?
Untested-but-otherwise-Signed-off-by David Woodhouse <[email protected]>
Thanks, sucessfully tested on 32bit (with the nptl testsuite of glibc). Will do some 64bit testing tomorrow.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 2 lines · Andreas Schwab
Thanks, sucessfully tested on 32bit (with the nptl testsuite of glibc). Will do some 64bit testing tomorrow.
Did you do that testing? What was the result?
Could you test David's latest patch without the memory clobber? For reference, here it is.
Thanks,
Paul.
include/asm-powerpc/futex.h +27 -1
@@ -84,7 +84,33 @@ static inline int futex_atomic_op_inuserstatic inline int futex_atomic_cmpxchg_inatomic (int __user *uaddr,int oldval,int newval) { -return -ENOSYS ; +int prev; + +if (!access_ok (VERIFY_WRITE , uaddr,sizeof (int ))) +return -EFAULT ; + + __asm__ __volatile__ ( +LWSYNC_ON_SMP +"1: lwarx %0,0,%2 # futex_atomic_cmpxchg_inatomic\n\ +cmpw 0,%0,%3\n\ +bne- 3f\n" + PPC405_ERR77(0,%2) +"2: stwcx. %4,0,%2\n\ +bne- 1b\n" +ISYNC_ON_SMP +"3: .section .fixup,\"ax\"\n\ +4: li %0,%5\n\ +b 3b\n\ +.previous\n\ +.section __ex_table,\"a\"\n\ +.align 3\n\ +" PPC_LONG "1b,4b,2b,4b\n\ +.previous" \ + : "=&r" (prev), "+m" (*uaddr) + : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) + : "cc"); + + return prev; }#endif /* __KERNEL__ */
Quoted 6 lines · Paul Mackerras
Quoted 2 lines · Andreas Schwab
Thanks, sucessfully tested on 32bit (with the nptl testsuite of glibc). Will do some 64bit testing tomorrow.
Did you do that testing? What was the result?
Yes, I did, successful.
Quoted 1 line
Could you test David's latest patch without the memory clobber?
I'll do.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 1 line · Paul Mackerras
Could you test David's latest patch without the memory clobber?
Looks good (only tested on ppc64 kernel this time, but both 32 and 64 bit userland).
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 1 line · David Woodhouse
Something like this?
Don't we need an access_ok() test in there? Otherwise, looks fine to me.
Thanks,
Paul.
Quoted 2 lines · Paul Mackerras
Don't we need an
access_ok()test in there? Otherwise, looks fine to me.
Oops, good point. Like this then...
Do we actually need the memory clobber, btw? We're not using this for locking in kernel space.
[PATCH] Implement PowerPC futex_atomic_cmpxchg_inatomic().
The sys_[gs]et_robust_list() syscalls were wired up on PowerPC but didn't work correctly because futex_atomic_cmpxchg_inatomic() wasn't implemented. Implement it, based on __cmpxchg_u32()
include/asm-powerpc/futex.h +27 -1
@@ -84,7 +84,33 @@ static inline int futex_atomic_op_inuserstatic inline int futex_atomic_cmpxchg_inatomic (int __user *uaddr,int oldval,int newval) { -return -ENOSYS ; +int prev; + +if (!access_ok (VERIFY_WRITE , uaddr,sizeof (int ))) +return -EFAULT ; + + __asm__ __volatile__ ( +LWSYNC_ON_SMP +"1: lwarx %0,0,%2 # futex_atomic_cmpxchg_inatomic\n\ +cmpw 0,%0,%3\n\ +bne- 3f\n" + PPC405_ERR77(0,%2) +"2: stwcx. %4,0,%2\n\ +bne- 1b\n" +ISYNC_ON_SMP +"3: .section .fixup,\"ax\"\n\ +4: li %0,%5\n\ +b 3b\n\ +.previous\n\ +.section __ex_table,\"a\"\n\ +.align 3\n\ +" PPC_LONG "1b,4b,2b,4b\n\ +.previous" \ + : "=&r" (prev), "+m" (*uaddr) + : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) + : "cc", "memory"); + + return prev; }#endif /* __KERNEL__ */
Signature · 1 line
dwmw2
Quoted 3 lines · Andreas Schwab
The syscalls set/get_robust_list must not be wired up until
futex_atomic_cmpxchg_inatomicis implemented. Otherwise the kernel will hang inhandle_futex_death.
Either Andreas' or my patch ought to go into 2.6.18, since [gs]et_robust_list() are otherwise broken there.
Signature · 1 line
dwmw2