Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: replace futex_atomic_cmpxchg_inatomic() with user_atomic_cmpxchg_inatomic

futex_atomic_cmpxchg_inatomic() is simply the 32-bit implementation of
user_atomic_cmpxchg_inatomic(), which in turn is simply a
generalization of the original code in
futex_atomic_cmpxchg_inatomic().

Use the newly generalized user_atomic_cmpxchg_inatomic() as the futex
implementation, too.

[ hpa: retain the inline in futex.h rather than changing it to a macro ]

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Link: http://lkml.kernel.org/r/1387002303-6620-2-git-send-email-qiaowei.ren@intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>

authored by

Qiaowei Ren and committed by
H. Peter Anvin
0ee3b6f8 f09174c5

+1 -20
+1 -20
arch/x86/include/asm/futex.h
··· 110 110 static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, 111 111 u32 oldval, u32 newval) 112 112 { 113 - int ret = 0; 114 - 115 - if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) 116 - return -EFAULT; 117 - 118 - asm volatile("\t" ASM_STAC "\n" 119 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" 120 - "2:\t" ASM_CLAC "\n" 121 - "\t.section .fixup, \"ax\"\n" 122 - "3:\tmov %3, %0\n" 123 - "\tjmp 2b\n" 124 - "\t.previous\n" 125 - _ASM_EXTABLE(1b, 3b) 126 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr) 127 - : "i" (-EFAULT), "r" (newval), "1" (oldval) 128 - : "memory" 129 - ); 130 - 131 - *uval = oldval; 132 - return ret; 113 + return user_atomic_cmpxchg_inatomic(uval, uaddr, oldval, newval); 133 114 } 134 115 135 116 #endif