more non-ABI asm-generic headers
Subsystems (20)
Arnd Bergmann
maintainercover more non-ABI asm-generic headers
Here are the remaining asm-generic headers I prepared, along with patches converting microblaze to use them, as an example.
The patches apply on top of my ABI related patches I posted earlier this week. If people agree with the concept and I have addressed all major concerns, I would like to get them into linux-next and hopefully merged in 2.6.31.
To avoid trouble with quilt mail, I'm now trying git-format-patch to generate them, hopefully this works a little better. Can anyone tell me why I can't add a 'To' header rather than just 'Cc' in git-format-patch?
Arnd <><
---
Arnd Bergmann (21):
asm-generic: rename atomic.h to atomic-long.h
asm-generic: add generic atomic.h
asm-generic: make pci.h usable directly
asm-generic: add legacy I/O header files
asm-generic: add generic io.h
asm-generic: add minimal cache description
asm-generic: add generic versions of common headers
asm-generic: add generic NOMMU versions of some headers
asm-generic: rename page.h to getorder.h
asm-generic: add generic page.h
asm-generic: add a NOMMU uaccess.h
asm-generic: make uaccess.h usable by mmu archs
asm-generic: make bitops.h usable
asm-generic: Add missing generic tlb_flush definition
asm-generic: introduce generic syscalls.h
add generic lib/checksum.c
microblaze: use generic syscalls.h
microblaze: make syscall_table implementation generic
microblaze: use generic swab.h
microblaze: don't include asm/mmu.h in hw_exception_handler
microblaze: use generic dma-mapping.h
Remis Lima Baima (6):
asm-generic: clean up asm-generic/io.h
microblaze: use the generic lib/checksum.c
microblaze: convert all simple headers to use asm-generic
microblaze: use generic uaccess.h
microblaze: make io.h use asm-generic/io.h
microblaze: use generic system.h
arch/alpha/include/asm/atomic.h | 2 +-
arch/alpha/include/asm/page.h | 2 +-
arch/arm/include/asm/atomic.h | 2 +-
arch/arm/include/asm/page.h | 2 +-
arch/avr32/include/asm/atomic.h | 2 +-
arch/blackfin/include/asm/atomic.h | 2 +-
arch/blackfin/include/asm/page.h | 2 +-
arch/cris/include/asm/atomic.h | 2 +-
arch/cris/include/asm/page.h | 2 +-
arch/frv/include/asm/atomic.h | 2 +-
arch/frv/include/asm/page.h | 2 +-
arch/frv/include/asm/pci.h | 13 +-
arch/h8300/include/asm/atomic.h | 2 +-
arch/h8300/include/asm/page.h | 2 +-
arch/ia64/include/asm/atomic.h | 2 +-
arch/m32r/include/asm/atomic.h | 2 +-
arch/m32r/include/asm/page.h | 2 +-
arch/m32r/include/asm/pci.h | 2 -
arch/m68k/include/asm/atomic_mm.h | 2 +-
arch/m68k/include/asm/atomic_no.h | 2 +-
arch/m68k/include/asm/page_mm.h | 2 +-
arch/m68k/include/asm/page_no.h | 2 +-
arch/microblaze/Kconfig | 8 +-
arch/microblaze/include/asm/atomic.h | 124 +------
arch/microblaze/include/asm/bitops.h | 28 +--
arch/microblaze/include/asm/bug.h | 14 -
arch/microblaze/include/asm/bugs.h | 18 +-
arch/microblaze/include/asm/checksum.h | 132 ++-----
arch/microblaze/include/asm/cmpxchg-local.h | 1 +
arch/microblaze/include/asm/dma-mapping.h | 130 +------
arch/microblaze/include/asm/hardirq.h | 14 +-
arch/microblaze/include/asm/io.h | 240 ++----------
arch/microblaze/include/asm/irq.h | 6 +-
arch/microblaze/include/asm/irqflags.h | 2 +-
arch/microblaze/include/asm/kmap_types.h | 30 +--
arch/microblaze/include/asm/mmu.h | 20 +-
arch/microblaze/include/asm/mmu_context.h | 22 +-
arch/microblaze/include/asm/module.h | 10 +-
arch/microblaze/include/asm/page.h | 2 +-
arch/microblaze/include/asm/pgalloc.h | 15 +-
arch/microblaze/include/asm/scatterlist.h | 29 +--
arch/microblaze/include/asm/serial.h | 15 +-
arch/microblaze/include/asm/shmparam.h | 7 +-
arch/microblaze/include/asm/swab.h | 9 +-
arch/microblaze/include/asm/syscalls.h | 48 +--
arch/microblaze/include/asm/system.h | 121 ++-----
arch/microblaze/include/asm/timex.h | 19 +-
arch/microblaze/include/asm/uaccess.h | 164 ++------
arch/microblaze/kernel/Makefile | 2 +-
arch/microblaze/kernel/hw_exception_handler.S | 1 -
arch/microblaze/kernel/sys_microblaze.c | 12 +-
arch/microblaze/lib/Makefile | 2 +-
arch/microblaze/lib/uaccess.c | 42 +--
arch/mips/include/asm/atomic.h | 2 +-
arch/mips/include/asm/page.h | 2 +-
arch/mn10300/include/asm/atomic.h | 2 +-
arch/parisc/include/asm/atomic.h | 2 +-
arch/parisc/include/asm/page.h | 2 +-
arch/parisc/include/asm/uaccess.h | 2 +-
arch/powerpc/include/asm/atomic.h | 2 +-
arch/powerpc/include/asm/page_32.h | 2 +-
arch/powerpc/include/asm/page_64.h | 2 +-
arch/s390/include/asm/atomic.h | 2 +-
arch/s390/include/asm/page.h | 2 +-
arch/sh/include/asm/atomic.h | 2 +-
arch/sh/include/asm/page.h | 2 +-
arch/sparc/include/asm/atomic_32.h | 2 +-
arch/sparc/include/asm/atomic_64.h | 2 +-
arch/sparc/include/asm/page_32.h | 2 +-
arch/sparc/include/asm/page_64.h | 2 +-
arch/sparc/include/asm/uaccess_64.h | 2 +-
arch/um/include/asm/page.h | 2 +-
arch/x86/include/asm/atomic_32.h | 2 +-
arch/x86/include/asm/atomic_64.h | 2 +-
arch/x86/include/asm/page.h | 2 +-
arch/xtensa/include/asm/atomic.h | 2 +-
arch/xtensa/include/asm/page.h | 2 +-
include/asm-generic/{atomic.h => atomic-long.h} | 6 +-
include/asm-generic/atomic.h | 423 ++++++++------------
include/asm-generic/bitops.h | 24 +-
include/asm-generic/bitops/atomic.h | 1 +
include/asm-generic/bugs.h | 10 +
include/asm-generic/cache.h | 12 +
include/asm-generic/cacheflush.h | 30 ++
.../include/asm => include/asm-generic}/checksum.h | 65 +--
include/asm-generic/current.h | 9 +
include/asm-generic/delay.h | 9 +
include/asm-generic/dma.h | 15 +
include/asm-generic/fb.h | 12 +
include/asm-generic/{page.h => getorder.h} | 8 +-
include/asm-generic/hardirq.h | 34 ++
include/asm-generic/hw_irq.h | 9 +
include/asm-generic/io.h | 300 ++++++++++++++
include/asm-generic/irq.h | 18 +
include/asm-generic/irqflags.h | 72 ++++
include/asm-generic/kmap_types.h | 29 ++
include/asm-generic/linkage.h | 8 +
include/asm-generic/mmu.h | 14 +
include/asm-generic/mmu_context.h | 45 ++
include/asm-generic/module.h | 22 +
include/asm-generic/mutex.h | 9 +
include/asm-generic/page.h | 123 +++++--
include/asm-generic/pci.h | 8 +
include/asm-generic/pgalloc.h | 12 +
include/asm-generic/scatterlist.h | 43 ++
include/asm-generic/segment.h | 9 +
include/asm-generic/serial.h | 13 +
include/asm-generic/spinlock.h | 11 +
include/asm-generic/string.h | 10 +
include/asm-generic/syscalls.h | 60 +++
include/asm-generic/system.h | 161 ++++++++
include/asm-generic/timex.h | 29 ++
include/asm-generic/tlb.h | 4 +
include/asm-generic/tlbflush.h | 18 +
.../asm-generic/{uaccess.h => uaccess-unaligned.h} | 6 +-
include/asm-generic/uaccess.h | 261 +++++++++++--
include/asm-generic/user.h | 8 +
kernel/Makefile | 1 +
{arch/microblaze/kernel => kernel}/syscall_table.c | 2 +-
lib/Makefile | 2 +
{arch/microblaze/lib => lib}/checksum.c | 43 ++-
121 files changed, 1850 insertions(+), 1548 deletions(-)
rewrite arch/microblaze/include/asm/atomic.h (98%)
rewrite arch/microblaze/include/asm/bitops.h (95%)
rewrite arch/microblaze/include/asm/checksum.h (68%)
create mode 100644 arch/microblaze/include/asm/cmpxchg-local.h
rewrite arch/microblaze/include/asm/dma-mapping.h (100%)
rewrite arch/microblaze/include/asm/io.h (94%)
rewrite arch/microblaze/include/asm/kmap_types.h (100%)
rewrite arch/microblaze/include/asm/mmu.h (100%)
rewrite arch/microblaze/include/asm/mmu_context.h (100%)
rewrite arch/microblaze/include/asm/scatterlist.h (100%)
rewrite arch/microblaze/include/asm/syscalls.h (94%)
rewrite arch/microblaze/include/asm/system.h (66%)
rewrite arch/microblaze/include/asm/timex.h (100%)
rewrite arch/microblaze/include/asm/uaccess.h (86%)
rewrite arch/microblaze/lib/uaccess.c (97%)
rename include/asm-generic/{atomic.h => atomic-long.h} (97%)
rewrite include/asm-generic/atomic.h (98%)
create mode 100644 include/asm-generic/bugs.h
create mode 100644 include/asm-generic/cache.h
create mode 100644 include/asm-generic/cacheflush.h
rename {arch/microblaze/include/asm => include/asm-generic}/checksum.h (57%)
create mode 100644 include/asm-generic/current.h
create mode 100644 include/asm-generic/delay.h
create mode 100644 include/asm-generic/dma.h
create mode 100644 include/asm-generic/fb.h
rename include/asm-generic/{page.h => getorder.h} (59%)
create mode 100644 include/asm-generic/hardirq.h
create mode 100644 include/asm-generic/hw_irq.h
create mode 100644 include/asm-generic/io.h
create mode 100644 include/asm-generic/irq.h
create mode 100644 include/asm-generic/irqflags.h
create mode 100644 include/asm-generic/kmap_types.h
create mode 100644 include/asm-generic/linkage.h
create mode 100644 include/asm-generic/mmu.h
create mode 100644 include/asm-generic/mmu_context.h
create mode 100644 include/asm-generic/module.h
create mode 100644 include/asm-generic/mutex.h
rewrite include/asm-generic/page.h (93%)
create mode 100644 include/asm-generic/pgalloc.h
create mode 100644 include/asm-generic/scatterlist.h
create mode 100644 include/asm-generic/segment.h
create mode 100644 include/asm-generic/serial.h
create mode 100644 include/asm-generic/spinlock.h
create mode 100644 include/asm-generic/string.h
create mode 100644 include/asm-generic/syscalls.h
create mode 100644 include/asm-generic/system.h
create mode 100644 include/asm-generic/timex.h
create mode 100644 include/asm-generic/tlbflush.h
rename include/asm-generic/{uaccess.h => uaccess-unaligned.h} (82%)
rewrite include/asm-generic/uaccess.h (96%)
create mode 100644 include/asm-generic/user.h
rename {arch/microblaze/kernel => kernel}/syscall_table.c (82%)
rename {arch/microblaze/lib => lib}/checksum.c (79%)Arnd Bergmann
maintainerPATCH 1/27 asm-generic: rename atomic.h to atomic-long.h
The existing asm-generic/atomic.h only defines the atomic_long type. This renames it to atomic-long.h so we have a place to add a truly generic atomic.h that can be used on all non-SMP systems.
---
arch/alpha/include/asm/atomic.h | 2 +-
arch/arm/include/asm/atomic.h | 2 +-
arch/avr32/include/asm/atomic.h | 2 +-
arch/blackfin/include/asm/atomic.h | 2 +-
arch/cris/include/asm/atomic.h | 2 +-
arch/frv/include/asm/atomic.h | 2 +-
arch/h8300/include/asm/atomic.h | 2 +-
arch/ia64/include/asm/atomic.h | 2 +-
arch/m32r/include/asm/atomic.h | 2 +-
arch/m68k/include/asm/atomic_mm.h | 2 +-
arch/m68k/include/asm/atomic_no.h | 2 +-
arch/microblaze/include/asm/atomic.h | 2 +-
arch/mips/include/asm/atomic.h | 2 +-
arch/mn10300/include/asm/atomic.h | 2 +-
arch/parisc/include/asm/atomic.h | 2 +-
arch/powerpc/include/asm/atomic.h | 2 +-
arch/s390/include/asm/atomic.h | 2 +-
arch/sh/include/asm/atomic.h | 2 +-
arch/sparc/include/asm/atomic_32.h | 2 +-
arch/sparc/include/asm/atomic_64.h | 2 +-
arch/x86/include/asm/atomic_32.h | 2 +-
arch/x86/include/asm/atomic_64.h | 2 +-
arch/xtensa/include/asm/atomic.h | 2 +-
include/asm-generic/{atomic.h => atomic-long.h} | 6 +++---
include/asm-generic/bitops/atomic.h | 1 +
25 files changed, 27 insertions(+), 26 deletions(-)
rename include/asm-generic/{atomic.h => atomic-long.h} (97%)arch/alpha/include/asm/atomic.h +1 -1
@@ -256,5 +256,5 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)#define smp_mb__before_atomic_inc () smp_mb()#define smp_mb__after_atomic_inc () smp_mb() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ALPHA_ATOMIC_H */
arch/arm/include/asm/atomic.h +1 -1
@@ -206,6 +206,6 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif #endif
arch/avr32/include/asm/atomic.h +1 -1
@@ -196,6 +196,6 @@ static inline int atomic_sub_if_positive(int i, atomic_t *v)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __ASM_AVR32_ATOMIC_H */
arch/blackfin/include/asm/atomic.h +1 -1
@@ -208,6 +208,6 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)#define atomic_sub_and_test (i,v) (atomic_sub_return((i), (v)) == 0)#define atomic_dec_and_test (v) (atomic_sub_return(1, (v)) == 0) -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __ARCH_BLACKFIN_ATOMIC __ */
arch/cris/include/asm/atomic.h +1 -1
@@ -158,5 +158,5 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif
arch/frv/include/asm/atomic.h +1 -1
@@ -194,5 +194,5 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)#define atomic_inc_not_zero (v) atomic_add_unless((v), 1, 0) -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_ATOMIC_H */
arch/h8300/include/asm/atomic.h +1 -1
@@ -141,5 +141,5 @@ static __inline__ void atomic_set_mask(unsigned long mask, unsigned long *v)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __ARCH_H8300_ATOMIC __ */
arch/ia64/include/asm/atomic.h +1 -1
@@ -216,5 +216,5 @@ atomic64_add_negative (__s64 i, atomic64_t *v)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_IA64_ATOMIC_H */
arch/m32r/include/asm/atomic.h +1 -1
@@ -314,5 +314,5 @@ static __inline__ void atomic_set_mask(unsigned long mask, atomic_t *addr)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_M32R_ATOMIC_H */
arch/m68k/include/asm/atomic_mm.h +1 -1
@@ -192,5 +192,5 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __ARCH_M68K_ATOMIC __ */
arch/m68k/include/asm/atomic_no.h +1 -1
@@ -151,5 +151,5 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)#define atomic_dec_return (v) atomic_sub_return(1,(v))#define atomic_inc_return (v) atomic_add_return(1,(v)) -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __ARCH_M68KNOMMU_ATOMIC __ */
arch/microblaze/include/asm/atomic.h +1 -1
@@ -118,6 +118,6 @@ static inline int atomic_dec_if_positive(atomic_t *v)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_MICROBLAZE_ATOMIC_H */
arch/mips/include/asm/atomic.h +1 -1
@@ -793,6 +793,6 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)#define smp_mb__before_atomic_inc () smp_llsc_mb()#define smp_mb__after_atomic_inc () smp_llsc_mb() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_ATOMIC_H */
arch/mn10300/include/asm/atomic.h +1 -1
@@ -151,7 +151,7 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __KERNEL__ */ #endif /* _ASM_ATOMIC_H */
arch/parisc/include/asm/atomic.h +1 -1
@@ -338,6 +338,6 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)#endif /* CONFIG_64BIT */ -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_PARISC_ATOMIC_H_ */
arch/powerpc/include/asm/atomic.h +1 -1
@@ -472,6 +472,6 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)#endif /* __powerpc64__ */ -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_ATOMIC_H_ */
arch/s390/include/asm/atomic.h +1 -1
@@ -275,6 +275,6 @@ static __inline__ int atomic64_add_unless(atomic64_t *v,#define smp_mb__before_atomic_inc () smp_mb()#define smp_mb__after_atomic_inc () smp_mb() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __KERNEL__ */ #endif /* __ARCH_S390_ATOMIC__ */
arch/sh/include/asm/atomic.h +1 -1
@@ -84,5 +84,5 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __ASM_SH_ATOMIC_H */
arch/sparc/include/asm/atomic_32.h +1 -1
@@ -161,5 +161,5 @@ static inline int __atomic24_sub(int i, atomic24_t *v)#endif /* !(__KERNEL__) */ -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* !(__ARCH_SPARC_ATOMIC__) */
arch/sparc/include/asm/atomic_64.h +1 -1
@@ -114,5 +114,5 @@ static inline int atomic64_add_unless(atomic64_t *v, long a, long u)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* !(__ARCH_SPARC64_ATOMIC__) */
arch/x86/include/asm/atomic_32.h +1 -1
@@ -247,5 +247,5 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_X86_ATOMIC_32_H */
arch/x86/include/asm/atomic_64.h +1 -1
@@ -455,5 +455,5 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* _ASM_X86_ATOMIC_64_H */
arch/xtensa/include/asm/atomic.h +1 -1
@@ -292,7 +292,7 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -#include <asm-generic/atomic.h> +#include <asm-generic/atomic-long.h> #endif /* __KERNEL__ */ #endif /* _XTENSA_ATOMIC_H */
include/asm-generic/atomic-long.h renamed from include/asm-generic/atomic.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef _ASM_GENERIC_ATOMIC_H -#define _ASM_GENERIC_ATOMIC_H +#ifndef _ASM_GENERIC_ATOMIC_LONG_H +#define _ASM_GENERIC_ATOMIC_LONG_H/* * Copyright (C) 2005 Silicon Graphics, Inc. * Christoph Lameter
@@ -255,4 +255,4 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)#endif /* BITS_PER_LONG == 64 */ -#endif /* _ASM_GENERIC_ATOMIC_H */ +#endif /* _ASM_GENERIC_ATOMIC_LONG_H */
include/asm-generic/bitops/atomic.h +1 -0
@@ -2,6 +2,7 @@#define _ASM_GENERIC_BITOPS_ATOMIC_H_#include <asm/types.h> +#include <asm/system.h> #ifdef CONFIG_SMP #include <asm/spinlock.h>
Signature · 1 line
1.5.6.3
Re: [PATCH 01/27] asm-generic: rename atomic.h to atomic-long.h
Quoted 22 lines · Arnd Bergmann
The existing
asm-generic/atomic.honly defines theatomic_longtype. This renames it toatomic-long.hso we have a place to add a truly genericatomic.hthat can be used on all non-SMP systems.Signed-off-by Remis Lima Baima <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>--- arch/alpha/include/asm/atomic.h | 2 +- arch/arm/include/asm/atomic.h | 2 +- arch/avr32/include/asm/atomic.h | 2 +- arch/blackfin/include/asm/atomic.h | 2 +- arch/cris/include/asm/atomic.h | 2 +- arch/frv/include/asm/atomic.h | 2 +- arch/h8300/include/asm/atomic.h | 2 +- arch/ia64/include/asm/atomic.h | 2 +- arch/m32r/include/asm/atomic.h | 2 +- arch/m68k/include/asm/atomic_mm.h | 2 +- arch/m68k/include/asm/atomic_no.h | 2 +- arch/microblaze/include/asm/atomic.h | 2 +- arch/mips/include/asm/atomic.h | 2 +- arch/mn10300/include/asm/atomic.h | 2 +-
Quoted 8 lines
arch/parisc/include/asm/atomic.h | 2 +- arch/powerpc/include/asm/atomic.h | 2 +- arch/s390/include/asm/atomic.h | 2 +- arch/sh/include/asm/atomic.h | 2 +- arch/sparc/include/asm/atomic_32.h | 2 +- arch/sparc/include/asm/atomic_64.h | 2 +- arch/x86/include/asm/atomic_32.h | 2 +- arch/x86/include/asm/atomic_64.h | 2 +-
Ingo
Arnd Bergmann
maintainerPATCH 2/27 asm-generic: add generic atomic.h
In reply to Arnd BergmannThe atomic.h implementation from mn10300 is generic enough that we can use it as a template for all future architectures. Those architectures that do not have native atomic operations or SMP can use this file directly.
--- include/asm-generic/atomic.h | 165 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 165 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/atomic.h
include/asm-generic/atomic.h new file +165 -0
@@ -0,0 +1,165 @@ +/* +* Generic C implementation of atomic counter operations +* Originally implemented for MN10300. +* +* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. +* Written by David Howells ([email protected]) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public Licence +* as published by the Free Software Foundation; either version +* 2 of the Licence, or (at your option) any later version. +*/ +#ifndef __ASM_GENERIC_ATOMIC_H +#define __ASM_GENERIC_ATOMIC_H + +#ifdef CONFIG_SMP +#error not SMP safe +#endif + +/* +* Atomic operations that C can't guarantee us. Useful for +* resource counting etc.. +*/ + +#define ATOMIC_INIT (i) { (i) } + +#ifdef __KERNEL__ + +/** +* atomic_read - read atomic variable +* @v: pointer of type atomic_t +* +* Atomically reads the value of @v. Note that the guaranteed +* useful range of an atomic_t is only 24 bits. +*/ +#define atomic_read (v) ((v)->counter) + +/** +* atomic_set - set atomic variable +* @v: pointer of type atomic_t +* @i: required value +* +* Atomically sets the value of @v to @i. Note that the guaranteed +* useful range of an atomic_t is only 24 bits. +*/ +#define atomic_set (v, i) (((v)->counter) = (i)) + +#include <asm/system.h> + +/** +* atomic_add_return - add integer to atomic variable +* @i: integer value to add +* @v: pointer of type atomic_t +* +* Atomically adds @i to @v and returns the result +* Note that the guaranteed useful range of an atomic_t is only 24 bits. +*/ +static inline int atomic_add_return (int i,atomic_t *v) +{ +unsigned long flags; +int temp; + +local_irq_save (flags); + temp = v->counter; + temp += i; + v->counter = temp; +local_irq_restore (flags); + +return temp; +} + +/** +* atomic_sub_return - subtract integer from atomic variable +* @i: integer value to subtract +* @v: pointer of type atomic_t +* +* Atomically subtracts @i from @v and returns the result +* Note that the guaranteed useful range of an atomic_t is only 24 bits. +*/ +static inline int atomic_sub_return (int i,atomic_t *v) +{ +unsigned long flags; +int temp; + +local_irq_save (flags); + temp = v->counter; + temp -= i; + v->counter = temp; +local_irq_restore (flags); + +return temp; +} + +static inline int atomic_add_negative (int i,atomic_t *v) +{ +return atomic_add_return (i, v) <0 ; +} + +static inline void atomic_add (int i,atomic_t *v) +{ +atomic_add_return (i, v); +} + +static inline void atomic_sub (int i,atomic_t *v) +{ +atomic_sub_return (i, v); +} + +static inline void atomic_inc (atomic_t *v) +{ +atomic_add_return (1 , v); +} + +static inline void atomic_dec (atomic_t *v) +{ +atomic_sub_return (1 , v); +} + +#define atomic_dec_return (v) atomic_sub_return(1, (v)) +#define atomic_inc_return (v) atomic_add_return(1, (v)) + +#define atomic_sub_and_test (i, v) (atomic_sub_return((i), (v)) == 0) +#define atomic_dec_and_test (v) (atomic_sub_return(1, (v)) == 0) +#define atomic_inc_and_test (v) (atomic_add_return(1, (v)) == 0) + +#define atomic_add_unless (v, a, u) \ +({ \ + int c, old; \ + c = atomic_read(v); \ + while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ + c = old; \ + c != (u); \ +}) + +#define atomic_inc_not_zero (v) atomic_add_unless((v), 1, 0) + +static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +{ +unsigned long flags; + + mask = ~mask; +local_irq_save (flags); + *addr &= mask; +local_irq_restore (flags); +} + +#define atomic_xchg (ptr, v) (xchg(&(ptr)->counter, (v))) +#define atomic_cmpxchg (v, old, new) (cmpxchg(&((v)->counter), (old), (new))) + +#define cmpxchg_local (ptr, o, n) \ + ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\ + (unsigned long)(n), sizeof(*(ptr)))) + +#define cmpxchg64_local (ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) + +/* Atomic operations are already serializing on MN10300??? */ +#define smp_mb__before_atomic_dec () barrier() +#define smp_mb__after_atomic_dec () barrier() +#define smp_mb__before_atomic_inc () barrier() +#define smp_mb__after_atomic_inc () barrier() + +#include <asm-generic/atomic-long.h> + +#endif /* __KERNEL__ */ +#endif /* __ASM_GENERIC_ATOMIC_H */
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 3/27 asm-generic: make pci.h usable directly
In reply to Arnd BergmannSome generic code is using the horribly misnamed PCI_DMA_BUS_IS_PHYS from asm/pci.h. This makes sure that an architecture without PCI support does not have to define this itself but can rely on the asm-generic version.
--- arch/frv/include/asm/pci.h | 13 +++---------- arch/m32r/include/asm/pci.h | 2 -- include/asm-generic/pci.h | 8 ++++++++ 3 files changed, 11 insertions(+), 12 deletions(-)
arch/frv/include/asm/pci.h +3 -10
@@ -10,8 +10,8 @@* 2 of the License, or (at your option) any later version. */ -#ifndef ASM_PCI_H -#define ASM_PCI_H +#ifndef _ASM_FRV_PCI_H +#define _ASM_FRV_PCI_H#include <linux/mm.h> #include <asm/scatterlist.h>
@@ -43,12 +43,6 @@ extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,/* Return the index of the PCI controller for device PDEV. */ #define pci_controller_num (PDEV ) (0) -/* The PCI address space does equal the physical memory -* address space. The networking and block device layers use -* this boolean for bounce buffer decisions. -*/ -#define PCI_DMA_BUS_IS_PHYS (1) -/* pci_unmap_{page,single} is a nop so... */ #define DECLARE_PCI_UNMAP_ADDR (ADDR_NAME )#define DECLARE_PCI_UNMAP_LEN (LEN_NAME )
@@ -114,5 +108,4 @@ static inline void pci_dma_sync_sg(struct pci_dev *hwdev, sg_dma_address(&sg[i])+sg_dma_len(&sg[i])); } - -#endif +#endif /* _ASM_FRV_PCI_H */
arch/m32r/include/asm/pci.h +0 -2
@@ -3,6 +3,4 @@#include <asm-generic/pci.h> -#define PCI_DMA_BUS_IS_PHYS (1) -#endif /* _ASM_M32R_PCI_H */
include/asm-generic/pci.h +8 -0
@@ -52,4 +52,12 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) }#endif /* HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ */ +/* +* By default, assume that no iommu is in use and that the PCI +* space is mapped to address physical 0. +*/ +#ifndef PCI_DMA_BUS_IS_PHYS +#define PCI_DMA_BUS_IS_PHYS (1)#endif + +#endif /* _ASM_GENERIC_PCI_H */
Signature · 1 line
1.5.6.3
PATCH 6/27 asm-generic: clean up asm-generic/io.h
In reply to Arnd BergmannFix various aspects of the new asm-generic/io.h, in particular warnings from sparse regarding __iomem annotations.
--- include/asm-generic/io.h | 37 ++++++++++++++++--------------------- 1 files changed, 16 insertions(+), 21 deletions(-)
include/asm-generic/io.h +16 -21
@@ -13,6 +13,7 @@#include <asm/page.h> /* I/O is all done through memory accesses */ #include <asm/cacheflush.h> +#include <linux/types.h> #ifdef CONFIG_GENERIC_IOMAP #include <asm-generic/iomap.h>
@@ -29,17 +30,17 @@*/ static inline u8 __raw_readb (const volatile void __iomem *addr) { -return *(const volatile u8 *) addr; +return *(const volatile u8 __force *) addr; }static inline u16 __raw_readw (const volatile void __iomem *addr) { -return *(const volatile u16 *) addr; +return *(const volatile u16 __force *) addr; }static inline u32 __raw_readl (const volatile void __iomem *addr) { -return *(const volatile u32 *) addr; +return *(const volatile u32 __force *) addr; }#define readb __raw_readb
@@ -48,17 +49,17 @@ static inline u32 __raw_readl(const volatile void __iomem *addr)static inline void __raw_writeb (u8 b,volatile void __iomem *addr) { - *(volatile u8 *) addr = b; + *(volatile u8 __force *) addr = b; }static inline void __raw_writew (u16 b,volatile void __iomem *addr) { - *(volatile u16 *) addr = b; + *(volatile u16 __force *) addr = b; }static inline void __raw_writel (u32 b,volatile void __iomem *addr) { - *(volatile u32 *) addr = b; + *(volatile u32 __force *) addr = b; }#define writeb __raw_writeb
@@ -68,13 +69,13 @@ static inline void __raw_writel(u32 b, volatile void __iomem *addr)#ifdef CONFIG_64BIT static inline u64 __raw_readq (const volatile void __iomem *addr) { -return *(const volatile u64 *) addr; +return *(const volatile u64 __force *) addr; }#define readq (addr) __le64_to_cpu(__raw_readq(addr))static inline void __raw_writeq (u64 b,volatile void __iomem *addr) { - *(volatile u64 *) addr = b; + *(volatile u64 __force *) addr = b; }#define writeq (b,addr) __raw_writeq(__cpu_to_le64(b),addr)#endif
@@ -101,17 +102,17 @@ static inline u32 inl(unsigned long addr)static inline void outb (u8 b,unsigned long addr) { -return writeb (b, (volatile void __iomem *) addr); +writeb (b, (volatile void __iomem *) addr); }static inline void outw (u16 b,unsigned long addr) { -return writew (b, (volatile void __iomem *) addr); +writew (b, (volatile void __iomem *) addr); }static inline void outl (u32 b,unsigned long addr) { -return writel (b, (volatile void __iomem *) addr); +writel (b, (volatile void __iomem *) addr); }#define inb_p (addr) inb(addr)
@@ -231,7 +232,7 @@ static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)*/ static inline unsigned long virt_to_phys (volatile void *address) { -return __pa (address); +return __pa ((unsigned long )address); }static inline void *phys_to_virt (unsigned long address)
@@ -242,16 +243,12 @@ static inline void *phys_to_virt(unsigned long address)/* * Change "struct page" to physical address. */ -static inline void *__ioremap (unsigned long offset,unsigned long size, -unsigned long flags) +static inline void __iomem *ioremap (phys_addr_t offset,unsigned long size) {return (void *) offset; } -static inline void *ioremap (unsigned long offset,unsigned long size) -{ -return (void *) offset; -} +#define __ioremap (offset, size, flags) ioremap(offset, size)#ifndef ioremap_nocache#define ioremap_nocache ioremap
@@ -279,7 +276,7 @@ extern void __iomem *ioport_map(unsigned long port, unsigned int nr);extern void ioport_unmap (void __iomem *p);#endif /* CONFIG_GENERIC_IOMAP */ -#define xlate_dev_kmem_ptr (p) ((void *) (p)) +#define xlate_dev_kmem_ptr (p) p#define xlate_dev_mem_ptr (p) ((void *) (p))#ifndef virt_to_bus
@@ -294,8 +291,6 @@ static inline void *bus_to_virt(unsigned long address) }#endif -#define page_to_bus page_to_phys -#define memset_io (a, b, c) memset(__io_virt(a), (b), (c))#define memcpy_fromio (a, b, c) memcpy((a), __io_virt(b), (c))#define memcpy_toio (a, b, c) memcpy(__io_virt(a), (b), (c))
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 4/27 asm-generic: add legacy I/O header files
In reply to Arnd BergmannThe dma.h, hw_irq.h, serial.h and timex.h files originally described PC-style i8237, i8259A, i8250 and i8253 chips. Modern architectures live happily without these specific interfaces, but a few definitions from these headers keep getting used in common code.
The new generic headers are what most architectures use anyway nowadays, just implementing the minimal definitions.
--- include/asm-generic/dma.h | 15 +++++++++++++++ include/asm-generic/hw_irq.h | 9 +++++++++ include/asm-generic/serial.h | 13 +++++++++++++ include/asm-generic/timex.h | 29 +++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/dma.h create mode 100644 include/asm-generic/hw_irq.h create mode 100644 include/asm-generic/serial.h create mode 100644 include/asm-generic/timex.h
include/asm-generic/dma.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef __ASM_GENERIC_DMA_H +#define __ASM_GENERIC_DMA_H +/* +* This file traditionally describes the i8237 PC style DMA controller. +* Most architectures don't have these any more and can get the minimal +* implementation from kernel/dma.c by not defining MAX_DMA_CHANNELS. +* +* Some code relies on seeing MAX_DMA_ADDRESS though. +*/ +#define MAX_DMA_ADDRESS PAGE_OFFSET + +extern int request_dma (unsigned int dmanr,const char *device_id); +extern void free_dma (unsigned int dmanr); + +#endif /* __ASM_GENERIC_DMA_H */
include/asm-generic/hw_irq.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_GENERIC_HW_IRQ_H +#define __ASM_GENERIC_HW_IRQ_H +/* +* hw_irq.h has internal declarations for the low-level interrupt +* controller, like the original i8259A. +* In general, this is not needed for new architectures. +*/ + +#endif /* __ASM_GENERIC_HW_IRQ_H */
include/asm-generic/serial.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __ASM_GENERIC_SERIAL_H +#define __ASM_GENERIC_SERIAL_H + +/* +* This should not be an architecture specific #define, oh well. +* +* Traditionally, it just describes i8250 and related serial ports +* that have this clock rate. +*/ + +#define BASE_BAUD (1843200 / 16) + +#endif /* __ASM_GENERIC_SERIAL_H */
include/asm-generic/timex.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef __ASM_GENERIC_TIMEX_H +#define __ASM_GENERIC_TIMEX_H + +/* +* CLOCK_TICK_RATE is highly PC-specific and should not +* be used in portable code. 1193182 is the value for the +* original i8253 PIC. +*/ +#ifndef CLOCK_TICK_RATE +#define CLOCK_TICK_RATE 1193182 +#endif + +/* +* If you have a cycle counter, return the value here. +*/ +typedef unsigned long cycles_t ; +static inline cycles_t get_cycles (void ) +{ +return 0 ; +} + +/* +* Architectures are encouraged to implement read_current_timer +* and define this in order to avoid the expensive delay loop +* calibration during boot. +*/ +#undef ARCH_HAS_READ_CURRENT_TIMER + +#endif /* __ASM_GENERIC_TIMEX_H */
Signature · 1 line
1.5.6.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
Arnd Bergmann
maintainerRe: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 11 lines · Michal Simek
include/asm-generic/timex.h line 11
Quoted 8 lines
include/asm-generic/timex.h new file +8
-0+/* +* CLOCK_TICK_RATE is highly PC-specific and should not +* be used in portable code. 1193182 is the value for the +* original i8253 PIC. +*/ +#ifndef CLOCK_TICK_RATE +#define CLOCK_TICK_RATE 1193182 +#endif Why is this in generic code?
CLOCK_TICK_RATE is only used in a few places:
drivers/char/vt_ioctl.c: arg = CLOCK_TICK_RATE / arg; drivers/char/vt_ioctl.c: count = CLOCK_TICK_RATE / count; drivers/clocksource/acpi_pm.c: ((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (CLOCK_TICK_RATE>>10)) drivers/input/joystick/analog.c:#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0 drivers/rtc/rtc-pxa.c:#define TIMER_FREQ CLOCK_TICK_RATE drivers/serial/serial_ks8695.c: .uartclk = CLOCK_TICK_RATE * 16, drivers/watchdog/davinci_wdt.c: timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) & 0xffffffff); drivers/watchdog/davinci_wdt.c: timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) >> 32); drivers/watchdog/ks8695_wdt.c: unsigned long tval = wdt_time * CLOCK_TICK_RATE; include/linux/jiffies.h:#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ include/linux/jiffies.h:#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) include/linux/timex.h: * Moved CLOCK_TICK_RATE, CLOCK_TICK_FACTOR and FINETUNE to asm/timex.h sound/oss/pas2_pcm.c: foo = ((CLOCK_TICK_RATE / 2) + (arg / 2)) / arg; sound/oss/pas2_pcm.c: arg = ((CLOCK_TICK_RATE / 2) + (foo / 2)) / foo; sound/oss/pas2_pcm.c: foo = (CLOCK_TICK_RATE + (arg / 2)) / arg; sound/oss/pas2_pcm.c: arg = (CLOCK_TICK_RATE + (foo / 2)) / foo;
All of these are either PC-specific, or they don't actually care about the specific value. Most architectures just use the value from the IBM PC, so we might as well make that the generic default.
Alternatively, we could also move the definition back to linux/timex.h and allow asm/timex.h to be empty.
Arnd <><
Michal Simek
maintainerRe: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 31 lines · Arnd Bergmann
Quoted 10 lines · Michal Simek
include/asm-generic/timex.h line 11
Quoted 8 lines
include/asm-generic/timex.h new file +8
-0+/* +* CLOCK_TICK_RATE is highly PC-specific and should not +* be used in portable code. 1193182 is the value for the +* original i8253 PIC. +*/ +#ifndef CLOCK_TICK_RATE +#define CLOCK_TICK_RATE 1193182 +#endif Why is this in generic code?
CLOCK_TICK_RATEis only used in a few places:drivers/char/vt_ioctl.c: arg = CLOCK_TICK_RATE / arg; drivers/char/vt_ioctl.c: count = CLOCK_TICK_RATE / count; drivers/clocksource/acpi_pm.c: ((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (CLOCK_TICK_RATE>>10)) drivers/input/joystick/analog.c:#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0 drivers/rtc/rtc-pxa.c:#define TIMER_FREQ CLOCK_TICK_RATE drivers/serial/serial_ks8695.c: .uartclk = CLOCK_TICK_RATE * 16, drivers/watchdog/davinci_wdt.c: timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) & 0xffffffff); drivers/watchdog/davinci_wdt.c: timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) >> 32); drivers/watchdog/ks8695_wdt.c: unsigned long tval = wdt_time * CLOCK_TICK_RATE; include/linux/jiffies.h:#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ include/linux/jiffies.h:#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) include/linux/timex.h: * Moved CLOCK_TICK_RATE, CLOCK_TICK_FACTOR and FINETUNE to asm/timex.h sound/oss/pas2_pcm.c: foo = ((CLOCK_TICK_RATE / 2) + (arg / 2)) / arg; sound/oss/pas2_pcm.c: arg = ((CLOCK_TICK_RATE / 2) + (foo / 2)) / foo; sound/oss/pas2_pcm.c: foo = (CLOCK_TICK_RATE + (arg / 2)) / arg; sound/oss/pas2_pcm.c: arg = (CLOCK_TICK_RATE + (foo / 2)) / foo;
Quoted 4 lines
All of these are either PC-specific, or they don't actually care about the specific value. Most architectures just use the value from the IBM PC, so we might as well make that the generic default.
ok. Let's move out from arch to generic location.
Michal
Quoted 6 lines
Alternatively, we could also move the definition back to
linux/timex.hand allowasm/timex.hto be empty.Arnd <><
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Re: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 32 lines · Michal Simek
Quoted 31 lines · Arnd Bergmann
Quoted 10 lines · Michal Simek
include/asm-generic/timex.h line 11
Quoted 8 lines
include/asm-generic/timex.h new file +8
-0+/* +* CLOCK_TICK_RATE is highly PC-specific and should not +* be used in portable code. 1193182 is the value for the +* original i8253 PIC. +*/ +#ifndef CLOCK_TICK_RATE +#define CLOCK_TICK_RATE 1193182 +#endif Why is this in generic code?
CLOCK_TICK_RATEis only used in a few places:drivers/char/vt_ioctl.c: arg = CLOCK_TICK_RATE / arg; drivers/char/vt_ioctl.c: count = CLOCK_TICK_RATE / count; drivers/clocksource/acpi_pm.c: ((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (CLOCK_TICK_RATE>>10)) drivers/input/joystick/analog.c:#define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0 drivers/rtc/rtc-pxa.c:#define TIMER_FREQ CLOCK_TICK_RATE drivers/serial/serial_ks8695.c: .uartclk = CLOCK_TICK_RATE * 16, drivers/watchdog/davinci_wdt.c: timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) & 0xffffffff); drivers/watchdog/davinci_wdt.c: timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) >> 32); drivers/watchdog/ks8695_wdt.c: unsigned long tval = wdt_time * CLOCK_TICK_RATE; include/linux/jiffies.h:#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ include/linux/jiffies.h:#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) include/linux/timex.h: * Moved CLOCK_TICK_RATE, CLOCK_TICK_FACTOR and FINETUNE to asm/timex.h sound/oss/pas2_pcm.c: foo = ((CLOCK_TICK_RATE / 2) + (arg / 2)) / arg; sound/oss/pas2_pcm.c: arg = ((CLOCK_TICK_RATE / 2) + (foo / 2)) / foo; sound/oss/pas2_pcm.c: foo = (CLOCK_TICK_RATE + (arg / 2)) / arg; sound/oss/pas2_pcm.c: arg = (CLOCK_TICK_RATE + (foo / 2)) / foo;
Quoted 6 lines
Quoted 4 lines
All of these are either PC-specific, or they don't actually care about the specific value. Most architectures just use the value from the IBM PC, so we might as well make that the generic default.
ok. Let's move out from arch to generic location.
That's only possible once the users have been fixed - otherwise the ARM stuff listed above _will_ break.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Arnd Bergmann
maintainerRe: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 9 lines · Russell King
Quoted 6 lines
Quoted 4 lines
All of these are either PC-specific, or they don't actually care about the specific value. Most architectures just use the value from the IBM PC, so we might as well make that the generic default.
ok. Let's move out from arch to generic location.
That's only possible once the users have been fixed - otherwise the ARM stuff listed above _will_ break.
My idea was to just add a fallback of
#ifndef CLOCK_TICK_RATE
#define CLOCK_TICK_RATE 1193182
#endif
to include/linux/timex.h. Since al existing architectures already define CLOCK_TICK_RATE as a macro, I don't see anything changing for them.
The only difference would be that all architectures that use the default value can have an empty timex.h.
Am I missing something?
Arnd <><
Re: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 11 lines
#ifndef
CLOCK_TICK_RATE
#defineCLOCK_TICK_RATE1193182
#endifto
include/linux/timex.h. Since al existing architectures already defineCLOCK_TICK_RATEas a macro, I don't see anything changing for them.The only difference would be that all architectures that use the default value can have an empty
timex.h.Am I missing something?
Currently if you create a new architecture you have to figure out what your equivalent tick rate is or you get an error for not defining it. Ditto if you try to build code using it on platforms that it is meaningless (eg S/390) you get an error.
You'd lose that rather useful property.
Alan
Arnd Bergmann
maintainerRe: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 6 lines · Alan Cox
Currently if you create a new architecture you have to figure out what your equivalent tick rate is or you get an error for not defining it. Ditto if you try to build code using it on platforms that it is meaningless (eg S/390) you get an error.
You'd lose that rather useful property.
In that case, I still think it would be good to have it in asm-generic. Half the architectures define it in this way currently, and new architectures would still have to think about it before falling back on the default.
Arnd <><
Re: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 3 lines
In that case, I still think it would be good to have it in asm-generic. Half the architectures define it in this way currently, and new architectures would still have to think about it before falling back on the default.
Only if they noticed it was even present in the generic includes. Why would they notice - meaningless code would just compile perfectly.
Re: [PATCH 04/27] asm-generic: add legacy I/O header files
In reply to Russell KingQuoted 14 lines · On Fri, 1 May 2009 13:37:28 +0100 Russell King <[email protected]>…
Quoted 13 lines · Michal Simek
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Michal Simek
include/asm-generic/timex.h line 11
Quoted 8 lines
include/asm-generic/timex.h new file +8
-0+/* +* CLOCK_TICK_RATE is highly PC-specific and should not +* be used in portable code. 1193182 is the value for the +* original i8253 PIC. +*/ +#ifndef CLOCK_TICK_RATE +#define CLOCK_TICK_RATE 1193182 +#endif Why is this in generic code?
Quoted 1 line
Quoted 1 line
Quoted 1 line
CLOCK_TICK_RATEis only used in a few places:
Joining in late but its not at all highly PC specific. The same frequency is used for a whole pile of setups (Alpha etc). It's not well named but there are good sound reasons the PC chose 1193182 and while those reasons have long lapsed its a good frequency for other reasons nowdays.
The clock isn't for the PIC either - its for the PIT (although its used to clock various other things).
We actually have a define of PIT_TICK_RATE internal to the x86 port for those x86 cases that can use it.
Alan
Arnd Bergmann
maintainerRe: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 10 lines · Alan Cox
Joining in late but its not at all highly PC specific. The same frequency is used for a whole pile of setups (Alpha etc). It's not well named but there are good sound reasons the PC chose 1193182 and while those reasons have long lapsed its a good frequency for other reasons nowdays.
The clock isn't for the PIC either - its for the PIT (although its used to clock various other things).
We actually have a define of
PIT_TICK_RATEinternal to the x86 port for those x86 cases that can use it.
How about this comment then:
/*
* CLOCK_TICK_RATE is traditionally the base frequency using the PC-style
* i8253 "PIT" timer. Architecture independent device drivers should not
* rely on this value.
* Any architecture that either has a real PC-style PIT, or does not have a
* fixed timer interval at all and just needs to provide some value here
* should just fall back to this default.
*/
Arnd <><
Re: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 8 lines
/*
*CLOCK_TICK_RATEis traditionally the base frequency using the PC-style
* i8253 "PIT" timer. Architecture independent device drivers should not
* rely on this value.
* Any architecture that either has a real PC-style PIT, or does not have a
* fixed timer interval at all and just needs to provide some value here
* should just fall back to this default.
*/
They shouldn't define it - we want those invalid cases to error. Stick CLOCK_TICK_RATE in the depths of the x86 arch includes and then we can fix the other cases properly. Either the device has an independant clock of the same frequency (some watchdogs do this), it relies upon a motherboard timer in which case the platform can define CLOCK_TICK_RATE (or a better name for it), or it doesn't have any meaning in which case we *want* it not to compile.
Arnd Bergmann
maintainerRe: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 7 lines · Alan Cox
They shouldn't define it - we want those invalid cases to error. Stick
CLOCK_TICK_RATEin the depths of the x86 arch includes and then we can fix the other cases properly. Either the device has an independant clock of the same frequency (some watchdogs do this), it relies upon a motherboard timer in which case the platform can defineCLOCK_TICK_RATE(or a better name for it), or it doesn't have any meaning in which case we *want* it not to compile.
I just noticed that linux/jiffies.h does not compile without a definition of CLOCK_TICK_RATE, so that's probably why every architecture defines it. If I find a way to remove that dependency, I can simply leave out the CLOCK_TICK_RATE from the generic header. I have not yet understood the relation of jiffies to CLOCK_TICK_RATE, but my suspicion is that it's not good for architectures that do not have a clock tick.
Arnd <><
Re: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 2 lines
I just noticed that
linux/jiffies.hdoes not compile without a definition ofCLOCK_TICK_RATE, so that's probably why every architecture defines it.
It should do so just fine what errors are you seeing ?
CLOCK_TICK_RATE produces ACTHZ and LATCH
ACTHZ is specific to the jiffies timer (and requires CLOCK_TICK_RATE represents the input frequency that is divided to generate the target HZ value for the system), LATCH is used in a couple of ugly bits of x86 code and can probably now go away.
So we now have at least two conflicting meanings for CLOCK_TICK_RATE which again says it needs fixing not wallpapering over.
Alan
Arnd Bergmann
maintainerRe: [PATCH 04/27] asm-generic: add legacy I/O header files
Quoted 2 lines · Alan Cox
So we now have at least two conflicting meanings for
CLOCK_TICK_RATEwhich again says it needs fixing not wallpapering over.
Right, I agree. I'll look into it next week.
Arnd <><
Re: [PATCH 04/27] asm-generic: add legacy I/O header files
In reply to Arnd BergmannQuoted 1 line · Arnd Bergmann
drivers/rtc/rtc-pxa.c:#define
TIMER_FREQCLOCK_TICK_RATE
Needs to use some separate definition, this is not related in any way to the ISA timer stuff.
Quoted 1 line
drivers/serial/serial_ks8695.c: .uartclk =CLOCK_TICK_RATE* 16,
Ditto.
Quoted 2 lines
drivers/watchdog/davinci_wdt.c:timer_margin= (((u64)heartbeat *CLOCK_TICK_RATE) &0xffffffff);drivers/watchdog/davinci_wdt.c:timer_margin= (((u64)heartbeat *CLOCK_TICK_RATE) >> 32);
Ditto.
Quoted 1 line
drivers/watchdog/ks8695_wdt.c: unsigned long tval =wdt_time*CLOCK_TICK_RATE;
Ditto.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Arnd Bergmann
maintainerPATCH 5/27 asm-generic: add generic io.h
In reply to Arnd BergmannArchitectures that only have strictly ordered memory mapped I/O can use a very simple asm/io.h implementation, which was first written for the mn10300 architecture.
Make it generic, so that future architectures can use it directly.
--- include/asm-generic/io.h | 305 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 305 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/io.h
include/asm-generic/io.h new file +305 -0
@@ -0,0 +1,305 @@ +/* Generic I/O port emulation, based on MN10300 code +* +* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. +* Written by David Howells ([email protected]) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public Licence +* as published by the Free Software Foundation; either version +* 2 of the Licence, or (at your option) any later version. +*/ +#ifndef __ASM_GENERIC_IO_H +#define __ASM_GENERIC_IO_H + +#include <asm/page.h> /* I/O is all done through memory accesses */ +#include <asm/cacheflush.h> + +#ifdef CONFIG_GENERIC_IOMAP +#include <asm-generic/iomap.h> +#endif + +#define mmiowb () do {} while (0) + +/*****************************************************************************/ +/* +* readX/writeX() are used to access memory mapped devices. On some +* architectures the memory mapped IO stuff needs to be accessed +* differently. On the simple architectures, we just read/write the +* memory location directly. +*/ +static inline u8 __raw_readb (const volatile void __iomem *addr) +{ +return *(const volatile u8 *) addr; +} + +static inline u16 __raw_readw (const volatile void __iomem *addr) +{ +return *(const volatile u16 *) addr; +} + +static inline u32 __raw_readl (const volatile void __iomem *addr) +{ +return *(const volatile u32 *) addr; +} + +#define readb __raw_readb +#define readw (addr) __le16_to_cpu(__raw_readw(addr)) +#define readl (addr) __le32_to_cpu(__raw_readl(addr)) + +static inline void __raw_writeb (u8 b,volatile void __iomem *addr) +{ + *(volatile u8 *) addr = b; +} + +static inline void __raw_writew (u16 b,volatile void __iomem *addr) +{ + *(volatile u16 *) addr = b; +} + +static inline void __raw_writel (u32 b,volatile void __iomem *addr) +{ + *(volatile u32 *) addr = b; +} + +#define writeb __raw_writeb +#define writew (b,addr) __raw_writew(__cpu_to_le16(b),addr) +#define writel (b,addr) __raw_writel(__cpu_to_le32(b),addr) + +#ifdef CONFIG_64BIT +static inline u64 __raw_readq (const volatile void __iomem *addr) +{ +return *(const volatile u64 *) addr; +} +#define readq (addr) __le64_to_cpu(__raw_readq(addr)) + +static inline void __raw_writeq (u64 b,volatile void __iomem *addr) +{ + *(volatile u64 *) addr = b; +} +#define writeq (b,addr) __raw_writeq(__cpu_to_le64(b),addr) +#endif + +/*****************************************************************************/ +/* +* traditional input/output functions +*/ + +static inline u8 inb (unsigned long addr) +{ +return readb ((volatile void __iomem *) addr); +} + +static inline u16 inw (unsigned long addr) +{ +return readw ((volatile void __iomem *) addr); +} + +static inline u32 inl (unsigned long addr) +{ +return readl ((volatile void __iomem *) addr); +} + +static inline void outb (u8 b,unsigned long addr) +{ +return writeb (b, (volatile void __iomem *) addr); +} + +static inline void outw (u16 b,unsigned long addr) +{ +return writew (b, (volatile void __iomem *) addr); +} + +static inline void outl (u32 b,unsigned long addr) +{ +return writel (b, (volatile void __iomem *) addr); +} + +#define inb_p (addr) inb(addr) +#define inw_p (addr) inw(addr) +#define inl_p (addr) inl(addr) +#define outb_p (x, addr) outb((x), (addr)) +#define outw_p (x, addr) outw((x), (addr)) +#define outl_p (x, addr) outl((x), (addr)) + +static inline void insb (unsigned long addr,void *buffer,int count) +{ +if (count) { +u8 *buf = buffer; +do { +u8 x =inb (addr); + *buf++ = x; + }while (--count); + } +} + +static inline void insw (unsigned long addr,void *buffer,int count) +{ +if (count) { +u16 *buf = buffer; +do { +u16 x =inw (addr); + *buf++ = x; + }while (--count); + } +} + +static inline void insl (unsigned long addr,void *buffer,int count) +{ +if (count) { +u32 *buf = buffer; +do { +u32 x =inl (addr); + *buf++ = x; + }while (--count); + } +} + +static inline void outsb (unsigned long addr,const void *buffer,int count) +{ +if (count) { +const u8 *buf = buffer; +do { +outb (*buf++, addr); + }while (--count); + } +} + +static inline void outsw (unsigned long addr,const void *buffer,int count) +{ +if (count) { +const u16 *buf = buffer; +do { +outw (*buf++, addr); + }while (--count); + } +} + +static inline void outsl (unsigned long addr,const void *buffer,int count) +{ +if (count) { +const u32 *buf = buffer; +do { +outl (*buf++, addr); + }while (--count); + } +} + +#ifndef CONFIG_GENERIC_IOMAP +#define ioread8 (addr) readb(addr) +#define ioread16 (addr) readw(addr) +#define ioread32 (addr) readl(addr) + +#define iowrite8 (v, addr) writeb((v), (addr)) +#define iowrite16 (v, addr) writew((v), (addr)) +#define iowrite32 (v, addr) writel((v), (addr)) + +#define ioread8_rep (p, dst, count) \ + insb((unsigned long) (p), (dst), (count)) +#define ioread16_rep (p, dst, count) \ + insw((unsigned long) (p), (dst), (count)) +#define ioread32_rep (p, dst, count) \ + insl((unsigned long) (p), (dst), (count)) + +#define iowrite8_rep (p, src, count) \ + outsb((unsigned long) (p), (src), (count)) +#define iowrite16_rep (p, src, count) \ + outsw((unsigned long) (p), (src), (count)) +#define iowrite32_rep (p, src, count) \ + outsl((unsigned long) (p), (src), (count)) +#endif /* CONFIG_GENERIC_IOMAP */ + + +#define IO_SPACE_LIMIT 0xffffffff + +#ifdef __KERNEL__ + +#include <linux/vmalloc.h> +#define __io_virt (x) ((void *) (x)) + +#ifndef CONFIG_GENERIC_IOMAP +/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ +struct pci_dev ; +extern void __iomem *pci_iomap (struct pci_dev *dev,int bar,unsigned long max); +static inline void pci_iounmap (struct pci_dev *dev,void __iomem *p) +{ +} +#endif /* CONFIG_GENERIC_IOMAP */ + +/* +* Change virtual addresses to physical addresses and vv. +* These are pretty trivial +*/ +static inline unsigned long virt_to_phys (volatile void *address) +{ +return __pa (address); +} + +static inline void *phys_to_virt (unsigned long address) +{ +return __va (address); +} + +/* +* Change "struct page" to physical address. +*/ +static inline void *__ioremap (unsigned long offset,unsigned long size, +unsigned long flags) +{ +return (void *) offset; +} + +static inline void *ioremap (unsigned long offset,unsigned long size) +{ +return (void *) offset; +} + +#ifndef ioremap_nocache +#define ioremap_nocache ioremap +#endif + +#ifndef ioremap_wc +#define ioremap_wc ioremap_nocache +#endif + +static inline void iounmap (void *addr) +{ +} + +#ifndef CONFIG_GENERIC_IOMAP +static inline void __iomem *ioport_map (unsigned long port,unsigned int nr) +{ +return (void __iomem *) port; +} + +static inline void ioport_unmap (void __iomem *p) +{ +} +#else /* CONFIG_GENERIC_IOMAP */ +extern void __iomem *ioport_map (unsigned long port,unsigned int nr); +extern void ioport_unmap (void __iomem *p); +#endif /* CONFIG_GENERIC_IOMAP */ + +#define xlate_dev_kmem_ptr (p) ((void *) (p)) +#define xlate_dev_mem_ptr (p) ((void *) (p)) + +#ifndef virt_to_bus +static inline unsigned long virt_to_bus (volatile void *address) +{ +return ((unsigned long ) address); +} + +static inline void *bus_to_virt (unsigned long address) +{ +return (void *) address; +} +#endif + +#define page_to_bus page_to_phys + +#define memset_io (a, b, c) memset(__io_virt(a), (b), (c)) +#define memcpy_fromio (a, b, c) memcpy((a), __io_virt(b), (c)) +#define memcpy_toio (a, b, c) memcpy(__io_virt(a), (b), (c)) + +#endif /* __KERNEL__ */ + +#endif /* __ASM_GENERIC_IO_H */
Signature · 1 line
1.5.6.3
Geert Uytterhoeven
maintainerRe: [PATCH 05/27] asm-generic: add generic io.h
Quoted 55 lines · Arnd Bergmann
include/asm-generic/io.h new file +52
-0+static inline void insb (unsigned long addr,void *buffer,int count) +{ + if (count) { + u8 *buf = buffer; + do { + u8 x = inb(addr); + *buf++ = x; + } while (--count); + } +} + +static inline void insw (unsigned long addr,void *buffer,int count) +{ + if (count) { + u16 *buf = buffer; + do { + u16 x = inw(addr); + *buf++ = x; + } while (--count); + } +} + +static inline void insl (unsigned long addr,void *buffer,int count) +{ + if (count) { + u32 *buf = buffer; + do { + u32 x = inl(addr); + *buf++ = x; + } while (--count); + } +} + +static inline void outsb (unsigned long addr,const void *buffer,int count) +{ + if (count) { + const u8 *buf = buffer; + do { + outb(*buf++, addr); + } while (--count); + } +} + +static inline void outsw (unsigned long addr,const void *buffer,int count) +{ + if (count) { + const u16 *buf = buffer; + do { + outw(*buf++, addr); + } while (--count); + } +}
include/asm-generic/io.h line 185
Quoted 10 lines
include/asm-generic/io.h new file +10
-0+ +static inline void outsl (unsigned long addr,const void *buffer,int count) +{ + if (count) { + const u32 *buf = buffer; + do { + outl(*buf++, addr); + } while (--count); + } +}
Do we ever call these with count == 0?
Quoted 3 lines
+/*
+ * Change "struct page" to physical address.
+ */
Which `struct page'?
include/asm-generic/io.h line 254
Quoted 10 lines
include/asm-generic/io.h new file +10
-0+static inline void *__ioremap (unsigned long offset,unsigned long size, + unsigned long flags) +{ + return (void *) offset; +} + +static inline void *ioremap (unsigned long offset,unsigned long size) +{ + return (void *) offset; +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerRe: [PATCH 05/27] asm-generic: add generic io.h
io.h is more or less a straight copy from the mn10300 code, so maybe David Howells is interested in this as well.
Quoted 14 lines · Geert Uytterhoeven
Quoted 13 lines · Arnd Bergmann
include/asm-generic/io.h new file +13
-0+static inline void outsw (unsigned long addr,const void *buffer,int count) +{ + if (count) { + const u16 *buf = buffer; + do { + outw(*buf++, addr); + } while (--count); + } +} + +static inline void outsl (unsigned long addr,const void *buffer,int count) +{ + if (count) {
Quoted 8 lines
Quoted 6 lines
+ const u32 *buf = buffer;
+ do {
+outl(*buf++, addr);
+ } while (--count);
+ }
+}Do we ever call these with count == 0?
I don't think it can, but code is still more correct if it can handle it. It could of course be written as
const u32 *buf; for (buf = buffer; count; count--) outl(*buf++, addr);
Quoted 5 lines
Quoted 3 lines
+/*
+ * Change "struct page" to physical address.
+ */Which `struct page'?
I can change the comment to what avr32 and m32r have:
arch/avr32/include/asm/io.h-/*
arch/avr32/include/asm/io.h: * ioremap - map bus memory into CPU space arch/avr32/include/asm/io.h- * @offset bus address of the memory arch/avr32/include/asm/io.h- * @size size of the resource to map
arch/avr32/include/asm/io.h- *arch/avr32/include/asm/io.h: * ioremap performs a platform specific sequence of operations to make arch/avr32/include/asm/io.h- * bus memory CPU accessible via the readb/.../writel functions and arch/avr32/include/asm/io.h- * the other mmio helpers. The returned address is not guaranteed to arch/avr32/include/asm/io.h- * be usable directly as a virtual address. arch/avr32/include/asm/io.h- */
Arnd <><
Arnd Bergmann
maintainerPATCH 7/27 asm-generic: add minimal cache description
In reply to Arnd BergmannMany architectures have a 32 byte cache line and never require flushing the cache, so they can use these generic implementation.
--- include/asm-generic/cache.h | 12 ++++++++++++ include/asm-generic/cacheflush.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/cache.h create mode 100644 include/asm-generic/cacheflush.h
include/asm-generic/cache.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_GENERIC_CACHE_H +#define __ASM_GENERIC_CACHE_H +/* +* 32 bytes appears to be the most common cache line size, +* so make that the default here. Architectures with larger +* cache lines need to provide their own cache.h. +*/ + +#define L1_CACHE_SHIFT 5 +#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) + +#endif /* __ASM_GENERIC_CACHE_H */
include/asm-generic/cacheflush.h new file +30 -0
@@ -0,0 +1,30 @@ +#ifndef __ASM_CACHEFLUSH_H +#define __ASM_CACHEFLUSH_H + +/* Keep includes the same across arches. */ +#include <linux/mm.h> + +/* +* The cache doesn't need to be flushed when TLB entries change when +* the cache is mapped to physical memory, not virtual memory +*/ +#define flush_cache_all () do { } while (0) +#define flush_cache_mm (mm) do { } while (0) +#define flush_cache_dup_mm (mm) do { } while (0) +#define flush_cache_range (vma, start, end) do { } while (0) +#define flush_cache_page (vma, vmaddr, pfn) do { } while (0) +#define flush_dcache_page (page) do { } while (0) +#define flush_dcache_mmap_lock (mapping) do { } while (0) +#define flush_dcache_mmap_unlock (mapping) do { } while (0) +#define flush_icache_range (start, end) do { } while (0) +#define flush_icache_page (vma,pg) do { } while (0) +#define flush_icache_user_range (vma,pg,adr,len) do { } while (0) +#define flush_cache_vmap (start, end) do { } while (0) +#define flush_cache_vunmap (start, end) do { } while (0) + +#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ + memcpy(dst, src, len) +#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ + memcpy(dst, src, len) + +#endif /* __ASM_CACHEFLUSH_H */
Signature · 1 line
1.5.6.3
A message that is not in the archive (sent off-list or not yet received): [email protected]
Arnd Bergmann
maintainerRe: [PATCH 07/27] asm-generic: add minimal cache description
Quoted 7 lines · Michal Simek
include/asm-generic/cacheflush.h line 28
Quoted 4 lines
include/asm-generic/cacheflush.h new file +4
-0+#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ + memcpy(dst, src, len) +#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ + memcpy(dst, src, len)IMHO these two macros will generate cast errors.
I did not see errors here, can you clarify? Note that despite the name, they don't take a __user pointer. Maybe they should be inline functions to make that more obvious.
Arnd <><
Michal Simek
maintainerRe: [PATCH 07/27] asm-generic: add minimal cache description
Quoted 11 lines · Arnd Bergmann
Quoted 6 lines · Michal Simek
include/asm-generic/cacheflush.h line 28
Quoted 4 lines
include/asm-generic/cacheflush.h new file +4
-0+#define copy_to_user_page (vma, page, vaddr, dst, src, len) \ + memcpy(dst, src, len) +#define copy_from_user_page (vma, page, vaddr, dst, src, len) \ + memcpy(dst, src, len)IMHO these two macros will generate cast errors.
I did not see errors here, can you clarify? Note that despite the name, they don't take a
__userpointer. Maybe they should be inline functions to make that more obvious.
you are right here with __user.
x86 use it as inline function.
Michal
Quoted 2 lines
Arnd <><
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Arnd Bergmann
maintainerPATCH 8/27 asm-generic: add generic versions of common headers
In reply to Arnd BergmannThese are all kernel internal interfaces that get copied around a lot. In most cases, architectures can provide their own optimized versions, but these generic versions can work as well.
I have tried to use the most common contents of each header to allow existing architectures to migrate easily.
--- include/asm-generic/bugs.h | 10 +++ include/asm-generic/current.h | 9 ++ include/asm-generic/delay.h | 9 ++ include/asm-generic/fb.h | 12 +++ include/asm-generic/hardirq.h | 34 ++++++++ include/asm-generic/irq.h | 18 ++++ include/asm-generic/irqflags.h | 72 ++++++++++++++++ include/asm-generic/kmap_types.h | 29 +++++++ include/asm-generic/linkage.h | 8 ++ include/asm-generic/module.h | 22 +++++ include/asm-generic/mutex.h | 9 ++ include/asm-generic/scatterlist.h | 43 ++++++++++ include/asm-generic/spinlock.h | 11 +++ include/asm-generic/string.h | 10 +++ include/asm-generic/system.h | 161 +++++++++++++++++++++++++++++++++++++ include/asm-generic/user.h | 8 ++ 16 files changed, 465 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/bugs.h create mode 100644 include/asm-generic/current.h create mode 100644 include/asm-generic/delay.h create mode 100644 include/asm-generic/fb.h create mode 100644 include/asm-generic/hardirq.h create mode 100644 include/asm-generic/irq.h create mode 100644 include/asm-generic/irqflags.h create mode 100644 include/asm-generic/kmap_types.h create mode 100644 include/asm-generic/linkage.h create mode 100644 include/asm-generic/module.h create mode 100644 include/asm-generic/mutex.h create mode 100644 include/asm-generic/scatterlist.h create mode 100644 include/asm-generic/spinlock.h create mode 100644 include/asm-generic/string.h create mode 100644 include/asm-generic/system.h create mode 100644 include/asm-generic/user.h
include/asm-generic/bugs.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef __ASM_GENERIC_BUGS_H +#define __ASM_GENERIC_BUGS_H +/* +* This file is included by 'init/main.c' to check for +* architecture-dependent bugs. +*/ + +static inline void check_bugs (void ) { } + +#endif /* __ASM_GENERIC_BUGS_H */
include/asm-generic/current.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_GENERIC_CURRENT_H +#define __ASM_GENERIC_CURRENT_H + +#include <linux/thread_info.h> + +#define get_current () (current_thread_info()->task) +#define current get_current() + +#endif /* __ASM_GENERIC_CURRENT_H */
include/asm-generic/delay.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_GENERIC_DELAY_H +#define __ASM_GENERIC_DELAY_H + +extern void __udelay (unsigned long usecs); +extern void __delay (unsigned long loops); + +#define udelay (n) __udelay(n) + +#endif /* __ASM_GENERIC_DELAY_H */
include/asm-generic/fb.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_GENERIC_FB_H_ +#define __ASM_GENERIC_FB_H_ +#include <linux/fb.h> + +#define fb_pgprotect (...) do {} while (0) + +static inline int fb_is_primary_device (struct fb_info *info) +{ +return 0 ; +} + +#endif /* __ASM_GENERIC_FB_H_ */
include/asm-generic/hardirq.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef __ASM_GENERIC_HARDIRQ_H +#define __ASM_GENERIC_HARDIRQ_H + +#include <linux/cache.h> +#include <linux/threads.h> +#include <linux/irq.h> + +typedef struct { +unsigned long __softirq_pending; +}____cacheline_aligned irq_cpustat_t ; + +#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ + +#ifndef HARDIRQ_BITS +#define HARDIRQ_BITS 8 +#endif + +/* +* The hardirq mask has to be large enough to have +* space for potentially all IRQ sources in the system +* nesting on a single CPU: +*/ +#if (1 <<HARDIRQ_BITS ) <NR_IRQS +# error HARDIRQ_BITS is too low! +#endif + +#ifndef ack_bad_irq +static inline void ack_bad_irq (unsigned int irq) +{ +printk (KERN_CRIT "unexpected IRQ trap at vector %02x\n" , irq); +} +#endif + +#endif /* __ASM_GENERIC_HARDIRQ_H */
include/asm-generic/irq.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __ASM_GENERIC_IRQ_H +#define __ASM_GENERIC_IRQ_H + +/* +* NR_IRQS is the upper bound of how many interrupts can be handled +* in the platform. It is used to size the static irq_map array, +* so don't make it too big. +*/ +#ifndef NR_IRQS +#define NR_IRQS 64 +#endif + +static inline int irq_canonicalize (int irq) +{ +return irq; +} + +#endif /* __ASM_GENERIC_IRQ_H */
include/asm-generic/irqflags.h new file +72 -0
72 lines not on this page · raw message
include/asm-generic/kmap_types.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef __ASM_GENERIC_KMAP_TYPES_H +#define __ASM_GENERIC_KMAP_TYPES_H + +#ifdef CONFIG_DEBUG_HIGHMEM +# define D (n) __KM_FENCE_##n , +#else +# define D (n) +#endif + +enum km_type { +D(0) KM_BOUNCE_READ, +D(1) KM_SKB_SUNRPC_DATA, +D(2) KM_SKB_DATA_SOFTIRQ, +D(3) KM_USER0, +D(4) KM_USER1, +D(5) KM_BIO_SRC_IRQ, +D(6) KM_BIO_DST_IRQ, +D(7) KM_PTE0, +D(8) KM_PTE1, +D(9) KM_IRQ0, +D(10) KM_IRQ1, +D(11) KM_SOFTIRQ0, +D(12) KM_SOFTIRQ1, +D(13) KM_TYPE_NR +}; + +#undef D + +#endif /* __ASM_GENERIC_KMAP_TYPES_H */
include/asm-generic/linkage.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __ASM_GENERIC_LINKAGE_H +#define __ASM_GENERIC_LINKAGE_H +/* +* linux/linkage.h provides reasonable defaults. +* an architecture can override them by providing its own version. +*/ + +#endif /* __ASM_GENERIC_LINKAGE_H */
include/asm-generic/module.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef __ASM_GENERIC_MODULE_H +#define __ASM_GENERIC_MODULE_H + +/* +* Many architectures just need a simple module +* loader without arch specific data. +*/ +struct mod_arch_specific +{ +}; + +#ifdef CONFIG_64BIT +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Ehdr Elf64_Ehdr +#else +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Ehdr Elf32_Ehdr +#endif + +#endif /* __ASM_GENERIC_MODULE_H */
include/asm-generic/mutex.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __ASM_GENERIC_MUTEX_H +#define __ASM_GENERIC_MUTEX_H +/* +* Pull in the generic implementation for the mutex fastpath, +* which is a reasonable default on many architectures. +*/ + +#include <asm-generic/mutex-dec.h> +#endif /* __ASM_GENERIC_MUTEX_H */
include/asm-generic/scatterlist.h new file +43 -0
43 lines not on this page · raw message
include/asm-generic/spinlock.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef __ASM_GENERIC_SPINLOCK_H +#define __ASM_GENERIC_SPINLOCK_H +/* +* You need to implement asm/spinlock.h for SMP support. The generic +* version does not handle SMP. +*/ +#ifdef CONFIG_SMP +#error need an architecture specific asm/spinlock.h +#endif + +#endif /* __ASM_GENERIC_SPINLOCK_H */
include/asm-generic/string.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef __ASM_GENERIC_STRING_H +#define __ASM_GENERIC_STRING_H +/* +* The kernel provides all required functions in lib/string.c +* +* Architectures probably want to provide at least their own optimized +* memcpy and memset functions though. +*/ + +#endif /* __ASM_GENERIC_STRING_H */
include/asm-generic/system.h new file +161 -0
161 lines not on this page · raw message
include/asm-generic/user.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __ASM_GENERIC_USER_H +#define __ASM_GENERIC_USER_H +/* +* This file may define a 'struct user' structure. However, it it only +* used for a.out file, which are not supported on new architectures. +*/ + +#endif /* __ASM_GENERIC_USER_H */
Signature · 1 line
1.5.6.3
David Miller
maintainerRe: [PATCH 08/27] asm-generic: add generic versions of common headers
From: Arnd Bergmann <[email protected]>
Date: Tue, 28 Apr 2009 16:15:26 +0200
Many sites are bouncing because the date on your emails is as much as two days in the past.
Please correct this, thank you.
Arnd Bergmann
maintainerRe: [PATCH 08/27] asm-generic: add generic versions of common headers
Quoted 2 lines · David Miller
Many sites are bouncing because the date on your emails is as much as two days in the past.
Any suggestions on which tool I should use? I've been burned by both 'quilt mail' and 'git-format-patch' this week and don't want to make any more experiments. I looked at git-send-email, but I'm sure I'd screw up even more with that because it directly sends out the patches rather than giving me an mbox file to look at.
Arnd <><
David Miller
maintainerRe: [PATCH 08/27] asm-generic: add generic versions of common headers
From: Arnd Bergmann <[email protected]>
Date: Thu, 30 Apr 2009 18:49:44 +0200
Quoted 10 lines · David Miller
Quoted 2 lines
Many sites are bouncing because the date on your emails is as much as two days in the past.
Any suggestions on which tool I should use? I've been burned by both 'quilt mail' and 'git-format-patch' this week and don't want to make any more experiments. I looked at git-send-email, but I'm sure I'd screw up even more with that because it directly sends out the patches rather than giving me an mbox file to look at.
I use "git format-patch" and send the postings by hand.
I don't trust automated tools to actually send the thing out, because as postmaster I've seen them screw up in so many monumental ways.
Arnd Bergmann
maintainerRe: [PATCH 08/27] asm-generic: add generic versions of common headers
Quoted 1 line · David Miller
I use "git format-patch" and send the postings by hand.
That's what I tried as well, but at least with --stdout, git-format-patch preserves the date and author (From) fields of the changesets, which should go in the body instead, while exporting the separate patches followed by 'quilt mail --mbox' drops these fields, in addition to occasionally screwing up the whole mbox format in the process.
I was hoping to find a simple tool to generate the mbox file in the right format for importing into the mail client, rather then importing every single file separately.
Arnd <><
David Miller
maintainerRe: [PATCH 08/27] asm-generic: add generic versions of common headers
From: Arnd Bergmann <[email protected]>
Date: Thu, 30 Apr 2009 19:07:45 +0200
Quoted 4 lines · David Miller
Quoted 1 line
I use "git format-patch" and send the postings by hand.
That's what I tried as well,
You didn't read what I said.
I extract the commit messages and patches using "git format-patch" merely as a formality, then I hand craft every aspect of the emails.
I never put "Date:" fields into the message body, that's rediculiously stupid. And it confuses patchwork as well. Just say NO.
If necessary I put the From: field in there to specify the author, or leave it out when it's me (which is %99.9999 of the time).
Arnd Bergmann
maintainerRe: [PATCH 08/27] asm-generic: add generic versions of common headers
Quoted 4 lines · David Miller
You didn't read what I said.
I extract the commit messages and patches using "git format-patch" merely as a formality, then I hand craft every aspect of the emails.
Right, this is what I do for smaller sets of patches, but I was hoping for something slightly simpler when sending out my 27 (plus the previous 18) patches.
Quoted 2 lines
I never put "Date:" fields into the message body, that's rediculiously stupid. And it confuses patchwork as well. Just say NO.
Right, fair enough. I figured it wouldn't hurt to have the date in the body because git-am can deal with it, but of course the problem was the wrong date in the header.
Arnd <><
David Miller
maintainerRe: [PATCH 08/27] asm-generic: add generic versions of common headers
From: Arnd Bergmann <[email protected]>
Date: Thu, 30 Apr 2009 19:34:58 +0200
Quoted 9 lines · David Miller
Quoted 4 lines
You didn't read what I said.
I extract the commit messages and patches using "git format-patch" merely as a formality, then I hand craft every aspect of the emails.
Right, this is what I do for smaller sets of patches, but I was hoping for something slightly simpler when sending out my 27 (plus the previous 18) patches.
You shouldn't be bombing the list with so many patches at once, another good reason to do it by hand :-)
Either consolidate or send in multiple phases after the initial patches of infrastructure and examples are OK'd by everyone.
Re: [PATCH 08/27] asm-generic: add generic versions of common headers
In reply to Arnd BergmannQuoted 10 lines · Arnd Bergmann
Quoted 2 lines · David Miller
Many sites are bouncing because the date on your emails is as much as two days in the past.
Any suggestions on which tool I should use? I've been burned by both 'quilt mail' and 'git-format-patch' this week and don't want to make any more experiments. I looked at git-send-email, but I'm sure I'd screw up even more with that because it directly sends out the patches rather than giving me an mbox file to look at.
I have been very pleased with git send-email.
I always send out the initial mail by hand "[PATCH 0/nn] xxx". When it has arrived I create a small shell script
so I can handcraft the options.
Typical shell script looks like this:
git send-email --quiet --no-chain-reply-to \
--in-reply-to "<[email protected]>" \
--to "Ingo Molnar <[email protected]>" \
--to "LKML <[email protected]>" \
00*
This works well when I have longer series of mail. And you can split it up so you do it in smaller groups of say 10 mails.
For a single patch or two I always do it manually.
Sam
Arnd Bergmann
maintainerPATCH 9/27 asm-generic: add generic NOMMU versions of some headers
In reply to Arnd BergmannMemory management in generic is highly architecture specific, but on NOMMU architectures, it is mostly trivial, so just add a default implementation in asm-generic that applies to all NOMMU architectures.
--- include/asm-generic/mmu.h | 14 +++++++++++ include/asm-generic/mmu_context.h | 45 +++++++++++++++++++++++++++++++++++++ include/asm-generic/pgalloc.h | 12 ++++++++++ include/asm-generic/segment.h | 9 +++++++ include/asm-generic/tlbflush.h | 18 ++++++++++++++ 5 files changed, 98 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/mmu.h create mode 100644 include/asm-generic/mmu_context.h create mode 100644 include/asm-generic/pgalloc.h create mode 100644 include/asm-generic/segment.h create mode 100644 include/asm-generic/tlbflush.h
include/asm-generic/mmu.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef __ASM_GENERIC_MMU_H +#define __ASM_GENERIC_MMU_H + +/* +* This is the mmu.h header for nommu implementations. +* Architectures with an MMU need something more complex. +*/ + +typedef struct { +struct vm_list_struct *vmlist; +unsigned long end_brk; +}mm_context_t ; + +#endif /* __ASM_GENERIC_MMU_H */
include/asm-generic/mmu_context.h new file +45 -0
45 lines not on this page · raw message
include/asm-generic/pgalloc.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __ASM_GENERIC_PGALLOC_H +#define __ASM_GENERIC_PGALLOC_H +/* +* an empty file is enough for a nommu architecture +*/ +#ifdef CONFIG_MMU +#error need to implement an architecture specific asm/pgalloc.h +#endif + +#define check_pgt_cache () do { } while (0) + +#endif /* __ASM_GENERIC_PGALLOC_H */
include/asm-generic/segment.h new file +9 -0
@@ -0,0 +1,9 @@ +#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 */
include/asm-generic/tlbflush.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef __ASM_GENERIC_TLBFLUSH_H +#define __ASM_GENERIC_TLBFLUSH_H +/* +* This is a dummy tlbflush implementation that can be used on all +* nommu architectures. +* If you have an MMU, you need to write your own functions. +*/ +#ifdef CONFIG_MMU +#error need to implement an architecture specific asm/tlbflush.h +#endif + +static inline void flush_tlb_mm (struct mm_struct *mm) +{ +BUG (); +} + + +#endif /* __ASM_GENERIC_TLBFLUSH_H */
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 10/27 asm-generic: rename page.h to getorder.h
In reply to Arnd BergmannThe current asm-generic/page.h only contains the get_order function. This renames the file to getorder.h to make room for a new page.h file that will be usable by all nommu architectures.
---
arch/alpha/include/asm/page.h | 2 +-
arch/arm/include/asm/page.h | 2 +-
arch/blackfin/include/asm/page.h | 2 +-
arch/cris/include/asm/page.h | 2 +-
arch/frv/include/asm/page.h | 2 +-
arch/h8300/include/asm/page.h | 2 +-
arch/m32r/include/asm/page.h | 2 +-
arch/m68k/include/asm/page_mm.h | 2 +-
arch/m68k/include/asm/page_no.h | 2 +-
arch/microblaze/include/asm/page.h | 2 +-
arch/mips/include/asm/page.h | 2 +-
arch/parisc/include/asm/page.h | 2 +-
arch/powerpc/include/asm/page_32.h | 2 +-
arch/powerpc/include/asm/page_64.h | 2 +-
arch/s390/include/asm/page.h | 2 +-
arch/sh/include/asm/page.h | 2 +-
arch/sparc/include/asm/page_32.h | 2 +-
arch/sparc/include/asm/page_64.h | 2 +-
arch/um/include/asm/page.h | 2 +-
arch/x86/include/asm/page.h | 2 +-
arch/xtensa/include/asm/page.h | 2 +-
include/asm-generic/{page.h => getorder.h} | 8 ++++----
22 files changed, 25 insertions(+), 25 deletions(-)
rename include/asm-generic/{page.h => getorder.h} (59%)arch/alpha/include/asm/page.h +1 -1
@@ -93,6 +93,6 @@ typedef struct page *pgtable_t; VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _ALPHA_PAGE_H */
arch/arm/include/asm/page.h +1 -1
@@ -209,6 +209,6 @@ typedef struct page *pgtable_t;#define ARCH_SLAB_MINALIGN 8#endif -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif
arch/blackfin/include/asm/page.h +1 -1
@@ -81,7 +81,7 @@ extern unsigned long memory_end;#define virt_addr_valid (kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ ((void *)(kaddr) < (void *)memory_end)) -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* __ASSEMBLY__ */
arch/cris/include/asm/page.h +1 -1
@@ -68,7 +68,7 @@ typedef struct page *pgtable_t; VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _CRIS_PAGE_H */
arch/frv/include/asm/page.h +1 -1
@@ -73,6 +73,6 @@ extern unsigned long max_pfn;#endif /* __ASSEMBLY__ */ #include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _ASM_PAGE_H */
arch/h8300/include/asm/page.h +1 -1
@@ -73,6 +73,6 @@ extern unsigned long memory_end;#endif /* __ASSEMBLY__ */ #include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _H8300_PAGE_H */
arch/m32r/include/asm/page.h +1 -1
@@ -82,6 +82,6 @@ typedef struct page *pgtable_t;#define devmem_is_allowed (x) 1#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _ASM_M32R_PAGE_H */
arch/m68k/include/asm/page_mm.h +1 -1
@@ -223,6 +223,6 @@ static inline __attribute_const__ int __virt_to_node_shift(void)#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _M68K_PAGE_H */
arch/m68k/include/asm/page_no.h +1 -1
@@ -72,6 +72,6 @@ extern unsigned long memory_end;#endif /* __ASSEMBLY__ */ -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _M68KNOMMU_PAGE_H */
arch/microblaze/include/asm/page.h +1 -1
@@ -135,6 +135,6 @@ extern unsigned int memory_size;#endif /* __KERNEL__ */ #include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _ASM_MICROBLAZE_PAGE_H */
arch/mips/include/asm/page.h +1 -1
@@ -186,6 +186,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;#define CAC_ADDR (addr) ((addr) - UNCAC_BASE + PAGE_OFFSET)#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _ASM_PAGE_H */
arch/parisc/include/asm/page.h +1 -1
@@ -159,6 +159,6 @@ extern int npmem_ranges; VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _PARISC_PAGE_H */
arch/powerpc/include/asm/page_32.h +1 -1
@@ -41,7 +41,7 @@ extern void clear_pages(void *page, int order);static inline void clear_page (void *page) {clear_pages (page,0 ); }extern void copy_page (void *to,void *from); -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #define PGD_T_LOG2 (__builtin_ffs(sizeof(pgd_t)) - 1)#define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1)
arch/powerpc/include/asm/page_64.h +1 -1
@@ -180,6 +180,6 @@ do { \ (test_thread_flag (TIF_32BIT ) ? \ VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64) -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _ASM_POWERPC_PAGE_64_H */
arch/s390/include/asm/page.h +1 -1
@@ -150,7 +150,7 @@ void arch_alloc_page(struct page *page, int order); VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #define __HAVE_ARCH_GATE_AREA 1
arch/sh/include/asm/page.h +1 -1
@@ -163,7 +163,7 @@ typedef struct page *pgtable_t; VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> /* vDSO support */ #ifdef CONFIG_VSYSCALL
arch/sparc/include/asm/page_32.h +1 -1
@@ -152,6 +152,6 @@ extern unsigned long pfn_base; VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _SPARC_PAGE_H */
arch/sparc/include/asm/page_64.h +1 -1
@@ -132,6 +132,6 @@ typedef struct page *pgtable_t;#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* _SPARC64_PAGE_H */
arch/um/include/asm/page.h +1 -1
@@ -116,7 +116,7 @@ extern unsigned long uml_physmem;#define virt_addr_valid (v) pfn_valid(phys_to_pfn(__pa(v)))#include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #endif /* __ASSEMBLY__ */ #endif /* __UM_PAGE_H */
arch/x86/include/asm/page.h +1 -1
@@ -56,7 +56,7 @@ extern bool __virt_addr_valid(unsigned long kaddr);#endif /* __ASSEMBLY__ */ #include <asm-generic/memory_model.h> -#include <asm-generic/page.h> +#include <asm-generic/getorder.h> #define __HAVE_ARCH_GATE_AREA 1
arch/xtensa/include/asm/page.h +1 -1
@@ -129,7 +129,7 @@ static inline __attribute_const__ int get_order(unsigned long size)#else -# include <asm-generic/page.h> +# include <asm-generic/getorder.h> #endif
include/asm-generic/getorder.h renamed from include/asm-generic/page.h +4 -4
@@ -1,12 +1,12 @@ -#ifndef _ASM_GENERIC_PAGE_H -#define _ASM_GENERIC_PAGE_H +#ifndef __ASM_GENERIC_GETORDER_H +#define __ASM_GENERIC_GETORDER_H #ifndef __ASSEMBLY__ #include <linux/compiler.h> /* Pure 2^n version of get_order */ -static __inline__ __attribute_const__ int get_order(unsigned long size) +static inline __attribute_const__ int get_order(unsigned long size) { int order;
@@ -21,4 +21,4 @@ static __inline__ __attribute_const__ int get_order(unsigned long size)#endif /* __ASSEMBLY__ */ -#endif /* _ASM_GENERIC_PAGE_H */ +#endif /* __ASM_GENERIC_GETORDER_H */
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 11/27 asm-generic: add generic page.h
In reply to Arnd BergmannArchitectures that have no mmu should not have to describe their page tables. This adds a new page.h file based on the existing nommu architectures that adds a lot of dummy definitions to let you correctly compile a nommu kernel.
--- include/asm-generic/page.h | 99 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 99 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/page.h
include/asm-generic/page.h new file +99 -0
@@ -0,0 +1,99 @@ +#ifndef __ASM_GENERIC_PAGE_H +#define __ASM_GENERIC_PAGE_H +/* +* Generic page.h implementation, for NOMMU architectures. +* This provides the dummy definitions for the memory management. +*/ + +#ifdef CONFIG_MMU +#error need to prove a real asm/page.h +#endif + + +/* PAGE_SHIFT determines the page size */ + +#define PAGE_SHIFT 12 +#ifdef __ASSEMBLY__ +#define PAGE_SIZE (1 << PAGE_SHIFT) +#else +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#endif +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#include <asm/setup.h> + +#ifndef __ASSEMBLY__ + +#define get_user_page (vaddr) __get_free_page(GFP_KERNEL) +#define free_user_page (page, addr) free_page(addr) + +#define clear_page (page) memset((page), 0, PAGE_SIZE) +#define copy_page (to,from) memcpy((to), (from), PAGE_SIZE) + +#define clear_user_page (page, vaddr, pg) clear_page(page) +#define copy_user_page (to, from, vaddr, pg) copy_page(to, from) + +/* +* These are used to make use of C type-checking.. +*/ +typedef struct { +unsigned long pte; +}pte_t ; +typedef struct { +unsigned long pmd[16 ]; +}pmd_t ; +typedef struct { +unsigned long pgd; +}pgd_t ; +typedef struct { +unsigned long pgprot; +}pgprot_t ; +typedef struct page *pgtable_t ; + +#define pte_val (x) ((x).pte) +#define pmd_val (x) ((&x)->pmd[0]) +#define pgd_val (x) ((x).pgd) +#define pgprot_val (x) ((x).pgprot) + +#define __pte (x) ((pte_t) { (x) } ) +#define __pmd (x) ((pmd_t) { (x) } ) +#define __pgd (x) ((pgd_t) { (x) } ) +#define __pgprot (x) ((pgprot_t) { (x) } ) + +extern unsigned long memory_start; +extern unsigned long memory_end; + +#endif /* !__ASSEMBLY__ */ + +#ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS +#define PAGE_OFFSET (CONFIG_KERNEL_RAM_BASE_ADDRESS) +#else +#define PAGE_OFFSET (0) +#endif + +#ifndef __ASSEMBLY__ + +#define __va (x) ((void *)((unsigned long)(x) + PAGE_OFFSET)) +#define __pa (x) ((unsigned long) (x) - PAGE_OFFSET) + +#define virt_to_pfn (kaddr) (__pa(kaddr) >> PAGE_SHIFT) +#define pfn_to_virt (pfn) __va((pfn) << PAGE_SHIFT) + +#define virt_to_page (addr) (mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT)) +#define page_to_virt (page) ((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET) + +#ifndef page_to_phys +#define page_to_phys (page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) +#endif + +#define pfn_valid (pfn) ((pfn) < max_mapnr) + +#define virt_addr_valid (kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ + ((void *)(kaddr) < (void *)memory_end)) + +#endif /* __ASSEMBLY__ */ + +#include <asm-generic/memory_model.h> +#include <asm-generic/getorder.h> + +#endif /* __ASM_GENERIC_PAGE_H */
Signature · 1 line
1.5.6.3
Geert Uytterhoeven
maintainerRe: [PATCH 11/27] asm-generic: add generic page.h
Quoted 28 lines · Arnd Bergmann
Architectures that have no mmu should not have to describe their page tables. This adds a new
page.hfile based on the existing nommu architectures that adds a lot of dummy definitions to let you correctly compile a nommu kernel.Signed-off-by Arnd Bergmann <[email protected]>---
include/asm-generic/page.h | 99 ++++++++++++++++++++++++++++++++++++++++++++1 files changed, 99 insertions(+), 0 deletions(-)create mode 100644
include/asm-generic/page.hinclude/asm-generic/page.h new file +10
-0@@ -0,0 +1,99 @@ +#ifndef __ASM_GENERIC_PAGE_H +#define __ASM_GENERIC_PAGE_H +/* +* Generic page.h implementation, for NOMMU architectures. +* This provides the dummy definitions for the memory management. +*/ + +#ifdef CONFIG_MMU +#error need to prove a real asm/page.h +#endif
include/asm-generic/page.h line 20
Quoted 10 lines
include/asm-generic/page.h new file +10
-0+ + +/* PAGE_SHIFT determines the page size */ + +#define PAGE_SHIFT 12 +#ifdef __ASSEMBLY__ +#define PAGE_SIZE (1 << PAGE_SHIFT) +#else +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#endif
#include <linux/const.h> and use (_AC(1, UL) << PAGE_SHIFT)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerPATCH 12/27 asm-generic: add a NOMMU uaccess.h
In reply to Arnd BergmannThis uaccess.h can be used by all NOMMU architectures, but it does not provide exception handlers that would be needed for an architecture with an MMU.
---
arch/parisc/include/asm/uaccess.h | 2 +-
arch/sparc/include/asm/uaccess_64.h | 2 +-
.../asm-generic/{uaccess.h => uaccess-unaligned.h} | 6 +-
include/asm-generic/uaccess.h | 235 +++++++++++++++++---
4 files changed, 214 insertions(+), 31 deletions(-)
rename include/asm-generic/{uaccess.h => uaccess-unaligned.h} (82%) rewrite include/asm-generic/uaccess.h (96%)
arch/parisc/include/asm/uaccess.h +1 -1
@@ -7,7 +7,7 @@#include <asm/page.h> #include <asm/system.h> #include <asm/cache.h> -#include <asm-generic/uaccess.h> +#include <asm-generic/uaccess-unaligned.h> #define VERIFY_READ 0#define VERIFY_WRITE 1
arch/sparc/include/asm/uaccess_64.h +1 -1
@@ -12,7 +12,7 @@#include <asm/asi.h> #include <asm/system.h> #include <asm/spitfire.h> -#include <asm-generic/uaccess.h> +#include <asm-generic/uaccess-unaligned.h> #endif #ifndef __ASSEMBLY__
include/asm-generic/uaccess-unaligned.h renamed from include/asm-generic/uaccess.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef _ASM_GENERIC_UACCESS_H_ -#define _ASM_GENERIC_UACCESS_H_ +#ifndef __ASM_GENERIC_UACCESS_UNALIGNED_H +#define __ASM_GENERIC_UACCESS_UNALIGNED_H/* * This macro should be used instead of __get_user() when accessing
@@ -23,4 +23,4 @@__copy_to_user ((ptr), &__x,sizeof (*(ptr))) ? -EFAULT :0 ; \ }) -#endif /* _ASM_GENERIC_UACCESS_H */ +#endif /* __ASM_GENERIC_UACCESS_UNALIGNED_H */
include/asm-generic/uaccess.h +209 -26
235 lines not on this page · raw message
Signature · 1 line
1.5.6.3
Michal Simek
maintainerRe: [PATCH 12/27] asm-generic: add a NOMMU uaccess.h
Quoted 276 lines · Arnd Bergmann
This
uaccess.hcan be used by all NOMMU architectures, but it does not provide exception handlers that would be needed for an architecture with an MMU.Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Remis Lima Baima <[email protected]>--- arch/parisc/include/asm/uaccess.h | 2 +- arch/sparc/include/asm/uaccess_64.h | 2 +- .../asm-generic/{uaccess.h => uaccess-unaligned.h} | 6 +- include/asm-generic/uaccess.h | 235 +++++++++++++++++--- 4 files changed, 214 insertions(+), 31 deletions(-) rename include/asm-generic/{uaccess.h => uaccess-unaligned.h} (82%)rewrite
include/asm-generic/uaccess.h(96%)arch/parisc/include/asm/uaccess.h +1
-1@@ -7,7 +7,7 @@#include <asm/page.h> #include <asm/system.h> #include <asm/cache.h> -#include <asm-generic/uaccess.h> +#include <asm-generic/uaccess-unaligned.h> #define VERIFY_READ 0#define VERIFY_WRITE 1arch/sparc/include/asm/uaccess_64.h +1
-1@@ -12,7 +12,7 @@#include <asm/asi.h> #include <asm/system.h> #include <asm/spitfire.h> -#include <asm-generic/uaccess.h> +#include <asm-generic/uaccess-unaligned.h> #endif #ifndef __ASSEMBLY__include/asm-generic/uaccess-unaligned.h renamed from include/asm-generic/uaccess.h +3
-3@@ -1,5 +1,5 @@ -#ifndef _ASM_GENERIC_UACCESS_H_ -#define _ASM_GENERIC_UACCESS_H_ +#ifndef __ASM_GENERIC_UACCESS_UNALIGNED_H +#define __ASM_GENERIC_UACCESS_UNALIGNED_H/* * This macro should be used instead of __get_user() when accessing @@ -23,4 +23,4 @@__copy_to_user ((ptr), &__x,sizeof (*(ptr))) ? -EFAULT :0 ; \ }) -#endif /* _ASM_GENERIC_UACCESS_H */ +#endif /* __ASM_GENERIC_UACCESS_UNALIGNED_H */ include/asm-generic/uaccess.h +182
-26@@ -1,26 +1,209 @@ -#ifndef _ASM_GENERIC_UACCESS_H_ -#define _ASM_GENERIC_UACCESS_H_ - -/* -* This macro should be used instead of __get_user() when accessing -* values at locations that are not known to be aligned. -*/ -#define __get_user_unaligned (x, ptr) \ -({ \ - __typeof__ (*(ptr)) __x; \ - __copy_from_user(&__x, (ptr), sizeof(*(ptr))) ? -EFAULT : 0; \ - (x) = __x; \ -}) - - -/* -* This macro should be used instead of __put_user() when accessing -* values at locations that are not known to be aligned. -*/ -#define __put_user_unaligned (x, ptr) \ -({ \ - __typeof__ (*(ptr)) __x = (x); \ - __copy_to_user((ptr), &__x, sizeof(*(ptr))) ? -EFAULT : 0; \ -}) - -#endif /* _ASM_GENERIC_UACCESS_H */ +#ifndef __ASM_GENERIC_UACCESS_H +#define __ASM_GENERIC_UACCESS_H + +/* +* User space memory access functions, these should work +* on a ny machine that has kernel and user data in the same +* address space, e.g. all NOMMU machines. +*/ +#include <linux/sched.h> +#include <linux/mm.h> +#include <linux/string.h> + +#include <asm/segment.h> + +#ifndef get_fs +#define MAKE_MM_SEG (s) ((mm_segment_t) { (s) }) +#define KERNEL_DS MAKE_MM_SEG(~0UL) +#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) + +#define get_ds () (KERNEL_DS) +#define get_fs () (current_thread_info()->addr_limit) + +static inline void set_fs (mm_segment_t fs) +{ +current_thread_info ()->addr_limit = fs; +} +#endif + +#define segment_eq (a, b) ((a).seg == (b).seg) + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +#define access_ok (type, addr, size) _access_ok((unsigned long)(addr),(size)) + +/* +* The architecture should really override this if possible, at least +* doing a check on the get_fs() +*/ +#ifndef _access_ok +static inline int _access_ok (unsigned long addr,unsigned long size) +{ +return 1 ; +} +#endif + +/* +* The exception table consists of pairs of addresses: the first is the +* address of an instruction that is allowed to fault, and the second is +* the address at which the program should continue. No registers are +* modified, so it is entirely up to the continuation code to figure out +* what to do. +* +* All the routines below use bits of fixup code that are out of line +* with the main instruction path. This means when everything is well, +* we don't even have to jump over them. Further, they do not intrude +* on our cache or tlb entries. +*/ + +struct exception_table_entry +{ +unsigned long insn, fixup; +}; + +/* Returns 0 if exception not found and fixup otherwise. */ +extern unsigned long search_exception_table (unsigned long ); + +/* +* These are the main single-value transfer routines. They automatically +* use the right size if we just have the right pointer type. +*/ +#ifndef __put_user +#define __put_user (x, ptr) \ +({ \ + int __pu_err = 0; \ + typeof(*(ptr)) __pu_val = (x); \ + switch (sizeof (*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + *(ptr) = (__pu_val); \ + break; \ + case 8: \ + memcpy(ptr, &__pu_val, sizeof (*(ptr)));\ + break; \ + default: \ + __pu_err = __put_user_bad(); \ + break; \ + } \ + __pu_err; \ +}) +extern int __put_user_bad (void ); +#endif + +#define put_user (x, ptr) ( \ + access_ok(VERIFY_WRITE, ptr, sizeof (*ptr)) ? \ + __put_user(x, ptr) : \ + -EFAULT) + +#ifndef __get_user +#define __get_user (x, ptr) \ +({ \ + int __gu_err = 0; \ + unsigned long __gu_val = (unsigned long)*ptr; \ + switch (sizeof(*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + case 8: \ + break; \ + default: \ + __gu_err = __get_user_bad(); \ + __gu_val = 0; \ + break; \ + } \ + (x) = (typeof(*ptr))__gu_val; \ + __gu_err; \ +}) +extern int __get_user_bad (void ); +#endif + +#define get_user (x, ptr) ( \ + access_ok(VERIFY_READ, ptr, sizeof (*ptr)) ? \ + __get_user(x, ptr) : \ + -EFAULT) + +#define __copy_from_user (to, from, n) (memcpy(to, from, n), 0) +#define __copy_to_user (to, from, n) (memcpy(to, from, n), 0) +#define __copy_to_user_inatomic __copy_to_user +#define __copy_from_user_inatomic __copy_from_user + +#define copy_to_user_ret (to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; }) + +#define copy_from_user_ret (to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; }) + +static inline long copy_from_user (void *to, +const void __user * from,unsigned long n) +{ +if (access_ok (VERIFY_READ , from, n)) +__copy_from_user (to, from, n); +else +return n; +return 0 ; +} + +static inline long copy_to_user (void *to, +const void __user * from,unsigned long n) +{ +if (access_ok (VERIFY_WRITE , to, n)) +__copy_to_user (to, from, n); +else +return n; +return 0 ; +} + +/* +* Copy a null terminated string from userspace. +*/ + +static inline long +__do_strncpy_from_user (char *dst,const char __user *src,long count) +{ +char *tmp; +strncpy (dst, src, count); +for (tmp = dst; *tmp && count >0 ; tmp++, count--) + ; +return (tmp - dst); +} + +static inline long +strncpy_from_user (char *dst,const char __user *src,long count) +{ +if (!access_ok (VERIFY_READ , src,1 )) +return -EFAULT ; +return __do_strncpy_from_user (dst, src, count); +} + +static inline long +__strncpy_from_user (char *dst,const char __user *src,long count) +{ +return __do_strncpy_from_user (dst, src, count); +}
include/asm-generic/uaccess.h line 192
Quoted 10 lines
include/asm-generic/uaccess.h +10
-0+ +/* +* Return the size of a string (including the ending 0) +* +* Return 0 on exception, a value greater than N if too long +*/ +static inline long strnlen_user (const char *src,long n) +{ +return strlen (src) +1 ; +}
Here is the cast problem too.
Michal
Quoted 17 lines
include/asm-generic/uaccess.h +17
-0+ +#define strlen_user (str) strnlen_user(str, 32767) + +/* +* Zero Userspace +*/ + +static inline unsigned long +__clear_user (void *to,unsigned long n) +{ +memset (to,0 , n); +return 0 ; +} + +#define clear_user (to, n) __clear_user(to, n) + +#endif /* __ASM_GENERIC_UACCESS_H */
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Re: [PATCH 12/27] asm-generic: add a NOMMU uaccess.h
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
include/asm-generic/uaccess.h +6
-0+#define put_user (x, ptr) ( \ + access_ok(VERIFY_WRITE, ptr, sizeof (*ptr)) ? \ + __put_user(x, ptr) : \ + -EFAULT) + +#ifndef __get_user
include/asm-generic/uaccess.h line 110
Quoted 10 lines
include/asm-generic/uaccess.h +10
-0+#define __get_user (x, ptr) \ +({ \ + int __gu_err = 0; \ + unsigned long __gu_val = (unsigned long)*ptr; \ + switch (sizeof(*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + case 8: \ + break; \
If sizeof(unsigned long) = 4, then how can the sizeof(*(ptr)) > 4 case work?
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
A message that is not in the archive (sent off-list or not yet received): [email protected]
Arnd Bergmann
maintainerRe: [PATCH 12/27] asm-generic: add a NOMMU uaccess.h
Quoted 8 lines · Michal Simek
Quoted 8 lines
include/asm-generic/uaccess.h +8
-0+#ifndef __put_user +#define __put_user (x, ptr) \ +({ \ + int __pu_err = 0; \ + typeof(*(ptr)) __pu_val = (x); \ + switch (sizeof (*(ptr))) { \ + case 1: \ + case 2: \
Quoted 8 lines
Quoted 5 lines
+ case 4: \
+ *(ptr) = (__pu_val); \
+ break; \
+ case 8: \
+memcpy(ptr, &__pu_val, sizeof (*(ptr)));\potential cast problem
Yes, I'm looking into this already, probably will do something based on the s390 code, which seems to do this correctly.
Quoted 7 lines
Quoted 4 lines
+#define
put_user(x, ptr)( \
+access_ok(VERIFY_WRITE, ptr, sizeof (*ptr))? \
+__put_user(x, ptr): \
+-EFAULT)IMHO write it as inline function with type checking.
Unfortunately, this doesn't work because of the callin
conventions: __put_user needs to know the type of ptr, so it has to be a macro.
Arnd <><
Michal Simek
maintainerRe: [PATCH 12/27] asm-generic: add a NOMMU uaccess.h
Quoted 25 lines · Arnd Bergmann
Quoted 7 lines · Michal Simek
Quoted 7 lines
include/asm-generic/uaccess.h +7
-0+#ifndef __put_user +#define __put_user (x, ptr) \ +({ \ + int __pu_err = 0; \ + typeof(*(ptr)) __pu_val = (x); \ + switch (sizeof (*(ptr))) { \ + case 1: \Quoted 8 lines
include/asm-generic/uaccess.h line 84
Quoted 6 lines
include/asm-generic/uaccess.h +6
-0+case 2 : \ +case 4 : \ + *(ptr) = (__pu_val); \ +break ; \ +case 8 : \ +memcpy (ptr, &__pu_val,sizeof (*(ptr)));\potential cast problem
Yes, I'm looking into this already, probably will do something based on the s390 code, which seems to do this correctly.
Quoted 5 lines
Quoted 4 lines
include/asm-generic/uaccess.h +4
-0+#define put_user (x, ptr) ( \ + access_ok(VERIFY_WRITE, ptr, sizeof (*ptr)) ? \ + __put_user(x, ptr) : \ + -EFAULT)
Quoted 5 lines
Quoted 1 line
IMHO write it as inline function with type checking.
Unfortunately, this doesn't work because of the callin
conventions:__put_userneeds to know the type of ptr, so it has to be a macro.
yes, I am looking on it too.
Michal
Quoted 2 lines
Arnd <><
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Arnd Bergmann
maintainerPATCH v3 1/1 asm-generic: add a generic uaccess.h
This adds a new asm-generic/uaccess.h file that should be usable by both all NOMMU architectures out of the box. Architectures with an MMU should override the __access_ok(), __copy_from_user() and __copy_to_user definitions with their own functions to provide correct exception handling.
include/asm-generic/uaccess.h new file +319 -0
@@ -0,0 +1,319 @@ +#ifndef __ASM_GENERIC_UACCESS_H +#define __ASM_GENERIC_UACCESS_H + +/* +* User space memory access functions, these should work +* on a ny machine that has kernel and user data in the same +* address space, e.g. all NOMMU machines. +*/ +#include <linux/sched.h> +#include <linux/mm.h> +#include <linux/string.h> + +#include <asm/segment.h> + +#ifndef get_fs +#define MAKE_MM_SEG (s) ((mm_segment_t) { (s) }) +#define KERNEL_DS MAKE_MM_SEG(~0UL) +#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) + +#define get_ds () (KERNEL_DS) +#define get_fs () (current_thread_info()->addr_limit) + +static inline void set_fs (mm_segment_t fs) +{ +current_thread_info ()->addr_limit = fs; +} +#endif + +#define segment_eq (a, b) ((a).seg == (b).seg) + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +#define access_ok (type, addr, size) __access_ok((unsigned long)(addr),(size)) + +/* +* The architecture should really override this if possible, at least +* doing a check on the get_fs() +*/ +#ifndef __access_ok +static inline int __access_ok (unsigned long addr,unsigned long size) +{ +return 1 ; +} +#endif + +/* +* The exception table consists of pairs of addresses: the first is the +* address of an instruction that is allowed to fault, and the second is +* the address at which the program should continue. No registers are +* modified, so it is entirely up to the continuation code to figure out +* what to do. +* +* All the routines below use bits of fixup code that are out of line +* with the main instruction path. This means when everything is well, +* we don't even have to jump over them. Further, they do not intrude +* on our cache or tlb entries. +*/ + +struct exception_table_entry +{ +unsigned long insn, fixup; +}; + +/* Returns 0 if exception not found and fixup otherwise. */ +extern unsigned long search_exception_table (unsigned long ); + +/* +* architectures with an MMU should override these two +*/ +#ifndef __copy_from_user +static inline __must_check long __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 +default : +break ; + } + } + +memcpy (to, (const void __force *)from, n); +return 0 ; +} +#endif + +#ifndef __copy_to_user +static inline __must_check long __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 ; +} +#endif + +/* +* These are the main single-value transfer routines. They automatically +* use the right size if we just have the right pointer type. +* This version just falls back to copy_{from,to}_user, which should +* provide a fast-path for small values. +*/ +#define __put_user (x, ptr) \ +({ \ + __typeof__(*(ptr)) __x = (x); \ + int __pu_err = -EFAULT; \ + __chk_user_ptr(ptr); \ + switch (sizeof (*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + case 8: \ + __pu_err = __put_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + break; \ + default: \ + __put_user_bad(); \ + break; \ + } \ + __pu_err; \ +}) + +#define put_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __put_user(x, ptr) : \ + -EFAULT; \ +}) + +static inline int __put_user_fn (size_t size,void __user *ptr,void *x) +{ + size =__copy_to_user (ptr, x, size); +return size ? -EFAULT : size; +} + +extern int __put_user_bad (void ) __attribute__((noreturn)); + +#define __get_user (x, ptr) \ +({ \ + int __gu_err = -EFAULT; \ + __chk_user_ptr(ptr); \ + switch (sizeof(*(ptr))) { \ + case 1: { \ + unsigned char __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 2: { \ + unsigned short __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 4: { \ + unsigned int __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 8: { \ + unsigned long long __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + default: \ + __get_user_bad(); \ + break; \ + } \ + __gu_err; \ +}) + +#define get_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __get_user(x, ptr) : \ + -EFAULT; \ +}) + +static inline int __get_user_fn (size_t size,const void __user *ptr,void *x) +{ + size =__copy_from_user (x, ptr, size); +return size ? -EFAULT : size; +} + +extern int __get_user_bad (void ) __attribute__((noreturn)); + +#ifndef __copy_from_user_inatomic +#define __copy_from_user_inatomic __copy_from_user +#endif + +#ifndef __copy_to_user_inatomic +#define __copy_to_user_inatomic __copy_to_user +#endif + +static inline long copy_from_user (void *to, +const void __user * from,unsigned long n) +{ +might_sleep (); +if (__access_ok (from, n)) +return __copy_from_user (to, from, n); +else +return n; +} + +static inline long copy_to_user (void __user *to, +const void *from,unsigned long n) +{ +might_sleep (); +if (__access_ok (to, n)) +return __copy_to_user (to, from, n); +else +return n; +} + +/* +* Copy a null terminated string from userspace. +*/ +#ifndef __strncpy_from_user +static inline long +__strncpy_from_user (char *dst,const char __user *src,long count) +{ +char *tmp; +strncpy (dst, (const char __force *)src, count); +for (tmp = dst; *tmp && count >0 ; tmp++, count--) + ; +return (tmp - dst); +} +#endif + +static inline long +strncpy_from_user (char *dst,const char __user *src,long count) +{ +if (!__access_ok (src,1 )) +return -EFAULT ; +return __strncpy_from_user (dst, src, count); +} + +/* +* Return the size of a string (including the ending 0) +* +* Return 0 on exception, a value greater than N if too long +*/ +#ifndef strnlen_user +static inline long strnlen_user (const char __user *src,long n) +{ +return strlen ((void *__force )src) +1 ; +} +#endif + +static inline long strlen_user (const char __user *src) +{ +return strnlen_user (src,32767 ); +} + +/* +* Zero Userspace +*/ +#ifndef __clear_user +static inline __must_check unsigned long +__clear_user (void __user *to,unsigned long n) +{ +memset ((void __force *)to,0 , n); +return 0 ; +} +#endif + +static inline __must_check unsigned long +clear_user (void __user *to,unsigned long n) +{ +might_sleep (); +if (!__access_ok (to, n)) +return n; + +return __clear_user (to, n); +} + +#endif /* __ASM_GENERIC_UACCESS_H */
Michal Simek
maintainerRe: [PATCH V3] asm-generic: add a generic uaccess.h
Quoted 20 lines · Arnd Bergmann
This adds a new
asm-generic/uaccess.hfile that should be usable by both all NOMMU architectures out of the box. Architectures with an MMU should override the__access_ok(),__copy_from_user()and__copy_to_userdefinitions with their own functions to provide correct exception handling.Signed-off-by Arnd Bergmann <[email protected]>include/asm-generic/uaccess.h new file +6
-0@@ -0,0 +1,319 @@ +#ifndef __ASM_GENERIC_UACCESS_H +#define __ASM_GENERIC_UACCESS_H + +/* +* User space memory access functions, these should work +* on a ny machine that has kernel and user data in the same
include/asm-generic/uaccess.h line 16
Quoted 10 lines
include/asm-generic/uaccess.h new file +10
-0+* address space, e.g. all NOMMU machines. +*/ +#include <linux/sched.h> +#include <linux/mm.h> +#include <linux/string.h> + +#include <asm/segment.h> + +#ifndef get_fs +#define MAKE_MM_SEG (s) ((mm_segment_t) { (s) })
one line above -> get_fs could be defined in different space and this arch could use MAKE_MM_SEG too -> for example powerpc.
Quoted 7 lines
include/asm-generic/uaccess.h new file +7
-0+#define KERNEL_DS MAKE_MM_SEG(~0UL) +#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) + +#define get_ds () (KERNEL_DS) +#define get_fs () (current_thread_info()->addr_limit) + +static inline void set_fs (mm_segment_t fs)
include/asm-generic/uaccess.h line 33
Quoted 10 lines
include/asm-generic/uaccess.h new file +10
-0+{ +current_thread_info ()->addr_limit = fs; +} +#endif + +#define segment_eq (a, b) ((a).seg == (b).seg) + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 +
Not sure if any arch do READ/WRITE check but if yes.
#ifndef access_ok
include/asm-generic/uaccess.h line 34
Quoted 1 line
include/asm-generic/uaccess.h new file +1
-0+#define access_ok (type, addr, size) __access_ok((unsigned long)(addr),(size))
#endif
include/asm-generic/uaccess.h line 39
Quoted 5 lines
include/asm-generic/uaccess.h new file +5
-0+ +/* +* The architecture should really override this if possible, at least +* doing a check on the get_fs() +*/
If they should really override it but why write it here.
Quoted 170 lines
include/asm-generic/uaccess.h new file +170
-0+#ifndef __access_ok +static inline int __access_ok (unsigned long addr,unsigned long size) +{ +return 1 ; +} +#endif + +/* +* The exception table consists of pairs of addresses: the first is the +* address of an instruction that is allowed to fault, and the second is +* the address at which the program should continue. No registers are +* modified, so it is entirely up to the continuation code to figure out +* what to do. +* +* All the routines below use bits of fixup code that are out of line +* with the main instruction path. This means when everything is well, +* we don't even have to jump over them. Further, they do not intrude +* on our cache or tlb entries. +*/ + +struct exception_table_entry +{ +unsigned long insn, fixup; +}; + +/* Returns 0 if exception not found and fixup otherwise. */ +extern unsigned long search_exception_table (unsigned long ); + +/* +* architectures with an MMU should override these two +*/ +#ifndef __copy_from_user +static inline __must_check long __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 +default : +break ; + } + } + +memcpy (to, (const void __force *)from, n); +return 0 ; +} +#endif + +#ifndef __copy_to_user +static inline __must_check long __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 ; +} +#endif + +/* +* These are the main single-value transfer routines. They automatically +* use the right size if we just have the right pointer type. +* This version just falls back to copy_{from,to}_user, which should +* provide a fast-path for small values. +*/ +#define __put_user (x, ptr) \ +({ \ + __typeof__(*(ptr)) __x = (x); \ + int __pu_err = -EFAULT; \ + __chk_user_ptr(ptr); \ + switch (sizeof (*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + case 8: \ + __pu_err = __put_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + break; \ + default: \ + __put_user_bad(); \ + break; \ + } \ + __pu_err; \ +}) + +#define put_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __put_user(x, ptr) : \ + -EFAULT; \ +}) + +static inline int __put_user_fn (size_t size,void __user *ptr,void *x) +{ + size =__copy_to_user (ptr, x, size); +return size ? -EFAULT : size; +} + +extern int __put_user_bad (void ) __attribute__((noreturn)); + +#define __get_user (x, ptr) \ +({ \ + int __gu_err = -EFAULT; \ + __chk_user_ptr(ptr); \ + switch (sizeof(*(ptr))) { \ + case 1: { \ + unsigned char __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 2: { \ + unsigned short __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 4: { \ + unsigned int __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 8: { \ + unsigned long long __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + default: \ + __get_user_bad(); \ + break; \ + } \
include/asm-generic/uaccess.h line 219
Quoted 10 lines
include/asm-generic/uaccess.h new file +10
-0+ __gu_err; \ +}) + +#define get_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __get_user(x, ptr) : \ + -EFAULT; \ +})
I am getting here (for put_user macro too) any error on noMMU. :-(
Quoted 37 lines
include/asm-generic/uaccess.h new file +37
-0+ +static inline int __get_user_fn (size_t size,const void __user *ptr,void *x) +{ + size =__copy_from_user (x, ptr, size); +return size ? -EFAULT : size; +} + +extern int __get_user_bad (void ) __attribute__((noreturn)); + +#ifndef __copy_from_user_inatomic +#define __copy_from_user_inatomic __copy_from_user +#endif + +#ifndef __copy_to_user_inatomic +#define __copy_to_user_inatomic __copy_to_user +#endif + +static inline long copy_from_user (void *to, +const void __user * from,unsigned long n) +{ +might_sleep (); +if (__access_ok (from, n)) +return __copy_from_user (to, from, n); +else +return n; +} + +static inline long copy_to_user (void __user *to, +const void *from,unsigned long n) +{ +might_sleep (); +if (__access_ok (to, n)) +return __copy_to_user (to, from, n); +else +return n; +} +
include/asm-generic/uaccess.h line 266
Quoted 10 lines
include/asm-generic/uaccess.h new file +10
-0+/* +* Copy a null terminated string from userspace. +*/ +#ifndef __strncpy_from_user +static inline long +__strncpy_from_user (char *dst,const char __user *src,long count) +{ +char *tmp; +strncpy (dst, (const char __force *)src, count); +for (tmp = dst; *tmp && count >0 ; tmp++, count--)
I have the same code here with ++tmp, --count.
include/asm-generic/uaccess.h line 278
Quoted 12 lines
include/asm-generic/uaccess.h new file +12
-0+ ; + return (tmp - dst); +} +#endif + +static inline long +strncpy_from_user (char *dst,const char __user *src,long count) +{ +if (!__access_ok (src,1 )) +return -EFAULT ; +return __strncpy_from_user (dst, src, count); +}
Is it a good place to add might_sleep() and unlikely(+ some other cases) too? We have almost the same code.
Michal
Quoted 41 lines
include/asm-generic/uaccess.h new file +41
-0+ +/* +* Return the size of a string (including the ending 0) +* +* Return 0 on exception, a value greater than N if too long +*/ +#ifndef strnlen_user +static inline long strnlen_user (const char __user *src,long n) +{ +return strlen ((void *__force )src) +1 ; +} +#endif + +static inline long strlen_user (const char __user *src) +{ +return strnlen_user (src,32767 ); +} + +/* +* Zero Userspace +*/ +#ifndef __clear_user +static inline __must_check unsigned long +__clear_user (void __user *to,unsigned long n) +{ +memset ((void __force *)to,0 , n); +return 0 ; +} +#endif + +static inline __must_check unsigned long +clear_user (void __user *to,unsigned long n) +{ +might_sleep (); +if (!__access_ok (to, n)) +return n; + +return __clear_user (to, n); +} + +#endif /* __ASM_GENERIC_UACCESS_H */
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Arnd Bergmann
maintainerRe: [PATCH V3] asm-generic: add a generic uaccess.h
Quoted 9 lines · Michal Simek
include/asm-generic/uaccess.h line 16
Quoted 5 lines · Arnd Bergmann
include/asm-generic/uaccess.h new file +5
-0+ +#include <asm/segment.h> + +#ifndef get_fs +#define MAKE_MM_SEG (s) ((mm_segment_t) { (s) })one line above ->
get_fscould be defined in different space and this arch could useMAKE_MM_SEGtoo -> for example powerpc.
I don't think I understand what you are trying to tell me. How do you think this should look?
Quoted 7 lines
include/asm-generic/uaccess.h line 33
Quoted 4 lines
include/asm-generic/uaccess.h new file +4
-0+ +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 +Not sure if any arch do READ/WRITE check but if yes.
I could not find any architecture using it either, but the API is defined this way.
Quoted 5 lines
#ifndef
access_okQuoted 1 line
+#define
access_ok(type, addr, size)__access_ok((unsigned long)(addr),(size))#endif
right, will change.
Quoted 7 lines
include/asm-generic/uaccess.h line 39
Quoted 5 lines
include/asm-generic/uaccess.h new file +5
-0+ +/* +* The architecture should really override this if possible, at least +* doing a check on the get_fs() +*/ If they should really override it but why write it here.
Mostly for documentation purposes, so that an architecture maintainer can copy the prototype. I see the asm-generic headers as both fallbacks for architectures and as templates of what should be implemented.
Quoted 9 lines
include/asm-generic/uaccess.h line 219
Quoted 7 lines
include/asm-generic/uaccess.h new file +7
-0+#define get_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __get_user(x, ptr) : \ + -EFAULT; \ +})I am getting here (for
put_usermacro too) any error on noMMU. :-(
What kind of error do you see?
Quoted 10 lines
include/asm-generic/uaccess.h line 278
Quoted 7 lines
include/asm-generic/uaccess.h new file +7
-0+static inline long +strncpy_from_user (char *dst,const char __user *src,long count) +{ +if (!__access_ok (src,1 )) +return -EFAULT ; +return __strncpy_from_user (dst, src, count); +}Is it a good place to add
might_sleep()and unlikely(+ some other cases) too? We have almost the same code.
Yes, I think so. The unlikely() can probably go into __access_ok() though, so we don't have to write it every time.
Arnd <><
Michal Simek
maintainerRe: [PATCH V3] asm-generic: add a generic uaccess.h
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · Michal Simek
include/asm-generic/uaccess.h line 16
Quoted 5 lines · Arnd Bergmann
include/asm-generic/uaccess.h new file +5
-0+ +#include <asm/segment.h> + +#ifndef get_fs +#define MAKE_MM_SEG (s) ((mm_segment_t) { (s) })one line above ->
get_fscould be defined in different space and this arch could useMAKE_MM_SEGtoo -> for example powerpc.
Quoted 2 lines
I don't think I understand what you are trying to tell me. How do you think this should look?
I meant move MAKE_MM_SEG macro to this position because this macro could be use with arch which define different get_fs.
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
#ifndef get_fs
...
Quoted 38 lines
Quoted 7 lines
include/asm-generic/uaccess.h line 33
Quoted 5 lines
include/asm-generic/uaccess.h new file +4
-0+ +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 +Not sure if any arch do READ/WRITE check but if yes.
I could not find any architecture using it either, but the API is defined this way.
Quoted 4 lines
#ifndef
access_okQuoted 1 line
+#define
access_ok(type, addr, size)__access_ok((unsigned long)(addr),(size))#endif
right, will change.
Quoted 6 lines
include/asm-generic/uaccess.h line 39
Quoted 5 lines
include/asm-generic/uaccess.h new file +5
-0+ +/* +* The architecture should really override this if possible, at least +* doing a check on the get_fs() +*/ If they should really override it but why write it here.
Mostly for documentation purposes, so that an architecture maintainer can copy the prototype. I see the asm-generic headers as both fallbacks for architectures and as templates of what should be implemented.
Quoted 8 lines
include/asm-generic/uaccess.h line 219
Quoted 7 lines
include/asm-generic/uaccess.h new file +7
-0+#define get_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __get_user(x, ptr) : \ + -EFAULT; \ +})I am getting here (for
put_usermacro too) any error on noMMU. :-(
Quoted 1 line
What kind of error do you see?
System is getting crazy with -> I am debugging it.
Quoted 11 lines
Quoted 10 lines
include/asm-generic/uaccess.h line 278
Quoted 8 lines
include/asm-generic/uaccess.h new file +7
-0+static inline long +strncpy_from_user (char *dst,const char __user *src,long count) +{ +if (!__access_ok (src,1 )) +return -EFAULT ; +return __strncpy_from_user (dst, src, count); +}Is it a good place to add
might_sleep()and unlikely(+ some other cases) too? We have almost the same code.
Quoted 2 lines
Yes, I think so. The
unlikely()can probably go into__access_ok()though, so we don't have to write it every time.
ok
Michal
Quoted 2 lines
Arnd <><
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Michal Simek
maintainerRe: [PATCH V3] asm-generic: add a generic uaccess.h
In reply to Arnd BergmannQuoted 31 lines · Arnd Bergmann
This adds a new
asm-generic/uaccess.hfile that should be usable by both all NOMMU architectures out of the box. Architectures with an MMU should override the__access_ok(),__copy_from_user()and__copy_to_userdefinitions with their own functions to provide correct exception handling.Signed-off-by Arnd Bergmann <[email protected]>include/asm-generic/uaccess.h new file +17
-0@@ -0,0 +1,319 @@ +#ifndef __ASM_GENERIC_UACCESS_H +#define __ASM_GENERIC_UACCESS_H + +/* +* User space memory access functions, these should work +* on a ny machine that has kernel and user data in the same +* address space, e.g. all NOMMU machines. +*/ +#include <linux/sched.h> +#include <linux/mm.h> +#include <linux/string.h> + +#include <asm/segment.h> + +#ifndef get_fs +#define MAKE_MM_SEG (s) ((mm_segment_t) { (s) }) +#define KERNEL_DS MAKE_MM_SEG(~0UL)
include/asm-generic/uaccess.h line 27
Quoted 10 lines
include/asm-generic/uaccess.h new file +10
-0+#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) + +#define get_ds () (KERNEL_DS) +#define get_fs () (current_thread_info()->addr_limit) + +static inline void set_fs (mm_segment_t fs) +{ +current_thread_info ()->addr_limit = fs; +} +#endif
This part should be rewrite to this style.
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
#ifndef KERNEL_DS
#define KERNEL_DS MAKE_MM_SEG(~0UL)
#endif
#ifndef USER_DS
#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1)
#endif
#ifndef get_fs
#define get_ds() (KERNEL_DS)
#define get_fs() (current_thread_info()->addr_limit)
static inline void set_fs(mm_segment_t fs)
{
current_thread_info()->addr_limit = fs;
}#endif
What do you think?
Michal
Quoted 292 lines
include/asm-generic/uaccess.h new file +292
-0+ +#define segment_eq (a, b) ((a).seg == (b).seg) + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +#define access_ok (type, addr, size) __access_ok((unsigned long)(addr),(size)) + +/* +* The architecture should really override this if possible, at least +* doing a check on the get_fs() +*/ +#ifndef __access_ok +static inline int __access_ok (unsigned long addr,unsigned long size) +{ +return 1 ; +} +#endif + +/* +* The exception table consists of pairs of addresses: the first is the +* address of an instruction that is allowed to fault, and the second is +* the address at which the program should continue. No registers are +* modified, so it is entirely up to the continuation code to figure out +* what to do. +* +* All the routines below use bits of fixup code that are out of line +* with the main instruction path. This means when everything is well, +* we don't even have to jump over them. Further, they do not intrude +* on our cache or tlb entries. +*/ + +struct exception_table_entry +{ +unsigned long insn, fixup; +}; + +/* Returns 0 if exception not found and fixup otherwise. */ +extern unsigned long search_exception_table (unsigned long ); + +/* +* architectures with an MMU should override these two +*/ +#ifndef __copy_from_user +static inline __must_check long __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 +default : +break ; + } + } + +memcpy (to, (const void __force *)from, n); +return 0 ; +} +#endif + +#ifndef __copy_to_user +static inline __must_check long __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 ; +} +#endif + +/* +* These are the main single-value transfer routines. They automatically +* use the right size if we just have the right pointer type. +* This version just falls back to copy_{from,to}_user, which should +* provide a fast-path for small values. +*/ +#define __put_user (x, ptr) \ +({ \ + __typeof__(*(ptr)) __x = (x); \ + int __pu_err = -EFAULT; \ + __chk_user_ptr(ptr); \ + switch (sizeof (*(ptr))) { \ + case 1: \ + case 2: \ + case 4: \ + case 8: \ + __pu_err = __put_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + break; \ + default: \ + __put_user_bad(); \ + break; \ + } \ + __pu_err; \ +}) + +#define put_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __put_user(x, ptr) : \ + -EFAULT; \ +}) + +static inline int __put_user_fn (size_t size,void __user *ptr,void *x) +{ + size =__copy_to_user (ptr, x, size); +return size ? -EFAULT : size; +} + +extern int __put_user_bad (void ) __attribute__((noreturn)); + +#define __get_user (x, ptr) \ +({ \ + int __gu_err = -EFAULT; \ + __chk_user_ptr(ptr); \ + switch (sizeof(*(ptr))) { \ + case 1: { \ + unsigned char __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 2: { \ + unsigned short __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 4: { \ + unsigned int __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + case 8: { \ + unsigned long long __x; \ + __gu_err = __get_user_fn(sizeof (*(ptr)), \ + ptr, &__x); \ + (x) = *(__force __typeof__(*(ptr)) *) &__x; \ + break; \ + }; \ + default: \ + __get_user_bad(); \ + break; \ + } \ + __gu_err; \ +}) + +#define get_user (x, ptr) \ +({ \ + might_sleep(); \ + __access_ok(ptr, sizeof (*ptr)) ? \ + __get_user(x, ptr) : \ + -EFAULT; \ +}) + +static inline int __get_user_fn (size_t size,const void __user *ptr,void *x) +{ + size =__copy_from_user (x, ptr, size); +return size ? -EFAULT : size; +} + +extern int __get_user_bad (void ) __attribute__((noreturn)); + +#ifndef __copy_from_user_inatomic +#define __copy_from_user_inatomic __copy_from_user +#endif + +#ifndef __copy_to_user_inatomic +#define __copy_to_user_inatomic __copy_to_user +#endif + +static inline long copy_from_user (void *to, +const void __user * from,unsigned long n) +{ +might_sleep (); +if (__access_ok (from, n)) +return __copy_from_user (to, from, n); +else +return n; +} + +static inline long copy_to_user (void __user *to, +const void *from,unsigned long n) +{ +might_sleep (); +if (__access_ok (to, n)) +return __copy_to_user (to, from, n); +else +return n; +} + +/* +* Copy a null terminated string from userspace. +*/ +#ifndef __strncpy_from_user +static inline long +__strncpy_from_user (char *dst,const char __user *src,long count) +{ +char *tmp; +strncpy (dst, (const char __force *)src, count); +for (tmp = dst; *tmp && count >0 ; tmp++, count--) + ; +return (tmp - dst); +} +#endif + +static inline long +strncpy_from_user (char *dst,const char __user *src,long count) +{ +if (!__access_ok (src,1 )) +return -EFAULT ; +return __strncpy_from_user (dst, src, count); +} + +/* +* Return the size of a string (including the ending 0) +* +* Return 0 on exception, a value greater than N if too long +*/ +#ifndef strnlen_user +static inline long strnlen_user (const char __user *src,long n) +{ +return strlen ((void *__force )src) +1 ; +} +#endif + +static inline long strlen_user (const char __user *src) +{ +return strnlen_user (src,32767 ); +} + +/* +* Zero Userspace +*/ +#ifndef __clear_user +static inline __must_check unsigned long +__clear_user (void __user *to,unsigned long n) +{ +memset ((void __force *)to,0 , n); +return 0 ; +} +#endif + +static inline __must_check unsigned long +clear_user (void __user *to,unsigned long n) +{ +might_sleep (); +if (!__access_ok (to, n)) +return n; + +return __clear_user (to, n); +} + +#endif /* __ASM_GENERIC_UACCESS_H */
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Arnd Bergmann
maintainerRe: [PATCH V3] asm-generic: add a generic uaccess.h
Quoted 15 lines · Michal Simek
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
#ifndef
KERNEL_DS
#define KERNEL_DS MAKE_MM_SEG(~0UL)
#endif#ifndef
USER_DS
#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1) #endif#ifndef
get_fs
#defineget_ds()(KERNEL_DS)
#defineget_fs()(current_thread_info()->addr_limit)
Quoted 6 lines
static inline void
set_fs(mm_segment_t fs)
{
current_thread_info()->addr_limit = fs;
}
#endif
yes, looks good. Thanks for the suggestion.
Arnd <><
Geert Uytterhoeven
maintainerRe: [PATCH 12/27] asm-generic: add a NOMMU uaccess.h
In reply to Arnd Bergmanninclude/asm-generic/uaccess.h line 6
Quoted 7 lines · Arnd Bergmann
index 549cb3a..ebeacd9 100644
include/asm-generic/uaccess.h +3
-0+/* +* User space memory access functions, these should work +* on a ny machine that has kernel and user data in the same
any
Quoted 2 lines
+ * address space, e.g. all NOMMU machines.
+ */
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerPATCH 13/27 asm-generic: make uaccess.h usable by mmu archs
In reply to Arnd BergmannMake it possible to override some functions from uaccess.h so that architectures with an mmu can provide assembly versions of the functions with their own fixup logic.
--- include/asm-generic/uaccess.h | 102 +++++++++++++++++++++++++--------------- 1 files changed, 64 insertions(+), 38 deletions(-)
include/asm-generic/uaccess.h +64 -38
@@ -31,14 +31,14 @@ static inline void set_fs(mm_segment_t fs)#define VERIFY_READ 0#define VERIFY_WRITE 1 -#define access_ok (type, addr, size) _access_ok((unsigned long)(addr),(size)) +#define access_ok (type, addr, size) __access_ok((unsigned long)(addr),(size))/* * The architecture should really override this if possible, at least * doing a check on the get_fs() */ -#ifndef _access_ok -static inline int _access_ok (unsigned long addr,unsigned long size) +#ifndef __access_ok +static inline int __access_ok (unsigned long addr,unsigned long size) {return 1 ; }
@@ -93,7 +93,7 @@ extern int __put_user_bad(void);#endif #define put_user (x, ptr) ( \ - access_ok(VERIFY_WRITE, ptr, sizeof (*ptr)) ? \ + __access_ok(ptr, sizeof (*ptr)) ? \ __put_user(x, ptr) : \ -EFAULT)
@@ -120,45 +120,62 @@ extern int __get_user_bad(void);#endif #define get_user (x, ptr) ( \ - access_ok(VERIFY_READ, ptr, sizeof (*ptr)) ? \ + __access_ok(ptr, sizeof (*ptr)) ? \ __get_user(x, ptr) : \ -EFAULT) -#define __copy_from_user (to, from, n) (memcpy(to, from, n), 0) -#define __copy_to_user (to, from, n) (memcpy(to, from, n), 0) -#define __copy_to_user_inatomic __copy_to_user -#define __copy_from_user_inatomic __copy_from_user +#ifndef __copy_from_user +static inline __must_check long __copy_from_user (void *to, +const void __user *from,unsigned long n) +{ +memcpy (to, (const void __force *)from, n); +return 0 ; +} +#endif -#define copy_to_user_ret (to,from,n,retval) ({ if (copy_to_user(to,from,n)) return retval; }) +#ifndef __copy_to_user +static inline __must_check long __copy_to_user (void __user *to, +const void *from,unsigned long n) +{ +memcpy ((void __force *)to, from, n); +return 0 ; +} +#endif + +#ifndef __copy_from_user_inatomic +#define __copy_from_user_inatomic __copy_from_user +#endif -#define copy_from_user_ret (to,from,n,retval) ({ if (copy_from_user(to,from,n)) return retval; }) +#ifndef __copy_to_user_inatomic +#define __copy_to_user_inatomic __copy_to_user +#endif static inline long copy_from_user (void *to, -const void __user * from,unsigned long n) +const void __user * from,unsigned long n) { -if (access_ok (VERIFY_READ , from, n)) -__copy_from_user (to, from, n); +might_sleep (); +if (__access_ok (from, n)) +return __copy_from_user (to, from, n);else return n; -return 0 ; } -static inline long copy_to_user (void *to, -const void __user * from,unsigned long n) +static inline long copy_to_user (void __user *to, +const void *from,unsigned long n) { -if (access_ok (VERIFY_WRITE , to, n)) -__copy_to_user (to, from, n); +might_sleep (); +if (__access_ok (to, n)) +return __copy_to_user (to, from, n);else return n; -return 0 ; }/* * Copy a null terminated string from userspace. */ - +#ifndef __strncpy_from_userstatic inline long -__do_strncpy_from_user (char *dst,const char __user *src,long count) +__strncpy_from_user (char *dst,const char __user *src,long count) {char *tmp;strncpy (dst, src, count);
@@ -166,19 +183,14 @@ __do_strncpy_from_user(char *dst, const char __user *src, long count) ; return (tmp - dst); } +#endif static inline long strncpy_from_user (char *dst,const char __user *src,long count) { -if (!access_ok (VERIFY_READ , src,1 )) +if (!__access_ok (src,1 ))return -EFAULT ; -return __do_strncpy_from_user (dst, src, count); -} - -static inline long -__strncpy_from_user (char *dst,const char __user *src,long count) -{ -return __do_strncpy_from_user (dst, src, count); +return __strncpy_from_user (dst, src, count); }/*
@@ -186,24 +198,38 @@ __strncpy_from_user(char *dst, const char __user *src, long count)* * Return 0 on exception, a value greater than N if too long */ -static inline long strnlen_user (const char *src,long n) +#ifndef strnlen_user +static inline long strnlen_user (const char __user *src,long n) { -return strlen (src) +1 ; +return strlen ((void *__force )src) +1 ; } +#endif -#define strlen_user (str) strnlen_user(str, 32767) +static inline long strlen_user (const char __user *src) +{ +return strnlen_user (src,32767 ); +}/* * Zero Userspace */ - -static inline unsigned long -__clear_user (void *to,unsigned long n) +#ifndef __clear_user +static inline __must_check unsigned long +__clear_user (void __user *to,unsigned long n) { -memset (to,0 , n); +memset ((void __force *)to,0 , n);return 0 ; } +#endif -#define clear_user (to, n) __clear_user(to, n) +static inline __must_check unsigned long +clear_user (void __user *to,unsigned long n) +{ +might_sleep (); +if (!__access_ok (to, n)) +return n; + +return __clear_user (to, n); +}#endif /* __ASM_GENERIC_UACCESS_H */
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 14/27 asm-generic: make bitops.h usable
In reply to Arnd Bergmannbitops.h apparently suffered from some level of bitrot, it was missing the smp_mb__{before,after}_clear_bit functions, and included other headers in an invalid order.
This changes the file so that new architectures can use it out of the box.
--- include/asm-generic/bitops.h | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-)
include/asm-generic/bitops.h +18 -6
@@ -1,19 +1,29 @@ -#ifndef _ASM_GENERIC_BITOPS_H_ -#define _ASM_GENERIC_BITOPS_H_ +#ifndef __ASM_GENERIC_BITOPS_H +#define __ASM_GENERIC_BITOPS_H/* * For the benefit of those who are trying to port Linux to another * architecture, here are some C-language equivalents. You should * recode these in the native assembly language, if at all possible. -* +* * C language equivalents written by Theodore Ts'o, 9/26/92 */ -#include <asm-generic/bitops/atomic.h> -#include <asm-generic/bitops/non-atomic.h> +#include <linux/irqflags.h> +#include <linux/compiler.h> + +/* +* clear_bit may not imply a memory barrier +*/ +#ifndef smp_mb__before_clear_bit +#define smp_mb__before_clear_bit () smp_mb() +#define smp_mb__after_clear_bit () smp_mb() +#endif +#include <asm-generic/bitops/__ffs.h> #include <asm-generic/bitops/ffz.h> #include <asm-generic/bitops/fls.h> +#include <asm-generic/bitops/__fls.h> #include <asm-generic/bitops/fls64.h> #include <asm-generic/bitops/find.h>
@@ -26,8 +36,10 @@#include <asm-generic/bitops/hweight.h> #include <asm-generic/bitops/lock.h> +#include <asm-generic/bitops/atomic.h> +#include <asm-generic/bitops/non-atomic.h> #include <asm-generic/bitops/ext2-non-atomic.h> #include <asm-generic/bitops/ext2-atomic.h> #include <asm-generic/bitops/minix.h> -#endif /* _ASM_GENERIC_BITOPS_H */ +#endif /* __ASM_GENERIC_BITOPS_H */
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 15/27 asm-generic: Add missing generic tlb_flush definition
In reply to Arnd BergmannAll architectures with an MMU define tlb_flush as flush_tlb_mm((tlb)->mm). This adds it as a default implementation in asm-generic/tlb.h so that new nommu architectures can simply use the header as is and others can stop defining it themselves.
--- include/asm-generic/tlb.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
include/asm-generic/tlb.h +4 -0
@@ -47,6 +47,10 @@ struct mmu_gather {/* Users of the generic TLB shootdown code must declare this storage space. */ DECLARE_PER_CPU(struct mmu_gather, mmu_gathers); +#ifndef tlb_flush +#define tlb_flush (tlb) flush_tlb_mm((tlb)->mm) +#endif +/* tlb_gather_mmu * Return a pointer to an initialized struct mmu_gather. */
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 16/27 asm-generic: introduce generic syscalls.h
In reply to Arnd BergmannAdd a generic syscalls.h with all common system calls that can not be declared in linux/syscalls.h because some architectures have unusual signatures.
All prototypes in here can be overriden by the architecture but default to the most common variant.
--- include/asm-generic/syscalls.h | 60 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/syscalls.h
include/asm-generic/syscalls.h new file +60 -0
@@ -0,0 +1,60 @@ +#ifndef __ASM_GENERIC_SYSCALLS_H +#define __ASM_GENERIC_SYSCALLS_H + +#include <linux/compiler.h> +#include <linux/linkage.h> + +/* +* Calling conventions for these system calls can differ, so +* it's possible to override them. +*/ +#ifndef sys_clone +asmlinkage long sys_clone (unsigned long clone_flags,unsigned long newsp, +void __user *parent_tid,void __user *child_tid, +struct pt_regs *regs); +#endif + +#ifndef sys_fork +asmlinkage long sys_fork (struct pt_regs *regs); +#endif + +#ifndef sys_fork +asmlinkage long sys_vfork (struct pt_regs *regs); +#endif + +#ifndef sys_execve +asmlinkage long sys_execve (char __user *filename,char __user *__user *argv, +char __user *__user *envp,struct pt_regs *regs); +#endif + +#ifndef sys_mmap2 +asmlinkage long sys_mmap2 (unsigned long addr,unsigned long len, +unsigned long prot,unsigned long flags, +unsigned long fd,unsigned long pgoff); +#endif + +#ifndef sys_mmap +asmlinkage long sys_mmap (unsigned long addr,unsigned long len, +unsigned long prot,unsigned long flags, +unsigned long fd,off_t pgoff); +#endif + +#ifndef sys_sigaltstack +asmlinkage long sys_sigaltstack (const stack_t __user *,stack_t __user *, +struct pt_regs *); +#endif + +#ifndef sys_rt_sigreturn +asmlinkage long sys_rt_sigreturn (struct pt_regs *regs); +#endif + +#ifndef sys_rt_sigsuspend +asmlinkage long sys_rt_sigsuspend (sigset_t __user *unewset,size_t sigsetsize); +#endif + +#ifndef sys_rt_sigaction +asmlinkage long sys_rt_sigaction (int sig,const struct sigaction __user *act, +struct sigaction __user *oact,size_t sigsetsize); +#endif + +#endif /* __ASM_GENERIC_SYSCALLS_H */
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 17/27 add generic lib/checksum.c
In reply to Arnd BergmannAdd a generic (unoptimized) implementation of checksum.c in pure C for use by all architectures.
Based on microblaze code by Michal Simek <[email protected]>
--- include/asm-generic/checksum.h | 79 +++++++++++++++++ lib/Makefile | 2 + lib/checksum.c | 188 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 269 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/checksum.h create mode 100644 lib/checksum.c
include/asm-generic/checksum.h new file +79 -0
@@ -0,0 +1,79 @@ +#ifndef __ASM_GENERIC_CHECKSUM_H +#define __ASM_GENERIC_CHECKSUM_H + +/* +* computes the checksum of a memory block at buff, length len, +* and adds in "sum" (32-bit) +* +* returns a 32-bit number suitable for feeding into itself +* or csum_tcpudp_magic +* +* this function must be called with even lengths, except +* for the last fragment, which may be odd +* +* it's best to have buff aligned on a 32-bit boundary +*/ +extern __wsum csum_partial (const void *buff,int len,__wsum sum); + +/* +* the same as csum_partial, but copies from src while it +* checksums +* +* here even more important to align src and dst on a 32-bit (or even +* better 64-bit) boundary +*/ +extern __wsum csum_partial_copy (const void *src,void *dst,int len,__wsum sum); + +/* +* the same as csum_partial_copy, but copies from user space. +* +* here even more important to align src and dst on a 32-bit (or even +* better 64-bit) boundary +*/ +extern __wsum csum_partial_copy_from_user (const void __user *src,void *dst, +int len,__wsum sum,int *csum_err); + +#define csum_partial_copy_nocheck (src, dst, len, sum) \ + csum_partial_copy((src), (dst), (len), (sum)) + +/* +* This is a version of ip_compute_csum() optimized for IP headers, +* which always checksum on 4 octet boundaries. +*/ +extern __sum16 ip_fast_csum (const void *iph,unsigned int ihl); + +/* +* Fold a partial checksum +*/ +static inline __sum16 csum_fold (__wsum csum) +{ +u32 sum = (__force u32 )csum; + sum = (sum &0xffff ) + (sum >>16 ); + sum = (sum &0xffff ) + (sum >>16 ); +return (__force __sum16 )~sum; +} + +#ifndef csum_tcpudp_nofold +/* +* computes the checksum of the TCP/UDP pseudo-header +* returns a 16-bit checksum, already complemented +*/ +extern __wsum +csum_tcpudp_nofold (__be32 saddr,__be32 daddr,unsigned short len, +unsigned short proto,__wsum sum); +#endif + +static inline __sum16 +csum_tcpudp_magic (__be32 saddr,__be32 daddr,unsigned short len, +unsigned short proto,__wsum sum) +{ +return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum)); +} + +/* +* this routine is used for miscellaneous IP-like checksums, mainly +* in icmp.c +*/ +extern __sum16 ip_compute_csum (const void *buff,int len); + +#endif /* __ASM_GENERIC_CHECKSUM_H */
lib/Makefile +2 -0
@@ -92,6 +92,8 @@ obj-$(CONFIG_NLATTR) += nlattr.o obj-$(CONFIG_DMA_API_DEBUG) += dma-debug.o +obj-$(CONFIG_GENERIC_CSUM) += checksum.o + hostprogs-y := gen_crc32table clean-files := crc32table.h
lib/checksum.c new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
1.5.6.3
Re: [PATCH 17/27] add generic lib/checksum.c
lib/checksum.c
Quoted 17 lines · Arnd Bergmann
Add a generic (unoptimized) implementation of
checksum.cin pure C for use by all architectures.Based on microblaze code by Michal Simek <[email protected]>
Cc Michal Simek <[email protected]>Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Remis Lima Baima <[email protected]>--- include/asm-generic/checksum.h | 79 +++++++++++++++++ lib/Makefile | 2 + lib/checksum.c | 188 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 269 insertions(+), 0 deletions(-) create mode 100644 include/asm-generic/checksum.h create mode 100644 lib/checksum.clib/checksum.c +0
-0
^^^^^^^^^^^^^^
lib/checksum.c line 2
Quoted 7 lines
new file mode 100644
index 0000000..4f80a4dlib/checksum.c new file +2
-0@@ -0,0 +1,188 @@ +/* +* arch/microblaze/lib/checksum.c
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/checksum.c line 4
Quoted 2 lines
lib/checksum.c new file +2
-0+* +* Copyright (C) 2008 Michal Simek <[email protected]>
I haven't looked at the code in detail, but it would be nice to see it show up soon. Just faced the IP checksumming code while resurrecting the VAX port.
MfG, JBG
Signature · 4 lines
Jan-Benedict Glaw [email protected] +49-172-7608481 Signature of: "really soon now": an unspecified period of time, likly to the second : be greater than any reasonable definition of "soon".
Arnd Bergmann
maintainerRe: [PATCH 17/27] add generic lib/checksum.c
Quoted 3 lines · Jan-Benedict Glaw
I haven't looked at the code in detail, but it would be nice to see it show up soon. Just faced the IP checksumming code while resurrecting the VAX port.
I hope my other header changes are helping you as well, that was the main point. The checksum code was one of the hardest to consolidate because every architecture tries to optimize this in a different way. After merging all the different approaches and throwing away all the assembly code from each of them, I made the code practically identical to Michals version.
Please tell me if you need more hooks in the checksum code for VAX optimizations. You might want to try overriding the csum_fold function.
Arnd <><
Re: [PATCH 17/27] add generic lib/checksum.c
In reply to Arnd Bergmannlib/checksum.c line 153
Quoted 10 lines · Arnd Bergmann
lib/checksum.c new file +10
-0+/* +* copy from fs while checksumming, otherwise like csum_partial +*/ +__wsum +csum_partial_copy_from_user (const void __user *src,void *dst,int len, +__wsum sum,int *csum_err) +{ +if (csum_err) + *csum_err =0 ; +memcpy (dst, src, len);
Since when has 'memcpy' been valid from user addresses?
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Michal Simek
maintainerRe: [PATCH 17/27] add generic lib/checksum.c
Quoted 14 lines · Russell King
lib/checksum.c line 153
Quoted 10 lines · Arnd Bergmann
lib/checksum.c new file +10
-0+/* +* copy from fs while checksumming, otherwise like csum_partial +*/ +__wsum +csum_partial_copy_from_user (const void __user *src,void *dst,int len, +__wsum sum,int *csum_err) +{ +if (csum_err) + *csum_err =0 ; +memcpy (dst, src, len);Since when has 'memcpy' been valid from user addresses?
yes, that's wrong
copy_from_user(dst, src, len);
should be there
Michal
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
Arnd Bergmann
maintainerRe: [PATCH 17/27] add generic lib/checksum.c
In reply to Russell KingQuoted 1 line · Russell King
Since when has 'memcpy' been valid from user addresses?
It's an artifact from the microblaze code, I found it after submitting the patches when running sparse over it (yes, I know I should do these things in a different order).
The s390 version seems to get this right, so I'll use this:
static inline __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
int len, __wsum sum, int *err_ptr)
{
int missing;
missing = copy_from_user(dst, src, len);
if (missing) {
memset(dst + len - missing, 0, missing);
*err_ptr = -EFAULT;
}
return csum_partial(dst, len, sum);
}On microblaze, the old code was only correct for NOMMU.
Thanks,
Arnd <><
Michal Simek
maintainerRe: [PATCH 17/27] add generic lib/checksum.c
Quoted 25 lines · Arnd Bergmann
Quoted 1 line · Russell King
Since when has 'memcpy' been valid from user addresses?
It's an artifact from the microblaze code, I found it after submitting the patches when running sparse over it (yes, I know I should do these things in a different order).
The s390 version seems to get this right, so I'll use this:
static inline
__wsumcsum_partial_copy_from_user(const void__user*src, void *dst,
int len,__wsumsum, int*err_ptr){ int missing; missing = copy_from_user(dst, src, len); if (missing) { memset(dst + len - missing, 0, missing); *err_ptr = -EFAULT; } return csum_partial(dst, len, sum); }
Quoted 1 line
On microblaze, the old code was only correct for NOMMU.
Not it wasn't there were address space problem too.
Michal
Quoted 4 lines
Thanks,
Arnd <><
Signature · 2 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854
PATCH 20/27 microblaze: use the generic lib/checksum.c
In reply to Arnd BergmannAdapt the code to use the more generic lib/checksum.c implementation.
--- arch/microblaze/Kconfig | 3 + arch/microblaze/lib/Makefile | 2 +- arch/microblaze/lib/checksum.c | 163 ---------------------------------------- 3 files changed, 4 insertions(+), 164 deletions(-) delete mode 100644 arch/microblaze/lib/checksum.c
arch/microblaze/Kconfig +3 -0
@@ -52,6 +52,9 @@ config GENERIC_HARDIRQS_NO__DO_IRQ config GENERIC_SYSCALL_TABLE def_bool y +config GENERIC_CSUM + def_bool y + config PCI depends on !MMU def_bool n
arch/microblaze/lib/Makefile +1 -1
@@ -2,7 +2,7 @@ # Makefile # -lib-y := memset.o checksum.o +lib-y := memset.o ifeq ($(CONFIG_OPT_LIB_ASM),y) lib-y += fastcopy.o
arch/microblaze/lib/checksum.c deleted +0 -163
163 lines not on this page · raw message
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 18/27 microblaze: use generic syscalls.h
In reply to Arnd BergmannThe prototypes in syscalls.h all make sense for microblaze, but for some of them, the actual implementation in sys_microblaze.c needs to be adapted.
--- arch/microblaze/include/asm/syscalls.h | 48 +++++------------------------- arch/microblaze/kernel/sys_microblaze.c | 12 ++++---- 2 files changed, 14 insertions(+), 46 deletions(-)
rewrite arch/microblaze/include/asm/syscalls.h (94%)
arch/microblaze/include/asm/syscalls.h +8 -40
@@ -1,40 +1,8 @@ -#ifndef __ASM_MICROBLAZE_SYSCALLS_H -#define __ASM_MICROBLAZE_SYSCALLS_H -#ifdef __KERNEL__ - -#include <linux/compiler.h> -#include <linux/linkage.h> -#include <linux/types.h> -#include <linux/signal.h> - -/* FIXME will be removed */ -asmlinkage int sys_ipc(uint call, int first, int second, -int third,void *ptr,long fifth); - -struct pt_regs ; -asmlinkage int sys_vfork(struct pt_regs *regs); -asmlinkage int sys_clone(int flags, unsigned long stack, struct pt_regs *regs); -asmlinkage int sys_execve(char __user *filenamei, char __user *__user *argv, -char __user *__user *envp,struct pt_regs *regs); - -asmlinkage unsigned long sys_mmap2 (unsigned long addr,size_t len, -unsigned long prot,unsigned long flags, -unsigned long fd,unsigned long pgoff); - -asmlinkage unsigned long sys_mmap (unsigned long addr,size_t len, -unsigned long prot,unsigned long flags, -unsigned long fd,off_t offset); - -/* from signal.c */ -asmlinkage long sys_rt_sigsuspend (sigset_t __user *unewset,size_t sigsetsize, -struct pt_regs *regs); - -asmlinkage long sys_sigaltstack (const stack_t __user *uss,stack_t __user *uoss, -struct pt_regs *regs); - -asmlinkage long sys_rt_sigaction (int sig,const struct sigaction __user * act,struct sigaction __user * oact,size_t sigsetsize); - -asmlinkage long sys_rt_sigreturn (struct pt_regs *regs); - -#endif /* __KERNEL__ */ -#endif /* __ASM_MICROBLAZE_SYSCALLS_H */ +#ifndef __ASM_MICROBLAZE_SYSCALLS_H + +asmlinkage long sys_clone (int flags,unsigned long stack,struct pt_regs *regs); +#define sys_clone sys_clone + +#include <asm-generic/syscalls.h> + +#endif /* __ASM_MICROBLAZE_SYSCALLS_H */
arch/microblaze/kernel/sys_microblaze.c +6 -6
@@ -39,7 +39,7 @@* * This is really horribly ugly. This will be remove with new toolchain. */ -asmlinkage int +asmlinkage long sys_ipc (uint call,int first,int second,int third,void *ptr,long fifth) {int version, ret;
@@ -134,20 +134,20 @@ sys_ipc(uint call, int first, int second, int third, void *ptr, long fifth)return -EINVAL ; } -asmlinkage int sys_vfork(struct pt_regs *regs) +asmlinkage long sys_vfork (struct pt_regs *regs) {return do_fork (CLONE_VFORK |CLONE_VM |SIGCHLD , regs->r1, regs,0 ,NULL ,NULL ); } -asmlinkage int sys_clone(int flags, unsigned long stack, struct pt_regs *regs) +asmlinkage long sys_clone (int flags,unsigned long stack,struct pt_regs *regs) {if (!stack) stack = regs->r1;return do_fork (flags, stack, regs,0 ,NULL ,NULL ); } -asmlinkage int sys_execve(char __user *filenamei, char __user *__user *argv, +asmlinkage long sys_execve (char __user *filenamei,char __user *__user *argv,char __user *__user *envp,struct pt_regs *regs) {int error;
@@ -163,7 +163,7 @@ out:return error; } -asmlinkage unsigned long +asmlinkage long sys_mmap2 (unsigned long addr,size_t len,unsigned long prot,unsigned long flags,unsigned long fd,unsigned long pgoff)
@@ -189,7 +189,7 @@ out:return ret; } -asmlinkage unsigned long sys_mmap (unsigned long addr,size_t len, +asmlinkage long sys_mmap (unsigned long addr,size_t len,unsigned long prot,unsigned long flags,unsigned long fd,off_t offset) {
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 19/27 microblaze: make syscall_table implementation generic
In reply to Arnd Bergmann---
arch/microblaze/Kconfig | 3 +++
arch/microblaze/kernel/Makefile | 2 +-
kernel/Makefile | 1 +
{arch/microblaze/kernel => kernel}/syscall_table.c | 2 +-
4 files changed, 6 insertions(+), 2 deletions(-)
rename {arch/microblaze/kernel => kernel}/syscall_table.c (82%)arch/microblaze/Kconfig +3 -0
@@ -49,6 +49,9 @@ config GENERIC_CLOCKEVENTS config GENERIC_HARDIRQS_NO__DO_IRQ def_bool y +config GENERIC_SYSCALL_TABLE + def_bool y + config PCI depends on !MMU def_bool n
arch/microblaze/kernel/Makefile +1 -1
@@ -7,7 +7,7 @@ extra-y := head.o vmlinux.lds obj-y += exceptions.o \ hw_exception_handler.o init_task.o intc.o irq.o of_device.o \ of_platform.o process.o prom.o prom_parse.o ptrace.o \ - setup.o signal.o sys_microblaze.o timer.o traps.o syscall_table.o + setup.o signal.o sys_microblaze.o timer.o traps.o obj-y += cpu/
kernel/Makefile +1 -0
@@ -95,6 +95,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += trace/ obj-$(CONFIG_TRACING) += trace/ obj-$(CONFIG_SMP) += sched_cpupri.o obj-$(CONFIG_SLOW_WORK) += slow-work.o +obj-$(CONFIG_GENERIC_SYSCALL_TABLE) += syscall_table.o ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y) # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
kernel/syscall_table.c renamed from arch/microblaze/kernel/syscall_table.c +1 -1
@@ -7,6 +7,6 @@#undef __SYSCALL#define __SYSCALL (nr, call) [nr] (call), -void *sys_call_table[__NR_syscalls] = { +void *sys_call_table[] = {#include <asm/unistd.h> };
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 21/27 microblaze: use generic swab.h
In reply to Arnd Bergmann--- arch/microblaze/include/asm/swab.h | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
arch/microblaze/include/asm/swab.h +1 -8
@@ -1,8 +1 @@ -#ifndef _ASM_MICROBLAZE_SWAB_H -#define _ASM_MICROBLAZE_SWAB_H - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) -#define __SWAB_64_THRU_32__ -#endif - -#endif /* _ASM_MICROBLAZE_SWAB_H */ +#include <asm-generic/swab.h>
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 22/27 microblaze: don't include asm/mmu.h in hw_exception_handler
In reply to Arnd BergmannThe generic mmu.h is not safe for use in assembly, but also doesn't contain anything that microblaze needs there.
--- arch/microblaze/kernel/hw_exception_handler.S | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
arch/microblaze/kernel/hw_exception_handler.S +0 -1
@@ -66,7 +66,6 @@ #include <asm/current.h> #include <linux/linkage.h> -#include <asm/mmu.h> #include <asm/pgtable.h> #include <asm/asm-offsets.h>
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainerPATCH 24/27 microblaze: use generic dma-mapping.h
In reply to Arnd BergmannMicroblaze does not support the Linux DMA mapping API at this point, so disable CONFIG_NO_DMA. This lets us use the generic dma-mapping-broken.h implementation instead of providing a different copy.
--- arch/microblaze/Kconfig | 2 +- arch/microblaze/include/asm/dma-mapping.h | 130 +---------------------------- 2 files changed, 2 insertions(+), 130 deletions(-)
rewrite arch/microblaze/include/asm/dma-mapping.h (100%)
arch/microblaze/Kconfig +1 -1
@@ -61,7 +61,7 @@ config PCI config NO_DMA depends on !MMU - def_bool n + def_bool y source "init/Kconfig"
arch/microblaze/include/asm/dma-mapping.h +1 -129
130 lines not on this page · raw message
Signature · 1 line
1.5.6.3
PATCH 23/27 microblaze: convert all simple headers to use asm-generic
In reply to Arnd BergmannAll the simple microblaze header files were adapted to use their asm-generic implementations. These files are more simple and were quite straightforward to change.
--- arch/microblaze/include/asm/atomic.h | 124 +--------------------------- arch/microblaze/include/asm/bitops.h | 28 +------ arch/microblaze/include/asm/bug.h | 14 --- arch/microblaze/include/asm/bugs.h | 18 +---- arch/microblaze/include/asm/checksum.h | 132 ++++++++--------------------- arch/microblaze/include/asm/hardirq.h | 14 +--- arch/microblaze/include/asm/irq.h | 6 +- arch/microblaze/include/asm/kmap_types.h | 30 +------ arch/microblaze/include/asm/mmu.h | 20 +---- arch/microblaze/include/asm/mmu_context.h | 22 +----- arch/microblaze/include/asm/module.h | 10 +-- arch/microblaze/include/asm/pgalloc.h | 15 +--- arch/microblaze/include/asm/scatterlist.h | 29 +------ arch/microblaze/include/asm/serial.h | 15 +--- arch/microblaze/include/asm/shmparam.h | 7 +-- arch/microblaze/include/asm/system.h | 3 + arch/microblaze/include/asm/timex.h | 19 +---- 17 files changed, 53 insertions(+), 453 deletions(-)
rewrite arch/microblaze/include/asm/atomic.h (100%) rewrite arch/microblaze/include/asm/bitops.h (95%) rewrite arch/microblaze/include/asm/checksum.h (68%) rewrite arch/microblaze/include/asm/kmap_types.h (100%) rewrite arch/microblaze/include/asm/mmu.h (100%) rewrite arch/microblaze/include/asm/mmu_context.h (100%) rewrite arch/microblaze/include/asm/scatterlist.h (100%) rewrite arch/microblaze/include/asm/timex.h (100%)
arch/microblaze/include/asm/atomic.h +1 -123
@@ -1,123 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_ATOMIC_H -#define _ASM_MICROBLAZE_ATOMIC_H - -#include <linux/types.h> -#include <linux/compiler.h> /* likely */ -#include <asm/system.h> /* local_irq_XXX and friends */ - -#define ATOMIC_INIT (i) { (i) } -#define atomic_read (v) ((v)->counter) -#define atomic_set (v, i) (((v)->counter) = (i)) - -#define atomic_inc (v) (atomic_add_return(1, (v))) -#define atomic_dec (v) (atomic_sub_return(1, (v))) - -#define atomic_add (i, v) (atomic_add_return(i, (v))) -#define atomic_sub (i, v) (atomic_sub_return(i, (v))) - -#define atomic_inc_return (v) (atomic_add_return(1, (v))) -#define atomic_dec_return (v) (atomic_sub_return(1, (v))) - -#define atomic_inc_and_test (v) (atomic_add_return(1, (v)) == 0) -#define atomic_dec_and_test (v) (atomic_sub_return(1, (v)) == 0) - -#define atomic_inc_not_zero (v) (atomic_add_unless((v), 1, 0)) - -#define atomic_sub_and_test (i, v) (atomic_sub_return((i), (v)) == 0) - -static inline int atomic_cmpxchg (atomic_t *v,int old,int new) -{ -int ret; -unsigned long flags; - -local_irq_save (flags); - ret = v->counter; -if (likely (ret == old)) - v->counter = new; -local_irq_restore (flags); - -return ret; -} - -static inline int atomic_add_unless (atomic_t *v,int a,int u) -{ -int c, old; - - c =atomic_read (v); -while (c != u && (old =atomic_cmpxchg ((v), c, c + a)) != c) - c = old; -return c != u; -} - -static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) -{ -unsigned long flags; - -local_irq_save (flags); - *addr &= ~mask; -local_irq_restore (flags); -} - -/** -* atomic_add_return - add and return -* @i: integer value to add -* @v: pointer of type atomic_t -* -* Atomically adds @i to @v and returns @i + @v -*/ -static inline int atomic_add_return (int i,atomic_t *v) -{ -unsigned long flags; -int val; - -local_irq_save (flags); - val = v->counter; - v->counter = val += i; -local_irq_restore (flags); - -return val; -} - -static inline int atomic_sub_return (int i,atomic_t *v) -{ -return atomic_add_return (-i, v); -} - -/* -* Atomically test *v and decrement if it is greater than 0. -* The function returns the old value of *v minus 1. -*/ -static inline int atomic_dec_if_positive (atomic_t *v) -{ -unsigned long flags; -int res; - -local_irq_save (flags); - res = v->counter -1 ; -if (res >=0 ) - v->counter = res; -local_irq_restore (flags); - -return res; -} - -#define atomic_add_negative (a, v) (atomic_add_return((a), (v)) < 0) -#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) - -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec () barrier() -#define smp_mb__after_atomic_dec () barrier() -#define smp_mb__before_atomic_inc () barrier() -#define smp_mb__after_atomic_inc () barrier() - -#include <asm-generic/atomic-long.h> - -#endif /* _ASM_MICROBLAZE_ATOMIC_H */ +#include <asm-generic/atomic.h>
arch/microblaze/include/asm/bitops.h +1 -27
@@ -1,27 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_BITOPS_H -#define _ASM_MICROBLAZE_BITOPS_H - -/* -* Copyright 1992, Linus Torvalds. -*/ - -#include <asm/byteorder.h> /* swab32 */ -#include <asm/system.h> /* save_flags */ - -/* -* clear_bit() doesn't provide any barrier for the compiler. -*/ -#define smp_mb__before_clear_bit () barrier() -#define smp_mb__after_clear_bit () barrier() -#include <asm-generic/bitops.h> -#include <asm-generic/bitops/__fls.h> - -#endif /* _ASM_MICROBLAZE_BITOPS_H */ +#include <asm-generic/bitops.h>
arch/microblaze/include/asm/bug.h +0 -14
@@ -1,15 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_BUG_H -#define _ASM_MICROBLAZE_BUG_H - -#include <linux/kernel.h> #include <asm-generic/bug.h> - -#endif /* _ASM_MICROBLAZE_BUG_H */
arch/microblaze/include/asm/bugs.h +1 -17
@@ -1,17 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_BUGS_H -#define _ASM_MICROBLAZE_BUGS_H - -static inline void check_bugs (void ) -{ -/* nothing to do */ -} - -#endif /* _ASM_MICROBLAZE_BUGS_H */ +#include <asm-generic/bugs.h>
arch/microblaze/include/asm/checksum.h +34 -98
132 lines not on this page · raw message
arch/microblaze/include/asm/hardirq.h +2 -12
@@ -9,21 +9,11 @@#ifndef _ASM_MICROBLAZE_HARDIRQ_H#define _ASM_MICROBLAZE_HARDIRQ_H -#include <linux/cache.h> -#include <linux/irq.h> -#include <asm/irq.h> -#include <asm/current.h> -#include <linux/ptrace.h> -/* should be defined in each interrupt controller driver */ extern unsigned int get_irq (struct pt_regs *regs); -typedef struct { -unsigned int __softirq_pending; -}____cacheline_aligned irq_cpustat_t ; - +#define ack_bad_irq ack_bad_irqvoid ack_bad_irq (unsigned int irq); - -#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */ +#include <asm-generic/hardirq.h> #endif /* _ASM_MICROBLAZE_HARDIRQ_H */
arch/microblaze/include/asm/irq.h +1 -5
@@ -10,6 +10,7 @@#define _ASM_MICROBLAZE_IRQ_H#define NR_IRQS 32 +#include <asm-generic/irq.h> #include <linux/interrupt.h>
@@ -17,11 +18,6 @@ extern unsigned int nr_irq;#define NO_IRQ (-1) -static inline int irq_canonicalize (int irq) -{ -return irq; -} -struct pt_regs ;extern void do_IRQ (struct pt_regs *regs);
arch/microblaze/include/asm/kmap_types.h +1 -29
@@ -1,29 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_KMAP_TYPES_H -#define _ASM_MICROBLAZE_KMAP_TYPES_H - -enum km_type { -KM_BOUNCE_READ , -KM_SKB_SUNRPC_DATA , -KM_SKB_DATA_SOFTIRQ , -KM_USER0 , -KM_USER1 , -KM_BIO_SRC_IRQ , -KM_BIO_DST_IRQ , -KM_PTE0 , -KM_PTE1 , -KM_IRQ0 , -KM_IRQ1 , -KM_SOFTIRQ0 , -KM_SOFTIRQ1 , -KM_TYPE_NR , -}; - -#endif /* _ASM_MICROBLAZE_KMAP_TYPES_H */ +#include <asm-generic/kmap_types.h>
arch/microblaze/include/asm/mmu.h +1 -19
@@ -1,19 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_MMU_H -#define _ASM_MICROBLAZE_MMU_H - -#ifndef __ASSEMBLY__ -typedef struct { -struct vm_list_struct *vmlist; -unsigned long end_brk; -}mm_context_t ; -#endif /* __ASSEMBLY__ */ - -#endif /* _ASM_MICROBLAZE_MMU_H */ +#include <asm-generic/mmu.h>
arch/microblaze/include/asm/mmu_context.h +1 -21
@@ -1,21 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_MMU_CONTEXT_H -#define _ASM_MICROBLAZE_MMU_CONTEXT_H - -# define init_new_context (tsk, mm) ({ 0; }) - -# define enter_lazy_tlb (mm, tsk) do {} while (0) -# define change_mm_context (old, ctx, _pml4) do {} while (0) -# define destroy_context (mm) do {} while (0) -# define deactivate_mm (tsk, mm) do {} while (0) -# define switch_mm (prev, next, tsk) do {} while (0) -# define activate_mm (prev, next) do {} while (0) - -#endif /* _ASM_MICROBLAZE_MMU_CONTEXT_H */ +#include <asm-generic/mmu_context.h>
arch/microblaze/include/asm/module.h +2 -8
@@ -9,6 +9,8 @@#ifndef _ASM_MICROBLAZE_MODULE_H#define _ASM_MICROBLAZE_MODULE_H +#include <asm-generic/module.h> +/* Microblaze Relocations */ #define R_MICROBLAZE_NONE 0#define R_MICROBLAZE_32 1
@@ -24,14 +26,6 @@/* Keep this the last entry. */ #define R_MICROBLAZE_NUM 11 -struct mod_arch_specific { -int foo; -}; - -#define Elf_Shdr Elf32_Shdr -#define Elf_Sym Elf32_Sym -#define Elf_Ehdr Elf32_Ehdr -typedef struct {volatile int counter; }module_t ;#endif /* _ASM_MICROBLAZE_MODULE_H */
arch/microblaze/include/asm/pgalloc.h +1 -14
@@ -1,14 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_PGALLOC_H -#define _ASM_MICROBLAZE_PGALLOC_H - -#define check_pgt_cache () do {} while (0) - -#endif /* _ASM_MICROBLAZE_PGALLOC_H */ +#include <asm-generic/pgalloc.h>
arch/microblaze/include/asm/scatterlist.h +1 -28
@@ -1,28 +1 @@ -/* -* Copyright (C) 2008 Michal Simek <[email protected]> -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_SCATTERLIST_H -#define _ASM_MICROBLAZE_SCATTERLIST_H - -struct scatterlist { -#ifdef CONFIG_DEBUG_SG -unsigned long sg_magic; -#endif -unsigned long page_link; -dma_addr_t dma_address; -unsigned int offset; -unsigned int length; -}; - -#define sg_dma_address (sg) ((sg)->dma_address) -#define sg_dma_len (sg) ((sg)->length) - -#define ISA_DMA_THRESHOLD (~0UL) - -#endif /* _ASM_MICROBLAZE_SCATTERLIST_H */ +#include <asm-generic/scatterlist.h>
arch/microblaze/include/asm/serial.h +1 -14
@@ -1,14 +1 @@ -/* -* Copyright (C) 2009 Michal Simek <[email protected]> -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_SERIAL_H -#define _ASM_MICROBLAZE_SERIAL_H - -# define BASE_BAUD (1843200 / 16) - -#endif /* _ASM_MICROBLAZE_SERIAL_H */ +#include <asm-generic/serial.h>
arch/microblaze/include/asm/shmparam.h +1 -6
@@ -1,6 +1 @@ -#ifndef _ASM_MICROBLAZE_SHMPARAM_H -#define _ASM_MICROBLAZE_SHMPARAM_H - -#define SHMLBA PAGE_SIZE/* attach addr a multiple of this */ - -#endif /* _ASM_MICROBLAZE_SHMPARAM_H */ +#include <asm-generic/shmparam.h>
arch/microblaze/include/asm/system.h +3 -0
@@ -13,6 +13,9 @@#include <asm/setup.h> #include <asm/irqflags.h> +#include <asm-generic/cmpxchg.h> +#include <asm-generic/cmpxchg-local.h> +struct task_struct ;struct thread_info ;
arch/microblaze/include/asm/timex.h +1 -18
@@ -1,18 +1 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_TIMEX_H -#define _ASM_MICROBLAZE_TIMEX_H - -#define CLOCK_TICK_RATE 1000/* Timer input freq. */ - -typedef unsigned long cycles_t ; - -#define get_cycles () (0) - -#endif /* _ASM_TIMEX_H */ +#include <asm-generic/timex.h>
Signature · 1 line
1.5.6.3
PATCH 25/27 microblaze: use generic uaccess.h
In reply to Arnd BergmannAdapt microblaze uaccess code to use the uaccess.h generic implementation.
--- arch/microblaze/include/asm/uaccess.h | 164 ++++++--------------------------- arch/microblaze/lib/uaccess.c | 42 +-------- 2 files changed, 31 insertions(+), 175 deletions(-)
rewrite arch/microblaze/include/asm/uaccess.h (86%) rewrite arch/microblaze/lib/uaccess.c (97%)
arch/microblaze/include/asm/uaccess.h +30 -134
@@ -1,134 +1,30 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_UACCESS_H -#define _ASM_MICROBLAZE_UACCESS_H - -#ifdef __KERNEL__ -#ifndef __ASSEMBLY__ - -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/sched.h> /* RLIMIT_FSIZE */ -#include <linux/mm.h> - -#include <asm/mmu.h> -#include <asm/page.h> -#include <asm/pgtable.h> -#include <asm/segment.h> -#include <linux/string.h> - -#define VERIFY_READ 0 -#define VERIFY_WRITE 1 - -extern int ___range_ok (unsigned long addr,unsigned long size); - -#define __range_ok (addr, size) \ - ___range_ok((unsigned long)(addr), (unsigned long)(size)) - -#define access_ok (type, addr, size) (__range_ok((addr), (size)) == 0) -#define __access_ok (add, size) (__range_ok((addr), (size)) == 0) - -extern inline int bad_user_access_length (void ) -{ -return 0 ; -} -/* FIXME this is function for optimalization -> memcpy */ -#define __get_user (var, ptr) \ - ({ \ - int __gu_err = 0; \ - switch (sizeof(*(ptr))) { \ - case 1: \ - case 2: \ - case 4: \ - (var) = *(ptr); \ - break; \ - case 8: \ - memcpy((void *) &(var), (ptr), 8); \ - break; \ - default: \ - (var) = 0; \ - __gu_err = __get_user_bad(); \ - break; \ - } \ - __gu_err; \ - }) - -#define __get_user_bad () (bad_user_access_length(), (-EFAULT)) - -#define __put_user (var, ptr) \ - ({ \ - int __pu_err = 0; \ - switch (sizeof(*(ptr))) { \ - case 1: \ - case 2: \ - case 4: \ - *(ptr) = (var); \ - break; \ - case 8: { \ - typeof(*(ptr)) __pu_val = var; \ - memcpy(ptr, &__pu_val, sizeof(__pu_val));\ - } \ - break; \ - default: \ - __pu_err = __put_user_bad(); \ - break; \ - } \ - __pu_err; \ - }) - -#define __put_user_bad () (bad_user_access_length(), (-EFAULT)) - -#define put_user (x, ptr) __put_user(x, ptr) -#define get_user (x, ptr) __get_user(x, ptr) - -#define copy_to_user (to, from, n) (memcpy(to, from, n), 0) -#define copy_from_user (to, from, n) (memcpy(to, from, n), 0) - -#define __copy_to_user (to, from, n) (copy_to_user(to, from, n)) -#define __copy_from_user (to, from, n) (copy_from_user(to, from, n)) -#define __copy_to_user_inatomic (to, from, n) (__copy_to_user(to, from, n)) -#define __copy_from_user_inatomic (to, from, n) (__copy_from_user(to, from, n)) - -#define __clear_user (addr, n) (memset((void *)addr, 0, n), 0) - -static inline unsigned long clear_user (void *addr,unsigned long size) -{ -if (access_ok (VERIFY_WRITE , addr, size)) - size =__clear_user (addr, size); -return size; -} - -/* Returns 0 if exception not found and fixup otherwise. */ -extern unsigned long search_exception_table (unsigned long ); - - -extern long strncpy_from_user (char *dst,const char __user *src,long count); -extern long strnlen_user (const char __user *src,long count); -extern long __strncpy_from_user (char *dst,const char __user *src,long count); - -/* -* The exception table consists of pairs of addresses: the first is the -* address of an instruction that is allowed to fault, and the second is -* the address at which the program should continue. No registers are -* modified, so it is entirely up to the continuation code to figure out -* what to do. -* -* All the routines below use bits of fixup code that are out of line -* with the main instruction path. This means when everything is well, -* we don't even have to jump over them. Further, they do not intrude -* on our cache or tlb entries. -*/ -struct exception_table_entry { -unsigned long insn, fixup; -}; - -#endif /* __ASSEMBLY__ */ -#endif /* __KERNEL__ */ - -#endif /* _ASM_MICROBLAZE_UACCESS_H */ +#ifndef _ASM_MICROBLAZE_UACCESS_H +#define _ASM_MICROBLAZE_UACCESS_H +/* +* Copyright (C) 2006 Atmark Techno, Inc. +* +* 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. +*/ + +#ifdef __KERNEL__ +#ifndef __ASSEMBLY__ + +#define __access_ok (addr, size) \ + (___range_ok((unsigned long)(addr), (unsigned long)(size)) == 0) +extern int ___range_ok (unsigned long addr,unsigned long size); + +#define __put_user_bad bad_user_access_length +#define __get_user_bad bad_user_access_length +extern inline int bad_user_access_length (void ) +{ +return 0 ; +} + +#include <asm-generic/uaccess.h> + +#endif /* __ASSEMBLY__ */ +#endif /* __KERNEL__ */ + +#endif /* _ASM_MICROBLAZE_UACCESS_H */
arch/microblaze/lib/uaccess.c +1 -41
42 lines not on this page · raw message
Signature · 1 line
1.5.6.3
PATCH 26/27 microblaze: make io.h use asm-generic/io.h
In reply to Arnd Bergmann--- arch/microblaze/include/asm/io.h | 240 +++++--------------------------------- 1 files changed, 32 insertions(+), 208 deletions(-)
rewrite arch/microblaze/include/asm/io.h (94%)
arch/microblaze/include/asm/io.h +32 -208
@@ -1,208 +1,32 @@ -/* -* Copyright (C) 2006 Atmark Techno, Inc. -* -* 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. -*/ - -#ifndef _ASM_MICROBLAZE_IO_H -#define _ASM_MICROBLAZE_IO_H - -#include <asm/byteorder.h> -#include <asm/page.h> -#include <linux/types.h> - -#define IO_SPACE_LIMIT (0xFFFFFFFF) - -static inline unsigned char __raw_readb (const volatile void __iomem *addr) -{ -return *(volatile unsigned char __force *)addr; -} -static inline unsigned short __raw_readw (const volatile void __iomem *addr) -{ -return *(volatile unsigned short __force *)addr; -} -static inline unsigned int __raw_readl (const volatile void __iomem *addr) -{ -return *(volatile unsigned int __force *)addr; -} -static inline unsigned long __raw_readq (const volatile void __iomem *addr) -{ -return *(volatile unsigned long __force *)addr; -} -static inline void __raw_writeb (unsigned char v,volatile void __iomem *addr) -{ - *(volatile unsigned char __force *)addr = v; -} -static inline void __raw_writew (unsigned short v,volatile void __iomem *addr) -{ - *(volatile unsigned short __force *)addr = v; -} -static inline void __raw_writel (unsigned int v,volatile void __iomem *addr) -{ - *(volatile unsigned int __force *)addr = v; -} -static inline void __raw_writeq (unsigned long v,volatile void __iomem *addr) -{ - *(volatile unsigned long __force *)addr = v; -} - -/* -* read (readb, readw, readl, readq) and write (writeb, writew, -* writel, writeq) accessors are for PCI and thus littel endian. -* Linux 2.4 for Microblaze had this wrong. -*/ -static inline unsigned char readb (const volatile void __iomem *addr) -{ -return *(volatile unsigned char __force *)addr; -} -static inline unsigned short readw (const volatile void __iomem *addr) -{ -return le16_to_cpu (*(volatile unsigned short __force *)addr); -} -static inline unsigned int readl (const volatile void __iomem *addr) -{ -return le32_to_cpu (*(volatile unsigned int __force *)addr); -} -static inline void writeb (unsigned char v,volatile void __iomem *addr) -{ - *(volatile unsigned char __force *)addr = v; -} -static inline void writew (unsigned short v,volatile void __iomem *addr) -{ - *(volatile unsigned short __force *)addr =cpu_to_le16 (v); -} -static inline void writel (unsigned int v,volatile void __iomem *addr) -{ - *(volatile unsigned int __force *)addr =cpu_to_le32 (v); -} - -/* ioread and iowrite variants. thease are for now same as __raw_ -* variants of accessors. we might check for endianess in the feature -*/ -#define ioread8 (addr) __raw_readb((u8 *)(addr)) -#define ioread16 (addr) __raw_readw((u16 *)(addr)) -#define ioread32 (addr) __raw_readl((u32 *)(addr)) -#define iowrite8 (v, addr) __raw_writeb((u8)(v), (u8 *)(addr)) -#define iowrite16 (v, addr) __raw_writew((u16)(v), (u16 *)(addr)) -#define iowrite32 (v, addr) __raw_writel((u32)(v), (u32 *)(addr)) - -/* These are the definitions for the x86 IO instructions -* inb/inw/inl/outb/outw/outl, the "string" versions -* insb/insw/insl/outsb/outsw/outsl, and the "pausing" versions -* inb_p/inw_p/... -* The macros don't do byte-swapping. -*/ -#define inb (port) readb((u8 *)((port))) -#define outb (val, port) writeb((val), (u8 *)((unsigned long)(port))) -#define inw (port) readw((u16 *)((port))) -#define outw (val, port) writew((val), (u16 *)((unsigned long)(port))) -#define inl (port) readl((u32 *)((port))) -#define outl (val, port) writel((val), (u32 *)((unsigned long)(port))) - -#define inb_p (port) inb((port)) -#define outb_p (val, port) outb((val), (port)) -#define inw_p (port) inw((port)) -#define outw_p (val, port) outw((val), (port)) -#define inl_p (port) inl((port)) -#define outl_p (val, port) outl((val), (port)) - -#define memset_io (a, b, c) memset((void *)(a), (b), (c)) -#define memcpy_fromio (a, b, c) memcpy((a), (void *)(b), (c)) -#define memcpy_toio (a, b, c) memcpy((void *)(a), (b), (c)) - -/** -* virt_to_phys - map virtual addresses to physical -* @address: address to remap -* -* The returned physical address is the physical (CPU) mapping for -* the memory address given. It is only valid to use this function on -* addresses directly mapped or allocated via kmalloc. -* -* This function does not give bus mappings for DMA transfers. In -* almost all conceivable cases a device driver should not be using -* this function -*/ -static inline unsigned long __iomem virt_to_phys (volatile void *address) -{ -return __pa ((unsigned long )address); -} - -#define virt_to_bus virt_to_phys - -/** -* phys_to_virt - map physical address to virtual -* @address: address to remap -* -* The returned virtual address is a current CPU mapping for -* the memory address given. It is only valid to use this function on -* addresses that have a kernel mapping -* -* This function does not handle bus mappings for DMA transfers. In -* almost all conceivable cases a device driver should not be using -* this function -*/ -static inline void *phys_to_virt (unsigned long address) -{ -return (void *)__va (address); -} - -#define bus_to_virt (a) phys_to_virt(a) - -static inline void __iomem *__ioremap (phys_addr_t address,unsigned long size, -unsigned long flags) -{ -return (void *)address; -} - -#define ioremap (physaddr, size) ((void __iomem *)(unsigned long)(physaddr)) -#define iounmap (addr) ((void)0) -#define ioremap_nocache (physaddr, size) ioremap(physaddr, size) - -/* -* Convert a physical pointer to a virtual kernel pointer for /dev/mem -* access -*/ -#define xlate_dev_mem_ptr (p) __va(p) - -/* -* Convert a virtual cached pointer to an uncached pointer -*/ -#define xlate_dev_kmem_ptr (p) p - -/* -* Big Endian -*/ -#define out_be32 (a, v) __raw_writel((v), (void __iomem __force *)(a)) -#define out_be16 (a, v) __raw_writew((v), (a)) - -#define in_be32 (a) __raw_readl((const void __iomem __force *)(a)) -#define in_be16 (a) __raw_readw(a) - -/* -* Little endian -*/ - -#define out_le32 (a, v) __raw_writel(__cpu_to_le32(v), (a)); -#define out_le16 (a, v) __raw_writew(__cpu_to_le16(v), (a)) - -#define in_le32 (a) __le32_to_cpu(__raw_readl(a)) -#define in_le16 (a) __le16_to_cpu(__raw_readw(a)) - -/* Byte ops */ -#define out_8 (a, v) __raw_writeb((v), (a)) -#define in_8 (a) __raw_readb(a) - -/* FIXME */ -static inline void __iomem *ioport_map (unsigned long port,unsigned int len) -{ -return (void __iomem *) (port); -} - -static inline void ioport_unmap (void __iomem *addr) -{ -/* Nothing to do */ -} - -#endif /* _ASM_MICROBLAZE_IO_H */ +/* +* Copyright (C) 2006 Atmark Techno, Inc. +* +* 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. +*/ +#ifndef _ASM_MICROBLAZE_IO_H +#define _ASM_MICROBLAZE_IO_H + +#include <asm-generic/io.h> + +#define virt_to_bus virt_to_phys +#define bus_to_virt phys_to_virt + +/* Big Endian */ +#define out_be32 (a, v) __raw_writel((v), (void __iomem __force *)(a)) +#define out_be16 (a, v) __raw_writew((v), (a)) +#define in_be32 (a) __raw_readl((const void __iomem __force *)(a)) +#define in_be16 (a) __raw_readw(a) + +/* Little endian */ +#define out_le32 (a, v) __raw_writel(__cpu_to_le32(v), (a)); +#define out_le16 (a, v) __raw_writew(__cpu_to_le16(v), (a)) +#define in_le32 (a) __le32_to_cpu(__raw_readl(a)) +#define in_le16 (a) __le16_to_cpu(__raw_readw(a)) + +/* Byte ops */ +#define out_8 (a, v) __raw_writeb((v), (a)) +#define in_8 (a) __raw_readb(a) + +#endif /* _ASM_MICROBLAZE_IO_H */
Signature · 1 line
1.5.6.3
PATCH 27/27 microblaze: use generic system.h
In reply to Arnd BergmannParts of the microblaze system.h can be removed by falling back to the asm-generic version.
--- arch/microblaze/include/asm/cmpxchg-local.h | 1 + arch/microblaze/include/asm/irqflags.h | 2 +- arch/microblaze/include/asm/system.h | 124 +++++++-------------------- 3 files changed, 32 insertions(+), 95 deletions(-) create mode 100644 arch/microblaze/include/asm/cmpxchg-local.h
rewrite arch/microblaze/include/asm/system.h (67%)
arch/microblaze/include/asm/cmpxchg-local.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/cmpxchg-local.h>
arch/microblaze/include/asm/irqflags.h +1 -1
@@ -9,7 +9,7 @@#ifndef _ASM_MICROBLAZE_IRQFLAGS_H#define _ASM_MICROBLAZE_IRQFLAGS_H -#include <linux/irqflags.h> +#include <asm/registers.h> # if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
arch/microblaze/include/asm/system.h +30 -94
124 lines not on this page · raw message
Signature · 1 line
1.5.6.3
Arnd Bergmann
maintainercover use generic headers in x86
In reply to Arnd BergmannOnce the generic headers are merged, we can apply these other patches from Remis to use them in x86.
Arnd <><
Arnd Bergmann
maintainerPATCH 1/2 x86: two small fixes in termios.h
From: Remis Lima Baima <[email protected]>
The operation with the variable 'c_line' was missing in the function 'user_termio_to_kernel_termios'. Also the casting '*(unsigned short *)' in the macro 'SET_LOW_TERMIOS_BITS' was a bit 'unhealthy'. So the macro was removed and the function was changed to be like in other archs (e.g. h8300, m68k, sparc) that have a more elegant solution.
In the function 'kernel_termios_to_user_termio' the return values of the functions calls 'put_user' and 'copy_to_user' were not being checked.
--- arch/x86/include/asm/termios.h | 56 +++++++++++++++++++++++++++------------- 1 files changed, 38 insertions(+), 18 deletions(-)
arch/x86/include/asm/termios.h +38 -18
@@ -54,20 +54,37 @@ struct termio {/* * Translate a "termio" structure into a "termios". Ugh. */ -#define SET_LOW_TERMIOS_BITS (termios, termio, x) { \ - unsigned short __tmp; \ - get_user(__tmp,&(termio)->x); \ - *(unsigned short *) &(termios)->x = __tmp; \ -} -static inline int user_termio_to_kernel_termios (struct ktermios *termios,struct termio __user *termio) -{ -SET_LOW_TERMIOS_BITS (termios, termio, c_iflag); -SET_LOW_TERMIOS_BITS (termios, termio, c_oflag); -SET_LOW_TERMIOS_BITS (termios, termio, c_cflag); -SET_LOW_TERMIOS_BITS (termios, termio, c_lflag); -return copy_from_user (termios->c_cc, termio->c_cc,NCC ); +{ +unsigned short tmp; + +if (get_user (tmp, &termio->c_iflag) <0 ) + goto fault; + termios->c_iflag = (0xffff0000 & termios->c_iflag) | tmp; + +if (get_user (tmp, &termio->c_oflag) <0 ) + goto fault; + termios->c_oflag = (0xffff0000 & termios->c_oflag) | tmp; + +if (get_user (tmp, &termio->c_cflag) <0 ) + goto fault; + termios->c_cflag = (0xffff0000 & termios->c_cflag) | tmp; + +if (get_user (tmp, &termio->c_lflag) <0 ) + goto fault; + termios->c_lflag = (0xffff0000 & termios->c_lflag) | tmp; + +if (get_user (termios->c_line, &termio->c_line) <0 ) + goto fault; + +if (copy_from_user (termios->c_cc, termio->c_cc,NCC ) !=0 ) + goto fault; + +return 0 ; + + fault: +return -EFAULT ; }/*
@@ -76,12 +93,15 @@ static inline int user_termio_to_kernel_termios(struct ktermios *termios,static inline int kernel_termios_to_user_termio (struct termio __user *termio,struct ktermios *termios) { -put_user ((termios)->c_iflag, &(termio)->c_iflag); -put_user ((termios)->c_oflag, &(termio)->c_oflag); -put_user ((termios)->c_cflag, &(termio)->c_cflag); -put_user ((termios)->c_lflag, &(termio)->c_lflag); -put_user ((termios)->c_line, &(termio)->c_line); -return copy_to_user ((termio)->c_cc, (termios)->c_cc,NCC ); +if (put_user (termios->c_iflag, &termio->c_iflag) <0 || +put_user (termios->c_oflag, &termio->c_oflag) <0 || +put_user (termios->c_cflag, &termio->c_cflag) <0 || +put_user (termios->c_lflag, &termio->c_lflag) <0 || +put_user (termios->c_line, &termio->c_line) <0 || +copy_to_user (termio->c_cc, termios->c_cc,NCC ) !=0 ) +return -EFAULT ; + +return 0 ; } static inline int user_termios_to_kernel_termios(struct ktermios *k,
Signature · 1 line
1.6.0.4
Arnd Bergmann
maintainerPATCH 2/2 x86: adapt simple headers to use generic headers
In reply to Arnd BergmannFrom: Remis Lima Baima <[email protected]>
A number of x86 specific headers can be significantly simplified by using the new asm-generic headers.
--- arch/x86/include/asm/ioctls.h | 95 +----------------- arch/x86/include/asm/ipcbuf.h | 34 +----- arch/x86/include/asm/kmap_types.h | 31 +----- arch/x86/include/asm/mman.h | 28 ++---- arch/x86/include/asm/module.h | 13 +-- arch/x86/include/asm/msgbuf.h | 40 +------- arch/x86/include/asm/param.h | 28 +---- arch/x86/include/asm/scatterlist.h | 41 ++------ arch/x86/include/asm/shmbuf.h | 52 +--------- arch/x86/include/asm/socket.h | 66 +----------- arch/x86/include/asm/sockios.h | 14 +--- arch/x86/include/asm/termbits.h | 199 +----------------------------------- arch/x86/include/asm/termios.h | 134 +------------------------ arch/x86/include/asm/types.h | 12 +-- arch/x86/include/asm/ucontext.h | 8 +-- 15 files changed, 46 insertions(+), 749 deletions(-)
rewrite arch/x86/include/asm/ioctls.h (100%)
rewrite arch/x86/include/asm/ipcbuf.h (86%)
rewrite arch/x86/include/asm/kmap_types.h (99%)
rewrite arch/x86/include/asm/mman.h (82%)
rewrite arch/x86/include/asm/msgbuf.h (100%)
rewrite arch/x86/include/asm/param.h (81%)
rewrite arch/x86/include/asm/scatterlist.h (82%)
rewrite arch/x86/include/asm/shmbuf.h (100%)
rewrite arch/x86/include/asm/socket.h (93%)
rewrite arch/x86/include/asm/termbits.h (100%)
rewrite arch/x86/include/asm/termios.h (100%)
arch/x86/include/asm/ioctls.h +1 -94
@@ -1,94 +1 @@ -#ifndef _ASM_X86_IOCTLS_H -#define _ASM_X86_IOCTLS_H - -#include <asm/ioctl.h> - -/* 0x54 is just a magic number to make these relatively unique ('T') */ - -#define TCGETS 0x5401 -#define TCSETS 0x5402/* Clashes with SNDCTL_TMR_START sound ioctl */ -#define TCSETSW 0x5403 -#define TCSETSF 0x5404 -#define TCGETA 0x5405 -#define TCSETA 0x5406 -#define TCSETAW 0x5407 -#define TCSETAF 0x5408 -#define TCSBRK 0x5409 -#define TCXONC 0x540A -#define TCFLSH 0x540B -#define TIOCEXCL 0x540C -#define TIOCNXCL 0x540D -#define TIOCSCTTY 0x540E -#define TIOCGPGRP 0x540F -#define TIOCSPGRP 0x5410 -#define TIOCOUTQ 0x5411 -#define TIOCSTI 0x5412 -#define TIOCGWINSZ 0x5413 -#define TIOCSWINSZ 0x5414 -#define TIOCMGET 0x5415 -#define TIOCMBIS 0x5416 -#define TIOCMBIC 0x5417 -#define TIOCMSET 0x5418 -#define TIOCGSOFTCAR 0x5419 -#define TIOCSSOFTCAR 0x541A -#define FIONREAD 0x541B -#define TIOCINQ FIONREAD -#define TIOCLINUX 0x541C -#define TIOCCONS 0x541D -#define TIOCGSERIAL 0x541E -#define TIOCSSERIAL 0x541F -#define TIOCPKT 0x5420 -#define FIONBIO 0x5421 -#define TIOCNOTTY 0x5422 -#define TIOCSETD 0x5423 -#define TIOCGETD 0x5424 -#define TCSBRKP 0x5425/* Needed for POSIX tcsendbreak() */ -/* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */ -#define TIOCSBRK 0x5427/* BSD compatibility */ -#define TIOCCBRK 0x5428/* BSD compatibility */ -#define TIOCGSID 0x5429/* Return the session ID of FD */ -#define TCGETS2 _IOR('T', 0x2A, struct termios2) -#define TCSETS2 _IOW('T', 0x2B, struct termios2) -#define TCSETSW2 _IOW('T', 0x2C, struct termios2) -#define TCSETSF2 _IOW('T', 0x2D, struct termios2) -#define TIOCGRS485 0x542E -#define TIOCSRS485 0x542F -#define TIOCGPTN _IOR('T', 0x30, unsigned int) -/* Get Pty Number (of pty-mux device) */ -#define TIOCSPTLCK _IOW('T', 0x31, int)/* Lock/unlock Pty */ -#define TCGETX 0x5432/* SYS5 TCGETX compatibility */ -#define TCSETX 0x5433 -#define TCSETXF 0x5434 -#define TCSETXW 0x5435 - -#define FIONCLEX 0x5450 -#define FIOCLEX 0x5451 -#define FIOASYNC 0x5452 -#define TIOCSERCONFIG 0x5453 -#define TIOCSERGWILD 0x5454 -#define TIOCSERSWILD 0x5455 -#define TIOCGLCKTRMIOS 0x5456 -#define TIOCSLCKTRMIOS 0x5457 -#define TIOCSERGSTRUCT 0x5458/* For debugging only */ -#define TIOCSERGETLSR 0x5459/* Get line status register */ -#define TIOCSERGETMULTI 0x545A/* Get multiport config */ -#define TIOCSERSETMULTI 0x545B/* Set multiport config */ - -#define TIOCMIWAIT 0x545C/* wait for a change on serial input line(s) */ -#define TIOCGICOUNT 0x545D/* read serial port inline interrupt counts */ -#define TIOCGHAYESESP 0x545E/* Get Hayes ESP configuration */ -#define TIOCSHAYESESP 0x545F/* Set Hayes ESP configuration */ -#define FIOQSIZE 0x5460 - -/* Used for packet mode */ -#define TIOCPKT_DATA 0 -#define TIOCPKT_FLUSHREAD 1 -#define TIOCPKT_FLUSHWRITE 2 -#define TIOCPKT_STOP 4 -#define TIOCPKT_START 8 -#define TIOCPKT_NOSTOP 16 -#define TIOCPKT_DOSTOP 32 - -#define TIOCSER_TEMT 0x01/* Transmitter physically empty */ - -#endif /* _ASM_X86_IOCTLS_H */ +#include <asm-generic/ioctls.h>
arch/x86/include/asm/ipcbuf.h +6 -28
@@ -1,28 +1,6 @@ -#ifndef _ASM_X86_IPCBUF_H -#define _ASM_X86_IPCBUF_H - -/* -* The ipc64_perm structure for x86 architecture. -* Note extra padding because this structure is passed back and forth -* between kernel and user space. -* -* Pad space is left for: -* - 32-bit mode_t and seq -* - 2 miscellaneous 32-bit values -*/ - -struct ipc64_perm { -__kernel_key_t key; -__kernel_uid32_t uid; -__kernel_gid32_t gid; -__kernel_uid32_t cuid; -__kernel_gid32_t cgid; -__kernel_mode_t mode; -unsigned short __pad1; -unsigned short seq; -unsigned short __pad2; -unsigned long __unused1; -unsigned long __unused2; -}; - -#endif /* _ASM_X86_IPCBUF_H */ +#ifndef _ASM_X86_IPCBUF_H +#define _ASM_X86_IPCBUF_H + +#include <asm-generic/ipcbuf.h> + +#endif /* _ASM_X86_IPCBUF_H */
arch/x86/include/asm/kmap_types.h +2 -29
@@ -1,29 +1,2 @@ -#ifndef _ASM_X86_KMAP_TYPES_H -#define _ASM_X86_KMAP_TYPES_H - -#if defined(CONFIG_X86_32 ) && defined(CONFIG_DEBUG_HIGHMEM ) -# define D (n) __KM_FENCE_##n , -#else -# define D (n) -#endif - -enum km_type { -D(0) KM_BOUNCE_READ, -D(1) KM_SKB_SUNRPC_DATA, -D(2) KM_SKB_DATA_SOFTIRQ, -D(3) KM_USER0, -D(4) KM_USER1, -D(5) KM_BIO_SRC_IRQ, -D(6) KM_BIO_DST_IRQ, -D(7) KM_PTE0, -D(8) KM_PTE1, -D(9) KM_IRQ0, -D(10) KM_IRQ1, -D(11) KM_SOFTIRQ0, -D(12) KM_SOFTIRQ1, -D(13) KM_TYPE_NR -}; - -#undef D - -#endif /* _ASM_X86_KMAP_TYPES_H */ +#include <asm-generic/kmap_types.h> +
arch/x86/include/asm/mman.h +8 -20
@@ -1,20 +1,8 @@ -#ifndef _ASM_X86_MMAN_H -#define _ASM_X86_MMAN_H - -#include <asm-generic/mman-common.h> - -#define MAP_32BIT 0x40/* only give out 32bit addresses */ - -#define MAP_GROWSDOWN 0x0100/* stack-like segment */ -#define MAP_DENYWRITE 0x0800/* ETXTBSY */ -#define MAP_EXECUTABLE 0x1000/* mark it as an executable */ -#define MAP_LOCKED 0x2000/* pages are locked */ -#define MAP_NORESERVE 0x4000/* don't check for reservations */ -#define MAP_POPULATE 0x8000/* populate (prefault) pagetables */ -#define MAP_NONBLOCK 0x10000/* do not block on IO */ -#define MAP_STACK 0x20000/* give out an address that is best suited for process/thread stacks */ - -#define MCL_CURRENT 1/* lock all current mappings */ -#define MCL_FUTURE 2/* lock all future mappings */ - -#endif /* _ASM_X86_MMAN_H */ +#ifndef _ASM_X86_MMAN_H +#define _ASM_X86_MMAN_H + +#define MAP_32BIT 0x40/* only give out 32bit addresses */ + +#include <asm-generic/mman.h> + +#endif /* _ASM_X86_MMAN_H */
arch/x86/include/asm/module.h +1 -12
@@ -1,18 +1,7 @@#ifndef _ASM_X86_MODULE_H#define _ASM_X86_MODULE_H -/* x86_32/64 are simple */ -struct mod_arch_specific {}; - -#ifdef CONFIG_X86_32 -# define Elf_Shdr Elf32_Shdr -# define Elf_Sym Elf32_Sym -# define Elf_Ehdr Elf32_Ehdr -#else -# define Elf_Shdr Elf64_Shdr -# define Elf_Sym Elf64_Sym -# define Elf_Ehdr Elf64_Ehdr -#endif +#include <asm-generic/module.h> #ifdef CONFIG_X86_64 /* X86_64 does not define MODULE_PROC_FAMILY */
arch/x86/include/asm/msgbuf.h +1 -39
@@ -1,39 +1 @@ -#ifndef _ASM_X86_MSGBUF_H -#define _ASM_X86_MSGBUF_H - -/* -* The msqid64_ds structure for i386 architecture. -* Note extra padding because this structure is passed back and forth -* between kernel and user space. -* -* Pad space on i386 is left for: -* - 64-bit time_t to solve y2038 problem -* - 2 miscellaneous 32-bit values -* -* Pad space on x8664 is left for: -* - 2 miscellaneous 64-bit values -*/ -struct msqid64_ds { -struct ipc64_perm msg_perm; -__kernel_time_t msg_stime;/* last msgsnd time */ -#ifdef __i386__ -unsigned long __unused1; -#endif -__kernel_time_t msg_rtime;/* last msgrcv time */ -#ifdef __i386__ -unsigned long __unused2; -#endif -__kernel_time_t msg_ctime;/* last change time */ -#ifdef __i386__ -unsigned long __unused3; -#endif -unsigned long msg_cbytes;/* current number of bytes on queue */ -unsigned long msg_qnum;/* number of messages in queue */ -unsigned long msg_qbytes;/* max number of bytes on queue */ -__kernel_pid_t msg_lspid;/* pid of last msgsnd */ -__kernel_pid_t msg_lrpid;/* last receive pid */ -unsigned long __unused4; -unsigned long __unused5; -}; - -#endif /* _ASM_X86_MSGBUF_H */ +#include <asm-generic/msgbuf.h>
arch/x86/include/asm/param.h +6 -22
@@ -1,22 +1,6 @@ -#ifndef _ASM_X86_PARAM_H -#define _ASM_X86_PARAM_H - -#ifdef __KERNEL__ -# define HZ CONFIG_HZ/* Internal kernel timer frequency */ -# define USER_HZ 100/* some user interfaces are */ -# define CLOCKS_PER_SEC (USER_HZ)/* in "ticks" like times() */ -#endif - -#ifndef HZ -#define HZ 100 -#endif - -#define EXEC_PAGESIZE 4096 - -#ifndef NOGROUP -#define NOGROUP (-1) -#endif - -#define MAXHOSTNAMELEN 64/* max length of hostname */ - -#endif /* _ASM_X86_PARAM_H */ +#ifndef _ASM_X86_PARAM_H +#define _ASM_X86_PARAM_H + +#include <asm-generic/param.h> + +#endif /* _ASM_X86_PARAM_H */
arch/x86/include/asm/scatterlist.h +8 -33
41 lines not on this page · raw message
arch/x86/include/asm/shmbuf.h +1 -51
52 lines not on this page · raw message
arch/x86/include/asm/socket.h +6 -60
66 lines not on this page · raw message
arch/x86/include/asm/sockios.h +1 -13
@@ -1,13 +1 @@ -#ifndef _ASM_X86_SOCKIOS_H -#define _ASM_X86_SOCKIOS_H - -/* Socket-level I/O control calls. */ -#define FIOSETOWN 0x8901 -#define SIOCSPGRP 0x8902 -#define FIOGETOWN 0x8903 -#define SIOCGPGRP 0x8904 -#define SIOCATMARK 0x8905 -#define SIOCGSTAMP 0x8906/* Get stamp (timeval) */ -#define SIOCGSTAMPNS 0x8907/* Get stamp (timespec) */ - -#endif /* _ASM_X86_SOCKIOS_H */ +#include <asm-generic/sockios.h>
arch/x86/include/asm/termbits.h +1 -198
199 lines not on this page · raw message
arch/x86/include/asm/termios.h +1 -133
134 lines not on this page · raw message
arch/x86/include/asm/types.h +2 -10
@@ -1,19 +1,11 @@#ifndef _ASM_X86_TYPES_H#define _ASM_X86_TYPES_H -#include <asm-generic/int-ll64.h> +#define dma_addr_t dma_addr_t -#ifndef __ASSEMBLY__ - -typedef unsigned short umode_t ; +#include <asm-generic/types.h> -#endif /* __ASSEMBLY__ */ - -/* -* These aren't exported outside the kernel to avoid name space clashes -*/ #ifdef __KERNEL__ -#ifndef __ASSEMBLY__typedef u64 dma64_addr_t ;
arch/x86/include/asm/ucontext.h +1 -7
@@ -7,12 +7,6 @@* sigcontext struct (uc_mcontext). */ -struct ucontext { -unsigned long uc_flags; -struct ucontext *uc_link; -stack_t uc_stack; -struct sigcontext uc_mcontext; -sigset_t uc_sigmask;/* mask last for extensibility */ -}; +#include <asm-generic/ucontext.h> #endif /* _ASM_X86_UCONTEXT_H */
Signature · 1 line
1.5.6.3
Quoted 5 lines · Arnd Bergmann
To avoid trouble with quilt mail, I'm now trying git-format-patch to generate them, hopefully this works a little better. Can anyone tell me why I can't add a 'To' header rather than just 'Cc' in git-format-patch?
I always specify the --to with git send-email.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerQuoted 8 lines · Geert Uytterhoeven
Quoted 5 lines · Arnd Bergmann
To avoid trouble with quilt mail, I'm now trying git-format-patch to generate them, hopefully this works a little better. Can anyone tell me why I can't add a 'To' header rather than just 'Cc' in git-format-patch?
I always specify the --to with git send-email.
I haven't tried using git send-email yet, because it does not let me inspect mails after changing the headers but before sending them out.
I have now gone back to my old method of
rm -rf patches
mkdir -p patches
git-format-patch -o patches | cut -f 2- -d/ > patches/series quilt mail --mbox ~/Mail/outbox
#manually edit outbox if necessary, then hit send button in mail client.
Arnd <><
Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Geert Uytterhoeven
Quoted 5 lines · Arnd Bergmann
To avoid trouble with quilt mail, I'm now trying git-format-patch to generate them, hopefully this works a little better. Can anyone tell me why I can't add a 'To' header rather than just 'Cc' in git-format-patch?
Quoted 5 lines
Quoted 1 line
I always specify the --to with git send-email.
I haven't tried using git send-email yet, because it does not let me inspect mails after changing the headers but before sending them out.
The --dry-run option is not sufficient for you?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerQuoted 6 lines · Geert Uytterhoeven
Quoted 3 lines · Arnd Bergmann
I haven't tried using git send-email yet, because it does not let me inspect mails after changing the headers but before sending them out.
The --dry-run option is not sufficient for you?
I've now started using git-send-email after yet another screwup with quilt+kmail. I now played around using '--suppress-cc all' sending patches to myself and fixed the problems I found there, which gave me enough confidence in the general procedure.
Arnd <><