riscv: implement __get_kernel_nofault and __put_user_nofault

Implement the non-faulting kernel access helpers directly instead of
abusing the uaccess routines under set_fs(KERNEL_DS).

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
This commit is contained in:
Christoph Hellwig 2020-09-07 07:58:24 +02:00 committed by Palmer Dabbelt
parent f289a34811
commit d464118cdc
No known key found for this signature in database
GPG Key ID: 2E1319F35FBB1889

View File

@ -486,6 +486,26 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n)
__ret; \ __ret; \
}) })
#define HAVE_GET_KERNEL_NOFAULT
#define __get_kernel_nofault(dst, src, type, err_label) \
do { \
long __kr_err; \
\
__get_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \
if (unlikely(__kr_err)) \
goto err_label; \
} while (0)
#define __put_kernel_nofault(dst, src, type, err_label) \
do { \
long __kr_err; \
\
__put_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \
if (unlikely(__kr_err)) \
goto err_label; \
} while (0)
#else /* CONFIG_MMU */ #else /* CONFIG_MMU */
#include <asm-generic/uaccess.h> #include <asm-generic/uaccess.h>
#endif /* CONFIG_MMU */ #endif /* CONFIG_MMU */