Commit ef4e277b authored by Michal Simek's avatar Michal Simek

microblaze: uaccess: Fix put_user for noMMU

Here is small regression on dhrystone tests and I think
that on all benchmarking tests. It is due to better checking
mechanism in put_user macro
Signed-off-by: default avatarMichal Simek <monstr@monstr.eu>
parent 3a6d7724
...@@ -213,32 +213,66 @@ extern long __user_bad(void); ...@@ -213,32 +213,66 @@ extern long __user_bad(void);
? __get_user((x), (ptr)) : -EFAULT; \ ? __get_user((x), (ptr)) : -EFAULT; \
}) })
/* Undefined function to trigger linker error */ #define __put_user_asm(insn, __gu_ptr, __gu_val, __gu_err) \
extern int bad_user_access_length(void); ({ \
__asm__ __volatile__ ( \
"1:" insn " %1, %2, r0;" \
" addk %0, r0, r0;" \
"2: " \
__FIXUP_SECTION \
"3: brid 2b;" \
" addik %0, r0, %3;" \
".previous;" \
__EX_TABLE_SECTION \
".word 1b,3b;" \
".previous;" \
: "=&r"(__gu_err) \
: "r"(__gu_val), "r"(__gu_ptr), "i"(-EFAULT) \
); \
})
/* FIXME is not there defined __pu_val */ #define __put_user_asm_8(__gu_ptr, __gu_val, __gu_err) \
#define __put_user(var, ptr) \
({ \ ({ \
int __pu_err = 0; \ __asm__ __volatile__ (" lwi %0, %1, 0;" \
switch (sizeof(*(ptr))) { \ "1: swi %0, %2, 0;" \
case 1: \ " lwi %0, %1, 4;" \
case 2: \ "2: swi %0, %2, 4;" \
case 4: \ " addk %0, r0, r0;" \
*(ptr) = (var); \ "3: " \
break; \ __FIXUP_SECTION \
case 8: { \ "4: brid 3b;" \
typeof(*(ptr)) __pu_val = (var); \ " addik %0, r0, %3;" \
memcpy(ptr, &__pu_val, sizeof(__pu_val)); \ ".previous;" \
} \ __EX_TABLE_SECTION \
break; \ ".word 1b,4b,2b,4b;" \
default: \ ".previous;" \
__pu_err = __put_user_bad(); \ : "=&r"(__gu_err) \
break; \ : "r"(&__gu_val), "r"(__gu_ptr), "i"(-EFAULT) \
} \ ); \
__pu_err; \
}) })
#define __put_user_bad() (bad_user_access_length(), (-EFAULT)) #define __put_user(x, ptr) \
({ \
__typeof__(*(ptr)) volatile __gu_val = (x); \
long __gu_err = 0; \
switch (sizeof(__gu_val)) { \
case 1: \
__put_user_asm("sb", (ptr), __gu_val, __gu_err); \
break; \
case 2: \
__put_user_asm("sh", (ptr), __gu_val, __gu_err); \
break; \
case 4: \
__put_user_asm("sw", (ptr), __gu_val, __gu_err); \
break; \
case 8: \
__put_user_asm_8((ptr), __gu_val, __gu_err); \
break; \
default: \
/*__gu_err = -EINVAL;*/ __gu_err = __user_bad(); \
} \
__gu_err; \
})
#define put_user(x, ptr) __put_user((x), (ptr)) #define put_user(x, ptr) __put_user((x), (ptr))
......
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