Nommu architectures do not have page tables and thus no page faults.
Implement the maccess helpers using get_unaligned and put_unaligned and
enable them unconditionally for !CONFIG_MMU.

Signed-off-by: Christoph Hellwig <[email protected]>
---
 include/asm-generic/uaccess.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index ba68ee4dabfaa7..cc3b2c8b68fab4 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -9,6 +9,26 @@
  */
 #include <linux/string.h>
 
+#ifndef CONFIG_MMU
+#include <asm/unaligned.h>
+
+#define __get_kernel_nofault(dst, src, type, err_label)                        
\
+do {                                                                   \
+       *((type *)dst) = get_unaligned((type *)(src));                  \
+       if (0) /* make sure the label looks used to the compiler */     \
+               goto err_label;                                         \
+} while (0)
+
+#define __put_kernel_nofault(dst, src, type, err_label)                        
\
+do {                                                                   \
+       put_unaligned(*((type *)src), (type *)(dst));                   \
+       if (0) /* make sure the label looks used to the compiler */     \
+               goto err_label;                                         \
+} while (0)
+
+#define HAVE_GET_KERNEL_NOFAULT 1
+#endif /* !CONFIG_MMU */
+
 #ifdef CONFIG_UACCESS_MEMCPY
 static inline __must_check unsigned long
 raw_copy_from_user(void *to, const void __user * from, unsigned long n)
-- 
2.28.0

Reply via email to