Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'asm-generic-nommu' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic

Pull nommu generic uaccess updates from Arnd Bergmann:
"asm-generic: kill <asm/segment.h> and improve nommu generic uaccess helpers

Christoph Hellwig writes:

This is a series doing two somewhat interwinded things. It improves
the asm-generic nommu uaccess helper to optionally be entirely
generic and not require any arch helpers for the actual uaccess.
For the generic uaccess.h to actually be generically useful I also
had to kill off the mess we made of <asm/segment.h>, which really
shouldn't exist on most architectures"

* tag 'asm-generic-nommu' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
asm-generic: optimize generic uaccess for 8-byte loads and stores
asm-generic: provide entirely generic nommu uaccess
arch: mostly remove <asm/segment.h>
asm-generic: don't include <asm/segment.h> from <asm/uaccess.h>

+64 -117
-6
arch/alpha/include/asm/segment.h
··· 1 - #ifndef __ALPHA_SEGMENT_H 2 - #define __ALPHA_SEGMENT_H 3 - 4 - /* Only here because we have some old header files that expect it.. */ 5 - 6 - #endif
-1
arch/alpha/kernel/smc37c669.c
··· 10 10 11 11 #include <asm/hwrpb.h> 12 12 #include <asm/io.h> 13 - #include <asm/segment.h> 14 13 15 14 #if 0 16 15 # define DBG_DEVS(args) printk args
-1
arch/alpha/kernel/smc37c93x.c
··· 11 11 12 12 #include <asm/hwrpb.h> 13 13 #include <asm/io.h> 14 - #include <asm/segment.h> 15 14 16 15 #define SMC_DEBUG 0 17 16
+1
arch/arc/include/asm/uaccess.h
··· 742 742 743 743 #endif 744 744 745 + #include <asm/segment.h> 745 746 #include <asm-generic/uaccess.h> 746 747 747 748 #endif
-1
arch/arm/include/asm/Kbuild
··· 14 14 generic-y += parport.h 15 15 generic-y += preempt.h 16 16 generic-y += seccomp.h 17 - generic-y += segment.h 18 17 generic-y += serial.h 19 18 generic-y += simd.h 20 19 generic-y += trace_clock.h
-1
arch/arm64/include/asm/Kbuild
··· 17 17 generic-y += msi.h 18 18 generic-y += qrwlock.h 19 19 generic-y += qspinlock.h 20 - generic-y += segment.h 21 20 generic-y += serial.h 22 21 generic-y += set_memory.h 23 22 generic-y += switch_to.h
-1
arch/c6x/include/asm/Kbuild
··· 30 30 generic-y += percpu.h 31 31 generic-y += pgalloc.h 32 32 generic-y += preempt.h 33 - generic-y += segment.h 34 33 generic-y += serial.h 35 34 generic-y += shmparam.h 36 35 generic-y += tlbflush.h
+1
arch/h8300/Kconfig
··· 23 23 select HAVE_ARCH_KGDB 24 24 select HAVE_ARCH_HASH 25 25 select CPU_NO_EFFICIENT_FFS 26 + select UACCESS_MEMCPY 26 27 27 28 config CPU_BIG_ENDIAN 28 29 def_bool y
+1
arch/h8300/include/asm/Kbuild
··· 47 47 generic-y += tlbflush.h 48 48 generic-y += topology.h 49 49 generic-y += trace_clock.h 50 + generic-y += uaccess.h 50 51 generic-y += unaligned.h 51 52 generic-y += vga.h 52 53 generic-y += word-at-a-time.h
-55
arch/h8300/include/asm/uaccess.h
··· 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
-1
arch/hexagon/include/asm/Kbuild
··· 29 29 generic-y += percpu.h 30 30 generic-y += preempt.h 31 31 generic-y += sections.h 32 - generic-y += segment.h 33 32 generic-y += serial.h 34 33 generic-y += shmparam.h 35 34 generic-y += topology.h
-1
arch/hexagon/include/asm/uaccess.h
··· 24 24 * User space memory access functions 25 25 */ 26 26 #include <linux/mm.h> 27 - #include <asm/segment.h> 28 27 #include <asm/sections.h> 29 28 30 29 /*
-6
arch/ia64/include/asm/segment.h
··· 1 - #ifndef _ASM_IA64_SEGMENT_H 2 - #define _ASM_IA64_SEGMENT_H 3 - 4 - /* Only here because we have some old header files that expect it.. */ 5 - 6 - #endif /* _ASM_IA64_SEGMENT_H */
-1
arch/mips/include/asm/Kbuild
··· 19 19 generic-y += qrwlock.h 20 20 generic-y += qspinlock.h 21 21 generic-y += sections.h 22 - generic-y += segment.h 23 22 generic-y += trace_clock.h 24 23 generic-y += unaligned.h 25 24 generic-y += user.h
-1
arch/nds32/include/asm/Kbuild
··· 37 37 generic-y += percpu.h 38 38 generic-y += preempt.h 39 39 generic-y += sections.h 40 - generic-y += segment.h 41 40 generic-y += serial.h 42 41 generic-y += switch_to.h 43 42 generic-y += timex.h
-1
arch/nios2/include/asm/Kbuild
··· 33 33 generic-y += percpu.h 34 34 generic-y += preempt.h 35 35 generic-y += sections.h 36 - generic-y += segment.h 37 36 generic-y += serial.h 38 37 generic-y += spinlock.h 39 38 generic-y += topology.h
-1
arch/openrisc/include/asm/Kbuild
··· 34 34 generic-y += qrwlock_types.h 35 35 generic-y += qrwlock.h 36 36 generic-y += sections.h 37 - generic-y += segment.h 38 37 generic-y += shmparam.h 39 38 generic-y += switch_to.h 40 39 generic-y += topology.h
-1
arch/openrisc/kernel/ptrace.c
··· 30 30 #include <linux/elf.h> 31 31 32 32 #include <asm/thread_info.h> 33 - #include <asm/segment.h> 34 33 #include <asm/page.h> 35 34 #include <asm/pgtable.h> 36 35
-1
arch/openrisc/kernel/setup.c
··· 39 39 #include <linux/device.h> 40 40 41 41 #include <asm/sections.h> 42 - #include <asm/segment.h> 43 42 #include <asm/pgtable.h> 44 43 #include <asm/types.h> 45 44 #include <asm/setup.h>
-1
arch/openrisc/kernel/traps.c
··· 35 35 #include <linux/kallsyms.h> 36 36 #include <linux/uaccess.h> 37 37 38 - #include <asm/segment.h> 39 38 #include <asm/io.h> 40 39 #include <asm/pgtable.h> 41 40 #include <asm/unwinder.h>
-1
arch/openrisc/mm/init.c
··· 32 32 #include <linux/blkdev.h> /* for initrd_* */ 33 33 #include <linux/pagemap.h> 34 34 35 - #include <asm/segment.h> 36 35 #include <asm/pgalloc.h> 37 36 #include <asm/pgtable.h> 38 37 #include <asm/dma.h>
-1
arch/openrisc/mm/tlb.c
··· 26 26 #include <linux/mm.h> 27 27 #include <linux/init.h> 28 28 29 - #include <asm/segment.h> 30 29 #include <asm/tlbflush.h> 31 30 #include <asm/pgtable.h> 32 31 #include <asm/mmu_context.h>
-1
arch/parisc/include/asm/Kbuild
··· 19 19 generic-y += percpu.h 20 20 generic-y += preempt.h 21 21 generic-y += seccomp.h 22 - generic-y += segment.h 23 22 generic-y += trace_clock.h 24 23 generic-y += user.h 25 24 generic-y += vga.h
-5
arch/s390/include/asm/segment.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASM_SEGMENT_H 3 - #define _ASM_SEGMENT_H 4 - 5 - #endif
-1
arch/s390/kernel/ptrace.c
··· 24 24 #include <linux/seccomp.h> 25 25 #include <linux/compat.h> 26 26 #include <trace/syscall.h> 27 - #include <asm/segment.h> 28 27 #include <asm/page.h> 29 28 #include <asm/pgtable.h> 30 29 #include <asm/pgalloc.h>
-1
arch/unicore32/include/asm/Kbuild
··· 28 28 generic-y += percpu.h 29 29 generic-y += preempt.h 30 30 generic-y += sections.h 31 - generic-y += segment.h 32 31 generic-y += serial.h 33 32 generic-y += shmparam.h 34 33 generic-y += syscalls.h
-16
arch/xtensa/include/asm/segment.h
··· 1 - /* 2 - * include/asm-xtensa/segment.h 3 - * 4 - * This file is subject to the terms and conditions of the GNU General Public 5 - * License. See the file "COPYING" in the main directory of this archive 6 - * for more details. 7 - * 8 - * Copyright (C) 2001 - 2005 Tensilica Inc. 9 - */ 10 - 11 - #ifndef _XTENSA_SEGMENT_H 12 - #define _XTENSA_SEGMENT_H 13 - 14 - #include <linux/uaccess.h> 15 - 16 - #endif /* _XTENSA_SEGEMENT_H */
-9
include/asm-generic/segment.h
··· 1 - #ifndef __ASM_GENERIC_SEGMENT_H 2 - #define __ASM_GENERIC_SEGMENT_H 3 - /* 4 - * Only here because we have some old header files that expect it... 5 - * 6 - * New architectures probably don't want to have their own version. 7 - */ 8 - 9 - #endif /* __ASM_GENERIC_SEGMENT_H */
+57 -1
include/asm-generic/uaccess.h
··· 9 9 */ 10 10 #include <linux/string.h> 11 11 12 - #include <asm/segment.h> 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 + #ifdef CONFIG_64BIT 28 + case 8: 29 + *(u64 *)to = *(u64 __force *)from; 30 + return 0; 31 + #endif 32 + } 33 + } 34 + 35 + memcpy(to, (const void __force *)from, n); 36 + return 0; 37 + } 38 + 39 + static inline __must_check unsigned long 40 + raw_copy_to_user(void __user *to, const void *from, unsigned long n) 41 + { 42 + if (__builtin_constant_p(n)) { 43 + switch(n) { 44 + case 1: 45 + *(u8 __force *)to = *(u8 *)from; 46 + return 0; 47 + case 2: 48 + *(u16 __force *)to = *(u16 *)from; 49 + return 0; 50 + case 4: 51 + *(u32 __force *)to = *(u32 *)from; 52 + return 0; 53 + #ifdef CONFIG_64BIT 54 + case 8: 55 + *(u64 __force *)to = *(u64 *)from; 56 + return 0; 57 + #endif 58 + default: 59 + break; 60 + } 61 + } 62 + 63 + memcpy((void __force *)to, from, n); 64 + return 0; 65 + } 66 + #define INLINE_COPY_FROM_USER 67 + #define INLINE_COPY_TO_USER 68 + #endif /* CONFIG_UACCESS_MEMCPY */ 13 69 14 70 #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 15 71
+4
lib/Kconfig
··· 601 601 config ARCH_HAS_PMEM_API 602 602 bool 603 603 604 + # use memcpy to implement user copies for nommu architectures 605 + config UACCESS_MEMCPY 606 + bool 607 + 604 608 config ARCH_HAS_UACCESS_FLUSHCACHE 605 609 bool 606 610