Skip to content

Commit 2d2d255

Browse files
Christoph Hellwigpalmer-dabbelt
authored andcommitted
asm-generic: add nommu implementations of __{get,put}_kernel_nofault
Add native implementations of __{get,put}_kernel_nofault using {get,put}_unaligned, just like the {get,put}_user implementations. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
1 parent 931de11 commit 2d2d255

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

include/asm-generic/uaccess.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ static inline int __put_user_fn(size_t size, void __user *to, void *from)
6161
}
6262
#define __put_user_fn(sz, u, k) __put_user_fn(sz, u, k)
6363

64+
#define __get_kernel_nofault(dst, src, type, err_label) \
65+
do { \
66+
*((type *)dst) = get_unaligned((type *)(src)); \
67+
if (0) /* make sure the label looks used to the compiler */ \
68+
goto err_label; \
69+
} while (0)
70+
71+
#define __put_kernel_nofault(dst, src, type, err_label) \
72+
do { \
73+
put_unaligned(*((type *)src), (type *)(dst)); \
74+
if (0) /* make sure the label looks used to the compiler */ \
75+
goto err_label; \
76+
} while (0)
77+
78+
#define HAVE_GET_KERNEL_NOFAULT 1
79+
6480
static inline __must_check unsigned long
6581
raw_copy_from_user(void *to, const void __user * from, unsigned long n)
6682
{

0 commit comments

Comments
 (0)