aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/uaccess.h
diff options
context:
space:
mode:
authorGlauber Costa <gcosta@redhat.com>2008-06-25 11:48:47 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-09 03:14:24 -0400
commit3f168221167ca7a844fde3bf58e1c7ca0bf9741e (patch)
treeca51b618a7319488049b151d9e03d899170106df /include/asm-x86/uaccess.h
parent6fd4725d75c5049641640ce23fa5896501dfbd42 (diff)
x86: merge __get_user_asm and its users.
Move __get_user_asm and __get_user_size and __get_user_nocheck to uaccess.h. This requires us to define a macro at __get_user_size for the 64-bit access case. Signed-off-by: Glauber Costa <gcosta@redhat.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86/uaccess.h')
-rw-r--r--include/asm-x86/uaccess.h50
1 files changed, 49 insertions, 1 deletions
diff --git a/include/asm-x86/uaccess.h b/include/asm-x86/uaccess.h
index bcda5d075921..4353b2267a02 100644
--- a/include/asm-x86/uaccess.h
+++ b/include/asm-x86/uaccess.h
@@ -233,6 +233,47 @@ do { \
233 233
234#endif 234#endif
235 235
236#ifdef CONFIG_X86_32
237#define __get_user_asm_u64(x, ptr, retval, errret) (x) = __get_user_bad()
238#else
239#define __get_user_asm_u64(x, ptr, retval, errret) \
240 __get_user_asm(x, ptr, retval, "q", "", "=r", errret)
241#endif
242
243#define __get_user_size(x, ptr, size, retval, errret) \
244do { \
245 retval = 0; \
246 __chk_user_ptr(ptr); \
247 switch (size) { \
248 case 1: \
249 __get_user_asm(x, ptr, retval, "b", "b", "=q", errret); \
250 break; \
251 case 2: \
252 __get_user_asm(x, ptr, retval, "w", "w", "=r", errret); \
253 break; \
254 case 4: \
255 __get_user_asm(x, ptr, retval, "l", "k", "=r", errret); \
256 break; \
257 case 8: \
258 __get_user_asm_u64(x, ptr, retval, errret); \
259 break; \
260 default: \
261 (x) = __get_user_bad(); \
262 } \
263} while (0)
264
265#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
266 asm volatile("1: mov"itype" %2,%"rtype"1\n" \
267 "2:\n" \
268 ".section .fixup,\"ax\"\n" \
269 "3: mov %3,%0\n" \
270 " xor"itype" %"rtype"1,%"rtype"1\n" \
271 " jmp 2b\n" \
272 ".previous\n" \
273 _ASM_EXTABLE(1b, 3b) \
274 : "=r" (err), ltype(x) \
275 : "m" (__m(addr)), "i" (errret), "0" (err))
276
236#define __put_user_nocheck(x, ptr, size) \ 277#define __put_user_nocheck(x, ptr, size) \
237({ \ 278({ \
238 long __pu_err; \ 279 long __pu_err; \
@@ -240,7 +281,14 @@ do { \
240 __pu_err; \ 281 __pu_err; \
241}) 282})
242 283
243 284#define __get_user_nocheck(x, ptr, size) \
285({ \
286 long __gu_err; \
287 unsigned long __gu_val; \
288 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
289 (x) = (__force __typeof__(*(ptr)))__gu_val; \
290 __gu_err; \
291})
244 292
245/* FIXME: this hack is definitely wrong -AK */ 293/* FIXME: this hack is definitely wrong -AK */
246struct __large_struct { unsigned long buf[100]; }; 294struct __large_struct { unsigned long buf[100]; };