[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200907055825.1917151-4-hch@lst.de>
Date: Mon, 7 Sep 2020 07:58:20 +0200
From: Christoph Hellwig <hch@....de>
To: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Arnd Bergmann <arnd@...db.de>,
Alexander Viro <viro@...iv.linux.org.uk>
Cc: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-arch@...r.kernel.org
Subject: [PATCH 3/8] 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@....de>
---
include/asm-generic/uaccess.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 6de5f524e9e631..b367f339be1a90 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -61,6 +61,22 @@ static inline int __put_user_fn(size_t size, void __user *to, void *from)
}
#define __put_user_fn(sz, u, k) __put_user_fn(sz, u, k)
+#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
+
static inline __must_check unsigned long
raw_copy_from_user(void *to, const void __user * from, unsigned long n)
{
--
2.28.0
Powered by blists - more mailing lists