hexagon: switch to RAW_COPY_USER
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 28 Mar 2017 05:28:09 +0000 (01:28 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 25 Apr 2017 00:28:29 +0000 (20:28 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/hexagon/Kconfig
arch/hexagon/include/asm/uaccess.h
arch/hexagon/kernel/hexagon_ksyms.c
arch/hexagon/mm/copy_from_user.S
arch/hexagon/mm/copy_to_user.S

index 1941e4baaee63fdd360da51e6a8c607132addaaf..0c536a83ea711b52823fae71d07570fa082054f0 100644 (file)
@@ -26,6 +26,7 @@ config HEXAGON
        select GENERIC_CLOCKEVENTS_BROADCAST
        select MODULES_USE_ELF_RELA
        select GENERIC_CPU_DEVICES
+       select ARCH_HAS_RAW_COPY_USER
        ---help---
          Qualcomm Hexagon is a processor architecture designed for high
          performance and low power across a wide variety of applications.
index 3a7f818e5ef7eee020ff0216256b3662338a94e1..458b69886b3452fc66d3a33957285645db1c70e0 100644 (file)
  */
 
 /*  Assembly somewhat optimized copy routines  */
-unsigned long __copy_from_user_hexagon(void *to, const void __user *from,
+unsigned long raw_copy_from_user(void *to, const void __user *from,
                                     unsigned long n);
-unsigned long __copy_to_user_hexagon(void __user *to, const void *from,
+unsigned long raw_copy_to_user(void __user *to, const void *from,
                                   unsigned long n);
-
-#define __copy_from_user(to, from, n) __copy_from_user_hexagon(to, from, n)
-#define __copy_to_user(to, from, n) __copy_to_user_hexagon(to, from, n)
-
-/*
- * XXX todo: some additonal performance gain is possible by
- * implementing __copy_to/from_user_inatomic, which is much
- * like __copy_to/from_user, but performs slightly less checking.
- */
+#define INLINE_COPY_FROM_USER
+#define INLINE_COPY_TO_USER
 
 __kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count);
 #define __clear_user(a, s) __clear_user_hexagon((a), (s))
@@ -104,10 +97,14 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src,
                return -EFAULT;
 
        if (res > n) {
-               copy_from_user(dst, src, n);
+               long left = raw_copy_from_user(dst, src, n);
+               if (unlikely(left))
+                       memset(dst + (n - left), 0, left);
                return n;
        } else {
-               copy_from_user(dst, src, res);
+               long left = raw_copy_from_user(dst, src, res);
+               if (unlikely(left))
+                       memset(dst + (res - left), 0, left);
                return res-1;
        }
 }
index af9dec4c28eb2aca42c2931fb20e0cff88959c6f..00bcad9cbd8f61cecf2820e7fbf1ff95c6c72988 100644 (file)
@@ -25,8 +25,8 @@
 
 /* Additional functions */
 EXPORT_SYMBOL(__clear_user_hexagon);
-EXPORT_SYMBOL(__copy_from_user_hexagon);
-EXPORT_SYMBOL(__copy_to_user_hexagon);
+EXPORT_SYMBOL(raw_copy_from_user);
+EXPORT_SYMBOL(raw_copy_to_user);
 EXPORT_SYMBOL(__iounmap);
 EXPORT_SYMBOL(__strnlen_user);
 EXPORT_SYMBOL(__vmgetie);
index 7fc94f3e66425b8d3020e808420cda7b9b78ba58..7da066fbd16f6d0b1dc9612caac8efbbb974bf85 100644 (file)
@@ -44,7 +44,7 @@
 #define bytes r2
 #define loopcount r5
 
-#define FUNCNAME __copy_from_user_hexagon
+#define FUNCNAME raw_copy_from_user
 #include "copy_user_template.S"
 
        /* LOAD FAULTS from COPY_FROM_USER */
index 0cfbcc09d1d942d47aa594b90f773de80a971372..a7b7f8db21df6368950267bc864f8b0565b96207 100644 (file)
@@ -43,7 +43,7 @@
 #define bytes r2
 #define loopcount r5
 
-#define FUNCNAME __copy_to_user_hexagon
+#define FUNCNAME raw_copy_to_user
 #include "copy_user_template.S"
 
        /* STORE FAULTS from COPY_TO_USER */