mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
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:
commit
27ebbf9d5b
@ -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
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include <asm/hwrpb.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/segment.h>
|
||||
|
||||
#if 0
|
||||
# define DBG_DEVS(args) printk args
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include <asm/hwrpb.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/segment.h>
|
||||
|
||||
#define SMC_DEBUG 0
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -24,7 +24,6 @@
|
||||
* User space memory access functions
|
||||
*/
|
||||
#include <linux/mm.h>
|
||||
#include <asm/segment.h>
|
||||
#include <asm/sections.h>
|
||||
|
||||
/*
|
||||
|
@ -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 */
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -1,5 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef _ASM_SEGMENT_H
|
||||
#define _ASM_SEGMENT_H
|
||||
|
||||
#endif
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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 */
|
@ -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 */
|
@ -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) })
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user