Skip to content

Commit

Permalink
riscv: implement __get_kernel_nofault and __put_user_nofault
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Palmer Dabbelt committed Oct 4, 2020
1 parent f289a34 commit d464118
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions arch/riscv/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,26 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n)
__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 */
#include <asm-generic/uaccess.h>
#endif /* CONFIG_MMU */
Expand Down

0 comments on commit d464118

Please sign in to comment.