blob: b8a2f43399032e1ce617e38a35eb28919f08a287 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __X86_64_UACCESS_H
2#define __X86_64_UACCESS_H
3
4/*
5 * User space memory access functions
6 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/compiler.h>
8#include <linux/errno.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/prefetch.h>
10#include <asm/page.h>
11
12#define VERIFY_READ 0
13#define VERIFY_WRITE 1
14
15/*
16 * The fs value determines whether argument validity checking should be
17 * performed or not. If get_fs() == USER_DS, checking is performed, with
18 * get_fs() == KERNEL_DS, checking is bypassed.
19 *
20 * For historical reasons, these macros are grossly misnamed.
21 */
22
23#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
24
25#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFFFFFFFFFUL)
26#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
27
28#define get_ds() (KERNEL_DS)
29#define get_fs() (current_thread_info()->addr_limit)
30#define set_fs(x) (current_thread_info()->addr_limit = (x))
31
Joe Perchesb8963132008-03-23 01:03:49 -070032#define segment_eq(a, b) ((a).seg == (b).seg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Joe Perchesb8963132008-03-23 01:03:49 -070034#define __addr_ok(addr) (!((unsigned long)(addr) & \
35 (current_thread_info()->addr_limit.seg)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37/*
38 * Uhhuh, this needs 65-bit arithmetic. We have a carry..
39 */
Joe Perchesb8963132008-03-23 01:03:49 -070040#define __range_not_ok(addr, size) \
41({ \
42 unsigned long flag, roksum; \
43 __chk_user_ptr(addr); \
44 asm("# range_ok\n\r" \
45 "addq %3,%1 ; sbbq %0,%0 ; cmpq %1,%4 ; sbbq $0,%0" \
46 : "=&r" (flag), "=r" (roksum) \
47 : "1" (addr), "g" ((long)(size)), \
48 "g" (current_thread_info()->addr_limit.seg)); \
49 flag; \
50})
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Joe Perchesb8963132008-03-23 01:03:49 -070052#define access_ok(type, addr, size) (__range_not_ok(addr, size) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Linus Torvalds1da177e2005-04-16 15:20:36 -070054/*
55 * The exception table consists of pairs of addresses: the first is the
56 * address of an instruction that is allowed to fault, and the second is
57 * the address at which the program should continue. No registers are
58 * modified, so it is entirely up to the continuation code to figure out
59 * what to do.
60 *
61 * All the routines below use bits of fixup code that are out of line
62 * with the main instruction path. This means when everything is well,
63 * we don't even have to jump over them. Further, they do not intrude
64 * on our cache or tlb entries.
65 */
66
Joe Perchesb8963132008-03-23 01:03:49 -070067struct exception_table_entry {
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 unsigned long insn, fixup;
69};
70
Harvey Harrison85f2adf2008-01-30 13:31:42 +010071extern int fixup_exception(struct pt_regs *regs);
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#define ARCH_HAS_SEARCH_EXTABLE
74
75/*
76 * These are the main single-value transfer routines. They automatically
77 * use the right size if we just have the right pointer type.
78 *
79 * This gets kind of ugly. We want to return _two_ values in "get_user()"
80 * and yet we don't want to do any pointers, because that is too much
81 * of a performance impact. Thus we have a few rather ugly macros here,
82 * and hide all the ugliness from the user.
83 *
84 * The "__xxx" versions of the user access functions are versions that
85 * do not verify the address space, that must have been done previously
86 * with a separate "access_ok()" call (this is used when we do multiple
87 * accesses to the same area of user memory).
88 */
89
Joe Perchesb8963132008-03-23 01:03:49 -070090#define __get_user_x(size, ret, x, ptr) \
91 asm volatile("call __get_user_" #size \
92 : "=a" (ret),"=d" (x) \
93 : "c" (ptr) \
94 : "r8")
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Joe Perchesb8963132008-03-23 01:03:49 -070096/* Careful: we have to cast the result to the type of the pointer
97 * for sign reasons */
98
99#define get_user(x, ptr) \
100({ \
101 unsigned long __val_gu; \
102 int __ret_gu; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 __chk_user_ptr(ptr); \
Joe Perchesb8963132008-03-23 01:03:49 -0700104 switch (sizeof(*(ptr))) { \
105 case 1: \
106 __get_user_x(1, __ret_gu, __val_gu, ptr); \
107 break; \
108 case 2: \
109 __get_user_x(2, __ret_gu, __val_gu, ptr); \
110 break; \
111 case 4: \
112 __get_user_x(4, __ret_gu, __val_gu, ptr); \
113 break; \
114 case 8: \
115 __get_user_x(8, __ret_gu, __val_gu, ptr); \
116 break; \
117 default: \
118 __get_user_bad(); \
119 break; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 } \
Al Virofdd33962007-07-26 17:35:39 +0100121 (x) = (__force typeof(*(ptr)))__val_gu; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 __ret_gu; \
123})
124
125extern void __put_user_1(void);
126extern void __put_user_2(void);
127extern void __put_user_4(void);
128extern void __put_user_8(void);
129extern void __put_user_bad(void);
130
Joe Perchesb8963132008-03-23 01:03:49 -0700131#define __put_user_x(size, ret, x, ptr) \
132 asm volatile("call __put_user_" #size \
133 :"=a" (ret) \
134 :"c" (ptr),"d" (x) \
135 :"r8")
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
Joe Perchesb8963132008-03-23 01:03:49 -0700137#define put_user(x, ptr) \
138 __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Joe Perchesb8963132008-03-23 01:03:49 -0700140#define __get_user(x, ptr) \
141 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
142#define __put_user(x, ptr) \
143 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145#define __get_user_unaligned __get_user
146#define __put_user_unaligned __put_user
147
Joe Perchesb8963132008-03-23 01:03:49 -0700148#define __put_user_nocheck(x, ptr, size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149({ \
150 int __pu_err; \
Joe Perchesb8963132008-03-23 01:03:49 -0700151 __put_user_size((x), (ptr), (size), __pu_err); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 __pu_err; \
153})
154
155
Joe Perchesb8963132008-03-23 01:03:49 -0700156#define __put_user_check(x, ptr, size) \
157({ \
158 int __pu_err; \
159 typeof(*(ptr)) __user *__pu_addr = (ptr); \
160 switch (size) { \
161 case 1: \
162 __put_user_x(1, __pu_err, x, __pu_addr); \
163 break; \
164 case 2: \
165 __put_user_x(2, __pu_err, x, __pu_addr); \
166 break; \
167 case 4: \
168 __put_user_x(4, __pu_err, x, __pu_addr); \
169 break; \
170 case 8: \
171 __put_user_x(8, __pu_err, x, __pu_addr); \
172 break; \
173 default: \
174 __put_user_bad(); \
175 } \
176 __pu_err; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177})
178
Joe Perchesb8963132008-03-23 01:03:49 -0700179#define __put_user_size(x, ptr, size, retval) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180do { \
181 retval = 0; \
182 __chk_user_ptr(ptr); \
183 switch (size) { \
Joe Perchesb8963132008-03-23 01:03:49 -0700184 case 1: \
185 __put_user_asm(x, ptr, retval, "b", "b", "iq", -EFAULT);\
186 break; \
187 case 2: \
188 __put_user_asm(x, ptr, retval, "w", "w", "ir", -EFAULT);\
189 break; \
190 case 4: \
191 __put_user_asm(x, ptr, retval, "l", "k", "ir", -EFAULT);\
192 break; \
193 case 8: \
194 __put_user_asm(x, ptr, retval, "q", "", "Zr", -EFAULT); \
195 break; \
196 default: \
197 __put_user_bad(); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 } \
199} while (0)
200
201/* FIXME: this hack is definitely wrong -AK */
202struct __large_struct { unsigned long buf[100]; };
203#define __m(x) (*(struct __large_struct __user *)(x))
204
205/*
206 * Tell gcc we read from memory instead of writing: this is because
207 * we do not write to any memory gcc knows about, so there are no
208 * aliasing issues.
209 */
210#define __put_user_asm(x, addr, err, itype, rtype, ltype, errno) \
Joe Perchesb8963132008-03-23 01:03:49 -0700211 asm volatile("1: mov"itype" %"rtype"1,%2\n" \
212 "2:\n" \
213 ".section .fixup, \"ax\"\n" \
214 "3: mov %3,%0\n" \
215 " jmp 2b\n" \
216 ".previous\n" \
217 _ASM_EXTABLE(1b, 3b) \
218 : "=r"(err) \
219 : ltype (x), "m" (__m(addr)), "i" (errno), "0" (err))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
221
Joe Perchesb8963132008-03-23 01:03:49 -0700222#define __get_user_nocheck(x, ptr, size) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223({ \
224 int __gu_err; \
225 unsigned long __gu_val; \
Joe Perchesb8963132008-03-23 01:03:49 -0700226 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
Al Virofdd33962007-07-26 17:35:39 +0100227 (x) = (__force typeof(*(ptr)))__gu_val; \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 __gu_err; \
229})
230
231extern int __get_user_1(void);
232extern int __get_user_2(void);
233extern int __get_user_4(void);
234extern int __get_user_8(void);
235extern int __get_user_bad(void);
236
Joe Perchesb8963132008-03-23 01:03:49 -0700237#define __get_user_size(x, ptr, size, retval) \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238do { \
239 retval = 0; \
240 __chk_user_ptr(ptr); \
241 switch (size) { \
Joe Perchesb8963132008-03-23 01:03:49 -0700242 case 1: \
243 __get_user_asm(x, ptr, retval, "b", "b", "=q", -EFAULT);\
244 break; \
245 case 2: \
246 __get_user_asm(x, ptr, retval, "w", "w", "=r", -EFAULT);\
247 break; \
248 case 4: \
249 __get_user_asm(x, ptr, retval, "l", "k", "=r", -EFAULT);\
250 break; \
251 case 8: \
252 __get_user_asm(x, ptr, retval, "q", "", "=r", -EFAULT); \
253 break; \
254 default: \
255 (x) = __get_user_bad(); \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 } \
257} while (0)
258
259#define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \
Joe Perchesb8963132008-03-23 01:03:49 -0700260 asm volatile("1: mov"itype" %2,%"rtype"1\n" \
261 "2:\n" \
262 ".section .fixup, \"ax\"\n" \
263 "3: mov %3,%0\n" \
264 " xor"itype" %"rtype"1,%"rtype"1\n" \
265 " jmp 2b\n" \
266 ".previous\n" \
267 _ASM_EXTABLE(1b, 3b) \
268 : "=r" (err), ltype (x) \
269 : "m" (__m(addr)), "i"(errno), "0"(err))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271/*
272 * Copy To/From Userspace
273 */
274
275/* Handles exceptions in both to and from, but doesn't do access_ok */
Andi Kleen95912002006-09-26 10:52:39 +0200276__must_check unsigned long
277copy_user_generic(void *to, const void *from, unsigned len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Andi Kleen95912002006-09-26 10:52:39 +0200279__must_check unsigned long
280copy_to_user(void __user *to, const void *from, unsigned len);
281__must_check unsigned long
282copy_from_user(void *to, const void __user *from, unsigned len);
283__must_check unsigned long
284copy_in_user(void __user *to, const void __user *from, unsigned len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Andi Kleen95912002006-09-26 10:52:39 +0200286static __always_inline __must_check
287int __copy_from_user(void *dst, const void __user *src, unsigned size)
Joe Perchesb8963132008-03-23 01:03:49 -0700288{
Andi Kleen383d0792006-09-26 10:52:40 +0200289 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 if (!__builtin_constant_p(size))
Joe Perchesb8963132008-03-23 01:03:49 -0700291 return copy_user_generic(dst, (__force void *)src, size);
292 switch (size) {
293 case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
294 ret, "b", "b", "=q", 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 return ret;
Joe Perchesb8963132008-03-23 01:03:49 -0700296 case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
297 ret, "w", "w", "=r", 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 return ret;
Joe Perchesb8963132008-03-23 01:03:49 -0700299 case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
300 ret, "l", "k", "=r", 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 return ret;
Joe Perchesb8963132008-03-23 01:03:49 -0700302 case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
303 ret, "q", "", "=r", 8);
304 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 case 10:
Joe Perchesb8963132008-03-23 01:03:49 -0700306 __get_user_asm(*(u64 *)dst, (u64 __user *)src,
307 ret, "q", "", "=r", 16);
308 if (unlikely(ret))
309 return ret;
310 __get_user_asm(*(u16 *)(8 + (char *)dst),
311 (u16 __user *)(8 + (char __user *)src),
312 ret, "w", "w", "=r", 2);
313 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 case 16:
Joe Perchesb8963132008-03-23 01:03:49 -0700315 __get_user_asm(*(u64 *)dst, (u64 __user *)src,
316 ret, "q", "", "=r", 16);
317 if (unlikely(ret))
318 return ret;
319 __get_user_asm(*(u64 *)(8 + (char *)dst),
320 (u64 __user *)(8 + (char __user *)src),
321 ret, "q", "", "=r", 8);
322 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 default:
Joe Perchesb8963132008-03-23 01:03:49 -0700324 return copy_user_generic(dst, (__force void *)src, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 }
Joe Perchesb8963132008-03-23 01:03:49 -0700326}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
Andi Kleen95912002006-09-26 10:52:39 +0200328static __always_inline __must_check
329int __copy_to_user(void __user *dst, const void *src, unsigned size)
Joe Perchesb8963132008-03-23 01:03:49 -0700330{
Andi Kleen383d0792006-09-26 10:52:40 +0200331 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 if (!__builtin_constant_p(size))
Joe Perchesb8963132008-03-23 01:03:49 -0700333 return copy_user_generic((__force void *)dst, src, size);
334 switch (size) {
335 case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
336 ret, "b", "b", "iq", 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 return ret;
Joe Perchesb8963132008-03-23 01:03:49 -0700338 case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
339 ret, "w", "w", "ir", 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 return ret;
Joe Perchesb8963132008-03-23 01:03:49 -0700341 case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
342 ret, "l", "k", "ir", 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 return ret;
Joe Perchesb8963132008-03-23 01:03:49 -0700344 case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
345 ret, "q", "", "ir", 8);
346 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 case 10:
Joe Perchesb8963132008-03-23 01:03:49 -0700348 __put_user_asm(*(u64 *)src, (u64 __user *)dst,
349 ret, "q", "", "ir", 10);
350 if (unlikely(ret))
351 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 asm("":::"memory");
Joe Perchesb8963132008-03-23 01:03:49 -0700353 __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
354 ret, "w", "w", "ir", 2);
355 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 case 16:
Joe Perchesb8963132008-03-23 01:03:49 -0700357 __put_user_asm(*(u64 *)src, (u64 __user *)dst,
358 ret, "q", "", "ir", 16);
359 if (unlikely(ret))
360 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 asm("":::"memory");
Joe Perchesb8963132008-03-23 01:03:49 -0700362 __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
363 ret, "q", "", "ir", 8);
364 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 default:
Joe Perchesb8963132008-03-23 01:03:49 -0700366 return copy_user_generic((__force void *)dst, src, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 }
Joe Perchesb8963132008-03-23 01:03:49 -0700368}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369
Andi Kleen95912002006-09-26 10:52:39 +0200370static __always_inline __must_check
371int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
Joe Perchesb8963132008-03-23 01:03:49 -0700372{
Andi Kleen383d0792006-09-26 10:52:40 +0200373 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 if (!__builtin_constant_p(size))
Joe Perchesb8963132008-03-23 01:03:49 -0700375 return copy_user_generic((__force void *)dst,
376 (__force void *)src, size);
377 switch (size) {
378 case 1: {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 u8 tmp;
Joe Perchesb8963132008-03-23 01:03:49 -0700380 __get_user_asm(tmp, (u8 __user *)src,
381 ret, "b", "b", "=q", 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 if (likely(!ret))
Joe Perchesb8963132008-03-23 01:03:49 -0700383 __put_user_asm(tmp, (u8 __user *)dst,
384 ret, "b", "b", "iq", 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 return ret;
386 }
Joe Perchesb8963132008-03-23 01:03:49 -0700387 case 2: {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 u16 tmp;
Joe Perchesb8963132008-03-23 01:03:49 -0700389 __get_user_asm(tmp, (u16 __user *)src,
390 ret, "w", "w", "=r", 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 if (likely(!ret))
Joe Perchesb8963132008-03-23 01:03:49 -0700392 __put_user_asm(tmp, (u16 __user *)dst,
393 ret, "w", "w", "ir", 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 return ret;
395 }
396
Joe Perchesb8963132008-03-23 01:03:49 -0700397 case 4: {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 u32 tmp;
Joe Perchesb8963132008-03-23 01:03:49 -0700399 __get_user_asm(tmp, (u32 __user *)src,
400 ret, "l", "k", "=r", 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 if (likely(!ret))
Joe Perchesb8963132008-03-23 01:03:49 -0700402 __put_user_asm(tmp, (u32 __user *)dst,
403 ret, "l", "k", "ir", 4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 return ret;
405 }
Joe Perchesb8963132008-03-23 01:03:49 -0700406 case 8: {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 u64 tmp;
Joe Perchesb8963132008-03-23 01:03:49 -0700408 __get_user_asm(tmp, (u64 __user *)src,
409 ret, "q", "", "=r", 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 if (likely(!ret))
Joe Perchesb8963132008-03-23 01:03:49 -0700411 __put_user_asm(tmp, (u64 __user *)dst,
412 ret, "q", "", "ir", 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 return ret;
414 }
415 default:
Joe Perchesb8963132008-03-23 01:03:49 -0700416 return copy_user_generic((__force void *)dst,
417 (__force void *)src, size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 }
Joe Perchesb8963132008-03-23 01:03:49 -0700419}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
Joe Perchesb8963132008-03-23 01:03:49 -0700421__must_check long
Andi Kleen95912002006-09-26 10:52:39 +0200422strncpy_from_user(char *dst, const char __user *src, long count);
Joe Perchesb8963132008-03-23 01:03:49 -0700423__must_check long
Andi Kleen95912002006-09-26 10:52:39 +0200424__strncpy_from_user(char *dst, const char __user *src, long count);
425__must_check long strnlen_user(const char __user *str, long n);
426__must_check long __strnlen_user(const char __user *str, long n);
427__must_check long strlen_user(const char __user *str);
428__must_check unsigned long clear_user(void __user *mem, unsigned long len);
429__must_check unsigned long __clear_user(void __user *mem, unsigned long len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
Joe Perchesb8963132008-03-23 01:03:49 -0700431__must_check long __copy_from_user_inatomic(void *dst, const void __user *src,
432 unsigned size);
Andi Kleenb8858082006-09-30 01:47:55 +0200433
434static __must_check __always_inline int
435__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
436{
437 return copy_user_generic((__force void *)dst, src, size);
438}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Andi Kleen0812a572007-02-13 13:26:19 +0100440#define ARCH_HAS_NOCACHE_UACCESS 1
Joe Perchesb8963132008-03-23 01:03:49 -0700441extern long __copy_user_nocache(void *dst, const void __user *src,
442 unsigned size, int zerorest);
Andi Kleen0812a572007-02-13 13:26:19 +0100443
Joe Perchesb8963132008-03-23 01:03:49 -0700444static inline int __copy_from_user_nocache(void *dst, const void __user *src,
445 unsigned size)
Andi Kleen0812a572007-02-13 13:26:19 +0100446{
447 might_sleep();
Al Viroecb75242007-03-14 09:20:20 +0000448 return __copy_user_nocache(dst, src, size, 1);
Andi Kleen0812a572007-02-13 13:26:19 +0100449}
450
Joe Perchesb8963132008-03-23 01:03:49 -0700451static inline int __copy_from_user_inatomic_nocache(void *dst,
452 const void __user *src,
453 unsigned size)
Andi Kleen0812a572007-02-13 13:26:19 +0100454{
Al Viroecb75242007-03-14 09:20:20 +0000455 return __copy_user_nocache(dst, src, size, 0);
Andi Kleen0812a572007-02-13 13:26:19 +0100456}
457
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458#endif /* __X86_64_UACCESS_H */