aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-x86/uaccess.h50
-rw-r--r--include/asm-x86/uaccess_32.h41
-rw-r--r--include/asm-x86/uaccess_64.h43
3 files changed, 49 insertions, 85 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]; };
diff --git a/include/asm-x86/uaccess_32.h b/include/asm-x86/uaccess_32.h
index fab755781b9b..ebfe6b23ba57 100644
--- a/include/asm-x86/uaccess_32.h
+++ b/include/asm-x86/uaccess_32.h
@@ -145,47 +145,6 @@ extern void __put_user_8(void);
145#define __put_user(x, ptr) \ 145#define __put_user(x, ptr) \
146 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) 146 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
147 147
148#define __get_user_nocheck(x, ptr, size) \
149({ \
150 long __gu_err; \
151 unsigned long __gu_val; \
152 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
153 (x) = (__typeof__(*(ptr)))__gu_val; \
154 __gu_err; \
155})
156
157#define __get_user_size(x, ptr, size, retval, errret) \
158do { \
159 retval = 0; \
160 __chk_user_ptr(ptr); \
161 switch (size) { \
162 case 1: \
163 __get_user_asm(x, ptr, retval, "b", "b", "=q", errret); \
164 break; \
165 case 2: \
166 __get_user_asm(x, ptr, retval, "w", "w", "=r", errret); \
167 break; \
168 case 4: \
169 __get_user_asm(x, ptr, retval, "l", "", "=r", errret); \
170 break; \
171 default: \
172 (x) = __get_user_bad(); \
173 } \
174} while (0)
175
176#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
177 asm volatile("1: mov"itype" %2,%"rtype"1\n" \
178 "2:\n" \
179 ".section .fixup,\"ax\"\n" \
180 "3: movl %3,%0\n" \
181 " xor"itype" %"rtype"1,%"rtype"1\n" \
182 " jmp 2b\n" \
183 ".previous\n" \
184 _ASM_EXTABLE(1b, 3b) \
185 : "=r" (err), ltype (x) \
186 : "m" (__m(addr)), "i" (errret), "0" (err))
187
188
189unsigned long __must_check __copy_to_user_ll 148unsigned long __must_check __copy_to_user_ll
190 (void __user *to, const void *from, unsigned long n); 149 (void __user *to, const void *from, unsigned long n);
191unsigned long __must_check __copy_from_user_ll 150unsigned long __must_check __copy_from_user_ll
diff --git a/include/asm-x86/uaccess_64.h b/include/asm-x86/uaccess_64.h
index e0875d7ae898..42a9769687e9 100644
--- a/include/asm-x86/uaccess_64.h
+++ b/include/asm-x86/uaccess_64.h
@@ -57,49 +57,6 @@ extern void __put_user_bad(void);
57 __pu_err; \ 57 __pu_err; \
58}) 58})
59 59
60#define __get_user_nocheck(x, ptr, size) \
61({ \
62 int __gu_err; \
63 unsigned long __gu_val; \
64 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT);\
65 (x) = (__force typeof(*(ptr)))__gu_val; \
66 __gu_err; \
67})
68
69#define __get_user_size(x, ptr, size, retval, errret) \
70do { \
71 retval = 0; \
72 __chk_user_ptr(ptr); \
73 switch (size) { \
74 case 1: \
75 __get_user_asm(x, ptr, retval, "b", "b", "=q", errret);\
76 break; \
77 case 2: \
78 __get_user_asm(x, ptr, retval, "w", "w", "=r", errret);\
79 break; \
80 case 4: \
81 __get_user_asm(x, ptr, retval, "l", "k", "=r", errret);\
82 break; \
83 case 8: \
84 __get_user_asm(x, ptr, retval, "q", "", "=r", errret); \
85 break; \
86 default: \
87 (x) = __get_user_bad(); \
88 } \
89} while (0)
90
91#define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \
92 asm volatile("1: mov"itype" %2,%"rtype"1\n" \
93 "2:\n" \
94 ".section .fixup, \"ax\"\n" \
95 "3: mov %3,%0\n" \
96 " xor"itype" %"rtype"1,%"rtype"1\n" \
97 " jmp 2b\n" \
98 ".previous\n" \
99 _ASM_EXTABLE(1b, 3b) \
100 : "=r" (err), ltype (x) \
101 : "m" (__m(addr)), "i"(errno), "0"(err))
102
103/* 60/*
104 * Copy To/From Userspace 61 * Copy To/From Userspace
105 */ 62 */