[RFC PATCH 2/3] arc: provide __{get,put}_kernel_nofault

Sergey Matyukevich geomatsi at gmail.com
Tue Feb 1 06:55:37 PST 2022


From: Sergey Matyukevich <sergey.matyukevich at synopsys.com>

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

Signed-off-by: Sergey Matyukevich <sergey.matyukevich at synopsys.com>
---
 arch/arc/include/asm/uaccess.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
index 9d1205bf90f1..c14b692a0a4e 100644
--- a/arch/arc/include/asm/uaccess.h
+++ b/arch/arc/include/asm/uaccess.h
@@ -657,6 +657,28 @@ static inline unsigned long __arc_clear_user(void __user *to, unsigned long n)
 	return res;
 }
 
+#define HAVE_GET_KERNEL_NOFAULT
+
+#define __get_kernel_nofault(dst, src, type, err_label)			\
+	do {								\
+		long __err;						\
+									\
+		__err = __get_user_fn(sizeof(type), (type *)(src),	\
+				      (type *)(dst));			\
+		if (unlikely(__err))					\
+			goto err_label;					\
+	} while (0)
+
+#define __put_kernel_nofault(dst, src, type, err_label)			\
+	do {								\
+		long __err;						\
+									\
+		__err = __put_user_fn(sizeof(type), (type *)(dst),	\
+				      (type *)(src));			\
+		if (unlikely(__err))					\
+			goto err_label;					\
+	} while (0)
+
 #ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
 
 #define INLINE_COPY_TO_USER
-- 
2.35.0




More information about the linux-snps-arc mailing list