提交 01eec1af 编写于 作者: C Christoph Hellwig 提交者: Geert Uytterhoeven

m68k: Factor the 8-byte lowlevel {get,put}_user code into helpers

Add new helpers for doing the grunt work of the 8-byte {get,put}_user
routines to allow for better reuse.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NMichael Schmitz <schmitzmic@gmail.com>
Tested-by: NMichael Schmitz <schmitzmic@gmail.com>
Link: https://lore.kernel.org/r/20210916070405.52750-5-hch@lst.deSigned-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
上级 25d2cae4
...@@ -57,6 +57,31 @@ asm volatile ("\n" \ ...@@ -57,6 +57,31 @@ asm volatile ("\n" \
: "+d" (res), "=m" (*(ptr)) \ : "+d" (res), "=m" (*(ptr)) \
: #reg (x), "i" (err)) : #reg (x), "i" (err))
#define __put_user_asm8(res, x, ptr) \
do { \
const void *__pu_ptr = (const void __force *)(ptr); \
\
asm volatile ("\n" \
"1: "MOVES".l %2,(%1)+\n" \
"2: "MOVES".l %R2,(%1)\n" \
"3:\n" \
" .section .fixup,\"ax\"\n" \
" .even\n" \
"10: movel %3,%0\n" \
" jra 3b\n" \
" .previous\n" \
"\n" \
" .section __ex_table,\"a\"\n" \
" .align 4\n" \
" .long 1b,10b\n" \
" .long 2b,10b\n" \
" .long 3b,10b\n" \
" .previous" \
: "+d" (res), "+a" (__pu_ptr) \
: "r" (x), "i" (-EFAULT) \
: "memory"); \
} while (0)
/* /*
* These are the main single-value transfer routines. They automatically * These are the main single-value transfer routines. They automatically
* use the right size if we just have the right pointer type. * use the right size if we just have the right pointer type.
...@@ -78,29 +103,8 @@ asm volatile ("\n" \ ...@@ -78,29 +103,8 @@ asm volatile ("\n" \
__put_user_asm(__pu_err, __pu_val, ptr, l, r, -EFAULT); \ __put_user_asm(__pu_err, __pu_val, ptr, l, r, -EFAULT); \
break; \ break; \
case 8: \ case 8: \
{ \ __put_user_asm8(__pu_err, __pu_val, ptr); \
const void __user *__pu_ptr = (ptr); \
asm volatile ("\n" \
"1: "MOVES".l %2,(%1)+\n" \
"2: "MOVES".l %R2,(%1)\n" \
"3:\n" \
" .section .fixup,\"ax\"\n" \
" .even\n" \
"10: movel %3,%0\n" \
" jra 3b\n" \
" .previous\n" \
"\n" \
" .section __ex_table,\"a\"\n" \
" .align 4\n" \
" .long 1b,10b\n" \
" .long 2b,10b\n" \
" .long 3b,10b\n" \
" .previous" \
: "+d" (__pu_err), "+a" (__pu_ptr) \
: "r" (__pu_val), "i" (-EFAULT) \
: "memory"); \
break; \ break; \
} \
default: \ default: \
BUILD_BUG(); \ BUILD_BUG(); \
} \ } \
...@@ -130,6 +134,38 @@ asm volatile ("\n" \ ...@@ -130,6 +134,38 @@ asm volatile ("\n" \
(x) = (__force typeof(*(ptr)))(__force unsigned long)__gu_val; \ (x) = (__force typeof(*(ptr)))(__force unsigned long)__gu_val; \
}) })
#define __get_user_asm8(res, x, ptr) \
do { \
const void *__gu_ptr = (const void __force *)(ptr); \
union { \
u64 l; \
__typeof__(*(ptr)) t; \
} __gu_val; \
\
asm volatile ("\n" \
"1: "MOVES".l (%2)+,%1\n" \
"2: "MOVES".l (%2),%R1\n" \
"3:\n" \
" .section .fixup,\"ax\"\n" \
" .even\n" \
"10: move.l %3,%0\n" \
" sub.l %1,%1\n" \
" sub.l %R1,%R1\n" \
" jra 3b\n" \
" .previous\n" \
"\n" \
" .section __ex_table,\"a\"\n" \
" .align 4\n" \
" .long 1b,10b\n" \
" .long 2b,10b\n" \
" .previous" \
: "+d" (res), "=&r" (__gu_val.l), \
"+a" (__gu_ptr) \
: "i" (-EFAULT) \
: "memory"); \
(x) = __gu_val.t; \
} while (0)
#define __get_user(x, ptr) \ #define __get_user(x, ptr) \
({ \ ({ \
int __gu_err = 0; \ int __gu_err = 0; \
...@@ -144,36 +180,9 @@ asm volatile ("\n" \ ...@@ -144,36 +180,9 @@ asm volatile ("\n" \
case 4: \ case 4: \
__get_user_asm(__gu_err, x, ptr, u32, l, r, -EFAULT); \ __get_user_asm(__gu_err, x, ptr, u32, l, r, -EFAULT); \
break; \ break; \
case 8: { \ case 8: \
const void __user *__gu_ptr = (ptr); \ __get_user_asm8(__gu_err, x, ptr); \
union { \
u64 l; \
__typeof__(*(ptr)) t; \
} __gu_val; \
asm volatile ("\n" \
"1: "MOVES".l (%2)+,%1\n" \
"2: "MOVES".l (%2),%R1\n" \
"3:\n" \
" .section .fixup,\"ax\"\n" \
" .even\n" \
"10: move.l %3,%0\n" \
" sub.l %1,%1\n" \
" sub.l %R1,%R1\n" \
" jra 3b\n" \
" .previous\n" \
"\n" \
" .section __ex_table,\"a\"\n" \
" .align 4\n" \
" .long 1b,10b\n" \
" .long 2b,10b\n" \
" .previous" \
: "+d" (__gu_err), "=&r" (__gu_val.l), \
"+a" (__gu_ptr) \
: "i" (-EFAULT) \
: "memory"); \
(x) = __gu_val.t; \
break; \ break; \
} \
default: \ default: \
BUILD_BUG(); \ BUILD_BUG(); \
} \ } \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册