diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/alpha/include/asm/futex.h | 29 | ||||
-rw-r--r-- | arch/arm/include/asm/futex.h | 29 | ||||
-rw-r--r-- | arch/frv/include/asm/futex.h | 5 | ||||
-rw-r--r-- | arch/frv/kernel/futex.c | 14 | ||||
-rw-r--r-- | arch/ia64/include/asm/futex.h | 15 | ||||
-rw-r--r-- | arch/microblaze/include/asm/futex.h | 31 | ||||
-rw-r--r-- | arch/mips/include/asm/futex.h | 39 | ||||
-rw-r--r-- | arch/parisc/include/asm/futex.h | 24 | ||||
-rw-r--r-- | arch/powerpc/include/asm/futex.h | 27 | ||||
-rw-r--r-- | arch/s390/include/asm/futex.h | 12 | ||||
-rw-r--r-- | arch/s390/include/asm/uaccess.h | 4 | ||||
-rw-r--r-- | arch/s390/lib/uaccess.h | 8 | ||||
-rw-r--r-- | arch/s390/lib/uaccess_pt.c | 17 | ||||
-rw-r--r-- | arch/s390/lib/uaccess_std.c | 8 | ||||
-rw-r--r-- | arch/sh/include/asm/futex-irq.h | 24 | ||||
-rw-r--r-- | arch/sh/include/asm/futex.h | 11 | ||||
-rw-r--r-- | arch/sparc/include/asm/futex_64.h | 20 | ||||
-rw-r--r-- | arch/tile/include/asm/futex.h | 27 | ||||
-rw-r--r-- | arch/x86/include/asm/futex.h | 22 |
19 files changed, 197 insertions, 169 deletions
diff --git a/arch/alpha/include/asm/futex.h b/arch/alpha/include/asm/futex.h index 945de222ab91..e8a761aee088 100644 --- a/arch/alpha/include/asm/futex.h +++ b/arch/alpha/include/asm/futex.h | |||
@@ -29,7 +29,7 @@ | |||
29 | : "r" (uaddr), "r"(oparg) \ | 29 | : "r" (uaddr), "r"(oparg) \ |
30 | : "memory") | 30 | : "memory") |
31 | 31 | ||
32 | static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | 32 | static inline int futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr) |
33 | { | 33 | { |
34 | int op = (encoded_op >> 28) & 7; | 34 | int op = (encoded_op >> 28) & 7; |
35 | int cmp = (encoded_op >> 24) & 15; | 35 | int cmp = (encoded_op >> 24) & 15; |
@@ -39,7 +39,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
39 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 39 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
40 | oparg = 1 << oparg; | 40 | oparg = 1 << oparg; |
41 | 41 | ||
42 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 42 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
43 | return -EFAULT; | 43 | return -EFAULT; |
44 | 44 | ||
45 | pagefault_disable(); | 45 | pagefault_disable(); |
@@ -81,21 +81,23 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
81 | } | 81 | } |
82 | 82 | ||
83 | static inline int | 83 | static inline int |
84 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 84 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
85 | u32 oldval, u32 newval) | ||
85 | { | 86 | { |
86 | int prev, cmp; | 87 | int ret = 0, cmp; |
88 | u32 prev; | ||
87 | 89 | ||
88 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 90 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
89 | return -EFAULT; | 91 | return -EFAULT; |
90 | 92 | ||
91 | __asm__ __volatile__ ( | 93 | __asm__ __volatile__ ( |
92 | __ASM_SMP_MB | 94 | __ASM_SMP_MB |
93 | "1: ldl_l %0,0(%2)\n" | 95 | "1: ldl_l %1,0(%3)\n" |
94 | " cmpeq %0,%3,%1\n" | 96 | " cmpeq %1,%4,%2\n" |
95 | " beq %1,3f\n" | 97 | " beq %2,3f\n" |
96 | " mov %4,%1\n" | 98 | " mov %5,%2\n" |
97 | "2: stl_c %1,0(%2)\n" | 99 | "2: stl_c %2,0(%3)\n" |
98 | " beq %1,4f\n" | 100 | " beq %2,4f\n" |
99 | "3: .subsection 2\n" | 101 | "3: .subsection 2\n" |
100 | "4: br 1b\n" | 102 | "4: br 1b\n" |
101 | " .previous\n" | 103 | " .previous\n" |
@@ -105,11 +107,12 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | |||
105 | " .long 2b-.\n" | 107 | " .long 2b-.\n" |
106 | " lda $31,3b-2b(%0)\n" | 108 | " lda $31,3b-2b(%0)\n" |
107 | " .previous\n" | 109 | " .previous\n" |
108 | : "=&r"(prev), "=&r"(cmp) | 110 | : "+r"(ret), "=&r"(prev), "=&r"(cmp) |
109 | : "r"(uaddr), "r"((long)oldval), "r"(newval) | 111 | : "r"(uaddr), "r"((long)oldval), "r"(newval) |
110 | : "memory"); | 112 | : "memory"); |
111 | 113 | ||
112 | return prev; | 114 | *uval = prev; |
115 | return ret; | ||
113 | } | 116 | } |
114 | 117 | ||
115 | #endif /* __KERNEL__ */ | 118 | #endif /* __KERNEL__ */ |
diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h index b33fe7065b38..199a6b6de7f4 100644 --- a/arch/arm/include/asm/futex.h +++ b/arch/arm/include/asm/futex.h | |||
@@ -35,7 +35,7 @@ | |||
35 | : "cc", "memory") | 35 | : "cc", "memory") |
36 | 36 | ||
37 | static inline int | 37 | static inline int |
38 | futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | 38 | futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr) |
39 | { | 39 | { |
40 | int op = (encoded_op >> 28) & 7; | 40 | int op = (encoded_op >> 28) & 7; |
41 | int cmp = (encoded_op >> 24) & 15; | 41 | int cmp = (encoded_op >> 24) & 15; |
@@ -46,7 +46,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
46 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 46 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
47 | oparg = 1 << oparg; | 47 | oparg = 1 << oparg; |
48 | 48 | ||
49 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 49 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
50 | return -EFAULT; | 50 | return -EFAULT; |
51 | 51 | ||
52 | pagefault_disable(); /* implies preempt_disable() */ | 52 | pagefault_disable(); /* implies preempt_disable() */ |
@@ -88,36 +88,35 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
88 | } | 88 | } |
89 | 89 | ||
90 | static inline int | 90 | static inline int |
91 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 91 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
92 | u32 oldval, u32 newval) | ||
92 | { | 93 | { |
93 | int val; | 94 | int ret = 0; |
95 | u32 val; | ||
94 | 96 | ||
95 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 97 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
96 | return -EFAULT; | 98 | return -EFAULT; |
97 | 99 | ||
98 | pagefault_disable(); /* implies preempt_disable() */ | ||
99 | |||
100 | __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n" | 100 | __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n" |
101 | "1: " T(ldr) " %0, [%3]\n" | 101 | "1: " T(ldr) " %1, [%4]\n" |
102 | " teq %0, %1\n" | 102 | " teq %1, %2\n" |
103 | " it eq @ explicit IT needed for the 2b label\n" | 103 | " it eq @ explicit IT needed for the 2b label\n" |
104 | "2: " T(streq) " %2, [%3]\n" | 104 | "2: " T(streq) " %3, [%4]\n" |
105 | "3:\n" | 105 | "3:\n" |
106 | " .pushsection __ex_table,\"a\"\n" | 106 | " .pushsection __ex_table,\"a\"\n" |
107 | " .align 3\n" | 107 | " .align 3\n" |
108 | " .long 1b, 4f, 2b, 4f\n" | 108 | " .long 1b, 4f, 2b, 4f\n" |
109 | " .popsection\n" | 109 | " .popsection\n" |
110 | " .pushsection .fixup,\"ax\"\n" | 110 | " .pushsection .fixup,\"ax\"\n" |
111 | "4: mov %0, %4\n" | 111 | "4: mov %0, %5\n" |
112 | " b 3b\n" | 112 | " b 3b\n" |
113 | " .popsection" | 113 | " .popsection" |
114 | : "=&r" (val) | 114 | : "+r" (ret), "=&r" (val) |
115 | : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT) | 115 | : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT) |
116 | : "cc", "memory"); | 116 | : "cc", "memory"); |
117 | 117 | ||
118 | pagefault_enable(); /* subsumes preempt_enable() */ | 118 | *uval = val; |
119 | 119 | return ret; | |
120 | return val; | ||
121 | } | 120 | } |
122 | 121 | ||
123 | #endif /* !SMP */ | 122 | #endif /* !SMP */ |
diff --git a/arch/frv/include/asm/futex.h b/arch/frv/include/asm/futex.h index 08b3d1da3583..4bea27f50a7a 100644 --- a/arch/frv/include/asm/futex.h +++ b/arch/frv/include/asm/futex.h | |||
@@ -7,10 +7,11 @@ | |||
7 | #include <asm/errno.h> | 7 | #include <asm/errno.h> |
8 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
9 | 9 | ||
10 | extern int futex_atomic_op_inuser(int encoded_op, int __user *uaddr); | 10 | extern int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr); |
11 | 11 | ||
12 | static inline int | 12 | static inline int |
13 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 13 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
14 | u32 oldval, u32 newval) | ||
14 | { | 15 | { |
15 | return -ENOSYS; | 16 | return -ENOSYS; |
16 | } | 17 | } |
diff --git a/arch/frv/kernel/futex.c b/arch/frv/kernel/futex.c index 14f64b054c7e..d155ca9e5098 100644 --- a/arch/frv/kernel/futex.c +++ b/arch/frv/kernel/futex.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * the various futex operations; MMU fault checking is ignored under no-MMU | 18 | * the various futex operations; MMU fault checking is ignored under no-MMU |
19 | * conditions | 19 | * conditions |
20 | */ | 20 | */ |
21 | static inline int atomic_futex_op_xchg_set(int oparg, int __user *uaddr, int *_oldval) | 21 | static inline int atomic_futex_op_xchg_set(int oparg, u32 __user *uaddr, int *_oldval) |
22 | { | 22 | { |
23 | int oldval, ret; | 23 | int oldval, ret; |
24 | 24 | ||
@@ -50,7 +50,7 @@ static inline int atomic_futex_op_xchg_set(int oparg, int __user *uaddr, int *_o | |||
50 | return ret; | 50 | return ret; |
51 | } | 51 | } |
52 | 52 | ||
53 | static inline int atomic_futex_op_xchg_add(int oparg, int __user *uaddr, int *_oldval) | 53 | static inline int atomic_futex_op_xchg_add(int oparg, u32 __user *uaddr, int *_oldval) |
54 | { | 54 | { |
55 | int oldval, ret; | 55 | int oldval, ret; |
56 | 56 | ||
@@ -83,7 +83,7 @@ static inline int atomic_futex_op_xchg_add(int oparg, int __user *uaddr, int *_o | |||
83 | return ret; | 83 | return ret; |
84 | } | 84 | } |
85 | 85 | ||
86 | static inline int atomic_futex_op_xchg_or(int oparg, int __user *uaddr, int *_oldval) | 86 | static inline int atomic_futex_op_xchg_or(int oparg, u32 __user *uaddr, int *_oldval) |
87 | { | 87 | { |
88 | int oldval, ret; | 88 | int oldval, ret; |
89 | 89 | ||
@@ -116,7 +116,7 @@ static inline int atomic_futex_op_xchg_or(int oparg, int __user *uaddr, int *_ol | |||
116 | return ret; | 116 | return ret; |
117 | } | 117 | } |
118 | 118 | ||
119 | static inline int atomic_futex_op_xchg_and(int oparg, int __user *uaddr, int *_oldval) | 119 | static inline int atomic_futex_op_xchg_and(int oparg, u32 __user *uaddr, int *_oldval) |
120 | { | 120 | { |
121 | int oldval, ret; | 121 | int oldval, ret; |
122 | 122 | ||
@@ -149,7 +149,7 @@ static inline int atomic_futex_op_xchg_and(int oparg, int __user *uaddr, int *_o | |||
149 | return ret; | 149 | return ret; |
150 | } | 150 | } |
151 | 151 | ||
152 | static inline int atomic_futex_op_xchg_xor(int oparg, int __user *uaddr, int *_oldval) | 152 | static inline int atomic_futex_op_xchg_xor(int oparg, u32 __user *uaddr, int *_oldval) |
153 | { | 153 | { |
154 | int oldval, ret; | 154 | int oldval, ret; |
155 | 155 | ||
@@ -186,7 +186,7 @@ static inline int atomic_futex_op_xchg_xor(int oparg, int __user *uaddr, int *_o | |||
186 | /* | 186 | /* |
187 | * do the futex operations | 187 | * do the futex operations |
188 | */ | 188 | */ |
189 | int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | 189 | int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
190 | { | 190 | { |
191 | int op = (encoded_op >> 28) & 7; | 191 | int op = (encoded_op >> 28) & 7; |
192 | int cmp = (encoded_op >> 24) & 15; | 192 | int cmp = (encoded_op >> 24) & 15; |
@@ -197,7 +197,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
197 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 197 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
198 | oparg = 1 << oparg; | 198 | oparg = 1 << oparg; |
199 | 199 | ||
200 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 200 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
201 | return -EFAULT; | 201 | return -EFAULT; |
202 | 202 | ||
203 | pagefault_disable(); | 203 | pagefault_disable(); |
diff --git a/arch/ia64/include/asm/futex.h b/arch/ia64/include/asm/futex.h index c7f0f062239c..8428525ddb22 100644 --- a/arch/ia64/include/asm/futex.h +++ b/arch/ia64/include/asm/futex.h | |||
@@ -46,7 +46,7 @@ do { \ | |||
46 | } while (0) | 46 | } while (0) |
47 | 47 | ||
48 | static inline int | 48 | static inline int |
49 | futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | 49 | futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr) |
50 | { | 50 | { |
51 | int op = (encoded_op >> 28) & 7; | 51 | int op = (encoded_op >> 28) & 7; |
52 | int cmp = (encoded_op >> 24) & 15; | 52 | int cmp = (encoded_op >> 24) & 15; |
@@ -56,7 +56,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
56 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 56 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
57 | oparg = 1 << oparg; | 57 | oparg = 1 << oparg; |
58 | 58 | ||
59 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | 59 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32))) |
60 | return -EFAULT; | 60 | return -EFAULT; |
61 | 61 | ||
62 | pagefault_disable(); | 62 | pagefault_disable(); |
@@ -100,23 +100,26 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | static inline int | 102 | static inline int |
103 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 103 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
104 | u32 oldval, u32 newval) | ||
104 | { | 105 | { |
105 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 106 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
106 | return -EFAULT; | 107 | return -EFAULT; |
107 | 108 | ||
108 | { | 109 | { |
109 | register unsigned long r8 __asm ("r8"); | 110 | register unsigned long r8 __asm ("r8") = 0; |
111 | unsigned long prev; | ||
110 | __asm__ __volatile__( | 112 | __asm__ __volatile__( |
111 | " mf;; \n" | 113 | " mf;; \n" |
112 | " mov ar.ccv=%3;; \n" | 114 | " mov ar.ccv=%3;; \n" |
113 | "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n" | 115 | "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n" |
114 | " .xdata4 \"__ex_table\", 1b-., 2f-. \n" | 116 | " .xdata4 \"__ex_table\", 1b-., 2f-. \n" |
115 | "[2:]" | 117 | "[2:]" |
116 | : "=r" (r8) | 118 | : "=r" (prev) |
117 | : "r" (uaddr), "r" (newval), | 119 | : "r" (uaddr), "r" (newval), |
118 | "rO" ((long) (unsigned) oldval) | 120 | "rO" ((long) (unsigned) oldval) |
119 | : "memory"); | 121 | : "memory"); |
122 | *uval = prev; | ||
120 | return r8; | 123 | return r8; |
121 | } | 124 | } |
122 | } | 125 | } |
diff --git a/arch/microblaze/include/asm/futex.h b/arch/microblaze/include/asm/futex.h index ad3fd61b2fe7..b0526d2716fa 100644 --- a/arch/microblaze/include/asm/futex.h +++ b/arch/microblaze/include/asm/futex.h | |||
@@ -29,7 +29,7 @@ | |||
29 | }) | 29 | }) |
30 | 30 | ||
31 | static inline int | 31 | static inline int |
32 | futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | 32 | futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
33 | { | 33 | { |
34 | int op = (encoded_op >> 28) & 7; | 34 | int op = (encoded_op >> 28) & 7; |
35 | int cmp = (encoded_op >> 24) & 15; | 35 | int cmp = (encoded_op >> 24) & 15; |
@@ -39,7 +39,7 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
39 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 39 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
40 | oparg = 1 << oparg; | 40 | oparg = 1 << oparg; |
41 | 41 | ||
42 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 42 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
43 | return -EFAULT; | 43 | return -EFAULT; |
44 | 44 | ||
45 | pagefault_disable(); | 45 | pagefault_disable(); |
@@ -94,31 +94,34 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
94 | } | 94 | } |
95 | 95 | ||
96 | static inline int | 96 | static inline int |
97 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 97 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
98 | u32 oldval, u32 newval) | ||
98 | { | 99 | { |
99 | int prev, cmp; | 100 | int ret = 0, cmp; |
101 | u32 prev; | ||
100 | 102 | ||
101 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 103 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
102 | return -EFAULT; | 104 | return -EFAULT; |
103 | 105 | ||
104 | __asm__ __volatile__ ("1: lwx %0, %2, r0; \ | 106 | __asm__ __volatile__ ("1: lwx %1, %3, r0; \ |
105 | cmp %1, %0, %3; \ | 107 | cmp %2, %1, %4; \ |
106 | beqi %1, 3f; \ | 108 | beqi %2, 3f; \ |
107 | 2: swx %4, %2, r0; \ | 109 | 2: swx %5, %3, r0; \ |
108 | addic %1, r0, 0; \ | 110 | addic %2, r0, 0; \ |
109 | bnei %1, 1b; \ | 111 | bnei %2, 1b; \ |
110 | 3: \ | 112 | 3: \ |
111 | .section .fixup,\"ax\"; \ | 113 | .section .fixup,\"ax\"; \ |
112 | 4: brid 3b; \ | 114 | 4: brid 3b; \ |
113 | addik %0, r0, %5; \ | 115 | addik %0, r0, %6; \ |
114 | .previous; \ | 116 | .previous; \ |
115 | .section __ex_table,\"a\"; \ | 117 | .section __ex_table,\"a\"; \ |
116 | .word 1b,4b,2b,4b; \ | 118 | .word 1b,4b,2b,4b; \ |
117 | .previous;" \ | 119 | .previous;" \ |
118 | : "=&r" (prev), "=&r"(cmp) \ | 120 | : "+r" (ret), "=&r" (prev), "=&r"(cmp) \ |
119 | : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT)); | 121 | : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT)); |
120 | 122 | ||
121 | return prev; | 123 | *uval = prev; |
124 | return ret; | ||
122 | } | 125 | } |
123 | 126 | ||
124 | #endif /* __KERNEL__ */ | 127 | #endif /* __KERNEL__ */ |
diff --git a/arch/mips/include/asm/futex.h b/arch/mips/include/asm/futex.h index b9cce90346cf..6ebf1734b411 100644 --- a/arch/mips/include/asm/futex.h +++ b/arch/mips/include/asm/futex.h | |||
@@ -75,7 +75,7 @@ | |||
75 | } | 75 | } |
76 | 76 | ||
77 | static inline int | 77 | static inline int |
78 | futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | 78 | futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
79 | { | 79 | { |
80 | int op = (encoded_op >> 28) & 7; | 80 | int op = (encoded_op >> 28) & 7; |
81 | int cmp = (encoded_op >> 24) & 15; | 81 | int cmp = (encoded_op >> 24) & 15; |
@@ -85,7 +85,7 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
85 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 85 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
86 | oparg = 1 << oparg; | 86 | oparg = 1 << oparg; |
87 | 87 | ||
88 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | 88 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32))) |
89 | return -EFAULT; | 89 | return -EFAULT; |
90 | 90 | ||
91 | pagefault_disable(); | 91 | pagefault_disable(); |
@@ -132,11 +132,13 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
132 | } | 132 | } |
133 | 133 | ||
134 | static inline int | 134 | static inline int |
135 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 135 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
136 | u32 oldval, u32 newval) | ||
136 | { | 137 | { |
137 | int retval; | 138 | int ret = 0; |
139 | u32 val; | ||
138 | 140 | ||
139 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 141 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
140 | return -EFAULT; | 142 | return -EFAULT; |
141 | 143 | ||
142 | if (cpu_has_llsc && R10000_LLSC_WAR) { | 144 | if (cpu_has_llsc && R10000_LLSC_WAR) { |
@@ -145,25 +147,25 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | |||
145 | " .set push \n" | 147 | " .set push \n" |
146 | " .set noat \n" | 148 | " .set noat \n" |
147 | " .set mips3 \n" | 149 | " .set mips3 \n" |
148 | "1: ll %0, %2 \n" | 150 | "1: ll %1, %3 \n" |
149 | " bne %0, %z3, 3f \n" | 151 | " bne %1, %z4, 3f \n" |
150 | " .set mips0 \n" | 152 | " .set mips0 \n" |
151 | " move $1, %z4 \n" | 153 | " move $1, %z5 \n" |
152 | " .set mips3 \n" | 154 | " .set mips3 \n" |
153 | "2: sc $1, %1 \n" | 155 | "2: sc $1, %2 \n" |
154 | " beqzl $1, 1b \n" | 156 | " beqzl $1, 1b \n" |
155 | __WEAK_LLSC_MB | 157 | __WEAK_LLSC_MB |
156 | "3: \n" | 158 | "3: \n" |
157 | " .set pop \n" | 159 | " .set pop \n" |
158 | " .section .fixup,\"ax\" \n" | 160 | " .section .fixup,\"ax\" \n" |
159 | "4: li %0, %5 \n" | 161 | "4: li %0, %6 \n" |
160 | " j 3b \n" | 162 | " j 3b \n" |
161 | " .previous \n" | 163 | " .previous \n" |
162 | " .section __ex_table,\"a\" \n" | 164 | " .section __ex_table,\"a\" \n" |
163 | " "__UA_ADDR "\t1b, 4b \n" | 165 | " "__UA_ADDR "\t1b, 4b \n" |
164 | " "__UA_ADDR "\t2b, 4b \n" | 166 | " "__UA_ADDR "\t2b, 4b \n" |
165 | " .previous \n" | 167 | " .previous \n" |
166 | : "=&r" (retval), "=R" (*uaddr) | 168 | : "+r" (ret), "=&r" (val), "=R" (*uaddr) |
167 | : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT) | 169 | : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT) |
168 | : "memory"); | 170 | : "memory"); |
169 | } else if (cpu_has_llsc) { | 171 | } else if (cpu_has_llsc) { |
@@ -172,31 +174,32 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | |||
172 | " .set push \n" | 174 | " .set push \n" |
173 | " .set noat \n" | 175 | " .set noat \n" |
174 | " .set mips3 \n" | 176 | " .set mips3 \n" |
175 | "1: ll %0, %2 \n" | 177 | "1: ll %1, %3 \n" |
176 | " bne %0, %z3, 3f \n" | 178 | " bne %1, %z4, 3f \n" |
177 | " .set mips0 \n" | 179 | " .set mips0 \n" |
178 | " move $1, %z4 \n" | 180 | " move $1, %z5 \n" |
179 | " .set mips3 \n" | 181 | " .set mips3 \n" |
180 | "2: sc $1, %1 \n" | 182 | "2: sc $1, %2 \n" |
181 | " beqz $1, 1b \n" | 183 | " beqz $1, 1b \n" |
182 | __WEAK_LLSC_MB | 184 | __WEAK_LLSC_MB |
183 | "3: \n" | 185 | "3: \n" |
184 | " .set pop \n" | 186 | " .set pop \n" |
185 | " .section .fixup,\"ax\" \n" | 187 | " .section .fixup,\"ax\" \n" |
186 | "4: li %0, %5 \n" | 188 | "4: li %0, %6 \n" |
187 | " j 3b \n" | 189 | " j 3b \n" |
188 | " .previous \n" | 190 | " .previous \n" |
189 | " .section __ex_table,\"a\" \n" | 191 | " .section __ex_table,\"a\" \n" |
190 | " "__UA_ADDR "\t1b, 4b \n" | 192 | " "__UA_ADDR "\t1b, 4b \n" |
191 | " "__UA_ADDR "\t2b, 4b \n" | 193 | " "__UA_ADDR "\t2b, 4b \n" |
192 | " .previous \n" | 194 | " .previous \n" |
193 | : "=&r" (retval), "=R" (*uaddr) | 195 | : "+r" (ret), "=&r" (val), "=R" (*uaddr) |
194 | : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT) | 196 | : "R" (*uaddr), "Jr" (oldval), "Jr" (newval), "i" (-EFAULT) |
195 | : "memory"); | 197 | : "memory"); |
196 | } else | 198 | } else |
197 | return -ENOSYS; | 199 | return -ENOSYS; |
198 | 200 | ||
199 | return retval; | 201 | *uval = val; |
202 | return ret; | ||
200 | } | 203 | } |
201 | 204 | ||
202 | #endif | 205 | #endif |
diff --git a/arch/parisc/include/asm/futex.h b/arch/parisc/include/asm/futex.h index 0c705c3a55ef..67a33cc27ef2 100644 --- a/arch/parisc/include/asm/futex.h +++ b/arch/parisc/include/asm/futex.h | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <asm/errno.h> | 8 | #include <asm/errno.h> |
9 | 9 | ||
10 | static inline int | 10 | static inline int |
11 | futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | 11 | futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr) |
12 | { | 12 | { |
13 | int op = (encoded_op >> 28) & 7; | 13 | int op = (encoded_op >> 28) & 7; |
14 | int cmp = (encoded_op >> 24) & 15; | 14 | int cmp = (encoded_op >> 24) & 15; |
@@ -18,7 +18,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
18 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 18 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
19 | oparg = 1 << oparg; | 19 | oparg = 1 << oparg; |
20 | 20 | ||
21 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | 21 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32))) |
22 | return -EFAULT; | 22 | return -EFAULT; |
23 | 23 | ||
24 | pagefault_disable(); | 24 | pagefault_disable(); |
@@ -51,10 +51,10 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
51 | 51 | ||
52 | /* Non-atomic version */ | 52 | /* Non-atomic version */ |
53 | static inline int | 53 | static inline int |
54 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 54 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
55 | u32 oldval, u32 newval) | ||
55 | { | 56 | { |
56 | int err = 0; | 57 | u32 val; |
57 | int uval; | ||
58 | 58 | ||
59 | /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is | 59 | /* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is |
60 | * our gateway page, and causes no end of trouble... | 60 | * our gateway page, and causes no end of trouble... |
@@ -62,15 +62,15 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | |||
62 | if (segment_eq(KERNEL_DS, get_fs()) && !uaddr) | 62 | if (segment_eq(KERNEL_DS, get_fs()) && !uaddr) |
63 | return -EFAULT; | 63 | return -EFAULT; |
64 | 64 | ||
65 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 65 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
66 | return -EFAULT; | 66 | return -EFAULT; |
67 | 67 | ||
68 | err = get_user(uval, uaddr); | 68 | if (get_user(val, uaddr)) |
69 | if (err) return -EFAULT; | 69 | return -EFAULT; |
70 | if (uval == oldval) | 70 | if (val == oldval && put_user(newval, uaddr)) |
71 | err = put_user(newval, uaddr); | 71 | return -EFAULT; |
72 | if (err) return -EFAULT; | 72 | *uval = val; |
73 | return uval; | 73 | return 0; |
74 | } | 74 | } |
75 | 75 | ||
76 | #endif /*__KERNEL__*/ | 76 | #endif /*__KERNEL__*/ |
diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/futex.h index 7c589ef81fb0..c94e4a3fe2ef 100644 --- a/arch/powerpc/include/asm/futex.h +++ b/arch/powerpc/include/asm/futex.h | |||
@@ -30,7 +30,7 @@ | |||
30 | : "b" (uaddr), "i" (-EFAULT), "r" (oparg) \ | 30 | : "b" (uaddr), "i" (-EFAULT), "r" (oparg) \ |
31 | : "cr0", "memory") | 31 | : "cr0", "memory") |
32 | 32 | ||
33 | static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | 33 | static inline int futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr) |
34 | { | 34 | { |
35 | int op = (encoded_op >> 28) & 7; | 35 | int op = (encoded_op >> 28) & 7; |
36 | int cmp = (encoded_op >> 24) & 15; | 36 | int cmp = (encoded_op >> 24) & 15; |
@@ -40,7 +40,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
40 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 40 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
41 | oparg = 1 << oparg; | 41 | oparg = 1 << oparg; |
42 | 42 | ||
43 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | 43 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32))) |
44 | return -EFAULT; | 44 | return -EFAULT; |
45 | 45 | ||
46 | pagefault_disable(); | 46 | pagefault_disable(); |
@@ -82,35 +82,38 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
82 | } | 82 | } |
83 | 83 | ||
84 | static inline int | 84 | static inline int |
85 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 85 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
86 | u32 oldval, u32 newval) | ||
86 | { | 87 | { |
87 | int prev; | 88 | int ret = 0; |
89 | u32 prev; | ||
88 | 90 | ||
89 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 91 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
90 | return -EFAULT; | 92 | return -EFAULT; |
91 | 93 | ||
92 | __asm__ __volatile__ ( | 94 | __asm__ __volatile__ ( |
93 | PPC_RELEASE_BARRIER | 95 | PPC_RELEASE_BARRIER |
94 | "1: lwarx %0,0,%2 # futex_atomic_cmpxchg_inatomic\n\ | 96 | "1: lwarx %1,0,%3 # futex_atomic_cmpxchg_inatomic\n\ |
95 | cmpw 0,%0,%3\n\ | 97 | cmpw 0,%1,%4\n\ |
96 | bne- 3f\n" | 98 | bne- 3f\n" |
97 | PPC405_ERR77(0,%2) | 99 | PPC405_ERR77(0,%3) |
98 | "2: stwcx. %4,0,%2\n\ | 100 | "2: stwcx. %5,0,%3\n\ |
99 | bne- 1b\n" | 101 | bne- 1b\n" |
100 | PPC_ACQUIRE_BARRIER | 102 | PPC_ACQUIRE_BARRIER |
101 | "3: .section .fixup,\"ax\"\n\ | 103 | "3: .section .fixup,\"ax\"\n\ |
102 | 4: li %0,%5\n\ | 104 | 4: li %0,%6\n\ |
103 | b 3b\n\ | 105 | b 3b\n\ |
104 | .previous\n\ | 106 | .previous\n\ |
105 | .section __ex_table,\"a\"\n\ | 107 | .section __ex_table,\"a\"\n\ |
106 | .align 3\n\ | 108 | .align 3\n\ |
107 | " PPC_LONG "1b,4b,2b,4b\n\ | 109 | " PPC_LONG "1b,4b,2b,4b\n\ |
108 | .previous" \ | 110 | .previous" \ |
109 | : "=&r" (prev), "+m" (*uaddr) | 111 | : "+r" (ret), "=&r" (prev), "+m" (*uaddr) |
110 | : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) | 112 | : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) |
111 | : "cc", "memory"); | 113 | : "cc", "memory"); |
112 | 114 | ||
113 | return prev; | 115 | *uval = prev; |
116 | return ret; | ||
114 | } | 117 | } |
115 | 118 | ||
116 | #endif /* __KERNEL__ */ | 119 | #endif /* __KERNEL__ */ |
diff --git a/arch/s390/include/asm/futex.h b/arch/s390/include/asm/futex.h index 5c5d02de49e9..81cf36b691f1 100644 --- a/arch/s390/include/asm/futex.h +++ b/arch/s390/include/asm/futex.h | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <linux/uaccess.h> | 7 | #include <linux/uaccess.h> |
8 | #include <asm/errno.h> | 8 | #include <asm/errno.h> |
9 | 9 | ||
10 | static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | 10 | static inline int futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr) |
11 | { | 11 | { |
12 | int op = (encoded_op >> 28) & 7; | 12 | int op = (encoded_op >> 28) & 7; |
13 | int cmp = (encoded_op >> 24) & 15; | 13 | int cmp = (encoded_op >> 24) & 15; |
@@ -18,7 +18,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
18 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 18 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
19 | oparg = 1 << oparg; | 19 | oparg = 1 << oparg; |
20 | 20 | ||
21 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | 21 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32))) |
22 | return -EFAULT; | 22 | return -EFAULT; |
23 | 23 | ||
24 | pagefault_disable(); | 24 | pagefault_disable(); |
@@ -39,13 +39,13 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) | |||
39 | return ret; | 39 | return ret; |
40 | } | 40 | } |
41 | 41 | ||
42 | static inline int futex_atomic_cmpxchg_inatomic(int __user *uaddr, | 42 | static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
43 | int oldval, int newval) | 43 | u32 oldval, u32 newval) |
44 | { | 44 | { |
45 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) | 45 | if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32))) |
46 | return -EFAULT; | 46 | return -EFAULT; |
47 | 47 | ||
48 | return uaccess.futex_atomic_cmpxchg(uaddr, oldval, newval); | 48 | return uaccess.futex_atomic_cmpxchg(uval, uaddr, oldval, newval); |
49 | } | 49 | } |
50 | 50 | ||
51 | #endif /* __KERNEL__ */ | 51 | #endif /* __KERNEL__ */ |
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h index d6b1ed0ec52b..2d9ea11f919a 100644 --- a/arch/s390/include/asm/uaccess.h +++ b/arch/s390/include/asm/uaccess.h | |||
@@ -83,8 +83,8 @@ struct uaccess_ops { | |||
83 | size_t (*clear_user)(size_t, void __user *); | 83 | size_t (*clear_user)(size_t, void __user *); |
84 | size_t (*strnlen_user)(size_t, const char __user *); | 84 | size_t (*strnlen_user)(size_t, const char __user *); |
85 | size_t (*strncpy_from_user)(size_t, const char __user *, char *); | 85 | size_t (*strncpy_from_user)(size_t, const char __user *, char *); |
86 | int (*futex_atomic_op)(int op, int __user *, int oparg, int *old); | 86 | int (*futex_atomic_op)(int op, u32 __user *, int oparg, int *old); |
87 | int (*futex_atomic_cmpxchg)(int __user *, int old, int new); | 87 | int (*futex_atomic_cmpxchg)(u32 *, u32 __user *, u32 old, u32 new); |
88 | }; | 88 | }; |
89 | 89 | ||
90 | extern struct uaccess_ops uaccess; | 90 | extern struct uaccess_ops uaccess; |
diff --git a/arch/s390/lib/uaccess.h b/arch/s390/lib/uaccess.h index 126011df14f1..1d2536cb630b 100644 --- a/arch/s390/lib/uaccess.h +++ b/arch/s390/lib/uaccess.h | |||
@@ -12,12 +12,12 @@ extern size_t copy_from_user_std(size_t, const void __user *, void *); | |||
12 | extern size_t copy_to_user_std(size_t, void __user *, const void *); | 12 | extern size_t copy_to_user_std(size_t, void __user *, const void *); |
13 | extern size_t strnlen_user_std(size_t, const char __user *); | 13 | extern size_t strnlen_user_std(size_t, const char __user *); |
14 | extern size_t strncpy_from_user_std(size_t, const char __user *, char *); | 14 | extern size_t strncpy_from_user_std(size_t, const char __user *, char *); |
15 | extern int futex_atomic_cmpxchg_std(int __user *, int, int); | 15 | extern int futex_atomic_cmpxchg_std(u32 *, u32 __user *, u32, u32); |
16 | extern int futex_atomic_op_std(int, int __user *, int, int *); | 16 | extern int futex_atomic_op_std(int, u32 __user *, int, int *); |
17 | 17 | ||
18 | extern size_t copy_from_user_pt(size_t, const void __user *, void *); | 18 | extern size_t copy_from_user_pt(size_t, const void __user *, void *); |
19 | extern size_t copy_to_user_pt(size_t, void __user *, const void *); | 19 | extern size_t copy_to_user_pt(size_t, void __user *, const void *); |
20 | extern int futex_atomic_op_pt(int, int __user *, int, int *); | 20 | extern int futex_atomic_op_pt(int, u32 __user *, int, int *); |
21 | extern int futex_atomic_cmpxchg_pt(int __user *, int, int); | 21 | extern int futex_atomic_cmpxchg_pt(u32 *, u32 __user *, u32, u32); |
22 | 22 | ||
23 | #endif /* __ARCH_S390_LIB_UACCESS_H */ | 23 | #endif /* __ARCH_S390_LIB_UACCESS_H */ |
diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c index 404f2de296dc..74833831417f 100644 --- a/arch/s390/lib/uaccess_pt.c +++ b/arch/s390/lib/uaccess_pt.c | |||
@@ -302,7 +302,7 @@ fault: | |||
302 | : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \ | 302 | : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \ |
303 | "m" (*uaddr) : "cc" ); | 303 | "m" (*uaddr) : "cc" ); |
304 | 304 | ||
305 | static int __futex_atomic_op_pt(int op, int __user *uaddr, int oparg, int *old) | 305 | static int __futex_atomic_op_pt(int op, u32 __user *uaddr, int oparg, int *old) |
306 | { | 306 | { |
307 | int oldval = 0, newval, ret; | 307 | int oldval = 0, newval, ret; |
308 | 308 | ||
@@ -335,7 +335,7 @@ static int __futex_atomic_op_pt(int op, int __user *uaddr, int oparg, int *old) | |||
335 | return ret; | 335 | return ret; |
336 | } | 336 | } |
337 | 337 | ||
338 | int futex_atomic_op_pt(int op, int __user *uaddr, int oparg, int *old) | 338 | int futex_atomic_op_pt(int op, u32 __user *uaddr, int oparg, int *old) |
339 | { | 339 | { |
340 | int ret; | 340 | int ret; |
341 | 341 | ||
@@ -354,26 +354,29 @@ int futex_atomic_op_pt(int op, int __user *uaddr, int oparg, int *old) | |||
354 | return ret; | 354 | return ret; |
355 | } | 355 | } |
356 | 356 | ||
357 | static int __futex_atomic_cmpxchg_pt(int __user *uaddr, int oldval, int newval) | 357 | static int __futex_atomic_cmpxchg_pt(u32 *uval, u32 __user *uaddr, |
358 | u32 oldval, u32 newval) | ||
358 | { | 359 | { |
359 | int ret; | 360 | int ret; |
360 | 361 | ||
361 | asm volatile("0: cs %1,%4,0(%5)\n" | 362 | asm volatile("0: cs %1,%4,0(%5)\n" |
362 | "1: lr %0,%1\n" | 363 | "1: la %0,0\n" |
363 | "2:\n" | 364 | "2:\n" |
364 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) | 365 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) |
365 | : "=d" (ret), "+d" (oldval), "=m" (*uaddr) | 366 | : "=d" (ret), "+d" (oldval), "=m" (*uaddr) |
366 | : "0" (-EFAULT), "d" (newval), "a" (uaddr), "m" (*uaddr) | 367 | : "0" (-EFAULT), "d" (newval), "a" (uaddr), "m" (*uaddr) |
367 | : "cc", "memory" ); | 368 | : "cc", "memory" ); |
369 | *uval = oldval; | ||
368 | return ret; | 370 | return ret; |
369 | } | 371 | } |
370 | 372 | ||
371 | int futex_atomic_cmpxchg_pt(int __user *uaddr, int oldval, int newval) | 373 | int futex_atomic_cmpxchg_pt(u32 *uval, u32 __user *uaddr, |
374 | u32 oldval, u32 newval) | ||
372 | { | 375 | { |
373 | int ret; | 376 | int ret; |
374 | 377 | ||
375 | if (segment_eq(get_fs(), KERNEL_DS)) | 378 | if (segment_eq(get_fs(), KERNEL_DS)) |
376 | return __futex_atomic_cmpxchg_pt(uaddr, oldval, newval); | 379 | return __futex_atomic_cmpxchg_pt(uval, uaddr, oldval, newval); |
377 | spin_lock(¤t->mm->page_table_lock); | 380 | spin_lock(¤t->mm->page_table_lock); |
378 | uaddr = (int __user *) __dat_user_addr((unsigned long) uaddr); | 381 | uaddr = (int __user *) __dat_user_addr((unsigned long) uaddr); |
379 | if (!uaddr) { | 382 | if (!uaddr) { |
@@ -382,7 +385,7 @@ int futex_atomic_cmpxchg_pt(int __user *uaddr, int oldval, int newval) | |||
382 | } | 385 | } |
383 | get_page(virt_to_page(uaddr)); | 386 | get_page(virt_to_page(uaddr)); |
384 | spin_unlock(¤t->mm->page_table_lock); | 387 | spin_unlock(¤t->mm->page_table_lock); |
385 | ret = __futex_atomic_cmpxchg_pt(uaddr, oldval, newval); | 388 | ret = __futex_atomic_cmpxchg_pt(uval, uaddr, oldval, newval); |
386 | put_page(virt_to_page(uaddr)); | 389 | put_page(virt_to_page(uaddr)); |
387 | return ret; | 390 | return ret; |
388 | } | 391 | } |
diff --git a/arch/s390/lib/uaccess_std.c b/arch/s390/lib/uaccess_std.c index a6c4f7ed24a4..bb1a7eed42ce 100644 --- a/arch/s390/lib/uaccess_std.c +++ b/arch/s390/lib/uaccess_std.c | |||
@@ -255,7 +255,7 @@ size_t strncpy_from_user_std(size_t size, const char __user *src, char *dst) | |||
255 | : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \ | 255 | : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \ |
256 | "m" (*uaddr) : "cc"); | 256 | "m" (*uaddr) : "cc"); |
257 | 257 | ||
258 | int futex_atomic_op_std(int op, int __user *uaddr, int oparg, int *old) | 258 | int futex_atomic_op_std(int op, u32 __user *uaddr, int oparg, int *old) |
259 | { | 259 | { |
260 | int oldval = 0, newval, ret; | 260 | int oldval = 0, newval, ret; |
261 | 261 | ||
@@ -287,19 +287,21 @@ int futex_atomic_op_std(int op, int __user *uaddr, int oparg, int *old) | |||
287 | return ret; | 287 | return ret; |
288 | } | 288 | } |
289 | 289 | ||
290 | int futex_atomic_cmpxchg_std(int __user *uaddr, int oldval, int newval) | 290 | int futex_atomic_cmpxchg_std(u32 *uval, u32 __user *uaddr, |
291 | u32 oldval, u32 newval) | ||
291 | { | 292 | { |
292 | int ret; | 293 | int ret; |
293 | 294 | ||
294 | asm volatile( | 295 | asm volatile( |
295 | " sacf 256\n" | 296 | " sacf 256\n" |
296 | "0: cs %1,%4,0(%5)\n" | 297 | "0: cs %1,%4,0(%5)\n" |
297 | "1: lr %0,%1\n" | 298 | "1: la %0,0\n" |
298 | "2: sacf 0\n" | 299 | "2: sacf 0\n" |
299 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) | 300 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) |
300 | : "=d" (ret), "+d" (oldval), "=m" (*uaddr) | 301 | : "=d" (ret), "+d" (oldval), "=m" (*uaddr) |
301 | : "0" (-EFAULT), "d" (newval), "a" (uaddr), "m" (*uaddr) | 302 | : "0" (-EFAULT), "d" (newval), "a" (uaddr), "m" (*uaddr) |
302 | : "cc", "memory" ); | 303 | : "cc", "memory" ); |
304 | *uval = oldval; | ||
303 | return ret; | 305 | return ret; |
304 | } | 306 | } |
305 | 307 | ||
diff --git a/arch/sh/include/asm/futex-irq.h b/arch/sh/include/asm/futex-irq.h index a9f16a7f9aea..6cb9f193a95e 100644 --- a/arch/sh/include/asm/futex-irq.h +++ b/arch/sh/include/asm/futex-irq.h | |||
@@ -3,7 +3,7 @@ | |||
3 | 3 | ||
4 | #include <asm/system.h> | 4 | #include <asm/system.h> |
5 | 5 | ||
6 | static inline int atomic_futex_op_xchg_set(int oparg, int __user *uaddr, | 6 | static inline int atomic_futex_op_xchg_set(int oparg, u32 __user *uaddr, |
7 | int *oldval) | 7 | int *oldval) |
8 | { | 8 | { |
9 | unsigned long flags; | 9 | unsigned long flags; |
@@ -20,7 +20,7 @@ static inline int atomic_futex_op_xchg_set(int oparg, int __user *uaddr, | |||
20 | return ret; | 20 | return ret; |
21 | } | 21 | } |
22 | 22 | ||
23 | static inline int atomic_futex_op_xchg_add(int oparg, int __user *uaddr, | 23 | static inline int atomic_futex_op_xchg_add(int oparg, u32 __user *uaddr, |
24 | int *oldval) | 24 | int *oldval) |
25 | { | 25 | { |
26 | unsigned long flags; | 26 | unsigned long flags; |
@@ -37,7 +37,7 @@ static inline int atomic_futex_op_xchg_add(int oparg, int __user *uaddr, | |||
37 | return ret; | 37 | return ret; |
38 | } | 38 | } |
39 | 39 | ||
40 | static inline int atomic_futex_op_xchg_or(int oparg, int __user *uaddr, | 40 | static inline int atomic_futex_op_xchg_or(int oparg, u32 __user *uaddr, |
41 | int *oldval) | 41 | int *oldval) |
42 | { | 42 | { |
43 | unsigned long flags; | 43 | unsigned long flags; |
@@ -54,7 +54,7 @@ static inline int atomic_futex_op_xchg_or(int oparg, int __user *uaddr, | |||
54 | return ret; | 54 | return ret; |
55 | } | 55 | } |
56 | 56 | ||
57 | static inline int atomic_futex_op_xchg_and(int oparg, int __user *uaddr, | 57 | static inline int atomic_futex_op_xchg_and(int oparg, u32 __user *uaddr, |
58 | int *oldval) | 58 | int *oldval) |
59 | { | 59 | { |
60 | unsigned long flags; | 60 | unsigned long flags; |
@@ -71,7 +71,7 @@ static inline int atomic_futex_op_xchg_and(int oparg, int __user *uaddr, | |||
71 | return ret; | 71 | return ret; |
72 | } | 72 | } |
73 | 73 | ||
74 | static inline int atomic_futex_op_xchg_xor(int oparg, int __user *uaddr, | 74 | static inline int atomic_futex_op_xchg_xor(int oparg, u32 __user *uaddr, |
75 | int *oldval) | 75 | int *oldval) |
76 | { | 76 | { |
77 | unsigned long flags; | 77 | unsigned long flags; |
@@ -88,11 +88,13 @@ static inline int atomic_futex_op_xchg_xor(int oparg, int __user *uaddr, | |||
88 | return ret; | 88 | return ret; |
89 | } | 89 | } |
90 | 90 | ||
91 | static inline int atomic_futex_op_cmpxchg_inatomic(int __user *uaddr, | 91 | static inline int atomic_futex_op_cmpxchg_inatomic(u32 *uval, |
92 | int oldval, int newval) | 92 | u32 __user *uaddr, |
93 | u32 oldval, u32 newval) | ||
93 | { | 94 | { |
94 | unsigned long flags; | 95 | unsigned long flags; |
95 | int ret, prev = 0; | 96 | int ret; |
97 | u32 prev = 0; | ||
96 | 98 | ||
97 | local_irq_save(flags); | 99 | local_irq_save(flags); |
98 | 100 | ||
@@ -102,10 +104,8 @@ static inline int atomic_futex_op_cmpxchg_inatomic(int __user *uaddr, | |||
102 | 104 | ||
103 | local_irq_restore(flags); | 105 | local_irq_restore(flags); |
104 | 106 | ||
105 | if (ret) | 107 | *uval = prev; |
106 | return ret; | 108 | return ret; |
107 | |||
108 | return prev; | ||
109 | } | 109 | } |
110 | 110 | ||
111 | #endif /* __ASM_SH_FUTEX_IRQ_H */ | 111 | #endif /* __ASM_SH_FUTEX_IRQ_H */ |
diff --git a/arch/sh/include/asm/futex.h b/arch/sh/include/asm/futex.h index 68256ec5fa35..7be39a646fbd 100644 --- a/arch/sh/include/asm/futex.h +++ b/arch/sh/include/asm/futex.h | |||
@@ -10,7 +10,7 @@ | |||
10 | /* XXX: UP variants, fix for SH-4A and SMP.. */ | 10 | /* XXX: UP variants, fix for SH-4A and SMP.. */ |
11 | #include <asm/futex-irq.h> | 11 | #include <asm/futex-irq.h> |
12 | 12 | ||
13 | static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | 13 | static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
14 | { | 14 | { |
15 | int op = (encoded_op >> 28) & 7; | 15 | int op = (encoded_op >> 28) & 7; |
16 | int cmp = (encoded_op >> 24) & 15; | 16 | int cmp = (encoded_op >> 24) & 15; |
@@ -21,7 +21,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
21 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 21 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
22 | oparg = 1 << oparg; | 22 | oparg = 1 << oparg; |
23 | 23 | ||
24 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 24 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
25 | return -EFAULT; | 25 | return -EFAULT; |
26 | 26 | ||
27 | pagefault_disable(); | 27 | pagefault_disable(); |
@@ -65,12 +65,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
65 | } | 65 | } |
66 | 66 | ||
67 | static inline int | 67 | static inline int |
68 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 68 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
69 | u32 oldval, u32 newval) | ||
69 | { | 70 | { |
70 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 71 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
71 | return -EFAULT; | 72 | return -EFAULT; |
72 | 73 | ||
73 | return atomic_futex_op_cmpxchg_inatomic(uaddr, oldval, newval); | 74 | return atomic_futex_op_cmpxchg_inatomic(uval, uaddr, oldval, newval); |
74 | } | 75 | } |
75 | 76 | ||
76 | #endif /* __KERNEL__ */ | 77 | #endif /* __KERNEL__ */ |
diff --git a/arch/sparc/include/asm/futex_64.h b/arch/sparc/include/asm/futex_64.h index 47f95839dc69..444e7bea23bc 100644 --- a/arch/sparc/include/asm/futex_64.h +++ b/arch/sparc/include/asm/futex_64.h | |||
@@ -30,7 +30,7 @@ | |||
30 | : "r" (uaddr), "r" (oparg), "i" (-EFAULT) \ | 30 | : "r" (uaddr), "r" (oparg), "i" (-EFAULT) \ |
31 | : "memory") | 31 | : "memory") |
32 | 32 | ||
33 | static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | 33 | static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
34 | { | 34 | { |
35 | int op = (encoded_op >> 28) & 7; | 35 | int op = (encoded_op >> 28) & 7; |
36 | int cmp = (encoded_op >> 24) & 15; | 36 | int cmp = (encoded_op >> 24) & 15; |
@@ -38,7 +38,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
38 | int cmparg = (encoded_op << 20) >> 20; | 38 | int cmparg = (encoded_op << 20) >> 20; |
39 | int oldval = 0, ret, tem; | 39 | int oldval = 0, ret, tem; |
40 | 40 | ||
41 | if (unlikely(!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))) | 41 | if (unlikely(!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))) |
42 | return -EFAULT; | 42 | return -EFAULT; |
43 | if (unlikely((((unsigned long) uaddr) & 0x3UL))) | 43 | if (unlikely((((unsigned long) uaddr) & 0x3UL))) |
44 | return -EINVAL; | 44 | return -EINVAL; |
@@ -85,26 +85,30 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | static inline int | 87 | static inline int |
88 | futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) | 88 | futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
89 | u32 oldval, u32 newval) | ||
89 | { | 90 | { |
91 | int ret = 0; | ||
92 | |||
90 | __asm__ __volatile__( | 93 | __asm__ __volatile__( |
91 | "\n1: casa [%3] %%asi, %2, %0\n" | 94 | "\n1: casa [%4] %%asi, %3, %1\n" |
92 | "2:\n" | 95 | "2:\n" |
93 | " .section .fixup,#alloc,#execinstr\n" | 96 | " .section .fixup,#alloc,#execinstr\n" |
94 | " .align 4\n" | 97 | " .align 4\n" |
95 | "3: sethi %%hi(2b), %0\n" | 98 | "3: sethi %%hi(2b), %0\n" |
96 | " jmpl %0 + %%lo(2b), %%g0\n" | 99 | " jmpl %0 + %%lo(2b), %%g0\n" |
97 | " mov %4, %0\n" | 100 | " mov %5, %0\n" |
98 | " .previous\n" | 101 | " .previous\n" |
99 | " .section __ex_table,\"a\"\n" | 102 | " .section __ex_table,\"a\"\n" |
100 | " .align 4\n" | 103 | " .align 4\n" |
101 | " .word 1b, 3b\n" | 104 | " .word 1b, 3b\n" |
102 | " .previous\n" | 105 | " .previous\n" |
103 | : "=r" (newval) | 106 | : "+r" (ret), "=r" (newval) |
104 | : "0" (newval), "r" (oldval), "r" (uaddr), "i" (-EFAULT) | 107 | : "1" (newval), "r" (oldval), "r" (uaddr), "i" (-EFAULT) |
105 | : "memory"); | 108 | : "memory"); |
106 | 109 | ||
107 | return newval; | 110 | *uval = newval; |
111 | return ret; | ||
108 | } | 112 | } |
109 | 113 | ||
110 | #endif /* !(_SPARC64_FUTEX_H) */ | 114 | #endif /* !(_SPARC64_FUTEX_H) */ |
diff --git a/arch/tile/include/asm/futex.h b/arch/tile/include/asm/futex.h index fe0d10dcae57..d03ec124a598 100644 --- a/arch/tile/include/asm/futex.h +++ b/arch/tile/include/asm/futex.h | |||
@@ -29,16 +29,16 @@ | |||
29 | #include <linux/uaccess.h> | 29 | #include <linux/uaccess.h> |
30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
31 | 31 | ||
32 | extern struct __get_user futex_set(int __user *v, int i); | 32 | extern struct __get_user futex_set(u32 __user *v, int i); |
33 | extern struct __get_user futex_add(int __user *v, int n); | 33 | extern struct __get_user futex_add(u32 __user *v, int n); |
34 | extern struct __get_user futex_or(int __user *v, int n); | 34 | extern struct __get_user futex_or(u32 __user *v, int n); |
35 | extern struct __get_user futex_andn(int __user *v, int n); | 35 | extern struct __get_user futex_andn(u32 __user *v, int n); |
36 | extern struct __get_user futex_cmpxchg(int __user *v, int o, int n); | 36 | extern struct __get_user futex_cmpxchg(u32 __user *v, int o, int n); |
37 | 37 | ||
38 | #ifndef __tilegx__ | 38 | #ifndef __tilegx__ |
39 | extern struct __get_user futex_xor(int __user *v, int n); | 39 | extern struct __get_user futex_xor(u32 __user *v, int n); |
40 | #else | 40 | #else |
41 | static inline struct __get_user futex_xor(int __user *uaddr, int n) | 41 | static inline struct __get_user futex_xor(u32 __user *uaddr, int n) |
42 | { | 42 | { |
43 | struct __get_user asm_ret = __get_user_4(uaddr); | 43 | struct __get_user asm_ret = __get_user_4(uaddr); |
44 | if (!asm_ret.err) { | 44 | if (!asm_ret.err) { |
@@ -53,7 +53,7 @@ static inline struct __get_user futex_xor(int __user *uaddr, int n) | |||
53 | } | 53 | } |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | 56 | static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
57 | { | 57 | { |
58 | int op = (encoded_op >> 28) & 7; | 58 | int op = (encoded_op >> 28) & 7; |
59 | int cmp = (encoded_op >> 24) & 15; | 59 | int cmp = (encoded_op >> 24) & 15; |
@@ -65,7 +65,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
65 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 65 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
66 | oparg = 1 << oparg; | 66 | oparg = 1 << oparg; |
67 | 67 | ||
68 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 68 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
69 | return -EFAULT; | 69 | return -EFAULT; |
70 | 70 | ||
71 | pagefault_disable(); | 71 | pagefault_disable(); |
@@ -119,16 +119,17 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
119 | return ret; | 119 | return ret; |
120 | } | 120 | } |
121 | 121 | ||
122 | static inline int futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, | 122 | static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
123 | int newval) | 123 | u32 oldval, u32 newval) |
124 | { | 124 | { |
125 | struct __get_user asm_ret; | 125 | struct __get_user asm_ret; |
126 | 126 | ||
127 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 127 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
128 | return -EFAULT; | 128 | return -EFAULT; |
129 | 129 | ||
130 | asm_ret = futex_cmpxchg(uaddr, oldval, newval); | 130 | asm_ret = futex_cmpxchg(uaddr, oldval, newval); |
131 | return asm_ret.err ? asm_ret.err : asm_ret.val; | 131 | *uval = asm_ret.val; |
132 | return asm_ret.err; | ||
132 | } | 133 | } |
133 | 134 | ||
134 | #ifndef __tilegx__ | 135 | #ifndef __tilegx__ |
diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h index 1f11ce44e956..d09bb03653f0 100644 --- a/arch/x86/include/asm/futex.h +++ b/arch/x86/include/asm/futex.h | |||
@@ -37,7 +37,7 @@ | |||
37 | "+m" (*uaddr), "=&r" (tem) \ | 37 | "+m" (*uaddr), "=&r" (tem) \ |
38 | : "r" (oparg), "i" (-EFAULT), "1" (0)) | 38 | : "r" (oparg), "i" (-EFAULT), "1" (0)) |
39 | 39 | ||
40 | static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | 40 | static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) |
41 | { | 41 | { |
42 | int op = (encoded_op >> 28) & 7; | 42 | int op = (encoded_op >> 28) & 7; |
43 | int cmp = (encoded_op >> 24) & 15; | 43 | int cmp = (encoded_op >> 24) & 15; |
@@ -48,7 +48,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
48 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) | 48 | if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) |
49 | oparg = 1 << oparg; | 49 | oparg = 1 << oparg; |
50 | 50 | ||
51 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 51 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
52 | return -EFAULT; | 52 | return -EFAULT; |
53 | 53 | ||
54 | #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP) | 54 | #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP) |
@@ -109,9 +109,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) | |||
109 | return ret; | 109 | return ret; |
110 | } | 110 | } |
111 | 111 | ||
112 | static inline int futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, | 112 | static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
113 | int newval) | 113 | u32 oldval, u32 newval) |
114 | { | 114 | { |
115 | int ret = 0; | ||
115 | 116 | ||
116 | #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP) | 117 | #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP) |
117 | /* Real i386 machines have no cmpxchg instruction */ | 118 | /* Real i386 machines have no cmpxchg instruction */ |
@@ -119,21 +120,22 @@ static inline int futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, | |||
119 | return -ENOSYS; | 120 | return -ENOSYS; |
120 | #endif | 121 | #endif |
121 | 122 | ||
122 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) | 123 | if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) |
123 | return -EFAULT; | 124 | return -EFAULT; |
124 | 125 | ||
125 | asm volatile("1:\t" LOCK_PREFIX "cmpxchgl %3, %1\n" | 126 | asm volatile("1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n" |
126 | "2:\t.section .fixup, \"ax\"\n" | 127 | "2:\t.section .fixup, \"ax\"\n" |
127 | "3:\tmov %2, %0\n" | 128 | "3:\tmov %3, %0\n" |
128 | "\tjmp 2b\n" | 129 | "\tjmp 2b\n" |
129 | "\t.previous\n" | 130 | "\t.previous\n" |
130 | _ASM_EXTABLE(1b, 3b) | 131 | _ASM_EXTABLE(1b, 3b) |
131 | : "=a" (oldval), "+m" (*uaddr) | 132 | : "+r" (ret), "=a" (oldval), "+m" (*uaddr) |
132 | : "i" (-EFAULT), "r" (newval), "0" (oldval) | 133 | : "i" (-EFAULT), "r" (newval), "1" (oldval) |
133 | : "memory" | 134 | : "memory" |
134 | ); | 135 | ); |
135 | 136 | ||
136 | return oldval; | 137 | *uval = oldval; |
138 | return ret; | ||
137 | } | 139 | } |
138 | 140 | ||
139 | #endif | 141 | #endif |