diff options
| -rw-r--r-- | arch/h8300/Kconfig | 1 | ||||
| -rw-r--r-- | arch/h8300/include/asm/Kbuild | 1 | ||||
| -rw-r--r-- | arch/h8300/include/asm/uaccess.h | 55 | ||||
| -rw-r--r-- | include/asm-generic/uaccess.h | 48 | ||||
| -rw-r--r-- | lib/Kconfig | 4 |
5 files changed, 54 insertions, 55 deletions
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index c071da34e081..c24d36241503 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig | |||
| @@ -23,6 +23,7 @@ config H8300 | |||
| 23 | select HAVE_ARCH_KGDB | 23 | select HAVE_ARCH_KGDB |
| 24 | select HAVE_ARCH_HASH | 24 | select HAVE_ARCH_HASH |
| 25 | select CPU_NO_EFFICIENT_FFS | 25 | select CPU_NO_EFFICIENT_FFS |
| 26 | select UACCESS_MEMCPY | ||
| 26 | 27 | ||
| 27 | config CPU_BIG_ENDIAN | 28 | config CPU_BIG_ENDIAN |
| 28 | def_bool y | 29 | def_bool y |
diff --git a/arch/h8300/include/asm/Kbuild b/arch/h8300/include/asm/Kbuild index 3e7c8ecf151e..988533f02e4a 100644 --- a/arch/h8300/include/asm/Kbuild +++ b/arch/h8300/include/asm/Kbuild | |||
| @@ -46,6 +46,7 @@ generic-y += timex.h | |||
| 46 | generic-y += tlbflush.h | 46 | generic-y += tlbflush.h |
| 47 | generic-y += topology.h | 47 | generic-y += topology.h |
| 48 | generic-y += trace_clock.h | 48 | generic-y += trace_clock.h |
| 49 | generic-y += uaccess.h | ||
| 49 | generic-y += unaligned.h | 50 | generic-y += unaligned.h |
| 50 | generic-y += vga.h | 51 | generic-y += vga.h |
| 51 | generic-y += word-at-a-time.h | 52 | generic-y += word-at-a-time.h |
diff --git a/arch/h8300/include/asm/uaccess.h b/arch/h8300/include/asm/uaccess.h deleted file mode 100644 index bc8031949d07..000000000000 --- a/arch/h8300/include/asm/uaccess.h +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef _ASM_UACCESS_H | ||
| 3 | #define _ASM_UACCESS_H | ||
| 4 | |||
| 5 | #include <linux/string.h> | ||
| 6 | |||
| 7 | static inline __must_check unsigned long | ||
| 8 | raw_copy_from_user(void *to, const void __user * from, unsigned long n) | ||
| 9 | { | ||
| 10 | if (__builtin_constant_p(n)) { | ||
| 11 | switch(n) { | ||
| 12 | case 1: | ||
| 13 | *(u8 *)to = *(u8 __force *)from; | ||
| 14 | return 0; | ||
| 15 | case 2: | ||
| 16 | *(u16 *)to = *(u16 __force *)from; | ||
| 17 | return 0; | ||
| 18 | case 4: | ||
| 19 | *(u32 *)to = *(u32 __force *)from; | ||
| 20 | return 0; | ||
| 21 | } | ||
| 22 | } | ||
| 23 | |||
| 24 | memcpy(to, (const void __force *)from, n); | ||
| 25 | return 0; | ||
| 26 | } | ||
| 27 | |||
| 28 | static inline __must_check unsigned long | ||
| 29 | raw_copy_to_user(void __user *to, const void *from, unsigned long n) | ||
| 30 | { | ||
| 31 | if (__builtin_constant_p(n)) { | ||
| 32 | switch(n) { | ||
| 33 | case 1: | ||
| 34 | *(u8 __force *)to = *(u8 *)from; | ||
| 35 | return 0; | ||
| 36 | case 2: | ||
| 37 | *(u16 __force *)to = *(u16 *)from; | ||
| 38 | return 0; | ||
| 39 | case 4: | ||
| 40 | *(u32 __force *)to = *(u32 *)from; | ||
| 41 | return 0; | ||
| 42 | default: | ||
| 43 | break; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | memcpy((void __force *)to, from, n); | ||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | #define INLINE_COPY_FROM_USER | ||
| 51 | #define INLINE_COPY_TO_USER | ||
| 52 | |||
| 53 | #include <asm-generic/uaccess.h> | ||
| 54 | |||
| 55 | #endif | ||
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index aac336831204..3dcabfceb21e 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h | |||
| @@ -9,6 +9,54 @@ | |||
| 9 | */ | 9 | */ |
| 10 | #include <linux/string.h> | 10 | #include <linux/string.h> |
| 11 | 11 | ||
| 12 | #ifdef CONFIG_UACCESS_MEMCPY | ||
| 13 | static inline __must_check unsigned long | ||
| 14 | raw_copy_from_user(void *to, const void __user * from, unsigned long n) | ||
| 15 | { | ||
| 16 | if (__builtin_constant_p(n)) { | ||
| 17 | switch(n) { | ||
| 18 | case 1: | ||
| 19 | *(u8 *)to = *(u8 __force *)from; | ||
| 20 | return 0; | ||
| 21 | case 2: | ||
| 22 | *(u16 *)to = *(u16 __force *)from; | ||
| 23 | return 0; | ||
| 24 | case 4: | ||
| 25 | *(u32 *)to = *(u32 __force *)from; | ||
| 26 | return 0; | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | memcpy(to, (const void __force *)from, n); | ||
| 31 | return 0; | ||
| 32 | } | ||
| 33 | |||
| 34 | static inline __must_check unsigned long | ||
| 35 | raw_copy_to_user(void __user *to, const void *from, unsigned long n) | ||
| 36 | { | ||
| 37 | if (__builtin_constant_p(n)) { | ||
| 38 | switch(n) { | ||
| 39 | case 1: | ||
| 40 | *(u8 __force *)to = *(u8 *)from; | ||
| 41 | return 0; | ||
| 42 | case 2: | ||
| 43 | *(u16 __force *)to = *(u16 *)from; | ||
| 44 | return 0; | ||
| 45 | case 4: | ||
| 46 | *(u32 __force *)to = *(u32 *)from; | ||
| 47 | return 0; | ||
| 48 | default: | ||
| 49 | break; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | memcpy((void __force *)to, from, n); | ||
| 54 | return 0; | ||
| 55 | } | ||
| 56 | #define INLINE_COPY_FROM_USER | ||
| 57 | #define INLINE_COPY_TO_USER | ||
| 58 | #endif /* CONFIG_UACCESS_MEMCPY */ | ||
| 59 | |||
| 12 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) | 60 | #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) |
| 13 | 61 | ||
| 14 | #ifndef KERNEL_DS | 62 | #ifndef KERNEL_DS |
diff --git a/lib/Kconfig b/lib/Kconfig index a9e56539bd11..7a3f01ac45e8 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -591,6 +591,10 @@ config ARCH_NO_SG_CHAIN | |||
| 591 | config ARCH_HAS_PMEM_API | 591 | config ARCH_HAS_PMEM_API |
| 592 | bool | 592 | bool |
| 593 | 593 | ||
| 594 | # use memcpy to implement user copies for nommu architectures | ||
| 595 | config UACCESS_MEMCPY | ||
| 596 | bool | ||
| 597 | |||
| 594 | config ARCH_HAS_UACCESS_FLUSHCACHE | 598 | config ARCH_HAS_UACCESS_FLUSHCACHE |
| 595 | bool | 599 | bool |
| 596 | 600 | ||
