From 737d42f75e943fd884ad13acb6d3ee3aff3dcd30 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 23 Apr 2019 18:38:06 +0200 Subject: asm-generic: don't include from is an odd x86 legacy that we shouldn't force on other architectures. arc used it to bring in mm_context_t, but we can do that inside the arc code easily. Signed-off-by: Christoph Hellwig Signed-off-by: Arnd Bergmann --- include/asm-generic/uaccess.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index b3d2241e03f8..aac336831204 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -9,8 +9,6 @@ */ #include -#include - #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) #ifndef KERNEL_DS -- cgit v1.2.3 From c67fdc1f00cba9de86c30f5a01eff21d3ea66c8f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 23 Apr 2019 18:38:07 +0200 Subject: arch: mostly remove A few architectures use internally, but nothing in common code does. Remove all the empty or almost empty versions of it, including the asm-generic one. Signed-off-by: Christoph Hellwig Signed-off-by: Arnd Bergmann --- include/asm-generic/segment.h | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 include/asm-generic/segment.h (limited to 'include') diff --git a/include/asm-generic/segment.h b/include/asm-generic/segment.h deleted file mode 100644 index 5580eace622c..000000000000 --- a/include/asm-generic/segment.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __ASM_GENERIC_SEGMENT_H -#define __ASM_GENERIC_SEGMENT_H -/* - * Only here because we have some old header files that expect it... - * - * New architectures probably don't want to have their own version. - */ - -#endif /* __ASM_GENERIC_SEGMENT_H */ -- cgit v1.2.3 From bd79f94758c011bdffd8d4afcfb578d169cb5e93 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 23 Apr 2019 18:38:08 +0200 Subject: asm-generic: provide entirely generic nommu uaccess Move the code to implement uaccess using memcpy or direct loads and stores to asm-generic/uaccess.h and make it selectable kconfig option. Signed-off-by: Christoph Hellwig Signed-off-by: Arnd Bergmann --- include/asm-generic/uaccess.h | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'include') 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 @@ */ #include +#ifdef CONFIG_UACCESS_MEMCPY +static inline __must_check unsigned long +raw_copy_from_user(void *to, const void __user * from, unsigned long n) +{ + if (__builtin_constant_p(n)) { + switch(n) { + case 1: + *(u8 *)to = *(u8 __force *)from; + return 0; + case 2: + *(u16 *)to = *(u16 __force *)from; + return 0; + case 4: + *(u32 *)to = *(u32 __force *)from; + return 0; + } + } + + memcpy(to, (const void __force *)from, n); + return 0; +} + +static inline __must_check unsigned long +raw_copy_to_user(void __user *to, const void *from, unsigned long n) +{ + if (__builtin_constant_p(n)) { + switch(n) { + case 1: + *(u8 __force *)to = *(u8 *)from; + return 0; + case 2: + *(u16 __force *)to = *(u16 *)from; + return 0; + case 4: + *(u32 __force *)to = *(u32 *)from; + return 0; + default: + break; + } + } + + memcpy((void __force *)to, from, n); + return 0; +} +#define INLINE_COPY_FROM_USER +#define INLINE_COPY_TO_USER +#endif /* CONFIG_UACCESS_MEMCPY */ + #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) #ifndef KERNEL_DS -- cgit v1.2.3 From 6edd1dbace0e8529ed167e8a5f9da63c0cc763cc Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 23 Apr 2019 18:38:09 +0200 Subject: asm-generic: optimize generic uaccess for 8-byte loads and stores On 64-bit architectures we can also use the direct load/store trick for 8-byte values. Signed-off-by: Christoph Hellwig Signed-off-by: Arnd Bergmann --- include/asm-generic/uaccess.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index 3dcabfceb21e..e935318804f8 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -24,6 +24,11 @@ raw_copy_from_user(void *to, const void __user * from, unsigned long n) case 4: *(u32 *)to = *(u32 __force *)from; return 0; +#ifdef CONFIG_64BIT + case 8: + *(u64 *)to = *(u64 __force *)from; + return 0; +#endif } } @@ -45,6 +50,11 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n) case 4: *(u32 __force *)to = *(u32 *)from; return 0; +#ifdef CONFIG_64BIT + case 8: + *(u64 __force *)to = *(u64 *)from; + return 0; +#endif default: break; } -- cgit v1.2.3