aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-sh/uaccess.h
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-05-13 23:52:56 -0400
committerPaul Mundt <lethal@hera.kernel.org>2007-06-07 22:43:36 -0400
commite08f457c7c0cc7720f28349f8780ea752c063441 (patch)
tree7b82666f2002d57dc57d022daf90c778265159e9 /include/asm-sh/uaccess.h
parent7a302a9674593259866de4a9d5ae8edc03dc1934 (diff)
sh: __user annotations for __get/__put_user().
This adds in some more __user annotations. These weren't being handled properly in some of the __get_user and __put_user paths, so tidy those up. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh/uaccess.h')
-rw-r--r--include/asm-sh/uaccess.h40
1 files changed, 22 insertions, 18 deletions
diff --git a/include/asm-sh/uaccess.h b/include/asm-sh/uaccess.h
index 5c49ed6715f2..f18a1a5c95c0 100644
--- a/include/asm-sh/uaccess.h
+++ b/include/asm-sh/uaccess.h
@@ -61,8 +61,6 @@ static inline void set_fs(mm_segment_t s)
61 */ 61 */
62static inline int __access_ok(unsigned long addr, unsigned long size) 62static inline int __access_ok(unsigned long addr, unsigned long size)
63{ 63{
64 extern unsigned long memory_start, memory_end;
65
66 return ((addr >= memory_start) && ((addr + size) < memory_end)); 64 return ((addr >= memory_start) && ((addr + size) < memory_end));
67} 65}
68#else /* CONFIG_MMU */ 66#else /* CONFIG_MMU */
@@ -76,7 +74,7 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
76 * __access_ok: Check if address with size is OK or not. 74 * __access_ok: Check if address with size is OK or not.
77 * 75 *
78 * We do three checks: 76 * We do three checks:
79 * (1) is it user space? 77 * (1) is it user space?
80 * (2) addr + size --> carry? 78 * (2) addr + size --> carry?
81 * (3) addr + size >= 0x80000000 (PAGE_OFFSET) 79 * (3) addr + size >= 0x80000000 (PAGE_OFFSET)
82 * 80 *
@@ -142,11 +140,12 @@ static inline int access_ok(int type, const void __user *p, unsigned long size)
142 __get_user_nocheck((x),(ptr),sizeof(*(ptr))) 140 __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
143 141
144struct __large_struct { unsigned long buf[100]; }; 142struct __large_struct { unsigned long buf[100]; };
145#define __m(x) (*(struct __large_struct *)(x)) 143#define __m(x) (*(struct __large_struct __user *)(x))
146 144
147#define __get_user_size(x,ptr,size,retval) \ 145#define __get_user_size(x,ptr,size,retval) \
148do { \ 146do { \
149 retval = 0; \ 147 retval = 0; \
148 __chk_user_ptr(ptr); \
150 switch (size) { \ 149 switch (size) { \
151 case 1: \ 150 case 1: \
152 __get_user_asm(x, ptr, retval, "b"); \ 151 __get_user_asm(x, ptr, retval, "b"); \
@@ -175,6 +174,7 @@ do { \
175#define __get_user_check(x,ptr,size) \ 174#define __get_user_check(x,ptr,size) \
176({ \ 175({ \
177 long __gu_err, __gu_val; \ 176 long __gu_err, __gu_val; \
177 __chk_user_ptr(ptr); \
178 switch (size) { \ 178 switch (size) { \
179 case 1: \ 179 case 1: \
180 __get_user_1(__gu_val, (ptr), __gu_err); \ 180 __get_user_1(__gu_val, (ptr), __gu_err); \
@@ -300,6 +300,7 @@ extern void __get_user_unknown(void);
300#define __put_user_size(x,ptr,size,retval) \ 300#define __put_user_size(x,ptr,size,retval) \
301do { \ 301do { \
302 retval = 0; \ 302 retval = 0; \
303 __chk_user_ptr(ptr); \
303 switch (size) { \ 304 switch (size) { \
304 case 1: \ 305 case 1: \
305 __put_user_asm(x, ptr, retval, "b"); \ 306 __put_user_asm(x, ptr, retval, "b"); \
@@ -328,7 +329,7 @@ do { \
328#define __put_user_check(x,ptr,size) \ 329#define __put_user_check(x,ptr,size) \
329({ \ 330({ \
330 long __pu_err = -EFAULT; \ 331 long __pu_err = -EFAULT; \
331 __typeof__(*(ptr)) *__pu_addr = (ptr); \ 332 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
332 \ 333 \
333 if (__access_ok((unsigned long)__pu_addr,size)) \ 334 if (__access_ok((unsigned long)__pu_addr,size)) \
334 __put_user_size((x),__pu_addr,(size),__pu_err); \ 335 __put_user_size((x),__pu_addr,(size),__pu_err); \
@@ -406,10 +407,10 @@ __asm__ __volatile__( \
406#endif 407#endif
407 408
408extern void __put_user_unknown(void); 409extern void __put_user_unknown(void);
409 410
410/* Generic arbitrary sized copy. */ 411/* Generic arbitrary sized copy. */
411/* Return the number of bytes NOT copied */ 412/* Return the number of bytes NOT copied */
412extern __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); 413__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
413 414
414#define copy_to_user(to,from,n) ({ \ 415#define copy_to_user(to,from,n) ({ \
415void *__copy_to = (void *) (to); \ 416void *__copy_to = (void *) (to); \
@@ -420,14 +421,6 @@ __copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \
420} else __copy_res = __copy_size; \ 421} else __copy_res = __copy_size; \
421__copy_res; }) 422__copy_res; })
422 423
423#define __copy_to_user(to,from,n) \
424 __copy_user((void *)(to), \
425 (void *)(from), n)
426
427#define __copy_to_user_inatomic __copy_to_user
428#define __copy_from_user_inatomic __copy_from_user
429
430
431#define copy_from_user(to,from,n) ({ \ 424#define copy_from_user(to,from,n) ({ \
432void *__copy_to = (void *) (to); \ 425void *__copy_to = (void *) (to); \
433void *__copy_from = (void *) (from); \ 426void *__copy_from = (void *) (from); \
@@ -438,9 +431,20 @@ __copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \
438} else __copy_res = __copy_size; \ 431} else __copy_res = __copy_size; \
439__copy_res; }) 432__copy_res; })
440 433
441#define __copy_from_user(to,from,n) \ 434static __always_inline unsigned long
442 __copy_user((void *)(to), \ 435__copy_from_user(void *to, const void __user *from, unsigned long n)
443 (void *)(from), n) 436{
437 return __copy_user(to, (__force void *)from, n);
438}
439
440static __always_inline unsigned long __must_check
441__copy_to_user(void __user *to, const void *from, unsigned long n)
442{
443 return __copy_user((__force void *)to, from, n);
444}
445
446#define __copy_to_user_inatomic __copy_to_user
447#define __copy_from_user_inatomic __copy_from_user
444 448
445/* 449/*
446 * Clear the area and return remaining number of bytes 450 * Clear the area and return remaining number of bytes