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.
 
 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJcv22JAAoJEGCrR//JCVInH3YP/i7hVIEo4azoRB3/PwFTPel8
 Buq9BUrGy1kptLWyi1yuOZf874gF6351hkVUo4EYq/uZ3x41ciojxFgbsIriAU0p
 2xzJAWY0YaVuWM+PIVj6KjyDA0N7/U5PcAG+03pl1Lhf0GHldmMbQIWt8D8HXbB8
 gyaOeBGM9BneKd8Xu0COUaId9/3GXUwsy2zYc77+PxaHHYJzGDPB5lqNdU0gbB54
 P9uXI2mpoAepFMsFgP6/FBvT/jCiMifRIdTXPD94NtjfG+Q4lo+LBQ6bpcLfw4ZD
 VNh0982Cyl5n7FNetlTK4CPBn0RZsmBRriMotYfXeghFg0mmNTLwNEMg1u6RQ+uq
 VYoBrVGhnx4SFB8xdkqO4md6UwprR2SERIIKwuCTbhwSgs+NkB7t4ftOwTzyQ1/6
 7WQjclAIxQK9J7uwAeRGCvyrNJplqSfOA/hRjuq/Z0BCE/+m26Gxfv4aDztU5wFO
 FWj2uFGTMuufp+DKoh5Vj5aJiFwfqK5/w1VYWSQdaoiWsHlmmu5IkTrrZyz+S3Tj
 cifO9Ghe75Pt+rDllc8yqzKYXa5mL89sWyKiy+2ItOvGVh5EqXBbPXtCrFFIHRFL
 WojVPu0yO+OoP0sEdamT/4FxbWO9VrV5YXdaRg/GjVA9ARlKNpFrZbuHtvEitwpi
 7AbhxMZwBSSb9R3cz67J
 =X2CH
 -----END PGP SIGNATURE-----

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>
This commit is contained in:
Linus Torvalds 2019-05-16 11:26:37 -07:00
commit 27ebbf9d5b
30 changed files with 64 additions and 117 deletions

View File

@ -1,6 +0,0 @@
#ifndef __ALPHA_SEGMENT_H
#define __ALPHA_SEGMENT_H
/* Only here because we have some old header files that expect it.. */
#endif

View File

@ -10,7 +10,6 @@
#include <asm/hwrpb.h> #include <asm/hwrpb.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/segment.h>
#if 0 #if 0
# define DBG_DEVS(args) printk args # define DBG_DEVS(args) printk args

View File

@ -11,7 +11,6 @@
#include <asm/hwrpb.h> #include <asm/hwrpb.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/segment.h>
#define SMC_DEBUG 0 #define SMC_DEBUG 0

View File

@ -742,6 +742,7 @@ extern long arc_strnlen_user_noinline(const char __user *src, long n);
#endif #endif
#include <asm/segment.h>
#include <asm-generic/uaccess.h> #include <asm-generic/uaccess.h>
#endif #endif

View File

@ -14,7 +14,6 @@ generic-y += msi.h
generic-y += parport.h generic-y += parport.h
generic-y += preempt.h generic-y += preempt.h
generic-y += seccomp.h generic-y += seccomp.h
generic-y += segment.h
generic-y += serial.h generic-y += serial.h
generic-y += simd.h generic-y += simd.h
generic-y += trace_clock.h generic-y += trace_clock.h

View File

@ -17,7 +17,6 @@ generic-y += mmiowb.h
generic-y += msi.h generic-y += msi.h
generic-y += qrwlock.h generic-y += qrwlock.h
generic-y += qspinlock.h generic-y += qspinlock.h
generic-y += segment.h
generic-y += serial.h generic-y += serial.h
generic-y += set_memory.h generic-y += set_memory.h
generic-y += switch_to.h generic-y += switch_to.h

View File

@ -30,7 +30,6 @@ generic-y += pci.h
generic-y += percpu.h generic-y += percpu.h
generic-y += pgalloc.h generic-y += pgalloc.h
generic-y += preempt.h generic-y += preempt.h
generic-y += segment.h
generic-y += serial.h generic-y += serial.h
generic-y += shmparam.h generic-y += shmparam.h
generic-y += tlbflush.h generic-y += tlbflush.h

View File

@ -23,6 +23,7 @@ config H8300
select HAVE_ARCH_KGDB select HAVE_ARCH_KGDB
select HAVE_ARCH_HASH select HAVE_ARCH_HASH
select CPU_NO_EFFICIENT_FFS select CPU_NO_EFFICIENT_FFS
select UACCESS_MEMCPY
config CPU_BIG_ENDIAN config CPU_BIG_ENDIAN
def_bool y def_bool y

View File

@ -47,6 +47,7 @@ generic-y += timex.h
generic-y += tlbflush.h generic-y += tlbflush.h
generic-y += topology.h generic-y += topology.h
generic-y += trace_clock.h generic-y += trace_clock.h
generic-y += uaccess.h
generic-y += unaligned.h generic-y += unaligned.h
generic-y += vga.h generic-y += vga.h
generic-y += word-at-a-time.h generic-y += word-at-a-time.h

View File

@ -1,55 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_UACCESS_H
#define _ASM_UACCESS_H
#include <linux/string.h>
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
#include <asm-generic/uaccess.h>
#endif

View File

@ -29,7 +29,6 @@ generic-y += pci.h
generic-y += percpu.h generic-y += percpu.h
generic-y += preempt.h generic-y += preempt.h
generic-y += sections.h generic-y += sections.h
generic-y += segment.h
generic-y += serial.h generic-y += serial.h
generic-y += shmparam.h generic-y += shmparam.h
generic-y += topology.h generic-y += topology.h

View File

@ -24,7 +24,6 @@
* User space memory access functions * User space memory access functions
*/ */
#include <linux/mm.h> #include <linux/mm.h>
#include <asm/segment.h>
#include <asm/sections.h> #include <asm/sections.h>
/* /*

View File

@ -1,6 +0,0 @@
#ifndef _ASM_IA64_SEGMENT_H
#define _ASM_IA64_SEGMENT_H
/* Only here because we have some old header files that expect it.. */
#endif /* _ASM_IA64_SEGMENT_H */

View File

@ -19,7 +19,6 @@ generic-y += preempt.h
generic-y += qrwlock.h generic-y += qrwlock.h
generic-y += qspinlock.h generic-y += qspinlock.h
generic-y += sections.h generic-y += sections.h
generic-y += segment.h
generic-y += trace_clock.h generic-y += trace_clock.h
generic-y += unaligned.h generic-y += unaligned.h
generic-y += user.h generic-y += user.h

View File

@ -37,7 +37,6 @@ generic-y += pci.h
generic-y += percpu.h generic-y += percpu.h
generic-y += preempt.h generic-y += preempt.h
generic-y += sections.h generic-y += sections.h
generic-y += segment.h
generic-y += serial.h generic-y += serial.h
generic-y += switch_to.h generic-y += switch_to.h
generic-y += timex.h generic-y += timex.h

View File

@ -33,7 +33,6 @@ generic-y += pci.h
generic-y += percpu.h generic-y += percpu.h
generic-y += preempt.h generic-y += preempt.h
generic-y += sections.h generic-y += sections.h
generic-y += segment.h
generic-y += serial.h generic-y += serial.h
generic-y += spinlock.h generic-y += spinlock.h
generic-y += topology.h generic-y += topology.h

View File

@ -34,7 +34,6 @@ generic-y += qspinlock.h
generic-y += qrwlock_types.h generic-y += qrwlock_types.h
generic-y += qrwlock.h generic-y += qrwlock.h
generic-y += sections.h generic-y += sections.h
generic-y += segment.h
generic-y += shmparam.h generic-y += shmparam.h
generic-y += switch_to.h generic-y += switch_to.h
generic-y += topology.h generic-y += topology.h

View File

@ -30,7 +30,6 @@
#include <linux/elf.h> #include <linux/elf.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/segment.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>

View File

@ -39,7 +39,6 @@
#include <linux/device.h> #include <linux/device.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/segment.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/types.h> #include <asm/types.h>
#include <asm/setup.h> #include <asm/setup.h>

View File

@ -35,7 +35,6 @@
#include <linux/kallsyms.h> #include <linux/kallsyms.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/segment.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/unwinder.h> #include <asm/unwinder.h>

View File

@ -32,7 +32,6 @@
#include <linux/blkdev.h> /* for initrd_* */ #include <linux/blkdev.h> /* for initrd_* */
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <asm/segment.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/dma.h> #include <asm/dma.h>

View File

@ -26,7 +26,6 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/segment.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>

View File

@ -19,7 +19,6 @@ generic-y += mmiowb.h
generic-y += percpu.h generic-y += percpu.h
generic-y += preempt.h generic-y += preempt.h
generic-y += seccomp.h generic-y += seccomp.h
generic-y += segment.h
generic-y += trace_clock.h generic-y += trace_clock.h
generic-y += user.h generic-y += user.h
generic-y += vga.h generic-y += vga.h

View File

@ -1,5 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_SEGMENT_H
#define _ASM_SEGMENT_H
#endif

View File

@ -24,7 +24,6 @@
#include <linux/seccomp.h> #include <linux/seccomp.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <trace/syscall.h> #include <trace/syscall.h>
#include <asm/segment.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>

View File

@ -28,7 +28,6 @@ generic-y += parport.h
generic-y += percpu.h generic-y += percpu.h
generic-y += preempt.h generic-y += preempt.h
generic-y += sections.h generic-y += sections.h
generic-y += segment.h
generic-y += serial.h generic-y += serial.h
generic-y += shmparam.h generic-y += shmparam.h
generic-y += syscalls.h generic-y += syscalls.h

View File

@ -1,16 +0,0 @@
/*
* include/asm-xtensa/segment.h
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 2001 - 2005 Tensilica Inc.
*/
#ifndef _XTENSA_SEGMENT_H
#define _XTENSA_SEGMENT_H
#include <linux/uaccess.h>
#endif /* _XTENSA_SEGEMENT_H */

View File

@ -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 */

View File

@ -9,7 +9,63 @@
*/ */
#include <linux/string.h> #include <linux/string.h>
#include <asm/segment.h> #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;
#ifdef CONFIG_64BIT
case 8:
*(u64 *)to = *(u64 __force *)from;
return 0;
#endif
}
}
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;
#ifdef CONFIG_64BIT
case 8:
*(u64 __force *)to = *(u64 *)from;
return 0;
#endif
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) }) #define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })

View File

@ -601,6 +601,10 @@ config ARCH_NO_SG_CHAIN
config ARCH_HAS_PMEM_API config ARCH_HAS_PMEM_API
bool bool
# use memcpy to implement user copies for nommu architectures
config UACCESS_MEMCPY
bool
config ARCH_HAS_UACCESS_FLUSHCACHE config ARCH_HAS_UACCESS_FLUSHCACHE
bool bool