Skip to content

Commit

Permalink
Merge tag 'asm-generic-nommu' of git://git.kernel.org/pub/scm/linux/k…
Browse files Browse the repository at this point in the history
…ernel/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>
  • Loading branch information
torvalds committed May 16, 2019
2 parents d396360 + 6edd1db commit 27ebbf9
Show file tree
Hide file tree
Showing 30 changed files with 64 additions and 117 deletions.
6 changes: 0 additions & 6 deletions arch/alpha/include/asm/segment.h

This file was deleted.

1 change: 0 additions & 1 deletion arch/alpha/kernel/smc37c669.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <asm/hwrpb.h>
#include <asm/io.h>
#include <asm/segment.h>

#if 0
# define DBG_DEVS(args) printk args
Expand Down
1 change: 0 additions & 1 deletion arch/alpha/kernel/smc37c93x.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <asm/hwrpb.h>
#include <asm/io.h>
#include <asm/segment.h>

#define SMC_DEBUG 0

Expand Down
1 change: 1 addition & 0 deletions arch/arc/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ extern long arc_strnlen_user_noinline(const char __user *src, long n);

#endif

#include <asm/segment.h>
#include <asm-generic/uaccess.h>

#endif
1 change: 0 additions & 1 deletion arch/arm/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ generic-y += msi.h
generic-y += parport.h
generic-y += preempt.h
generic-y += seccomp.h
generic-y += segment.h
generic-y += serial.h
generic-y += simd.h
generic-y += trace_clock.h
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ generic-y += mmiowb.h
generic-y += msi.h
generic-y += qrwlock.h
generic-y += qspinlock.h
generic-y += segment.h
generic-y += serial.h
generic-y += set_memory.h
generic-y += switch_to.h
Expand Down
1 change: 0 additions & 1 deletion arch/c6x/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ generic-y += pci.h
generic-y += percpu.h
generic-y += pgalloc.h
generic-y += preempt.h
generic-y += segment.h
generic-y += serial.h
generic-y += shmparam.h
generic-y += tlbflush.h
Expand Down
1 change: 1 addition & 0 deletions arch/h8300/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ config H8300
select HAVE_ARCH_KGDB
select HAVE_ARCH_HASH
select CPU_NO_EFFICIENT_FFS
select UACCESS_MEMCPY

config CPU_BIG_ENDIAN
def_bool y
Expand Down
1 change: 1 addition & 0 deletions arch/h8300/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ generic-y += timex.h
generic-y += tlbflush.h
generic-y += topology.h
generic-y += trace_clock.h
generic-y += uaccess.h
generic-y += unaligned.h
generic-y += vga.h
generic-y += word-at-a-time.h
Expand Down
55 changes: 0 additions & 55 deletions arch/h8300/include/asm/uaccess.h

This file was deleted.

1 change: 0 additions & 1 deletion arch/hexagon/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ generic-y += pci.h
generic-y += percpu.h
generic-y += preempt.h
generic-y += sections.h
generic-y += segment.h
generic-y += serial.h
generic-y += shmparam.h
generic-y += topology.h
Expand Down
1 change: 0 additions & 1 deletion arch/hexagon/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* User space memory access functions
*/
#include <linux/mm.h>
#include <asm/segment.h>
#include <asm/sections.h>

/*
Expand Down
6 changes: 0 additions & 6 deletions arch/ia64/include/asm/segment.h

This file was deleted.

1 change: 0 additions & 1 deletion arch/mips/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ generic-y += preempt.h
generic-y += qrwlock.h
generic-y += qspinlock.h
generic-y += sections.h
generic-y += segment.h
generic-y += trace_clock.h
generic-y += unaligned.h
generic-y += user.h
Expand Down
1 change: 0 additions & 1 deletion arch/nds32/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ generic-y += pci.h
generic-y += percpu.h
generic-y += preempt.h
generic-y += sections.h
generic-y += segment.h
generic-y += serial.h
generic-y += switch_to.h
generic-y += timex.h
Expand Down
1 change: 0 additions & 1 deletion arch/nios2/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ generic-y += pci.h
generic-y += percpu.h
generic-y += preempt.h
generic-y += sections.h
generic-y += segment.h
generic-y += serial.h
generic-y += spinlock.h
generic-y += topology.h
Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ generic-y += qspinlock.h
generic-y += qrwlock_types.h
generic-y += qrwlock.h
generic-y += sections.h
generic-y += segment.h
generic-y += shmparam.h
generic-y += switch_to.h
generic-y += topology.h
Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <linux/elf.h>

#include <asm/thread_info.h>
#include <asm/segment.h>
#include <asm/page.h>
#include <asm/pgtable.h>

Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <linux/device.h>

#include <asm/sections.h>
#include <asm/segment.h>
#include <asm/pgtable.h>
#include <asm/types.h>
#include <asm/setup.h>
Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <linux/kallsyms.h>
#include <linux/uaccess.h>

#include <asm/segment.h>
#include <asm/io.h>
#include <asm/pgtable.h>
#include <asm/unwinder.h>
Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <linux/blkdev.h> /* for initrd_* */
#include <linux/pagemap.h>

#include <asm/segment.h>
#include <asm/pgalloc.h>
#include <asm/pgtable.h>
#include <asm/dma.h>
Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/mm/tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <linux/mm.h>
#include <linux/init.h>

#include <asm/segment.h>
#include <asm/tlbflush.h>
#include <asm/pgtable.h>
#include <asm/mmu_context.h>
Expand Down
1 change: 0 additions & 1 deletion arch/parisc/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ generic-y += mmiowb.h
generic-y += percpu.h
generic-y += preempt.h
generic-y += seccomp.h
generic-y += segment.h
generic-y += trace_clock.h
generic-y += user.h
generic-y += vga.h
Expand Down
5 changes: 0 additions & 5 deletions arch/s390/include/asm/segment.h

This file was deleted.

1 change: 0 additions & 1 deletion arch/s390/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <linux/seccomp.h>
#include <linux/compat.h>
#include <trace/syscall.h>
#include <asm/segment.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
Expand Down
1 change: 0 additions & 1 deletion arch/unicore32/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ generic-y += parport.h
generic-y += percpu.h
generic-y += preempt.h
generic-y += sections.h
generic-y += segment.h
generic-y += serial.h
generic-y += shmparam.h
generic-y += syscalls.h
Expand Down
16 changes: 0 additions & 16 deletions arch/xtensa/include/asm/segment.h

This file was deleted.

9 changes: 0 additions & 9 deletions include/asm-generic/segment.h

This file was deleted.

58 changes: 57 additions & 1 deletion include/asm-generic/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,63 @@
*/
#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) })

Expand Down
4 changes: 4 additions & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ config ARCH_NO_SG_CHAIN
config ARCH_HAS_PMEM_API
bool

# use memcpy to implement user copies for nommu architectures
config UACCESS_MEMCPY
bool

config ARCH_HAS_UACCESS_FLUSHCACHE
bool

Expand Down

0 comments on commit 27ebbf9

Please sign in to comment.