Commit 5ff294fa authored by Mike Frysinger's avatar Mike Frysinger Committed by Bryan Wu

Blackfin arch: fixup get_user() macros

 - to avoid uninitialized errors
 - make invalid sizes a build error
Signed-off-by: default avatarMike Frysinger <vapier.adi@gmail.com>
Signed-off-by: default avatarBryan Wu <cooloney@kernel.org>
parent 9f20cf25
...@@ -149,54 +149,42 @@ static inline int bad_user_access_length(void) ...@@ -149,54 +149,42 @@ static inline int bad_user_access_length(void)
: /* no outputs */ \ : /* no outputs */ \
:"d" (x),"a" (__ptr(p)) : "memory") :"d" (x),"a" (__ptr(p)) : "memory")
#define get_user(x,p) \ #define get_user(x, ptr) \
({ \ ({ \
int _err = 0; \ int _err = 0; \
typeof(*(p)) *_p = (p); \ unsigned long _val = 0; \
if (!access_ok(VERIFY_READ, _p, sizeof(*(_p)))) { \ const typeof(*(ptr)) __user *_p = (ptr); \
_err = -EFAULT; \ const size_t ptr_size = sizeof(*(_p)); \
} \ if (likely(access_ok(VERIFY_READ, _p, ptr_size))) { \
else { \ BUILD_BUG_ON(ptr_size >= 8); \
switch (sizeof(*(_p))) { \ switch (ptr_size) { \
case 1: \ case 1: \
__get_user_asm(x, _p, B,(Z)); \ __get_user_asm(_val, _p, B,(Z)); \
break; \ break; \
case 2: \ case 2: \
__get_user_asm(x, _p, W,(Z)); \ __get_user_asm(_val, _p, W,(Z)); \
break; \ break; \
case 4: \ case 4: \
__get_user_asm(x, _p, , ); \ __get_user_asm(_val, _p, , ); \
break; \ break; \
case 8: { \ } \
unsigned long _xl, _xh; \ } else \
__get_user_asm(_xl, ((unsigned long *)_p)+0, , ); \ _err = -EFAULT; \
__get_user_asm(_xh, ((unsigned long *)_p)+1, , ); \ x = (typeof(*(ptr)))_val; \
((unsigned long *)&x)[0] = _xl; \ _err; \
((unsigned long *)&x)[1] = _xh; \ })
} break; \
default: \
x = 0; \
printk(KERN_INFO "get_user_bad: %s:%d %s\n", \
__FILE__, __LINE__, __func__); \
_err = __get_user_bad(); \
break; \
} \
} \
_err; \
})
#define __get_user(x,p) get_user(x,p) #define __get_user(x,p) get_user(x,p)
#define __get_user_bad() (bad_user_access_length(), (-EFAULT)) #define __get_user_bad() (bad_user_access_length(), (-EFAULT))
#define __get_user_asm(x,p,bhw,option) \ #define __get_user_asm(x, ptr, bhw, option) \
{ \ ({ \
unsigned long _tmp; \ __asm__ __volatile__ ( \
__asm__ ("%0 =" #bhw "[%1]"#option";\n\t" \ "%0 =" #bhw "[%1]" #option ";" \
: "=d" (_tmp) \ : "=d" (x) \
: "a" (__ptr(p))); \ : "a" (__ptr(ptr))); \
(x) = (__typeof__(*(p))) _tmp; \ })
}
#define __copy_from_user(to, from, n) copy_from_user(to, from, n) #define __copy_from_user(to, from, n) copy_from_user(to, from, n)
#define __copy_to_user(to, from, n) copy_to_user(to, from, n) #define __copy_to_user(to, from, n) copy_to_user(to, from, n)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment