From 5e5419734c8719cbc01af959ad9c0844002c0df5 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Mon, 4 Feb 2008 22:29:14 -0800 Subject: add mm argument to pte/pmd/pud/pgd_free (with Martin Schwidefsky ) The pgd/pud/pmd/pte page table allocation functions get a mm_struct pointer as first argument. The free functions do not get the mm_struct argument. This is 1) asymmetrical and 2) to do mm related page table allocations the mm argument is needed on the free function as well. [kamalesh@linux.vnet.ibm.com: i386 fix] [akpm@linux-foundation.org: coding-syle fixes] Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Martin Schwidefsky Cc: Signed-off-by: Kamalesh Babulal Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-frv/pgalloc.h | 8 ++++---- include/asm-frv/pgtable.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include/asm-frv') diff --git a/include/asm-frv/pgalloc.h b/include/asm-frv/pgalloc.h index ce982a6c610..e89620ef08c 100644 --- a/include/asm-frv/pgalloc.h +++ b/include/asm-frv/pgalloc.h @@ -31,18 +31,18 @@ do { \ */ extern pgd_t *pgd_alloc(struct mm_struct *); -extern void pgd_free(pgd_t *); +extern void pgd_free(struct mm_struct *mm, pgd_t *); extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); extern struct page *pte_alloc_one(struct mm_struct *, unsigned long); -static inline void pte_free_kernel(pte_t *pte) +static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) { free_page((unsigned long)pte); } -static inline void pte_free(struct page *pte) +static inline void pte_free(struct mm_struct *mm, struct page *pte) { __free_page(pte); } @@ -55,7 +55,7 @@ static inline void pte_free(struct page *pte) * (In the PAE case we free the pmds as part of the pgd.) */ #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *) 2); }) -#define pmd_free(x) do { } while (0) +#define pmd_free(mm, x) do { } while (0) #define __pmd_free_tlb(tlb,x) do { } while (0) #endif /* CONFIG_MMU */ diff --git a/include/asm-frv/pgtable.h b/include/asm-frv/pgtable.h index 3c402afb9e7..6c0682ed5fc 100644 --- a/include/asm-frv/pgtable.h +++ b/include/asm-frv/pgtable.h @@ -226,7 +226,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address) * inside the pgd, so has no extra memory associated with it. */ #define pud_alloc_one(mm, address) NULL -#define pud_free(x) do { } while (0) +#define pud_free(mm, x) do { } while (0) #define __pud_free_tlb(tlb, x) do { } while (0) /* -- cgit v1.2.3-70-g09d2 From 82b12e232d2a71f566dca48df4ae4548e6d8d53d Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Mon, 4 Feb 2008 22:29:54 -0800 Subject: FRV: move DMA macros to scatterlist.h for consistency. To be consistent with other architectures, these two DMA macros should be defined in scatterlist.h as opposed to dma-mapping.h Signed-off-by: Robert P. J. Day Acked-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-frv/dma-mapping.h | 10 ---------- include/asm-frv/scatterlist.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'include/asm-frv') diff --git a/include/asm-frv/dma-mapping.h b/include/asm-frv/dma-mapping.h index bcb2df68496..2e8966ca030 100644 --- a/include/asm-frv/dma-mapping.h +++ b/include/asm-frv/dma-mapping.h @@ -16,16 +16,6 @@ extern unsigned long __nongprelbss dma_coherent_mem_end; void *dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp); void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle); -/* - * These macros should be used after a pci_map_sg call has been done - * to get bus addresses of each of the SG entries and their lengths. - * You should only work with the number of sg entries pci_map_sg - * returns, or alternatively stop on the first sg_dma_len(sg) which - * is 0. - */ -#define sg_dma_address(sg) ((sg)->dma_address) -#define sg_dma_len(sg) ((sg)->length) - /* * Map a single buffer of the indicated size for DMA in streaming mode. * The 32-bit bus address to use is returned. diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h index 2e7143b5a7a..4bca8a28546 100644 --- a/include/asm-frv/scatterlist.h +++ b/include/asm-frv/scatterlist.h @@ -31,6 +31,16 @@ struct scatterlist { unsigned int length; }; +/* + * These macros should be used after a pci_map_sg call has been done + * to get bus addresses of each of the SG entries and their lengths. + * You should only work with the number of sg entries pci_map_sg + * returns, or alternatively stop on the first sg_dma_len(sg) which + * is 0. + */ +#define sg_dma_address(sg) ((sg)->dma_address) +#define sg_dma_len(sg) ((sg)->length) + #define ISA_DMA_THRESHOLD (0xffffffffUL) #endif /* !_ASM_SCATTERLIST_H */ -- cgit v1.2.3-70-g09d2 From 8c5900b2d669c7aac1e5b3e8bb8e331a0e6cff61 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Mon, 4 Feb 2008 22:29:55 -0800 Subject: frv: remove dead config symbol from FRV code Remove dead config symbol from FRV code. Signed-off-by: Jiri Olsa Acked-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-frv/page.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include/asm-frv') diff --git a/include/asm-frv/page.h b/include/asm-frv/page.h index 213d92fd652..bd9bd2d9cc7 100644 --- a/include/asm-frv/page.h +++ b/include/asm-frv/page.h @@ -76,10 +76,6 @@ extern unsigned long max_pfn; #endif /* __ASSEMBLY__ */ -#ifdef CONFIG_CONTIGUOUS_PAGE_ALLOC -#define WANT_PAGE_VIRTUAL 1 -#endif - #include #include -- cgit v1.2.3-70-g09d2 From 9692bd9c140618e3f6a2848900aee96c9cd8a65c Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 5 Feb 2008 14:22:56 -0800 Subject: timerfd: fix remaining architectures Cc: David Howells Cc: Hirokazu Takata Cc: Paul Mundt Cc: Kazumoto Kojima Cc: Richard Curnow Cc: Davide Libenzi Cc: Michael Kerrisk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/frv/kernel/entry.S | 2 +- arch/m32r/kernel/syscall_table.S | 2 +- arch/sh/kernel/syscalls_32.S | 2 +- arch/sh/kernel/syscalls_64.S | 2 +- include/asm-frv/unistd.h | 2 +- include/asm-m32r/unistd.h | 2 +- include/asm-sh/unistd_32.h | 2 +- include/asm-sh/unistd_64.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'include/asm-frv') diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S index 99046b1f51c..ca6a345b87e 100644 --- a/arch/frv/kernel/entry.S +++ b/arch/frv/kernel/entry.S @@ -1494,7 +1494,7 @@ sys_call_table: .long sys_epoll_pwait .long sys_utimensat /* 320 */ .long sys_signalfd - .long sys_timerfd + .long sys_ni_syscall .long sys_eventfd .long sys_fallocate diff --git a/arch/m32r/kernel/syscall_table.S b/arch/m32r/kernel/syscall_table.S index 95aa7987484..aa3bf4cfab3 100644 --- a/arch/m32r/kernel/syscall_table.S +++ b/arch/m32r/kernel/syscall_table.S @@ -321,6 +321,6 @@ ENTRY(sys_call_table) .long sys_epoll_pwait .long sys_utimensat /* 320 */ .long sys_signalfd - .long sys_timerfd + .long sys_ni_syscall .long sys_eventfd .long sys_fallocate diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S index 10bec45415b..719e127a7c0 100644 --- a/arch/sh/kernel/syscalls_32.S +++ b/arch/sh/kernel/syscalls_32.S @@ -338,6 +338,6 @@ ENTRY(sys_call_table) .long sys_epoll_pwait .long sys_utimensat /* 320 */ .long sys_signalfd - .long sys_timerfd + .long sys_ni_syscall .long sys_eventfd .long sys_fallocate diff --git a/arch/sh/kernel/syscalls_64.S b/arch/sh/kernel/syscalls_64.S index 98a93efe369..12c7340356a 100644 --- a/arch/sh/kernel/syscalls_64.S +++ b/arch/sh/kernel/syscalls_64.S @@ -376,6 +376,6 @@ sys_call_table: .long sys_epoll_pwait .long sys_utimensat .long sys_signalfd - .long sys_timerfd /* 350 */ + .long sys_ni_syscall /* 350 */ .long sys_eventfd .long sys_fallocate diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h index cd84f1771e3..e8c98666753 100644 --- a/include/asm-frv/unistd.h +++ b/include/asm-frv/unistd.h @@ -328,7 +328,7 @@ #define __NR_epoll_pwait 319 #define __NR_utimensat 320 #define __NR_signalfd 321 -#define __NR_timerfd 322 +/* #define __NR_timerfd 322 removed */ #define __NR_eventfd 323 #define __NR_fallocate 324 diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h index f467eac9ba7..cf701c93324 100644 --- a/include/asm-m32r/unistd.h +++ b/include/asm-m32r/unistd.h @@ -327,7 +327,7 @@ #define __NR_epoll_pwait 319 #define __NR_utimensat 320 #define __NR_signalfd 321 -#define __NR_timerfd 322 +/* #define __NR_timerfd 322 removed */ #define __NR_eventfd 323 #define __NR_fallocate 324 diff --git a/include/asm-sh/unistd_32.h b/include/asm-sh/unistd_32.h index b182b1cb05f..433fd1b48fa 100644 --- a/include/asm-sh/unistd_32.h +++ b/include/asm-sh/unistd_32.h @@ -330,7 +330,7 @@ #define __NR_epoll_pwait 319 #define __NR_utimensat 320 #define __NR_signalfd 321 -#define __NR_timerfd 322 +/* #define __NR_timerfd 322 removed */ #define __NR_eventfd 323 #define __NR_fallocate 324 diff --git a/include/asm-sh/unistd_64.h b/include/asm-sh/unistd_64.h index 944511882ca..108d2ba897f 100644 --- a/include/asm-sh/unistd_64.h +++ b/include/asm-sh/unistd_64.h @@ -370,7 +370,7 @@ #define __NR_epoll_pwait 347 #define __NR_utimensat 348 #define __NR_signalfd 349 -#define __NR_timerfd 350 +/* #define __NR_timerfd 350 removed */ #define __NR_eventfd 351 #define __NR_fallocate 352 -- cgit v1.2.3-70-g09d2 From 516c25a86f6bdad77ded01a43c52c5569c8d690c Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 7 Feb 2008 00:15:54 -0800 Subject: Cleanup asm/{elf,page,user}.h: #ifdef __KERNEL__ is no longer needed asm/elf.h, asm/page.h and asm/user.h don't export to userspace now, so we can drop #ifdef __KERNEL__ for them. [k.shutemov@gmail.com: remove #ifdef __KERNEL_] Signed-off-by: Kirill A. Shutemov Reviewed-by: David Woodhouse Cc: Signed-off-by: Kirill A. Shutemov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-alpha/elf.h | 3 --- include/asm-alpha/page.h | 3 --- include/asm-arm/elf.h | 3 --- include/asm-arm/page.h | 5 ----- include/asm-avr32/elf.h | 2 -- include/asm-avr32/page.h | 4 ---- include/asm-blackfin/elf.h | 2 -- include/asm-blackfin/page.h | 3 --- include/asm-cris/elf.h | 3 --- include/asm-cris/page.h | 4 ---- include/asm-frv/elf.h | 2 -- include/asm-frv/page.h | 4 ---- include/asm-h8300/elf.h | 2 -- include/asm-h8300/page.h | 4 ---- include/asm-ia64/elf.h | 3 --- include/asm-ia64/page.h | 3 --- include/asm-m32r/elf.h | 2 -- include/asm-m32r/page.h | 2 -- include/asm-m68k/elf.h | 2 -- include/asm-m68k/page.h | 5 ----- include/asm-m68knommu/elf.h | 2 -- include/asm-m68knommu/page.h | 4 ---- include/asm-mips/elf.h | 4 ---- include/asm-mips/page.h | 5 ----- include/asm-mips/user.h | 4 ---- include/asm-parisc/elf.h | 3 --- include/asm-parisc/page.h | 4 ---- include/asm-powerpc/page.h | 3 --- include/asm-powerpc/page_32.h | 2 -- include/asm-powerpc/page_64.h | 2 -- include/asm-powerpc/user.h | 4 ---- include/asm-s390/elf.h | 2 -- include/asm-s390/page.h | 3 --- include/asm-sh/page.h | 3 --- include/asm-sparc/elf.h | 3 --- include/asm-sparc/page.h | 4 ---- include/asm-sparc64/elf.h | 4 ---- include/asm-sparc64/page.h | 3 --- include/asm-v850/elf.h | 2 -- include/asm-v850/page.h | 4 ---- include/asm-v850/user.h | 4 ---- include/asm-x86/elf.h | 3 --- include/asm-x86/user.h | 14 +++----------- include/asm-xtensa/elf.h | 3 --- include/asm-xtensa/page.h | 3 --- 45 files changed, 3 insertions(+), 150 deletions(-) (limited to 'include/asm-frv') diff --git a/include/asm-alpha/elf.h b/include/asm-alpha/elf.h index 4b518e3b952..fc1002ea1e0 100644 --- a/include/asm-alpha/elf.h +++ b/include/asm-alpha/elf.h @@ -144,8 +144,6 @@ extern int dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task); : amask (AMASK_CIX) ? "ev6" : "ev67"); \ }) -#ifdef __KERNEL__ - #define SET_PERSONALITY(EX, IBCS2) \ set_personality(((EX).e_flags & EF_ALPHA_32BIT) \ ? PER_LINUX_32BIT : (IBCS2) ? PER_SVR4 : PER_LINUX) @@ -164,5 +162,4 @@ extern int alpha_l3_cacheshape; NEW_AUX_ENT(AT_L3_CACHESHAPE, alpha_l3_cacheshape); \ } while (0) -#endif /* __KERNEL__ */ #endif /* __ASM_ALPHA_ELF_H */ diff --git a/include/asm-alpha/page.h b/include/asm-alpha/page.h index 8cc97bfd378..05f09f997d8 100644 --- a/include/asm-alpha/page.h +++ b/include/asm-alpha/page.h @@ -1,8 +1,6 @@ #ifndef _ALPHA_PAGE_H #define _ALPHA_PAGE_H -#ifdef __KERNEL__ - #include #include @@ -98,5 +96,4 @@ typedef unsigned long pgprot_t; #include #include -#endif /* __KERNEL__ */ #endif /* _ALPHA_PAGE_H */ diff --git a/include/asm-arm/elf.h b/include/asm-arm/elf.h index ec1c685562c..4ca75162748 100644 --- a/include/asm-arm/elf.h +++ b/include/asm-arm/elf.h @@ -41,7 +41,6 @@ typedef struct user_fp elf_fpregset_t; #endif #define ELF_ARCH EM_ARM -#ifdef __KERNEL__ #ifndef __ASSEMBLY__ /* * This yields a string that ld.so will use to load implementation @@ -115,5 +114,3 @@ extern char elf_platform[]; } while (0) #endif - -#endif diff --git a/include/asm-arm/page.h b/include/asm-arm/page.h index 7e85db77d99..31ff12f4ffb 100644 --- a/include/asm-arm/page.h +++ b/include/asm-arm/page.h @@ -10,9 +10,6 @@ #ifndef _ASMARM_PAGE_H #define _ASMARM_PAGE_H - -#ifdef __KERNEL__ - /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 12 #define PAGE_SIZE (1UL << PAGE_SHIFT) @@ -192,6 +189,4 @@ typedef unsigned long pgprot_t; #include -#endif /* __KERNEL__ */ - #endif diff --git a/include/asm-avr32/elf.h b/include/asm-avr32/elf.h index d334b4994d2..64ce40ee1d5 100644 --- a/include/asm-avr32/elf.h +++ b/include/asm-avr32/elf.h @@ -103,8 +103,6 @@ typedef struct user_fpu_struct elf_fpregset_t; #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) -#endif #endif /* __ASM_AVR32_ELF_H */ diff --git a/include/asm-avr32/page.h b/include/asm-avr32/page.h index 0f630b3e993..ee23499cec3 100644 --- a/include/asm-avr32/page.h +++ b/include/asm-avr32/page.h @@ -8,8 +8,6 @@ #ifndef __ASM_AVR32_PAGE_H #define __ASM_AVR32_PAGE_H -#ifdef __KERNEL__ - /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 12 #ifdef __ASSEMBLY__ @@ -107,6 +105,4 @@ static inline int get_order(unsigned long size) */ #define HIGHMEM_START 0x20000000UL -#endif /* __KERNEL__ */ - #endif /* __ASM_AVR32_PAGE_H */ diff --git a/include/asm-blackfin/elf.h b/include/asm-blackfin/elf.h index 5264b5536a7..30303fc8292 100644 --- a/include/asm-blackfin/elf.h +++ b/include/asm-blackfin/elf.h @@ -120,8 +120,6 @@ do { \ #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) -#endif #endif diff --git a/include/asm-blackfin/page.h b/include/asm-blackfin/page.h index 8bc86717021..d5c9d143378 100644 --- a/include/asm-blackfin/page.h +++ b/include/asm-blackfin/page.h @@ -11,8 +11,6 @@ #endif #define PAGE_MASK (~(PAGE_SIZE-1)) -#ifdef __KERNEL__ - #include #ifndef __ASSEMBLY__ @@ -88,6 +86,5 @@ extern unsigned long memory_end; #include #endif /* __ASSEMBLY__ */ -#endif /* __KERNEL__ */ #endif /* _BLACKFIN_PAGE_H */ diff --git a/include/asm-cris/elf.h b/include/asm-cris/elf.h index 96a40c1de57..001f64ad11e 100644 --- a/include/asm-cris/elf.h +++ b/include/asm-cris/elf.h @@ -45,7 +45,6 @@ typedef unsigned long elf_fpregset_t; #define ELF_DATA ELFDATA2LSB #define ELF_ARCH EM_CRIS -#ifdef __KERNEL__ #include /* The master for these definitions is {binutils}/include/elf/cris.h: */ @@ -91,6 +90,4 @@ typedef unsigned long elf_fpregset_t; #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) -#endif /* __KERNEL__ */ - #endif diff --git a/include/asm-cris/page.h b/include/asm-cris/page.h index b84353ef699..3b0156c4631 100644 --- a/include/asm-cris/page.h +++ b/include/asm-cris/page.h @@ -1,8 +1,6 @@ #ifndef _CRIS_PAGE_H #define _CRIS_PAGE_H -#ifdef __KERNEL__ - #include #include @@ -74,7 +72,5 @@ typedef struct { unsigned long pgprot; } pgprot_t; #include #include -#endif /* __KERNEL__ */ - #endif /* _CRIS_PAGE_H */ diff --git a/include/asm-frv/elf.h b/include/asm-frv/elf.h index 7df58a3e6e4..9fb946bb7dc 100644 --- a/include/asm-frv/elf.h +++ b/include/asm-frv/elf.h @@ -137,8 +137,6 @@ do { \ #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) -#endif #endif diff --git a/include/asm-frv/page.h b/include/asm-frv/page.h index bd9bd2d9cc7..cacc045700d 100644 --- a/include/asm-frv/page.h +++ b/include/asm-frv/page.h @@ -1,8 +1,6 @@ #ifndef _ASM_PAGE_H #define _ASM_PAGE_H -#ifdef __KERNEL__ - #include #include #include @@ -79,6 +77,4 @@ extern unsigned long max_pfn; #include #include -#endif /* __KERNEL__ */ - #endif /* _ASM_PAGE_H */ diff --git a/include/asm-h8300/elf.h b/include/asm-h8300/elf.h index 7ba6a0af447..26bfc7e641d 100644 --- a/include/asm-h8300/elf.h +++ b/include/asm-h8300/elf.h @@ -55,9 +55,7 @@ typedef unsigned long elf_fpregset_t; #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX) -#endif #define R_H8_NONE 0 #define R_H8_DIR32 1 diff --git a/include/asm-h8300/page.h b/include/asm-h8300/page.h index c8cc81a3aca..a8349244913 100644 --- a/include/asm-h8300/page.h +++ b/include/asm-h8300/page.h @@ -1,8 +1,6 @@ #ifndef _H8300_PAGE_H #define _H8300_PAGE_H -#ifdef __KERNEL__ - /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT (12) @@ -79,6 +77,4 @@ extern unsigned long memory_end; #include #include -#endif /* __KERNEL__ */ - #endif /* _H8300_PAGE_H */ diff --git a/include/asm-ia64/elf.h b/include/asm-ia64/elf.h index f10e29b60b0..f8e83eca67a 100644 --- a/include/asm-ia64/elf.h +++ b/include/asm-ia64/elf.h @@ -177,7 +177,6 @@ extern void ia64_elf_core_copy_regs (struct pt_regs *src, elf_gregset_t dst); relevant until we have real hardware to play with... */ #define ELF_PLATFORM NULL -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX) #define elf_read_implies_exec(ex, executable_stack) \ ((executable_stack!=EXSTACK_DISABLE_X) && ((ex).e_flags & EF_IA_64_LINUX_EXECUTABLE_STACK) != 0) @@ -248,6 +247,4 @@ do { \ } \ } while (0) -#endif /* __KERNEL__ */ - #endif /* _ASM_IA64_ELF_H */ diff --git a/include/asm-ia64/page.h b/include/asm-ia64/page.h index d6345464a2b..8a8aa3fd7cd 100644 --- a/include/asm-ia64/page.h +++ b/include/asm-ia64/page.h @@ -7,8 +7,6 @@ * David Mosberger-Tang */ -# ifdef __KERNEL__ - #include #include @@ -227,5 +225,4 @@ get_order (unsigned long size) (((current->personality & READ_IMPLIES_EXEC) != 0) \ ? VM_EXEC : 0)) -# endif /* __KERNEL__ */ #endif /* _ASM_IA64_PAGE_H */ diff --git a/include/asm-m32r/elf.h b/include/asm-m32r/elf.h index bbee8b25d17..67bcd77494a 100644 --- a/include/asm-m32r/elf.h +++ b/include/asm-m32r/elf.h @@ -129,8 +129,6 @@ typedef elf_fpreg_t elf_fpregset_t; intent than poking at uname or /proc/cpuinfo. */ #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX) -#endif #endif /* _ASM_M32R__ELF_H */ diff --git a/include/asm-m32r/page.h b/include/asm-m32r/page.h index 04fd183a2c5..05d43bbbf94 100644 --- a/include/asm-m32r/page.h +++ b/include/asm-m32r/page.h @@ -6,7 +6,6 @@ #define PAGE_SIZE (1UL << PAGE_SHIFT) #define PAGE_MASK (~(PAGE_SIZE-1)) -#ifdef __KERNEL__ #ifndef __ASSEMBLY__ extern void clear_page(void *to); @@ -87,5 +86,4 @@ typedef struct { unsigned long pgprot; } pgprot_t; #include #include -#endif /* __KERNEL__ */ #endif /* _ASM_M32R_PAGE_H */ diff --git a/include/asm-m68k/elf.h b/include/asm-m68k/elf.h index eb63b85f933..14ea42152b9 100644 --- a/include/asm-m68k/elf.h +++ b/include/asm-m68k/elf.h @@ -114,8 +114,6 @@ typedef struct user_m68kfp_struct elf_fpregset_t; #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) -#endif #endif diff --git a/include/asm-m68k/page.h b/include/asm-m68k/page.h index 1431ea0b59e..3f29e2a03a4 100644 --- a/include/asm-m68k/page.h +++ b/include/asm-m68k/page.h @@ -1,9 +1,6 @@ #ifndef _M68K_PAGE_H #define _M68K_PAGE_H - -#ifdef __KERNEL__ - #include /* PAGE_SHIFT determines the page size */ @@ -230,6 +227,4 @@ static inline __attribute_const__ int __virt_to_node_shift(void) #include -#endif /* __KERNEL__ */ - #endif /* _M68K_PAGE_H */ diff --git a/include/asm-m68knommu/elf.h b/include/asm-m68knommu/elf.h index 40b1ed6827d..27f0ec70fba 100644 --- a/include/asm-m68knommu/elf.h +++ b/include/asm-m68knommu/elf.h @@ -105,8 +105,6 @@ typedef struct user_m68kfp_struct elf_fpregset_t; #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) -#endif #endif diff --git a/include/asm-m68knommu/page.h b/include/asm-m68knommu/page.h index 9efa0a9851b..6af480c7f29 100644 --- a/include/asm-m68knommu/page.h +++ b/include/asm-m68knommu/page.h @@ -1,8 +1,6 @@ #ifndef _M68KNOMMU_PAGE_H #define _M68KNOMMU_PAGE_H -#ifdef __KERNEL__ - /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT (12) @@ -78,6 +76,4 @@ extern unsigned long memory_end; #include -#endif /* __KERNEL__ */ - #endif /* _M68KNOMMU_PAGE_H */ diff --git a/include/asm-mips/elf.h b/include/asm-mips/elf.h index 766f91ad5cd..f69f7acba63 100644 --- a/include/asm-mips/elf.h +++ b/include/asm-mips/elf.h @@ -239,8 +239,6 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; #endif /* !defined(ELF_ARCH) */ -#ifdef __KERNEL__ - struct mips_abi; extern struct mips_abi mips_abi; @@ -328,8 +326,6 @@ extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *); #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) \ dump_task_fpu(tsk, elf_fpregs) -#endif /* __KERNEL__ */ - #define USE_ELF_CORE_DUMP #define ELF_EXEC_PAGESIZE PAGE_SIZE diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h index d2ea983bec0..635aa44d229 100644 --- a/include/asm-mips/page.h +++ b/include/asm-mips/page.h @@ -9,9 +9,6 @@ #ifndef _ASM_PAGE_H #define _ASM_PAGE_H - -#ifdef __KERNEL__ - #include /* @@ -190,6 +187,4 @@ typedef struct { unsigned long pgprot; } pgprot_t; #include #include -#endif /* defined (__KERNEL__) */ - #endif /* _ASM_PAGE_H */ diff --git a/include/asm-mips/user.h b/include/asm-mips/user.h index 61f2a093b91..89bf8b4cab3 100644 --- a/include/asm-mips/user.h +++ b/include/asm-mips/user.h @@ -8,8 +8,6 @@ #ifndef _ASM_USER_H #define _ASM_USER_H -#ifdef __KERNEL__ - #include #include @@ -57,6 +55,4 @@ struct user { #define HOST_DATA_START_ADDR (u.start_data) #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) -#endif /* __KERNEL__ */ - #endif /* _ASM_USER_H */ diff --git a/include/asm-parisc/elf.h b/include/asm-parisc/elf.h index 8e7946a141d..ce0c0d844c7 100644 --- a/include/asm-parisc/elf.h +++ b/include/asm-parisc/elf.h @@ -237,14 +237,11 @@ typedef unsigned long elf_greg_t; #define ELF_PLATFORM ("PARISC\0" /*+((boot_cpu_data.x86-3)*5) */) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) \ current->personality = PER_LINUX; \ current->thread.map_base = DEFAULT_MAP_BASE; \ current->thread.task_size = DEFAULT_TASK_SIZE \ -#endif - /* * Fill in general registers in a core dump. This saves pretty * much the same registers as hp-ux, although in a different order. diff --git a/include/asm-parisc/page.h b/include/asm-parisc/page.h index b59a1504fc7..b08d9151c71 100644 --- a/include/asm-parisc/page.h +++ b/include/asm-parisc/page.h @@ -1,8 +1,6 @@ #ifndef _PARISC_PAGE_H #define _PARISC_PAGE_H -#ifdef __KERNEL__ - #include #if defined(CONFIG_PARISC_PAGE_SIZE_4KB) @@ -175,6 +173,4 @@ extern int npmem_ranges; #include #include -#endif /* __KERNEL__ */ - #endif /* _PARISC_PAGE_H */ diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h index 236a9210e5f..61e3725bbd3 100644 --- a/include/asm-powerpc/page.h +++ b/include/asm-powerpc/page.h @@ -10,7 +10,6 @@ * 2 of the License, or (at your option) any later version. */ -#ifdef __KERNEL__ #include #include @@ -194,6 +193,4 @@ struct vm_area_struct; #include #endif /* __ASSEMBLY__ */ -#endif /* __KERNEL__ */ - #endif /* _ASM_POWERPC_PAGE_H */ diff --git a/include/asm-powerpc/page_32.h b/include/asm-powerpc/page_32.h index 17110aff26e..65ea19eec95 100644 --- a/include/asm-powerpc/page_32.h +++ b/include/asm-powerpc/page_32.h @@ -1,6 +1,5 @@ #ifndef _ASM_POWERPC_PAGE_32_H #define _ASM_POWERPC_PAGE_32_H -#ifdef __KERNEL__ #define VM_DATA_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS32 @@ -32,5 +31,4 @@ extern void copy_page(void *to, void *from); #endif /* __ASSEMBLY__ */ -#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PAGE_32_H */ diff --git a/include/asm-powerpc/page_64.h b/include/asm-powerpc/page_64.h index 4ee82c61e4d..67834eae570 100644 --- a/include/asm-powerpc/page_64.h +++ b/include/asm-powerpc/page_64.h @@ -1,6 +1,5 @@ #ifndef _ASM_POWERPC_PAGE_64_H #define _ASM_POWERPC_PAGE_64_H -#ifdef __KERNEL__ /* * Copyright (C) 2001 PPC64 Team, IBM Corp @@ -183,5 +182,4 @@ do { \ #include -#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PAGE_64_H */ diff --git a/include/asm-powerpc/user.h b/include/asm-powerpc/user.h index e59ade4b3df..ba8dd4c12d9 100644 --- a/include/asm-powerpc/user.h +++ b/include/asm-powerpc/user.h @@ -1,8 +1,6 @@ #ifndef _ASM_POWERPC_USER_H #define _ASM_POWERPC_USER_H -#ifdef __KERNEL__ - #include #include @@ -50,6 +48,4 @@ struct user { #define HOST_TEXT_START_ADDR (u.start_code) #define HOST_DATA_START_ADDR (u.start_data) #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) - -#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_USER_H */ diff --git a/include/asm-s390/elf.h b/include/asm-s390/elf.h index 91d06325cc7..b73a424d0f9 100644 --- a/include/asm-s390/elf.h +++ b/include/asm-s390/elf.h @@ -113,7 +113,6 @@ typedef s390_fp_regs elf_fpregset_t; typedef s390_regs elf_gregset_t; -#ifdef __KERNEL__ #include /* for task_struct */ #include /* for save_access_regs */ @@ -214,6 +213,5 @@ do { \ clear_thread_flag(TIF_31BIT); \ } while (0) #endif /* __s390x__ */ -#endif #endif diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h index 584d0ee3c7f..a55f9d979df 100644 --- a/include/asm-s390/page.h +++ b/include/asm-s390/page.h @@ -19,7 +19,6 @@ #define PAGE_DEFAULT_ACC 0 #define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4) -#ifdef __KERNEL__ #include #ifndef __ASSEMBLY__ @@ -172,6 +171,4 @@ static inline int pfn_valid(unsigned long pfn) #include #include -#endif /* __KERNEL__ */ - #endif /* _S390_PAGE_H */ diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h index 002e64a4f04..e0fe02950f5 100644 --- a/include/asm-sh/page.h +++ b/include/asm-sh/page.h @@ -7,8 +7,6 @@ #include -#ifdef __KERNEL__ - /* PAGE_SHIFT determines the page size */ #if defined(CONFIG_PAGE_SIZE_4KB) # define PAGE_SHIFT 12 @@ -178,5 +176,4 @@ typedef struct { unsigned long pgd; } pgd_t; #define ARCH_SLAB_MINALIGN 8 #endif -#endif /* __KERNEL__ */ #endif /* __ASM_SH_PAGE_H */ diff --git a/include/asm-sparc/elf.h b/include/asm-sparc/elf.h index aaf6ef40ee2..668814e1e53 100644 --- a/include/asm-sparc/elf.h +++ b/include/asm-sparc/elf.h @@ -85,7 +85,6 @@ typedef struct { unsigned int pr_q[64]; } elf_fpregset_t; -#ifdef __KERNEL__ #include #include @@ -166,6 +165,4 @@ do { unsigned long *dest = &(__elf_regs[0]); \ #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX) -#endif /* __KERNEL__ */ - #endif /* !(__ASMSPARC_ELF_H) */ diff --git a/include/asm-sparc/page.h b/include/asm-sparc/page.h index ff57648eb8f..cbc48c0c4e1 100644 --- a/include/asm-sparc/page.h +++ b/include/asm-sparc/page.h @@ -8,8 +8,6 @@ #ifndef _SPARC_PAGE_H #define _SPARC_PAGE_H -#ifdef __KERNEL__ - #ifdef CONFIG_SUN4 #define PAGE_SHIFT 13 #else @@ -163,6 +161,4 @@ extern unsigned long pfn_base; #include #include -#endif /* __KERNEL__ */ - #endif /* _SPARC_PAGE_H */ diff --git a/include/asm-sparc64/elf.h b/include/asm-sparc64/elf.h index 8653e866500..dc7bc63e507 100644 --- a/include/asm-sparc64/elf.h +++ b/include/asm-sparc64/elf.h @@ -7,11 +7,9 @@ */ #include -#ifdef __KERNEL__ #include #include #include -#endif /* * Sparc section types @@ -175,7 +173,6 @@ static inline unsigned int sparc64_elf_hwcap(void) #define ELF_PLATFORM (NULL) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) \ do { unsigned long new_flags = current_thread_info()->flags; \ new_flags &= _TIF_32BIT; \ @@ -194,6 +191,5 @@ do { unsigned long new_flags = current_thread_info()->flags; \ else if (current->personality != PER_LINUX32) \ set_personality(PER_LINUX); \ } while (0) -#endif #endif /* !(__ASM_SPARC64_ELF_H) */ diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h index 7af1077451f..cdf950e017e 100644 --- a/include/asm-sparc64/page.h +++ b/include/asm-sparc64/page.h @@ -3,8 +3,6 @@ #ifndef _SPARC64_PAGE_H #define _SPARC64_PAGE_H -#ifdef __KERNEL__ - #include #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB) @@ -143,5 +141,4 @@ typedef unsigned long pgprot_t; #include -#endif /* __KERNEL__ */ #endif /* _SPARC64_PAGE_H */ diff --git a/include/asm-v850/elf.h b/include/asm-v850/elf.h index 7db8edffb1c..28f5b176ff1 100644 --- a/include/asm-v850/elf.h +++ b/include/asm-v850/elf.h @@ -94,8 +94,6 @@ typedef struct user_fpu_struct elf_fpregset_t; 0; \ } while (0) -#ifdef __KERNEL__ #define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) -#endif #endif /* __V850_ELF_H__ */ diff --git a/include/asm-v850/page.h b/include/asm-v850/page.h index d693ffb1364..661d8cd0883 100644 --- a/include/asm-v850/page.h +++ b/include/asm-v850/page.h @@ -14,8 +14,6 @@ #ifndef __V850_PAGE_H__ #define __V850_PAGE_H__ -#ifdef __KERNEL__ - #include @@ -126,6 +124,4 @@ typedef unsigned long pgprot_t; #include #include -#endif /* KERNEL */ - #endif /* __V850_PAGE_H__ */ diff --git a/include/asm-v850/user.h b/include/asm-v850/user.h index ccf4cea6dc9..be90eea5285 100644 --- a/include/asm-v850/user.h +++ b/include/asm-v850/user.h @@ -3,8 +3,6 @@ /* Adapted from . */ -#ifdef __KERNEL__ - #include #include @@ -51,6 +49,4 @@ struct user { #define HOST_DATA_START_ADDR (u.start_data) #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) -#endif /* __KERNEL__ */ - #endif /* __V850_USER_H__ */ diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h index d9c94e70728..fb62f9941e3 100644 --- a/include/asm-x86/elf.h +++ b/include/asm-x86/elf.h @@ -72,7 +72,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t; #endif -#ifdef __KERNEL__ #include extern unsigned int vdso_enabled; @@ -321,6 +320,4 @@ extern int syscall32_setup_pages(struct linux_binprm *, int exstack); extern unsigned long arch_randomize_brk(struct mm_struct *mm); #define arch_randomize_brk arch_randomize_brk -#endif /* __KERNEL__ */ - #endif diff --git a/include/asm-x86/user.h b/include/asm-x86/user.h index 484715abe74..999873b22e7 100644 --- a/include/asm-x86/user.h +++ b/include/asm-x86/user.h @@ -1,13 +1,5 @@ -#ifdef __KERNEL__ -# ifdef CONFIG_X86_32 -# include "user_32.h" -# else -# include "user_64.h" -# endif +#ifdef CONFIG_X86_32 +# include "user_32.h" #else -# ifdef __i386__ -# include "user_32.h" -# else -# include "user_64.h" -# endif +# include "user_64.h" #endif diff --git a/include/asm-xtensa/elf.h b/include/asm-xtensa/elf.h index 7083d46766a..46738454250 100644 --- a/include/asm-xtensa/elf.h +++ b/include/asm-xtensa/elf.h @@ -257,8 +257,6 @@ extern void xtensa_elf_core_copy_regs (xtensa_gregset_t *, struct pt_regs *); _r->areg[12]=0; _r->areg[13]=0; _r->areg[14]=0; _r->areg[15]=0; \ } while (0) -#ifdef __KERNEL__ - #define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) struct task_struct; @@ -272,5 +270,4 @@ extern void do_save_fpregs (elf_fpregset_t*, struct pt_regs*, extern int do_restore_fpregs (elf_fpregset_t*, struct pt_regs*, struct task_struct*); -#endif /* __KERNEL__ */ #endif /* _XTENSA_ELF_H */ diff --git a/include/asm-xtensa/page.h b/include/asm-xtensa/page.h index 55ce2c9749a..1adedbf41d0 100644 --- a/include/asm-xtensa/page.h +++ b/include/asm-xtensa/page.h @@ -11,8 +11,6 @@ #ifndef _XTENSA_PAGE_H #define _XTENSA_PAGE_H -#ifdef __KERNEL__ - #include #include #include @@ -174,5 +172,4 @@ extern void copy_user_page(void*, void*, unsigned long, struct page*); VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) #include -#endif /* __KERNEL__ */ #endif /* _XTENSA_PAGE_H */ -- cgit v1.2.3-70-g09d2 From ed7b1889da256977574663689b598d88950bbd23 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 7 Feb 2008 00:15:56 -0800 Subject: Unexport asm/page.h Do not export asm/page.h during make headers_install. This removes PAGE_SIZE from userspace headers. Signed-off-by: Kirill A. Shutemov Reviewed-by: David Woodhouse Cc: David Howells Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: Thomas Gleixner Cc: Ingo Molnar Cc: H. Peter Anvin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-frv/Kbuild | 1 - include/asm-generic/Kbuild.asm | 3 --- include/asm-s390/kexec.h | 2 ++ include/linux/Kbuild | 1 - include/linux/a.out.h | 8 ++++++++ include/linux/shm.h | 8 ++++++++ 6 files changed, 18 insertions(+), 5 deletions(-) (limited to 'include/asm-frv') diff --git a/include/asm-frv/Kbuild b/include/asm-frv/Kbuild index 966a9836d55..bc3f12c5b7e 100644 --- a/include/asm-frv/Kbuild +++ b/include/asm-frv/Kbuild @@ -4,4 +4,3 @@ header-y += registers.h unifdef-y += termios.h unifdef-y += ptrace.h -unifdef-y += page.h diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm index d00fd67e636..57ba6063595 100644 --- a/include/asm-generic/Kbuild.asm +++ b/include/asm-generic/Kbuild.asm @@ -27,6 +27,3 @@ unifdef-y += termbits.h unifdef-y += termios.h unifdef-y += types.h unifdef-y += unistd.h - -# These probably shouldn't be exported -unifdef-y += page.h diff --git a/include/asm-s390/kexec.h b/include/asm-s390/kexec.h index 7592af708b4..f219c6411e0 100644 --- a/include/asm-s390/kexec.h +++ b/include/asm-s390/kexec.h @@ -10,7 +10,9 @@ #ifndef _S390_KEXEC_H #define _S390_KEXEC_H +#ifdef __KERNEL__ #include +#endif #include /* * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return. diff --git a/include/linux/Kbuild b/include/linux/Kbuild index 0d4f55d97ae..2ebf068ba50 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -18,7 +18,6 @@ header-y += usb/ header-y += affs_hardblocks.h header-y += aio_abi.h -header-y += a.out.h header-y += arcfb.h header-y += atmapi.h header-y += atmbr2684.h diff --git a/include/linux/a.out.h b/include/linux/a.out.h index f913cc3e1b0..82cd918f2ab 100644 --- a/include/linux/a.out.h +++ b/include/linux/a.out.h @@ -128,12 +128,20 @@ enum machine_type { #endif #ifdef linux +#ifdef __KERNEL__ #include +#else +#include +#endif #if defined(__i386__) || defined(__mc68000__) #define SEGMENT_SIZE 1024 #else #ifndef SEGMENT_SIZE +#ifdef __KERNEL__ #define SEGMENT_SIZE PAGE_SIZE +#else +#define SEGMENT_SIZE getpagesize() +#endif #endif #endif #endif diff --git a/include/linux/shm.h b/include/linux/shm.h index eeaed921a1d..eca6235a46c 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h @@ -3,7 +3,11 @@ #include #include +#ifdef __KERNEL__ #include +#else +#include +#endif /* * SHMMAX, SHMMNI and SHMALL are upper limits are defaults which can @@ -13,7 +17,11 @@ #define SHMMAX 0x2000000 /* max shared seg size (bytes) */ #define SHMMIN 1 /* min shared seg size (bytes) */ #define SHMMNI 4096 /* max num of segs system wide */ +#ifdef __KERNEL__ #define SHMALL (SHMMAX/PAGE_SIZE*(SHMMNI/16)) /* max shm system wide (pages) */ +#else +#define SHMALL (SHMMAX/getpagesize()*(SHMMNI/16)) +#endif #define SHMSEG SHMMNI /* max shared segs per process */ #ifdef __KERNEL__ -- cgit v1.2.3-70-g09d2 From 14e0cb3c60b89c4a2512852ffc18601c72314a0f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 7 Feb 2008 00:16:14 -0800 Subject: Add cmpxchg_local to frv Use the new generic cmpxchg_local (disables interrupt) for 8, 16 and 64 bits arguments. Use the 32 bits cmpxchg available on the architecture for 32 bits arguments. Signed-off-by: Mathieu Desnoyers Cc: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-frv/system.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include/asm-frv') diff --git a/include/asm-frv/system.h b/include/asm-frv/system.h index 9f5663ba19f..59be5443a68 100644 --- a/include/asm-frv/system.h +++ b/include/asm-frv/system.h @@ -268,5 +268,29 @@ extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new); #endif +#include + +static inline unsigned long __cmpxchg_local(volatile void *ptr, + unsigned long old, + unsigned long new, int size) +{ + switch (size) { + case 4: + return cmpxchg(ptr, old, new); + default: + return __cmpxchg_local_generic(ptr, old, new, size); + } + + return old; +} + +/* + * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make + * them available. + */ +#define cmpxchg_local(ptr, o, n) \ + ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \ + (unsigned long)(n), sizeof(*(ptr)))) +#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n)) #endif /* _ASM_SYSTEM_H */ -- cgit v1.2.3-70-g09d2 From 7fa3031500ec9b0a7460c8c23751799006ffee74 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 8 Feb 2008 04:19:28 -0800 Subject: aout: suppress A.OUT library support if !CONFIG_ARCH_SUPPORTS_AOUT Suppress A.OUT library support if CONFIG_ARCH_SUPPORTS_AOUT is not set. Not all architectures support the A.OUT binfmt, so the ELF binfmt should not be permitted to go looking for A.OUT libraries to load in such a case. Not only that, but under such conditions A.OUT core dumps are not produced either. To make this work, this patch also does the following: (1) Makes the existence of the contents of linux/a.out.h contingent on CONFIG_ARCH_SUPPORTS_AOUT. (2) Renames dump_thread() to aout_dump_thread() as it's only called by A.OUT core dumping code. (3) Moves aout_dump_thread() into asm/a.out-core.h and makes it inline. This is then included only where needed. This means that this bit of arch code will be stored in the appropriate A.OUT binfmt module rather than the core kernel. (4) Drops A.OUT support for Blackfin (according to Mike Frysinger it's not needed) and FRV. This patch depends on the previous patch to move STACK_TOP[_MAX] out of asm/a.out.h and into asm/processor.h as they're required whether or not A.OUT format is available. [jdike@addtoit.com: uml: re-remove accidentally restored code] Signed-off-by: David Howells Cc: Signed-off-by: Jeff Dike Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/alpha/kernel/process.c | 62 ---------------------------- arch/arm/kernel/process.c | 29 -------------- arch/m68k/kernel/process.c | 47 ---------------------- arch/sparc/kernel/process.c | 32 --------------- arch/sparc/kernel/sparc_ksyms.c | 2 - arch/sparc64/kernel/binfmt_aout32.c | 3 +- arch/sparc64/kernel/process.c | 11 ----- arch/um/kernel/ksyms.c | 1 - arch/um/kernel/process.c | 4 -- arch/x86/kernel/process_32.c | 49 ----------------------- fs/Kconfig.binfmt | 3 +- fs/binfmt_aout.c | 3 +- fs/binfmt_elf.c | 34 ++++++++++++---- fs/exec.c | 2 +- include/asm-alpha/a.out-core.h | 80 +++++++++++++++++++++++++++++++++++++ include/asm-arm/a.out-core.h | 49 +++++++++++++++++++++++ include/asm-frv/a.out.h | 5 --- include/asm-generic/Kbuild.asm | 2 + include/asm-m68k/a.out-core.h | 67 +++++++++++++++++++++++++++++++ include/asm-sparc/a.out-core.h | 52 ++++++++++++++++++++++++ include/asm-sparc64/a.out-core.h | 31 ++++++++++++++ include/asm-um/a.out-core.h | 27 +++++++++++++ include/asm-x86/a.out-core.h | 71 ++++++++++++++++++++++++++++++++ include/linux/a.out.h | 12 +++++- include/linux/kernel.h | 2 - 25 files changed, 423 insertions(+), 257 deletions(-) create mode 100644 include/asm-alpha/a.out-core.h create mode 100644 include/asm-arm/a.out-core.h delete mode 100644 include/asm-frv/a.out.h create mode 100644 include/asm-m68k/a.out-core.h create mode 100644 include/asm-sparc/a.out-core.h create mode 100644 include/asm-sparc64/a.out-core.h create mode 100644 include/asm-um/a.out-core.h create mode 100644 include/asm-x86/a.out-core.h (limited to 'include/asm-frv') diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c index 92b61629fe3..9aed4776378 100644 --- a/arch/alpha/kernel/process.c +++ b/arch/alpha/kernel/process.c @@ -317,68 +317,6 @@ copy_thread(int nr, unsigned long clone_flags, unsigned long usp, return 0; } -/* - * Fill in the user structure for an ECOFF core dump. - */ -void -dump_thread(struct pt_regs * pt, struct user * dump) -{ - /* switch stack follows right below pt_regs: */ - struct switch_stack * sw = ((struct switch_stack *) pt) - 1; - - dump->magic = CMAGIC; - dump->start_code = current->mm->start_code; - dump->start_data = current->mm->start_data; - dump->start_stack = rdusp() & ~(PAGE_SIZE - 1); - dump->u_tsize = ((current->mm->end_code - dump->start_code) - >> PAGE_SHIFT); - dump->u_dsize = ((current->mm->brk + PAGE_SIZE-1 - dump->start_data) - >> PAGE_SHIFT); - dump->u_ssize = (current->mm->start_stack - dump->start_stack - + PAGE_SIZE-1) >> PAGE_SHIFT; - - /* - * We store the registers in an order/format that is - * compatible with DEC Unix/OSF/1 as this makes life easier - * for gdb. - */ - dump->regs[EF_V0] = pt->r0; - dump->regs[EF_T0] = pt->r1; - dump->regs[EF_T1] = pt->r2; - dump->regs[EF_T2] = pt->r3; - dump->regs[EF_T3] = pt->r4; - dump->regs[EF_T4] = pt->r5; - dump->regs[EF_T5] = pt->r6; - dump->regs[EF_T6] = pt->r7; - dump->regs[EF_T7] = pt->r8; - dump->regs[EF_S0] = sw->r9; - dump->regs[EF_S1] = sw->r10; - dump->regs[EF_S2] = sw->r11; - dump->regs[EF_S3] = sw->r12; - dump->regs[EF_S4] = sw->r13; - dump->regs[EF_S5] = sw->r14; - dump->regs[EF_S6] = sw->r15; - dump->regs[EF_A3] = pt->r19; - dump->regs[EF_A4] = pt->r20; - dump->regs[EF_A5] = pt->r21; - dump->regs[EF_T8] = pt->r22; - dump->regs[EF_T9] = pt->r23; - dump->regs[EF_T10] = pt->r24; - dump->regs[EF_T11] = pt->r25; - dump->regs[EF_RA] = pt->r26; - dump->regs[EF_T12] = pt->r27; - dump->regs[EF_AT] = pt->r28; - dump->regs[EF_SP] = rdusp(); - dump->regs[EF_PS] = pt->ps; - dump->regs[EF_PC] = pt->pc; - dump->regs[EF_GP] = pt->gp; - dump->regs[EF_A0] = pt->r16; - dump->regs[EF_A1] = pt->r17; - dump->regs[EF_A2] = pt->r18; - memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8); -} -EXPORT_SYMBOL(dump_thread); - /* * Fill in the user structure for a ELF core dump. */ diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 4f1a03124a7..436380a5f4c 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -367,35 +367,6 @@ int dump_fpu (struct pt_regs *regs, struct user_fp *fp) } EXPORT_SYMBOL(dump_fpu); -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - struct task_struct *tsk = current; - - dump->magic = CMAGIC; - dump->start_code = tsk->mm->start_code; - dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1); - - dump->u_tsize = (tsk->mm->end_code - tsk->mm->start_code) >> PAGE_SHIFT; - dump->u_dsize = (tsk->mm->brk - tsk->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT; - dump->u_ssize = 0; - - dump->u_debugreg[0] = tsk->thread.debug.bp[0].address; - dump->u_debugreg[1] = tsk->thread.debug.bp[1].address; - dump->u_debugreg[2] = tsk->thread.debug.bp[0].insn.arm; - dump->u_debugreg[3] = tsk->thread.debug.bp[1].insn.arm; - dump->u_debugreg[4] = tsk->thread.debug.nsaved; - - if (dump->start_stack < 0x04000000) - dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT; - - dump->regs = *regs; - dump->u_fpvalid = dump_fpu (regs, &dump->u_fp); -} -EXPORT_SYMBOL(dump_thread); - /* * Shuffle the argument into the correct register before calling the * thread function. r1 is the thread argument, r2 is the pointer to diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c index f85b928ffac..5f45567318d 100644 --- a/arch/m68k/kernel/process.c +++ b/arch/m68k/kernel/process.c @@ -315,53 +315,6 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu) } EXPORT_SYMBOL(dump_fpu); -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - struct switch_stack *sw; - -/* changed the size calculations - should hopefully work better. lbt */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = rdusp() & ~(PAGE_SIZE - 1); - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; - dump->u_dsize = ((unsigned long) (current->mm->brk + - (PAGE_SIZE-1))) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - - if (dump->start_stack < TASK_SIZE) - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; - - dump->u_ar0 = offsetof(struct user, regs); - sw = ((struct switch_stack *)regs) - 1; - dump->regs.d1 = regs->d1; - dump->regs.d2 = regs->d2; - dump->regs.d3 = regs->d3; - dump->regs.d4 = regs->d4; - dump->regs.d5 = regs->d5; - dump->regs.d6 = sw->d6; - dump->regs.d7 = sw->d7; - dump->regs.a0 = regs->a0; - dump->regs.a1 = regs->a1; - dump->regs.a2 = regs->a2; - dump->regs.a3 = sw->a3; - dump->regs.a4 = sw->a4; - dump->regs.a5 = sw->a5; - dump->regs.a6 = sw->a6; - dump->regs.d0 = regs->d0; - dump->regs.orig_d0 = regs->orig_d0; - dump->regs.stkadj = regs->stkadj; - dump->regs.sr = regs->sr; - dump->regs.pc = regs->pc; - dump->regs.fmtvec = (regs->format << 12) | regs->vector; - /* dump floating point stuff */ - dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp); -} -EXPORT_SYMBOL(dump_thread); - /* * sys_execve() executes a new program. */ diff --git a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c index 77460e316a0..a248e81caa0 100644 --- a/arch/sparc/kernel/process.c +++ b/arch/sparc/kernel/process.c @@ -566,38 +566,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, return 0; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - unsigned long first_stack_page; - - dump->magic = SUNOS_CORE_MAGIC; - dump->len = sizeof(struct user); - dump->regs.psr = regs->psr; - dump->regs.pc = regs->pc; - dump->regs.npc = regs->npc; - dump->regs.y = regs->y; - /* fuck me plenty */ - memcpy(&dump->regs.regs[0], ®s->u_regs[1], (sizeof(unsigned long) * 15)); - dump->uexec = current->thread.core_exec; - dump->u_tsize = (((unsigned long) current->mm->end_code) - - ((unsigned long) current->mm->start_code)) & ~(PAGE_SIZE - 1); - dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))); - dump->u_dsize -= dump->u_tsize; - dump->u_dsize &= ~(PAGE_SIZE - 1); - first_stack_page = (regs->u_regs[UREG_FP] & ~(PAGE_SIZE - 1)); - dump->u_ssize = (TASK_SIZE - first_stack_page) & ~(PAGE_SIZE - 1); - memcpy(&dump->fpu.fpstatus.fregs.regs[0], ¤t->thread.float_regs[0], (sizeof(unsigned long) * 32)); - dump->fpu.fpstatus.fsr = current->thread.fsr; - dump->fpu.fpstatus.flags = dump->fpu.fpstatus.extra = 0; - dump->fpu.fpstatus.fpq_count = current->thread.fpqdepth; - memcpy(&dump->fpu.fpstatus.fpq[0], ¤t->thread.fpqueue[0], - ((sizeof(unsigned long) * 2) * 16)); - dump->sigcode = 0; -} - /* * fill in the fpu structure for a core dump. */ diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c index ef647acc479..62f6221db74 100644 --- a/arch/sparc/kernel/sparc_ksyms.c +++ b/arch/sparc/kernel/sparc_ksyms.c @@ -214,8 +214,6 @@ EXPORT_SYMBOL(kunmap_atomic); EXPORT_SYMBOL(svr4_setcontext); EXPORT_SYMBOL(svr4_getcontext); -EXPORT_SYMBOL(dump_thread); - /* prom symbols */ EXPORT_SYMBOL(idprom); EXPORT_SYMBOL(prom_root_node); diff --git a/arch/sparc64/kernel/binfmt_aout32.c b/arch/sparc64/kernel/binfmt_aout32.c index 92c1b36a2e1..9877f2d7672 100644 --- a/arch/sparc64/kernel/binfmt_aout32.c +++ b/arch/sparc64/kernel/binfmt_aout32.c @@ -32,6 +32,7 @@ #include #include #include +#include static int load_aout32_binary(struct linux_binprm *, struct pt_regs * regs); static int load_aout32_library(struct file*); @@ -101,7 +102,7 @@ static int aout32_core_dump(long signr, struct pt_regs *regs, struct file *file, current->flags |= PF_DUMPCORE; strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); dump.signal = signr; - dump_thread(regs, &dump); + aout_dump_thread(regs, &dump); /* If the size of the dump file exceeds the rlimit, then see what would happen if we wrote the stack, but not the data area. */ diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c index ca7cdfd55f7..6e21785bb36 100644 --- a/arch/sparc64/kernel/process.c +++ b/arch/sparc64/kernel/process.c @@ -725,17 +725,6 @@ pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) return retval; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - /* Only should be used for SunOS and ancient a.out - * SparcLinux binaries... Not worth implementing. - */ - memset(dump, 0, sizeof(struct user)); -} - typedef struct { union { unsigned int pr_regs[32]; diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c index 5311ee93ede..19ce9dbf46c 100644 --- a/arch/um/kernel/ksyms.c +++ b/arch/um/kernel/ksyms.c @@ -60,7 +60,6 @@ EXPORT_SYMBOL(os_accept_connection); EXPORT_SYMBOL(os_rcv_fd); EXPORT_SYMBOL(run_helper); EXPORT_SYMBOL(start_thread); -EXPORT_SYMBOL(dump_thread); #ifdef CONFIG_SMP diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index c07961bedb7..fc50d2f959d 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -258,10 +258,6 @@ void cpu_idle(void) default_idle(); } -void dump_thread(struct pt_regs *regs, struct user *u) -{ -} - int __cant_sleep(void) { return in_atomic() || irqs_disabled() || in_interrupt(); /* Is in_interrupt() really needed? */ diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index dabdbeff1f7..78858068e24 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -539,55 +539,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, return err; } -/* - * fill in the user structure for a core dump.. - */ -void dump_thread(struct pt_regs * regs, struct user * dump) -{ - u16 gs; - -/* changed the size calculations - should hopefully work better. lbt */ - dump->magic = CMAGIC; - dump->start_code = 0; - dump->start_stack = regs->sp & ~(PAGE_SIZE - 1); - dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; - dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; - dump->u_dsize -= dump->u_tsize; - dump->u_ssize = 0; - dump->u_debugreg[0] = current->thread.debugreg0; - dump->u_debugreg[1] = current->thread.debugreg1; - dump->u_debugreg[2] = current->thread.debugreg2; - dump->u_debugreg[3] = current->thread.debugreg3; - dump->u_debugreg[4] = 0; - dump->u_debugreg[5] = 0; - dump->u_debugreg[6] = current->thread.debugreg6; - dump->u_debugreg[7] = current->thread.debugreg7; - - if (dump->start_stack < TASK_SIZE) - dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; - - dump->regs.bx = regs->bx; - dump->regs.cx = regs->cx; - dump->regs.dx = regs->dx; - dump->regs.si = regs->si; - dump->regs.di = regs->di; - dump->regs.bp = regs->bp; - dump->regs.ax = regs->ax; - dump->regs.ds = (u16)regs->ds; - dump->regs.es = (u16)regs->es; - dump->regs.fs = (u16)regs->fs; - savesegment(gs,gs); - dump->regs.orig_ax = regs->orig_ax; - dump->regs.ip = regs->ip; - dump->regs.cs = (u16)regs->cs; - dump->regs.flags = regs->flags; - dump->regs.sp = regs->sp; - dump->regs.ss = (u16)regs->ss; - - dump->u_fpvalid = dump_fpu (regs, &dump->i387); -} -EXPORT_SYMBOL(dump_thread); - #ifdef CONFIG_SECCOMP static void hard_disable_TSC(void) { diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 7c3d5f923da..b5c3b6114ad 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -61,7 +61,8 @@ config BINFMT_SHARED_FLAT config BINFMT_AOUT tristate "Kernel support for a.out and ECOFF binaries" - depends on X86_32 || ALPHA || ARM || M68K || SPARC32 + depends on ARCH_SUPPORTS_AOUT && \ + (X86_32 || ALPHA || ARM || M68K || SPARC32) ---help--- A.out (Assembler.OUTput) is a set of formats for libraries and executables used in the earliest versions of UNIX. Linux used diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index 7f65e71bf85..a1bb2244cac 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c @@ -28,6 +28,7 @@ #include #include #include +#include static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); static int load_aout_library(struct file*); @@ -118,7 +119,7 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u dump.u_ar0 = offsetof(struct user, regs); #endif dump.signal = signr; - dump_thread(regs, &dump); + aout_dump_thread(regs, &dump); /* If the size of the dump file exceeds the rlimit, then see what would happen if we wrote the stack, but not the data area. */ diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 111771d38e6..a93b1170551 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -513,6 +513,7 @@ out: return error; } +#ifdef CONFIG_ARCH_SUPPORTS_AOUT static unsigned long load_aout_interp(struct exec *interp_ex, struct file *interpreter) { @@ -558,6 +559,14 @@ static unsigned long load_aout_interp(struct exec *interp_ex, out: return elf_entry; } +#else +/* dummy extern - the function should never be called if !CONFIG_AOUT_BINFMT */ +static inline unsigned long load_aout_interp(struct exec *interp_ex, + struct file *interpreter) +{ + return -ELIBACC; +} +#endif /* * These are the functions used to load ELF style executables and shared @@ -565,9 +574,15 @@ out: */ #define INTERPRETER_NONE 0 -#define INTERPRETER_AOUT 1 #define INTERPRETER_ELF 2 +#ifdef CONFIG_ARCH_SUPPORTS_AOUT +#define INTERPRETER_AOUT 1 +#define IS_AOUT_INTERP(x) ((x) == INTERPRETER_AOUT) +#else +#define IS_AOUT_INTERP(x) (0) +#endif + #ifndef STACK_RND_MASK #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) /* 8MB of VA */ #endif @@ -775,6 +790,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) /* Some simple consistency checks for the interpreter */ if (elf_interpreter) { static int warn; +#ifdef CONFIG_ARCH_SUPPORTS_AOUT interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; /* Now figure out which format our binary is */ @@ -782,11 +798,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) (N_MAGIC(loc->interp_ex) != ZMAGIC) && (N_MAGIC(loc->interp_ex) != QMAGIC)) interpreter_type = INTERPRETER_ELF; - +#else + interpreter_type = INTERPRETER_ELF; +#endif if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) interpreter_type &= ~INTERPRETER_ELF; - if (interpreter_type == INTERPRETER_AOUT && warn < 10) { + if (IS_AOUT_INTERP(interpreter_type) && warn < 10) { printk(KERN_WARNING "a.out ELF interpreter %s is " "deprecated and will not be supported " "after Linux 2.6.25\n", elf_interpreter); @@ -815,7 +833,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) /* OK, we are done with that, now set up the arg stuff, and then start this sucker up */ - if ((!bprm->sh_bang) && (interpreter_type == INTERPRETER_AOUT)) { + if (IS_AOUT_INTERP(interpreter_type) && !bprm->sh_bang) { char *passed_p = passed_fileno; sprintf(passed_fileno, "%d", elf_exec_fileno); @@ -1004,7 +1022,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) } if (elf_interpreter) { - if (interpreter_type == INTERPRETER_AOUT) { + if (IS_AOUT_INTERP(interpreter_type)) { elf_entry = load_aout_interp(&loc->interp_ex, interpreter); } else { @@ -1045,7 +1063,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) kfree(elf_phdata); - if (interpreter_type != INTERPRETER_AOUT) + if (!IS_AOUT_INTERP(interpreter_type)) sys_close(elf_exec_fileno); set_binfmt(&elf_format); @@ -1061,14 +1079,14 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) compute_creds(bprm); current->flags &= ~PF_FORKNOEXEC; retval = create_elf_tables(bprm, &loc->elf_ex, - (interpreter_type == INTERPRETER_AOUT), + IS_AOUT_INTERP(interpreter_type), load_addr, interp_load_addr); if (retval < 0) { send_sig(SIGKILL, current, 0); goto out; } /* N.B. passed_fileno might not be initialized? */ - if (interpreter_type == INTERPRETER_AOUT) + if (IS_AOUT_INTERP(interpreter_type)) current->mm->arg_start += strlen(passed_fileno) + 1; current->mm->end_code = end_code; current->mm->start_code = start_code; diff --git a/fs/exec.c b/fs/exec.c index 927a7c5ef4a..9f9c27224d7 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1166,7 +1166,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) { int try,retval; struct linux_binfmt *fmt; -#ifdef __alpha__ +#if defined(__alpha__) && defined(CONFIG_ARCH_SUPPORTS_AOUT) /* handle /sbin/loader.. */ { struct exec * eh = (struct exec *) bprm->buf; diff --git a/include/asm-alpha/a.out-core.h b/include/asm-alpha/a.out-core.h new file mode 100644 index 00000000000..9e33e92e524 --- /dev/null +++ b/include/asm-alpha/a.out-core.h @@ -0,0 +1,80 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * 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_A_OUT_CORE_H +#define _ASM_A_OUT_CORE_H + +#ifdef __KERNEL__ + +#include + +/* + * Fill in the user structure for an ECOFF core dump. + */ +static inline void aout_dump_thread(struct pt_regs *pt, struct user *dump) +{ + /* switch stack follows right below pt_regs: */ + struct switch_stack * sw = ((struct switch_stack *) pt) - 1; + + dump->magic = CMAGIC; + dump->start_code = current->mm->start_code; + dump->start_data = current->mm->start_data; + dump->start_stack = rdusp() & ~(PAGE_SIZE - 1); + dump->u_tsize = ((current->mm->end_code - dump->start_code) + >> PAGE_SHIFT); + dump->u_dsize = ((current->mm->brk + PAGE_SIZE-1 - dump->start_data) + >> PAGE_SHIFT); + dump->u_ssize = (current->mm->start_stack - dump->start_stack + + PAGE_SIZE-1) >> PAGE_SHIFT; + + /* + * We store the registers in an order/format that is + * compatible with DEC Unix/OSF/1 as this makes life easier + * for gdb. + */ + dump->regs[EF_V0] = pt->r0; + dump->regs[EF_T0] = pt->r1; + dump->regs[EF_T1] = pt->r2; + dump->regs[EF_T2] = pt->r3; + dump->regs[EF_T3] = pt->r4; + dump->regs[EF_T4] = pt->r5; + dump->regs[EF_T5] = pt->r6; + dump->regs[EF_T6] = pt->r7; + dump->regs[EF_T7] = pt->r8; + dump->regs[EF_S0] = sw->r9; + dump->regs[EF_S1] = sw->r10; + dump->regs[EF_S2] = sw->r11; + dump->regs[EF_S3] = sw->r12; + dump->regs[EF_S4] = sw->r13; + dump->regs[EF_S5] = sw->r14; + dump->regs[EF_S6] = sw->r15; + dump->regs[EF_A3] = pt->r19; + dump->regs[EF_A4] = pt->r20; + dump->regs[EF_A5] = pt->r21; + dump->regs[EF_T8] = pt->r22; + dump->regs[EF_T9] = pt->r23; + dump->regs[EF_T10] = pt->r24; + dump->regs[EF_T11] = pt->r25; + dump->regs[EF_RA] = pt->r26; + dump->regs[EF_T12] = pt->r27; + dump->regs[EF_AT] = pt->r28; + dump->regs[EF_SP] = rdusp(); + dump->regs[EF_PS] = pt->ps; + dump->regs[EF_PC] = pt->pc; + dump->regs[EF_GP] = pt->gp; + dump->regs[EF_A0] = pt->r16; + dump->regs[EF_A1] = pt->r17; + dump->regs[EF_A2] = pt->r18; + memcpy((char *)dump->regs + EF_SIZE, sw->fp, 32 * 8); +} + +#endif /* __KERNEL__ */ +#endif /* _ASM_A_OUT_CORE_H */ diff --git a/include/asm-arm/a.out-core.h b/include/asm-arm/a.out-core.h new file mode 100644 index 00000000000..93d04acaa31 --- /dev/null +++ b/include/asm-arm/a.out-core.h @@ -0,0 +1,49 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * 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_A_OUT_CORE_H +#define _ASM_A_OUT_CORE_H + +#ifdef __KERNEL__ + +#include +#include + +/* + * fill in the user structure for an a.out core dump + */ +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump) +{ + struct task_struct *tsk = current; + + dump->magic = CMAGIC; + dump->start_code = tsk->mm->start_code; + dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1); + + dump->u_tsize = (tsk->mm->end_code - tsk->mm->start_code) >> PAGE_SHIFT; + dump->u_dsize = (tsk->mm->brk - tsk->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT; + dump->u_ssize = 0; + + dump->u_debugreg[0] = tsk->thread.debug.bp[0].address; + dump->u_debugreg[1] = tsk->thread.debug.bp[1].address; + dump->u_debugreg[2] = tsk->thread.debug.bp[0].insn.arm; + dump->u_debugreg[3] = tsk->thread.debug.bp[1].insn.arm; + dump->u_debugreg[4] = tsk->thread.debug.nsaved; + + if (dump->start_stack < 0x04000000) + dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT; + + dump->regs = *regs; + dump->u_fpvalid = dump_fpu (regs, &dump->u_fp); +} + +#endif /* __KERNEL__ */ +#endif /* _ASM_A_OUT_CORE_H */ diff --git a/include/asm-frv/a.out.h b/include/asm-frv/a.out.h deleted file mode 100644 index dd3b7e5754c..00000000000 --- a/include/asm-frv/a.out.h +++ /dev/null @@ -1,5 +0,0 @@ -/* - * FRV doesn't do AOUT format. This header file should be removed as - * soon as fs/exec.c and fs/proc/kcore.c and the archs that require - * them to include linux/a.out.h are fixed. - */ diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm index 57ba6063595..fd9dcfd91c3 100644 --- a/include/asm-generic/Kbuild.asm +++ b/include/asm-generic/Kbuild.asm @@ -1,4 +1,6 @@ +ifeq ($(wildcard include/asm-$(SRCARCH)/a.out.h),include/asm-$(SRCARCH)/a.out.h) unifdef-y += a.out.h +endif unifdef-y += auxvec.h unifdef-y += byteorder.h unifdef-y += errno.h diff --git a/include/asm-m68k/a.out-core.h b/include/asm-m68k/a.out-core.h new file mode 100644 index 00000000000..f6bfc1d63ff --- /dev/null +++ b/include/asm-m68k/a.out-core.h @@ -0,0 +1,67 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * 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_A_OUT_CORE_H +#define _ASM_A_OUT_CORE_H + +#ifdef __KERNEL__ + +#include +#include + +/* + * fill in the user structure for an a.out core dump + */ +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump) +{ + struct switch_stack *sw; + +/* changed the size calculations - should hopefully work better. lbt */ + dump->magic = CMAGIC; + dump->start_code = 0; + dump->start_stack = rdusp() & ~(PAGE_SIZE - 1); + dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; + dump->u_dsize = ((unsigned long) (current->mm->brk + + (PAGE_SIZE-1))) >> PAGE_SHIFT; + dump->u_dsize -= dump->u_tsize; + dump->u_ssize = 0; + + if (dump->start_stack < TASK_SIZE) + dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; + + dump->u_ar0 = offsetof(struct user, regs); + sw = ((struct switch_stack *)regs) - 1; + dump->regs.d1 = regs->d1; + dump->regs.d2 = regs->d2; + dump->regs.d3 = regs->d3; + dump->regs.d4 = regs->d4; + dump->regs.d5 = regs->d5; + dump->regs.d6 = sw->d6; + dump->regs.d7 = sw->d7; + dump->regs.a0 = regs->a0; + dump->regs.a1 = regs->a1; + dump->regs.a2 = regs->a2; + dump->regs.a3 = sw->a3; + dump->regs.a4 = sw->a4; + dump->regs.a5 = sw->a5; + dump->regs.a6 = sw->a6; + dump->regs.d0 = regs->d0; + dump->regs.orig_d0 = regs->orig_d0; + dump->regs.stkadj = regs->stkadj; + dump->regs.sr = regs->sr; + dump->regs.pc = regs->pc; + dump->regs.fmtvec = (regs->format << 12) | regs->vector; + /* dump floating point stuff */ + dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp); +} + +#endif /* __KERNEL__ */ +#endif /* _ASM_A_OUT_CORE_H */ diff --git a/include/asm-sparc/a.out-core.h b/include/asm-sparc/a.out-core.h new file mode 100644 index 00000000000..e8fd338ed0b --- /dev/null +++ b/include/asm-sparc/a.out-core.h @@ -0,0 +1,52 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * 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_A_OUT_CORE_H +#define _ASM_A_OUT_CORE_H + +#ifdef __KERNEL__ + +#include + +/* + * fill in the user structure for an a.out core dump + */ +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump) +{ + unsigned long first_stack_page; + + dump->magic = SUNOS_CORE_MAGIC; + dump->len = sizeof(struct user); + dump->regs.psr = regs->psr; + dump->regs.pc = regs->pc; + dump->regs.npc = regs->npc; + dump->regs.y = regs->y; + /* fuck me plenty */ + memcpy(&dump->regs.regs[0], ®s->u_regs[1], (sizeof(unsigned long) * 15)); + dump->uexec = current->thread.core_exec; + dump->u_tsize = (((unsigned long) current->mm->end_code) - + ((unsigned long) current->mm->start_code)) & ~(PAGE_SIZE - 1); + dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))); + dump->u_dsize -= dump->u_tsize; + dump->u_dsize &= ~(PAGE_SIZE - 1); + first_stack_page = (regs->u_regs[UREG_FP] & ~(PAGE_SIZE - 1)); + dump->u_ssize = (TASK_SIZE - first_stack_page) & ~(PAGE_SIZE - 1); + memcpy(&dump->fpu.fpstatus.fregs.regs[0], ¤t->thread.float_regs[0], (sizeof(unsigned long) * 32)); + dump->fpu.fpstatus.fsr = current->thread.fsr; + dump->fpu.fpstatus.flags = dump->fpu.fpstatus.extra = 0; + dump->fpu.fpstatus.fpq_count = current->thread.fpqdepth; + memcpy(&dump->fpu.fpstatus.fpq[0], ¤t->thread.fpqueue[0], + ((sizeof(unsigned long) * 2) * 16)); + dump->sigcode = 0; +} + +#endif /* __KERNEL__ */ +#endif /* _ASM_A_OUT_CORE_H */ diff --git a/include/asm-sparc64/a.out-core.h b/include/asm-sparc64/a.out-core.h new file mode 100644 index 00000000000..3499b3c425c --- /dev/null +++ b/include/asm-sparc64/a.out-core.h @@ -0,0 +1,31 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * 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_A_OUT_CORE_H +#define _ASM_A_OUT_CORE_H + +#ifdef __KERNEL__ + +#include + +/* + * fill in the user structure for an a.out core dump + */ +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump) +{ + /* Only should be used for SunOS and ancient a.out + * SparcLinux binaries... Not worth implementing. + */ + memset(dump, 0, sizeof(struct user)); +} + +#endif /* __KERNEL__ */ +#endif /* _ASM_A_OUT_CORE_H */ diff --git a/include/asm-um/a.out-core.h b/include/asm-um/a.out-core.h new file mode 100644 index 00000000000..995643b1830 --- /dev/null +++ b/include/asm-um/a.out-core.h @@ -0,0 +1,27 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * 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 __UM_A_OUT_CORE_H +#define __UM_A_OUT_CORE_H + +#ifdef __KERNEL__ + +#include + +/* + * fill in the user structure for an a.out core dump + */ +static inline void aout_dump_thread(struct pt_regs *regs, struct user *u) +{ +} + +#endif /* __KERNEL__ */ +#endif /* __UM_A_OUT_CORE_H */ diff --git a/include/asm-x86/a.out-core.h b/include/asm-x86/a.out-core.h new file mode 100644 index 00000000000..d2b6e11d3e9 --- /dev/null +++ b/include/asm-x86/a.out-core.h @@ -0,0 +1,71 @@ +/* a.out coredump register dumper + * + * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * 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_A_OUT_CORE_H +#define _ASM_A_OUT_CORE_H + +#ifdef __KERNEL__ +#ifdef CONFIG_X86_32 + +#include +#include + +/* + * fill in the user structure for an a.out core dump + */ +static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump) +{ + u16 gs; + +/* changed the size calculations - should hopefully work better. lbt */ + dump->magic = CMAGIC; + dump->start_code = 0; + dump->start_stack = regs->sp & ~(PAGE_SIZE - 1); + dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT; + dump->u_dsize = ((unsigned long) (current->mm->brk + (PAGE_SIZE-1))) >> PAGE_SHIFT; + dump->u_dsize -= dump->u_tsize; + dump->u_ssize = 0; + dump->u_debugreg[0] = current->thread.debugreg0; + dump->u_debugreg[1] = current->thread.debugreg1; + dump->u_debugreg[2] = current->thread.debugreg2; + dump->u_debugreg[3] = current->thread.debugreg3; + dump->u_debugreg[4] = 0; + dump->u_debugreg[5] = 0; + dump->u_debugreg[6] = current->thread.debugreg6; + dump->u_debugreg[7] = current->thread.debugreg7; + + if (dump->start_stack < TASK_SIZE) + dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT; + + dump->regs.bx = regs->bx; + dump->regs.cx = regs->cx; + dump->regs.dx = regs->dx; + dump->regs.si = regs->si; + dump->regs.di = regs->di; + dump->regs.bp = regs->bp; + dump->regs.ax = regs->ax; + dump->regs.ds = (u16)regs->ds; + dump->regs.es = (u16)regs->es; + dump->regs.fs = (u16)regs->fs; + savesegment(gs,gs); + dump->regs.orig_ax = regs->orig_ax; + dump->regs.ip = regs->ip; + dump->regs.cs = (u16)regs->cs; + dump->regs.flags = regs->flags; + dump->regs.sp = regs->sp; + dump->regs.ss = (u16)regs->ss; + + dump->u_fpvalid = dump_fpu (regs, &dump->i387); +} + +#endif /* CONFIG_X86_32 */ +#endif /* __KERNEL__ */ +#endif /* _ASM_A_OUT_CORE_H */ diff --git a/include/linux/a.out.h b/include/linux/a.out.h index 82cd918f2ab..208f4e8ed30 100644 --- a/include/linux/a.out.h +++ b/include/linux/a.out.h @@ -1,6 +1,8 @@ #ifndef __A_OUT_GNU_H__ #define __A_OUT_GNU_H__ +#ifdef CONFIG_ARCH_SUPPORTS_AOUT + #define __GNU_EXEC_MACROS__ #ifndef __STRUCT_EXEC_OVERRIDE__ @@ -9,6 +11,8 @@ #endif /* __STRUCT_EXEC_OVERRIDE__ */ +#ifndef __ASSEMBLY__ + /* these go in the N_MACHTYPE field */ enum machine_type { #if defined (M_OLDSUN2) @@ -272,5 +276,11 @@ struct relocation_info }; #endif /* no N_RELOCATION_INFO_DECLARED. */ - +#endif /*__ASSEMBLY__ */ +#else /* CONFIG_ARCH_SUPPORTS_AOUT */ +#ifndef __ASSEMBLY__ +struct exec { +}; +#endif +#endif /* CONFIG_ARCH_SUPPORTS_AOUT */ #endif /* __A_OUT_GNU_H__ */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 9e01f376840..568042290c0 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -172,8 +172,6 @@ extern int kernel_text_address(unsigned long addr); struct pid; extern struct pid *session_of_pgrp(struct pid *pgrp); -extern void dump_thread(struct pt_regs *regs, struct user *dump); - #ifdef CONFIG_PRINTK asmlinkage int vprintk(const char *fmt, va_list args) __attribute__ ((format (printf, 1, 0))); -- cgit v1.2.3-70-g09d2 From 531d7d4256f3726b93f7a91f97132a944ab28148 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 8 Feb 2008 04:20:22 -0800 Subject: asm-*/posix_types.h: scrub __GLIBC__ Some arches (like alpha and ia64) already have a clean posix_types.h header. This brings all the others in line by removing all references to __GLIBC__ (and some undocumented __USE_ALL). Signed-off-by: Mike Frysinger Acked-by: Ingo Molnar Cc: Ulrich Drepper Cc: Roland McGrath Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-arm/posix_types.h | 6 +----- include/asm-avr32/posix_types.h | 4 ---- include/asm-blackfin/posix_types.h | 8 ++------ include/asm-cris/posix_types.h | 4 ---- include/asm-frv/posix_types.h | 8 ++------ include/asm-h8300/posix_types.h | 8 ++------ include/asm-m32r/posix_types.h | 8 ++------ include/asm-m68k/posix_types.h | 8 ++------ include/asm-mips/posix_types.h | 4 ++-- include/asm-parisc/posix_types.h | 8 ++------ include/asm-powerpc/posix_types.h | 5 ++--- include/asm-sparc/posix_types.h | 8 ++------ include/asm-sparc64/posix_types.h | 8 ++------ include/asm-v850/posix_types.h | 8 ++------ include/asm-x86/posix_types_32.h | 8 ++------ include/asm-xtensa/posix_types.h | 5 ++--- 16 files changed, 27 insertions(+), 81 deletions(-) (limited to 'include/asm-frv') diff --git a/include/asm-arm/posix_types.h b/include/asm-arm/posix_types.h index e142a2a016c..c37379dadcb 100644 --- a/include/asm-arm/posix_types.h +++ b/include/asm-arm/posix_types.h @@ -51,14 +51,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET #define __FD_SET(fd, fdsetp) \ diff --git a/include/asm-avr32/posix_types.h b/include/asm-avr32/posix_types.h index 9e255b99963..fe0c0c01438 100644 --- a/include/asm-avr32/posix_types.h +++ b/include/asm-avr32/posix_types.h @@ -46,11 +46,7 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; #if defined(__KERNEL__) diff --git a/include/asm-blackfin/posix_types.h b/include/asm-blackfin/posix_types.h index c3fa50fa50b..23aa1f8c1bd 100644 --- a/include/asm-blackfin/posix_types.h +++ b/include/asm-blackfin/posix_types.h @@ -39,14 +39,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) @@ -60,6 +56,6 @@ typedef struct { #undef __FD_ZERO #define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif diff --git a/include/asm-cris/posix_types.h b/include/asm-cris/posix_types.h index 3a5e4c43eae..ce3fb25a460 100644 --- a/include/asm-cris/posix_types.h +++ b/include/asm-cris/posix_types.h @@ -44,11 +44,7 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; #ifdef __KERNEL__ diff --git a/include/asm-frv/posix_types.h b/include/asm-frv/posix_types.h index 73c2ba8d76b..a9f1f5be063 100644 --- a/include/asm-frv/posix_types.h +++ b/include/asm-frv/posix_types.h @@ -39,14 +39,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) @@ -60,7 +56,7 @@ typedef struct { #undef __FD_ZERO #define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif diff --git a/include/asm-h8300/posix_types.h b/include/asm-h8300/posix_types.h index 7de94b1fd0e..5c553927fc5 100644 --- a/include/asm-h8300/posix_types.h +++ b/include/asm-h8300/posix_types.h @@ -38,14 +38,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) @@ -59,6 +55,6 @@ typedef struct { #undef __FD_ZERO #define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif diff --git a/include/asm-m32r/posix_types.h b/include/asm-m32r/posix_types.h index 1caac65d208..b309c585863 100644 --- a/include/asm-m32r/posix_types.h +++ b/include/asm-m32r/posix_types.h @@ -39,14 +39,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp) @@ -117,6 +113,6 @@ static __inline__ void __FD_ZERO(__kernel_fd_set *__p) } } -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif /* _ASM_M32R_POSIX_TYPES_H */ diff --git a/include/asm-m68k/posix_types.h b/include/asm-m68k/posix_types.h index fa166ee3028..63cdcc142d9 100644 --- a/include/asm-m68k/posix_types.h +++ b/include/asm-m68k/posix_types.h @@ -39,14 +39,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) @@ -60,6 +56,6 @@ typedef struct { #undef __FD_ZERO #define __FD_ZERO(fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif diff --git a/include/asm-mips/posix_types.h b/include/asm-mips/posix_types.h index c2e8a0070da..c200102c858 100644 --- a/include/asm-mips/posix_types.h +++ b/include/asm-mips/posix_types.h @@ -69,7 +69,7 @@ typedef struct { #endif } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp) @@ -139,6 +139,6 @@ static __inline__ void __FD_ZERO(__kernel_fd_set *__p) } } -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif /* _ASM_POSIX_TYPES_H */ diff --git a/include/asm-parisc/posix_types.h b/include/asm-parisc/posix_types.h index b634e3c47fd..bb725a6630b 100644 --- a/include/asm-parisc/posix_types.h +++ b/include/asm-parisc/posix_types.h @@ -47,18 +47,14 @@ typedef unsigned long long __kernel_ino64_t; typedef unsigned int __kernel_old_dev_t; typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; /* compatibility stuff */ typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_gid_t __kernel_old_gid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp) @@ -128,6 +124,6 @@ static __inline__ void __FD_ZERO(__kernel_fd_set *__p) } } -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif diff --git a/include/asm-powerpc/posix_types.h b/include/asm-powerpc/posix_types.h index 2f2288f520b..c4e396b540d 100644 --- a/include/asm-powerpc/posix_types.h +++ b/include/asm-powerpc/posix_types.h @@ -64,8 +64,7 @@ typedef struct { #else /* __GNUC__ */ -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) \ - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0) +#if defined(__KERNEL__) /* With GNU C, use inline functions instead so args are evaluated only once: */ #undef __FD_SET @@ -124,6 +123,6 @@ static __inline__ void __FD_ZERO(__kernel_fd_set *p) } } -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif /* __GNUC__ */ #endif /* _ASM_POWERPC_POSIX_TYPES_H */ diff --git a/include/asm-sparc/posix_types.h b/include/asm-sparc/posix_types.h index 62c8fa7b36d..dcc07eb5e18 100644 --- a/include/asm-sparc/posix_types.h +++ b/include/asm-sparc/posix_types.h @@ -39,14 +39,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) @@ -117,6 +113,6 @@ static inline void __FD_ZERO(__kernel_fd_set *p) } } -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif /* !(__ARCH_SPARC_POSIX_TYPES_H) */ diff --git a/include/asm-sparc64/posix_types.h b/include/asm-sparc64/posix_types.h index 3426a65ecd3..4eaaa019663 100644 --- a/include/asm-sparc64/posix_types.h +++ b/include/asm-sparc64/posix_types.h @@ -43,14 +43,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) @@ -121,6 +117,6 @@ static inline void __FD_ZERO(__kernel_fd_set *p) } } -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif /* !(__ARCH_SPARC64_POSIX_TYPES_H) */ diff --git a/include/asm-v850/posix_types.h b/include/asm-v850/posix_types.h index ccb7297a0ed..7f403b76539 100644 --- a/include/asm-v850/posix_types.h +++ b/include/asm-v850/posix_types.h @@ -44,15 +44,11 @@ typedef __kernel_uid_t __kernel_old_uid_t; typedef unsigned int __kernel_old_dev_t; typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) /* We used to include here, which seems the right thing, but it caused nasty include-file definition order problems. Removing the @@ -71,6 +67,6 @@ typedef struct { #define __FD_ZERO(fd_set) \ memset (fd_set, 0, sizeof (*(fd_set *)fd_set)) -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif /* __V850_POSIX_TYPES_H__ */ diff --git a/include/asm-x86/posix_types_32.h b/include/asm-x86/posix_types_32.h index 133e31e7dfd..015e539cdef 100644 --- a/include/asm-x86/posix_types_32.h +++ b/include/asm-x86/posix_types_32.h @@ -39,14 +39,10 @@ typedef long long __kernel_loff_t; #endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ - int __val[2]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) +#if defined(__KERNEL__) #undef __FD_SET #define __FD_SET(fd,fdsetp) \ @@ -77,6 +73,6 @@ do { \ "2" ((__kernel_fd_set *) (fdsetp)) : "memory"); \ } while (0) -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif diff --git a/include/asm-xtensa/posix_types.h b/include/asm-xtensa/posix_types.h index 4ad77dda6d5..43f9dd1126a 100644 --- a/include/asm-xtensa/posix_types.h +++ b/include/asm-xtensa/posix_types.h @@ -64,8 +64,7 @@ typedef struct { #else /* __GNUC__ */ -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) \ - || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0) +#if defined(__KERNEL__) /* With GNU C, use inline functions instead so args are evaluated only once: */ #undef __FD_SET @@ -118,6 +117,6 @@ static __inline__ void __FD_ZERO(__kernel_fd_set *p) } } -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif /* __GNUC__ */ #endif /* _XTENSA_POSIX_TYPES_H */ -- cgit v1.2.3-70-g09d2 From bdc807871d58285737d50dc6163d0feb72cb0dc2 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 8 Feb 2008 04:21:26 -0800 Subject: avoid overflows in kernel/time.c When the conversion factor between jiffies and milli- or microseconds is not a single multiply or divide, as for the case of HZ == 300, we currently do a multiply followed by a divide. The intervening result, however, is subject to overflows, especially since the fraction is not simplified (for HZ == 300, we multiply by 300 and divide by 1000). This is exposed to the user when passing a large timeout to poll(), for example. This patch replaces the multiply-divide with a reciprocal multiplication on 32-bit platforms. When the input is an unsigned long, there is no portable way to do this on 64-bit platforms there is no portable way to do this since it requires a 128-bit intermediate result (which gcc does support on 64-bit platforms but may generate libgcc calls, e.g. on 64-bit s390), but since the output is a 32-bit integer in the cases affected, just simplify the multiply-divide (*3/10 instead of *300/1000). The reciprocal multiply used can have off-by-one errors in the upper half of the valid output range. This could be avoided at the expense of having to deal with a potential 65-bit intermediate result. Since the intent is to avoid overflow problems and most of the other time conversions are only semiexact, the off-by-one errors were considered an acceptable tradeoff. At Ralf Baechle's suggestion, this version uses a Perl script to compute the necessary constants. We already have dependencies on Perl for kernel compiles. This does, however, require the Perl module Math::BigInt, which is included in the standard Perl distribution starting with version 5.8.0. In order to support older versions of Perl, include a table of canned constants in the script itself, and structure the script so that Math::BigInt isn't required if pulling values from said table. Running the script requires that the HZ value is available from the Makefile. Thus, this patch also adds the Kconfig variable CONFIG_HZ to the architectures which didn't already have it (alpha, cris, frv, h8300, m32r, m68k, m68knommu, sparc, v850, and xtensa.) It does *not* touch the sh or sh64 architectures, since Paul Mundt has dealt with those separately in the sh tree. Signed-off-by: H. Peter Anvin Cc: Ralf Baechle , Cc: Sam Ravnborg , Cc: Paul Mundt , Cc: Richard Henderson , Cc: Michael Starvik , Cc: David Howells , Cc: Yoshinori Sato , Cc: Hirokazu Takata , Cc: Geert Uytterhoeven , Cc: Roman Zippel , Cc: William L. Irwin , Cc: Chris Zankel , Cc: H. Peter Anvin , Cc: Jan Engelhardt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/alpha/Kconfig | 5 + arch/cris/Kconfig | 4 + arch/frv/Kconfig | 4 + arch/h8300/Kconfig | 4 + arch/m32r/Kconfig | 4 + arch/m68k/Kconfig | 4 + arch/m68knommu/Kconfig | 5 + arch/sparc/Kconfig | 4 + arch/v850/Kconfig | 7 + arch/xtensa/Kconfig | 4 + include/asm-alpha/param.h | 10 +- include/asm-cris/param.h | 2 +- include/asm-frv/param.h | 2 +- include/asm-h8300/param.h | 2 +- include/asm-m32r/param.h | 2 +- include/asm-m68k/param.h | 2 +- include/asm-m68knommu/param.h | 8 +- include/asm-sparc/param.h | 2 +- include/asm-v850/anna.h | 6 - include/asm-v850/as85ep1.h | 6 - include/asm-v850/fpga85e2c.h | 6 - include/asm-v850/param.h | 3 +- include/asm-v850/rte_cb.h | 6 - include/asm-v850/sim.h | 5 - include/asm-v850/sim85e2.h | 6 - include/asm-xtensa/param.h | 2 +- kernel/Makefile | 8 + kernel/time.c | 29 ++- kernel/timeconst.pl | 402 ++++++++++++++++++++++++++++++++++++++++++ 29 files changed, 486 insertions(+), 68 deletions(-) create mode 100644 kernel/timeconst.pl (limited to 'include/asm-frv') diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index d9df913a464..5b7dcd5a0e7 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -615,6 +615,11 @@ config VERBOSE_MCHECK_ON Take the default (1) unless you want more control or more info. +config HZ + int + default 1200 if ALPHA_RAWHIDE + default 1024 + source "drivers/pci/Kconfig" source "drivers/eisa/Kconfig" diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 27b082ac7f1..ff078e60e76 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig @@ -55,6 +55,10 @@ config CRIS bool default y +config HZ + int + default 100 + source "init/Kconfig" menu "General setup" diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig index 96f7d70f447..9e561ede092 100644 --- a/arch/frv/Kconfig +++ b/arch/frv/Kconfig @@ -57,6 +57,10 @@ config ARCH_HAS_ILOG2_U64 bool default y +config HZ + int + default 1000 + mainmenu "Fujitsu FR-V Kernel Configuration" source "init/Kconfig" diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index b4ba4f8b505..f69e5ea3855 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig @@ -82,6 +82,10 @@ config PCI bool default n +config HZ + int + default 100 + source "init/Kconfig" source "arch/h8300/Kconfig.cpu" diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index fe61e00a604..d4679ab55b9 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -38,6 +38,10 @@ config NO_DMA config ARCH_SUPPORTS_AOUT def_bool y +config HZ + int + default 100 + source "init/Kconfig" diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index bcbf3e4ee9d..2b0ed89cd17 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -55,6 +55,10 @@ config NO_DMA config ARCH_SUPPORTS_AOUT def_bool y +config HZ + int + default 100 + mainmenu "Linux/68k Kernel Configuration" source "init/Kconfig" diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig index 24f732342d3..548a7b32163 100644 --- a/arch/m68knommu/Kconfig +++ b/arch/m68knommu/Kconfig @@ -525,6 +525,11 @@ config 4KSTACKS running more threads on a system and also reduces the pressure on the VM subsystem for higher order allocations. +config HZ + int + default 1000 if CLEOPATRA + default 100 + comment "RAM configuration" config RAMBASE diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 08821b078ec..7c674a3503b 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -30,6 +30,10 @@ config OF config ARCH_SUPPORTS_AOUT def_bool y +config HZ + int + default 100 + source "init/Kconfig" menu "General machine setup" diff --git a/arch/v850/Kconfig b/arch/v850/Kconfig index 225f30d7cb3..7b6d3716efc 100644 --- a/arch/v850/Kconfig +++ b/arch/v850/Kconfig @@ -215,6 +215,13 @@ menu "Processor type and features" bool default !V850E_CACHE && !V850E2_CACHE + # HZ depends on the platform + config HZ + int + default 24 if V850E_SIM || V850E2_SIM85E2 + default 122 if V850E2_FPGA85E2C + default 100 + #### Misc config config ROM_KERNEL diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 5d5546ce88f..fd36764d7fb 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -49,6 +49,10 @@ config ARCH_HAS_ILOG2_U64 config NO_IOPORT def_bool y +config HZ + int + default 100 + source "init/Kconfig" menu "Processor type and features" diff --git a/include/asm-alpha/param.h b/include/asm-alpha/param.h index 214e7996346..0982f1d3949 100644 --- a/include/asm-alpha/param.h +++ b/include/asm-alpha/param.h @@ -5,15 +5,7 @@ hardware ignores reprogramming. We also need userland buy-in to the change in HZ, since this is visible in the wait4 resources etc. */ - -#ifndef HZ -# ifndef CONFIG_ALPHA_RAWHIDE -# define HZ 1024 -# else -# define HZ 1200 -# endif -#endif - +#define HZ CONFIG_HZ #define USER_HZ HZ #define EXEC_PAGESIZE 8192 diff --git a/include/asm-cris/param.h b/include/asm-cris/param.h index b2497263983..0e47994e40b 100644 --- a/include/asm-cris/param.h +++ b/include/asm-cris/param.h @@ -3,7 +3,7 @@ /* Currently we assume that HZ=100 is good for CRIS. */ #ifdef __KERNEL__ -# define HZ 100 /* Internal kernel timer frequency */ +# define HZ CONFIG_HZ /* Internal kernel timer frequency */ # define USER_HZ 100 /* .. some user interfaces are in "ticks" */ # define CLOCKS_PER_SEC (USER_HZ) /* like times() */ #endif diff --git a/include/asm-frv/param.h b/include/asm-frv/param.h index 365653b1726..6859dd503ed 100644 --- a/include/asm-frv/param.h +++ b/include/asm-frv/param.h @@ -2,7 +2,7 @@ #define _ASM_PARAM_H #ifdef __KERNEL__ -#define HZ 1000 /* Internal kernel timer frequency */ +#define HZ CONFIG_HZ /* Internal kernel timer frequency */ #define USER_HZ 100 /* .. some user interfaces are in "ticks" */ #define CLOCKS_PER_SEC (USER_HZ) /* like times() */ #endif diff --git a/include/asm-h8300/param.h b/include/asm-h8300/param.h index c25806ed1fb..04f64f10037 100644 --- a/include/asm-h8300/param.h +++ b/include/asm-h8300/param.h @@ -3,7 +3,7 @@ #ifndef HZ -#define HZ 100 +#define HZ CONFIG_HZ #endif #ifdef __KERNEL__ diff --git a/include/asm-m32r/param.h b/include/asm-m32r/param.h index 3e14026e39c..94c77019604 100644 --- a/include/asm-m32r/param.h +++ b/include/asm-m32r/param.h @@ -2,7 +2,7 @@ #define _ASM_M32R_PARAM_H #ifdef __KERNEL__ -# define HZ 100 /* Internal kernel timer frequency */ +# define HZ CONFIG_HZ /* Internal kernel timer frequency */ # define USER_HZ 100 /* .. some user interfaces are in "ticks" */ # define CLOCKS_PER_SEC (USER_HZ) /* like times() */ #endif diff --git a/include/asm-m68k/param.h b/include/asm-m68k/param.h index 60f409d8165..536a2788835 100644 --- a/include/asm-m68k/param.h +++ b/include/asm-m68k/param.h @@ -2,7 +2,7 @@ #define _M68K_PARAM_H #ifdef __KERNEL__ -# define HZ 100 /* Internal kernel timer frequency */ +# define HZ CONFIG_HZ /* Internal kernel timer frequency */ # define USER_HZ 100 /* .. some user interfaces are in "ticks" */ # define CLOCKS_PER_SEC (USER_HZ) /* like times() */ #endif diff --git a/include/asm-m68knommu/param.h b/include/asm-m68knommu/param.h index 4c9904d6512..96c45101832 100644 --- a/include/asm-m68knommu/param.h +++ b/include/asm-m68knommu/param.h @@ -1,13 +1,7 @@ #ifndef _M68KNOMMU_PARAM_H #define _M68KNOMMU_PARAM_H - -#if defined(CONFIG_CLEOPATRA) -#define HZ 1000 -#endif -#ifndef HZ -#define HZ 100 -#endif +#define HZ CONFIG_HZ #ifdef __KERNEL__ #define USER_HZ HZ diff --git a/include/asm-sparc/param.h b/include/asm-sparc/param.h index beaf02d364f..86ba59af9d2 100644 --- a/include/asm-sparc/param.h +++ b/include/asm-sparc/param.h @@ -3,7 +3,7 @@ #define _ASMSPARC_PARAM_H #ifdef __KERNEL__ -# define HZ 100 /* Internal kernel timer frequency */ +# define HZ CONFIG_HZ /* Internal kernel timer frequency */ # define USER_HZ 100 /* .. some user interfaces are in "ticks" */ # define CLOCKS_PER_SEC (USER_HZ) #endif diff --git a/include/asm-v850/anna.h b/include/asm-v850/anna.h index 3be77d5ecfc..cd5eaee103b 100644 --- a/include/asm-v850/anna.h +++ b/include/asm-v850/anna.h @@ -134,10 +134,4 @@ extern void anna_uart_pre_configure (unsigned chan, #define V850E_TIMER_D_TMCD_CS_MIN 1 /* min 2^1 divider */ -/* For */ -#ifndef HZ -#define HZ 100 -#endif - - #endif /* __V850_ANNA_H__ */ diff --git a/include/asm-v850/as85ep1.h b/include/asm-v850/as85ep1.h index 659bc910ffd..5a5ca9073d0 100644 --- a/include/asm-v850/as85ep1.h +++ b/include/asm-v850/as85ep1.h @@ -149,10 +149,4 @@ extern void as85ep1_uart_pre_configure (unsigned chan, #define V850E_TIMER_D_TMCD_CS_MIN 2 /* min 2^2 divider */ -/* For */ -#ifndef HZ -#define HZ 100 -#endif - - #endif /* __V850_AS85EP1_H__ */ diff --git a/include/asm-v850/fpga85e2c.h b/include/asm-v850/fpga85e2c.h index d32f04504b1..23aae666c71 100644 --- a/include/asm-v850/fpga85e2c.h +++ b/include/asm-v850/fpga85e2c.h @@ -79,10 +79,4 @@ extern char _r0_ram; #endif -/* For */ -#ifndef HZ -#define HZ 122 /* actually, 8.192ms ticks =~ 122.07 */ -#endif - - #endif /* __V850_FPGA85E2C_H__ */ diff --git a/include/asm-v850/param.h b/include/asm-v850/param.h index 3c65bd57378..28183269029 100644 --- a/include/asm-v850/param.h +++ b/include/asm-v850/param.h @@ -23,8 +23,7 @@ #define MAXHOSTNAMELEN 64 /* max length of hostname */ #ifdef __KERNEL__ -#include /* For HZ */ - +# define HZ CONFIG_HZ # define USER_HZ 100 # define CLOCKS_PER_SEC USER_HZ #endif diff --git a/include/asm-v850/rte_cb.h b/include/asm-v850/rte_cb.h index e85d261b79b..db9879f00aa 100644 --- a/include/asm-v850/rte_cb.h +++ b/include/asm-v850/rte_cb.h @@ -69,12 +69,6 @@ #endif /* CONFIG_RTE_MB_A_PCI */ -/* For */ -#ifndef HZ -#define HZ 100 -#endif - - #ifndef __ASSEMBLY__ extern void rte_cb_early_init (void); extern void rte_cb_init_irqs (void); diff --git a/include/asm-v850/sim.h b/include/asm-v850/sim.h index 10236abbe9b..026932d476c 100644 --- a/include/asm-v850/sim.h +++ b/include/asm-v850/sim.h @@ -40,11 +40,6 @@ #define R0_RAM_ADDR 0xFFFFF000 -/* For */ -#ifndef HZ -#define HZ 24 /* Minimum supported frequency. */ -#endif - /* For */ #define NUM_CPU_IRQS 6 diff --git a/include/asm-v850/sim85e2.h b/include/asm-v850/sim85e2.h index 17dd4fa318e..8b4d6974066 100644 --- a/include/asm-v850/sim85e2.h +++ b/include/asm-v850/sim85e2.h @@ -66,10 +66,4 @@ #define R0_RAM_ADDR 0xFFFFE000 -/* For */ -#ifndef HZ -#define HZ 24 /* Minimum supported frequency. */ -#endif - - #endif /* __V850_SIM85E2_H__ */ diff --git a/include/asm-xtensa/param.h b/include/asm-xtensa/param.h index ce3a336cad0..82ad34d92d3 100644 --- a/include/asm-xtensa/param.h +++ b/include/asm-xtensa/param.h @@ -12,7 +12,7 @@ #define _XTENSA_PARAM_H #ifdef __KERNEL__ -# define HZ 100 /* internal timer frequency */ +# define HZ CONFIG_HZ /* internal timer frequency */ # define USER_HZ 100 /* for user interfaces in "ticks" */ # define CLOCKS_PER_SEC (USER_HZ) /* frequnzy at which times() counts */ #endif diff --git a/kernel/Makefile b/kernel/Makefile index 60cd39c84e6..6c584c55a6e 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -91,3 +91,11 @@ quiet_cmd_ikconfiggz = IKCFG $@ targets += config_data.h $(obj)/config_data.h: $(obj)/config_data.gz FORCE $(call if_changed,ikconfiggz) + +$(obj)/time.o: $(obj)/timeconst.h + +quiet_cmd_timeconst = TIMEC $@ + cmd_timeconst = $(PERL) $< $(CONFIG_HZ) > $@ +targets += timeconst.h +$(obj)/timeconst.h: $(src)/timeconst.pl FORCE + $(call if_changed,timeconst) diff --git a/kernel/time.c b/kernel/time.c index 3b705ecc3fb..a5ec013b6c8 100644 --- a/kernel/time.c +++ b/kernel/time.c @@ -39,6 +39,8 @@ #include #include +#include "timeconst.h" + /* * The timezone where the local system is located. Used as a default by some * programs who obtain this value by using gettimeofday. @@ -93,7 +95,8 @@ asmlinkage long sys_stime(time_t __user *tptr) #endif /* __ARCH_WANT_SYS_TIME */ -asmlinkage long sys_gettimeofday(struct timeval __user *tv, struct timezone __user *tz) +asmlinkage long sys_gettimeofday(struct timeval __user *tv, + struct timezone __user *tz) { if (likely(tv != NULL)) { struct timeval ktv; @@ -118,7 +121,7 @@ asmlinkage long sys_gettimeofday(struct timeval __user *tv, struct timezone __us * hard to make the program warp the clock precisely n hours) or * compile in the timezone information into the kernel. Bad, bad.... * - * - TYT, 1992-01-01 + * - TYT, 1992-01-01 * * The best thing to do is to keep the CMOS clock in universal time (UTC) * as real UNIX machines always do it. This avoids all headaches about @@ -240,7 +243,11 @@ unsigned int inline jiffies_to_msecs(const unsigned long j) #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC) return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC); #else - return (j * MSEC_PER_SEC) / HZ; +# if BITS_PER_LONG == 32 + return ((u64)HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32; +# else + return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN; +# endif #endif } EXPORT_SYMBOL(jiffies_to_msecs); @@ -252,7 +259,11 @@ unsigned int inline jiffies_to_usecs(const unsigned long j) #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) return (j + (HZ / USEC_PER_SEC) - 1)/(HZ / USEC_PER_SEC); #else - return (j * USEC_PER_SEC) / HZ; +# if BITS_PER_LONG == 32 + return ((u64)HZ_TO_USEC_MUL32 * j) >> HZ_TO_USEC_SHR32; +# else + return (j * HZ_TO_USEC_NUM) / HZ_TO_USEC_DEN; +# endif #endif } EXPORT_SYMBOL(jiffies_to_usecs); @@ -352,7 +363,7 @@ EXPORT_SYMBOL(mktime); * normalize to the timespec storage format * * Note: The tv_nsec part is always in the range of - * 0 <= tv_nsec < NSEC_PER_SEC + * 0 <= tv_nsec < NSEC_PER_SEC * For negative values only the tv_sec field is negative ! */ void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec) @@ -453,12 +464,13 @@ unsigned long msecs_to_jiffies(const unsigned int m) /* * Generic case - multiply, round and divide. But first * check that if we are doing a net multiplication, that - * we wouldnt overflow: + * we wouldn't overflow: */ if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) return MAX_JIFFY_OFFSET; - return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC; + return ((u64)MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32) + >> MSEC_TO_HZ_SHR32; #endif } EXPORT_SYMBOL(msecs_to_jiffies); @@ -472,7 +484,8 @@ unsigned long usecs_to_jiffies(const unsigned int u) #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC) return u * (HZ / USEC_PER_SEC); #else - return (u * HZ + USEC_PER_SEC - 1) / USEC_PER_SEC; + return ((u64)USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32) + >> USEC_TO_HZ_SHR32; #endif } EXPORT_SYMBOL(usecs_to_jiffies); diff --git a/kernel/timeconst.pl b/kernel/timeconst.pl new file mode 100644 index 00000000000..62b1287932e --- /dev/null +++ b/kernel/timeconst.pl @@ -0,0 +1,402 @@ +#!/usr/bin/perl +# ----------------------------------------------------------------------- +# +# Copyright 2007 rPath, Inc. - All Rights Reserved +# +# This file is part of the Linux kernel, and is made available under +# the terms of the GNU General Public License version 2 or (at your +# option) any later version; incorporated herein by reference. +# +# ----------------------------------------------------------------------- +# + +# +# Usage: timeconst.pl HZ > timeconst.h +# + +# Precomputed values for systems without Math::BigInt +# Generated by: +# timeconst.pl --can 24 32 48 64 100 122 128 200 250 256 300 512 1000 1024 1200 +%canned_values = ( + 24 => [ + '0xa6aaaaab','0x2aaaaaa',26, + '0xa6aaaaaaaaaaaaab','0x2aaaaaaaaaaaaaa',58, + 125,3, + '0xc49ba5e4','0x1fbe76c8b4',37, + '0xc49ba5e353f7ceda','0x1fbe76c8b439581062',69, + 3,125, + '0xa2c2aaab','0xaaaa',16, + '0xa2c2aaaaaaaaaaab','0xaaaaaaaaaaaa',48, + 125000,3, + '0xc9539b89','0x7fffbce4217d',47, + '0xc9539b8887229e91','0x7fffbce4217d2849cb25',79, + 3,125000, + ], 32 => [ + '0xfa000000','0x6000000',27, + '0xfa00000000000000','0x600000000000000',59, + 125,4, + '0x83126e98','0xfdf3b645a',36, + '0x83126e978d4fdf3c','0xfdf3b645a1cac0831',68, + 4,125, + '0xf4240000','0x0',17, + '0xf424000000000000','0x0',49, + 31250,1, + '0x8637bd06','0x3fff79c842fa',46, + '0x8637bd05af6c69b6','0x3fff79c842fa5093964a',78, + 1,31250, + ], 48 => [ + '0xa6aaaaab','0x6aaaaaa',27, + '0xa6aaaaaaaaaaaaab','0x6aaaaaaaaaaaaaa',59, + 125,6, + '0xc49ba5e4','0xfdf3b645a',36, + '0xc49ba5e353f7ceda','0xfdf3b645a1cac0831',68, + 6,125, + '0xa2c2aaab','0x15555',17, + '0xa2c2aaaaaaaaaaab','0x1555555555555',49, + 62500,3, + '0xc9539b89','0x3fffbce4217d',46, + '0xc9539b8887229e91','0x3fffbce4217d2849cb25',78, + 3,62500, + ], 64 => [ + '0xfa000000','0xe000000',28, + '0xfa00000000000000','0xe00000000000000',60, + 125,8, + '0x83126e98','0x7ef9db22d',35, + '0x83126e978d4fdf3c','0x7ef9db22d0e560418',67, + 8,125, + '0xf4240000','0x0',18, + '0xf424000000000000','0x0',50, + 15625,1, + '0x8637bd06','0x1fff79c842fa',45, + '0x8637bd05af6c69b6','0x1fff79c842fa5093964a',77, + 1,15625, + ], 100 => [ + '0xa0000000','0x0',28, + '0xa000000000000000','0x0',60, + 10,1, + '0xcccccccd','0x733333333',35, + '0xcccccccccccccccd','0x73333333333333333',67, + 1,10, + '0x9c400000','0x0',18, + '0x9c40000000000000','0x0',50, + 10000,1, + '0xd1b71759','0x1fff2e48e8a7',45, + '0xd1b71758e219652c','0x1fff2e48e8a71de69ad4',77, + 1,10000, + ], 122 => [ + '0x8325c53f','0xfbcda3a',28, + '0x8325c53ef368eb05','0xfbcda3ac10c9714',60, + 500,61, + '0xf9db22d1','0x7fbe76c8b',35, + '0xf9db22d0e560418a','0x7fbe76c8b43958106',67, + 61,500, + '0x8012e2a0','0x3ef36',18, + '0x8012e29f79b47583','0x3ef368eb04325',50, + 500000,61, + '0xffda4053','0x1ffffbce4217',45, + '0xffda4052d666a983','0x1ffffbce4217d2849cb2',77, + 61,500000, + ], 128 => [ + '0xfa000000','0x1e000000',29, + '0xfa00000000000000','0x1e00000000000000',61, + 125,16, + '0x83126e98','0x3f7ced916',34, + '0x83126e978d4fdf3c','0x3f7ced916872b020c',66, + 16,125, + '0xf4240000','0x40000',19, + '0xf424000000000000','0x4000000000000',51, + 15625,2, + '0x8637bd06','0xfffbce4217d',44, + '0x8637bd05af6c69b6','0xfffbce4217d2849cb25',76, + 2,15625, + ], 200 => [ + '0xa0000000','0x0',29, + '0xa000000000000000','0x0',61, + 5,1, + '0xcccccccd','0x333333333',34, + '0xcccccccccccccccd','0x33333333333333333',66, + 1,5, + '0x9c400000','0x0',19, + '0x9c40000000000000','0x0',51, + 5000,1, + '0xd1b71759','0xfff2e48e8a7',44, + '0xd1b71758e219652c','0xfff2e48e8a71de69ad4',76, + 1,5000, + ], 250 => [ + '0x80000000','0x0',29, + '0x8000000000000000','0x0',61, + 4,1, + '0x80000000','0x180000000',33, + '0x8000000000000000','0x18000000000000000',65, + 1,4, + '0xfa000000','0x0',20, + '0xfa00000000000000','0x0',52, + 4000,1, + '0x83126e98','0x7ff7ced9168',43, + '0x83126e978d4fdf3c','0x7ff7ced916872b020c4',75, + 1,4000, + ], 256 => [ + '0xfa000000','0x3e000000',30, + '0xfa00000000000000','0x3e00000000000000',62, + 125,32, + '0x83126e98','0x1fbe76c8b',33, + '0x83126e978d4fdf3c','0x1fbe76c8b43958106',65, + 32,125, + '0xf4240000','0xc0000',20, + '0xf424000000000000','0xc000000000000',52, + 15625,4, + '0x8637bd06','0x7ffde7210be',43, + '0x8637bd05af6c69b6','0x7ffde7210be9424e592',75, + 4,15625, + ], 300 => [ + '0xd5555556','0x2aaaaaaa',30, + '0xd555555555555556','0x2aaaaaaaaaaaaaaa',62, + 10,3, + '0x9999999a','0x1cccccccc',33, + '0x999999999999999a','0x1cccccccccccccccc',65, + 3,10, + '0xd0555556','0xaaaaa',20, + '0xd055555555555556','0xaaaaaaaaaaaaa',52, + 10000,3, + '0x9d495183','0x7ffcb923a29',43, + '0x9d495182a9930be1','0x7ffcb923a29c779a6b5',75, + 3,10000, + ], 512 => [ + '0xfa000000','0x7e000000',31, + '0xfa00000000000000','0x7e00000000000000',63, + 125,64, + '0x83126e98','0xfdf3b645',32, + '0x83126e978d4fdf3c','0xfdf3b645a1cac083',64, + 64,125, + '0xf4240000','0x1c0000',21, + '0xf424000000000000','0x1c000000000000',53, + 15625,8, + '0x8637bd06','0x3ffef39085f',42, + '0x8637bd05af6c69b6','0x3ffef39085f4a1272c9',74, + 8,15625, + ], 1000 => [ + '0x80000000','0x0',31, + '0x8000000000000000','0x0',63, + 1,1, + '0x80000000','0x0',31, + '0x8000000000000000','0x0',63, + 1,1, + '0xfa000000','0x0',22, + '0xfa00000000000000','0x0',54, + 1000,1, + '0x83126e98','0x1ff7ced9168',41, + '0x83126e978d4fdf3c','0x1ff7ced916872b020c4',73, + 1,1000, + ], 1024 => [ + '0xfa000000','0xfe000000',32, + '0xfa00000000000000','0xfe00000000000000',64, + 125,128, + '0x83126e98','0x7ef9db22',31, + '0x83126e978d4fdf3c','0x7ef9db22d0e56041',63, + 128,125, + '0xf4240000','0x3c0000',22, + '0xf424000000000000','0x3c000000000000',54, + 15625,16, + '0x8637bd06','0x1fff79c842f',41, + '0x8637bd05af6c69b6','0x1fff79c842fa5093964',73, + 16,15625, + ], 1200 => [ + '0xd5555556','0xd5555555',32, + '0xd555555555555556','0xd555555555555555',64, + 5,6, + '0x9999999a','0x66666666',31, + '0x999999999999999a','0x6666666666666666',63, + 6,5, + '0xd0555556','0x2aaaaa',22, + '0xd055555555555556','0x2aaaaaaaaaaaaa',54, + 2500,3, + '0x9d495183','0x1ffcb923a29',41, + '0x9d495182a9930be1','0x1ffcb923a29c779a6b5',73, + 3,2500, + ] +); + +$has_bigint = eval 'use Math::BigInt qw(bgcd); 1;'; + +sub bint($) +{ + my($x) = @_; + return Math::BigInt->new($x); +} + +# +# Constants for division by reciprocal multiplication. +# (bits, numerator, denominator) +# +sub fmul($$$) +{ + my ($b,$n,$d) = @_; + + $n = bint($n); + $d = bint($d); + + return scalar (($n << $b)+$d-bint(1))/$d; +} + +sub fadj($$$) +{ + my($b,$n,$d) = @_; + + $n = bint($n); + $d = bint($d); + + $d = $d/bgcd($n, $d); + return scalar (($d-bint(1)) << $b)/$d; +} + +sub fmuls($$$) { + my($b,$n,$d) = @_; + my($s,$m); + my($thres) = bint(1) << ($b-1); + + $n = bint($n); + $d = bint($d); + + for ($s = 0; 1; $s++) { + $m = fmul($s,$n,$d); + return $s if ($m >= $thres); + } + return 0; +} + +# Provides mul, adj, and shr factors for a specific +# (bit, time, hz) combination +sub muladj($$$) { + my($b, $t, $hz) = @_; + my $s = fmuls($b, $t, $hz); + my $m = fmul($s, $t, $hz); + my $a = fadj($s, $t, $hz); + return ($m->as_hex(), $a->as_hex(), $s); +} + +# Provides numerator, denominator values +sub numden($$) { + my($n, $d) = @_; + my $g = bgcd($n, $d); + return ($n/$g, $d/$g); +} + +# All values for a specific (time, hz) combo +sub conversions($$) { + my ($t, $hz) = @_; + my @val = (); + + # HZ_TO_xx + push(@val, muladj(32, $t, $hz)); + push(@val, muladj(64, $t, $hz)); + push(@val, numden($t, $hz)); + + # xx_TO_HZ + push(@val, muladj(32, $hz, $t)); + push(@val, muladj(64, $hz, $t)); + push(@val, numden($hz, $t)); + + return @val; +} + +sub compute_values($) { + my($hz) = @_; + my @val = (); + my $s, $m, $a, $g; + + if (!$has_bigint) { + die "$0: HZ == $hz not canned and ". + "Math::BigInt not available\n"; + } + + # MSEC conversions + push(@val, conversions(1000, $hz)); + + # USEC conversions + push(@val, conversions(1000000, $hz)); + + return @val; +} + +sub output($@) +{ + my($hz, @val) = @_; + my $pfx, $bit, $suf, $s, $m, $a; + + print "/* Automatically generated by kernel/timeconst.pl */\n"; + print "/* Conversion constants for HZ == $hz */\n"; + print "\n"; + print "#ifndef KERNEL_TIMECONST_H\n"; + print "#define KERNEL_TIMECONST_H\n"; + print "\n"; + + print "#include \n"; + + print "\n"; + print "#if HZ != $hz\n"; + print "#error \"kernel/timeconst.h has the wrong HZ value!\"\n"; + print "#endif\n"; + print "\n"; + + foreach $pfx ('HZ_TO_MSEC','MSEC_TO_HZ', + 'USEC_TO_HZ','HZ_TO_USEC') { + foreach $bit (32, 64) { + foreach $suf ('MUL', 'ADJ', 'SHR') { + printf "#define %-23s %s\n", + "${pfx}_$suf$bit", shift(@val); + } + } + foreach $suf ('NUM', 'DEN') { + printf "#define %-23s %s\n", + "${pfx}_$suf", shift(@val); + } + } + + print "\n"; + print "#endif /* KERNEL_TIMECONST_H */\n"; +} + +($hz) = @ARGV; + +# Use this to generate the %canned_values structure +if ($hz eq '--can') { + shift(@ARGV); + @hzlist = sort {$a <=> $b} (@ARGV); + + print "# Precomputed values for systems without Math::BigInt\n"; + print "# Generated by:\n"; + print "# timeconst.pl --can ", join(' ', @hzlist), "\n"; + print "\%canned_values = (\n"; + my $pf = "\t"; + foreach $hz (@hzlist) { + my @values = compute_values($hz); + print "$pf$hz => [\n"; + while (scalar(@values)) { + my $bit; + foreach $bit (32, 64) { + my $m = shift(@values); + my $a = shift(@values); + my $s = shift(@values); + print "\t\t\'",$m,"\',\'",$a,"\',",$s,",\n"; + } + my $n = shift(@values); + my $d = shift(@values); + print "\t\t",$n,',',$d,",\n"; + } + print "\t]"; + $pf = ', '; + } + print "\n);\n"; +} else { + $hz += 0; # Force to number + if ($hz < 1) { + die "Usage: $0 HZ\n"; + } + + @val = @{$canned_values{$hz}}; + if (!defined(@val)) { + @val = compute_values($hz); + } + output($hz, @val); +} +exit 0; -- cgit v1.2.3-70-g09d2 From 2f569afd9ced9ebec9a6eb3dbf6f83429be0a7b4 Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 8 Feb 2008 04:22:04 -0800 Subject: CONFIG_HIGHPTE vs. sub-page page tables. Background: I've implemented 1K/2K page tables for s390. These sub-page page tables are required to properly support the s390 virtualization instruction with KVM. The SIE instruction requires that the page tables have 256 page table entries (pte) followed by 256 page status table entries (pgste). The pgstes are only required if the process is using the SIE instruction. The pgstes are updated by the hardware and by the hypervisor for a number of reasons, one of them is dirty and reference bit tracking. To avoid wasting memory the standard pte table allocation should return 1K/2K (31/64 bit) and 2K/4K if the process is using SIE. Problem: Page size on s390 is 4K, page table size is 1K or 2K. That means the s390 version for pte_alloc_one cannot return a pointer to a struct page. Trouble is that with the CONFIG_HIGHPTE feature on x86 pte_alloc_one cannot return a pointer to a pte either, since that would require more than 32 bit for the return value of pte_alloc_one (and the pte * would not be accessible since its not kmapped). Solution: The only solution I found to this dilemma is a new typedef: a pgtable_t. For s390 pgtable_t will be a (pte *) - to be introduced with a later patch. For everybody else it will be a (struct page *). The additional problem with the initialization of the ptl lock and the NR_PAGETABLE accounting is solved with a constructor pgtable_page_ctor and a destructor pgtable_page_dtor. The page table allocation and free functions need to call these two whenever a page table page is allocated or freed. pmd_populate will get a pgtable_t instead of a struct page pointer. To get the pgtable_t back from a pmd entry that has been installed with pmd_populate a new function pmd_pgtable is added. It replaces the pmd_page call in free_pte_range and apply_to_pte_range. Signed-off-by: Martin Schwidefsky Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/frv/mm/pgalloc.c | 8 +++++--- arch/powerpc/mm/pgtable_32.c | 14 ++++++++------ arch/ppc/mm/pgtable.c | 9 ++++++--- arch/s390/mm/pgtable.c | 2 ++ arch/sparc/mm/srmmu.c | 10 +++++++--- arch/sparc/mm/sun4c.c | 14 ++++++++++---- arch/um/kernel/mem.c | 4 +++- arch/x86/mm/pgtable_32.c | 5 ++++- include/asm-alpha/page.h | 2 ++ include/asm-alpha/pgalloc.h | 22 ++++++++++++++-------- include/asm-arm/page.h | 2 ++ include/asm-arm/pgalloc.h | 9 ++++++--- include/asm-avr32/page.h | 1 + include/asm-avr32/pgalloc.h | 16 ++++++++++++---- include/asm-cris/page.h | 1 + include/asm-cris/pgalloc.h | 14 ++++++++++---- include/asm-frv/page.h | 1 + include/asm-frv/pgalloc.h | 12 +++++++++--- include/asm-ia64/page.h | 2 ++ include/asm-ia64/pgalloc.h | 20 ++++++++++++++------ include/asm-m32r/page.h | 1 + include/asm-m32r/pgalloc.h | 10 ++++++---- include/asm-m68k/motorola_pgalloc.h | 14 ++++++++------ include/asm-m68k/page.h | 1 + include/asm-m68k/sun3_pgalloc.h | 17 ++++++++++++----- include/asm-mips/page.h | 1 + include/asm-mips/pgalloc.h | 17 ++++++++++++----- include/asm-parisc/page.h | 1 + include/asm-parisc/pgalloc.h | 11 +++++++++-- include/asm-powerpc/page.h | 2 ++ include/asm-powerpc/pgalloc-32.h | 6 ++++-- include/asm-powerpc/pgalloc-64.h | 27 ++++++++++++++++++++------- include/asm-ppc/pgalloc.h | 6 ++++-- include/asm-s390/page.h | 2 ++ include/asm-s390/pgalloc.h | 3 ++- include/asm-s390/tlb.h | 2 +- include/asm-sh/page.h | 2 ++ include/asm-sh/pgalloc.h | 27 ++++++++++++++++++++------- include/asm-sparc/page.h | 2 ++ include/asm-sparc/pgalloc.h | 5 +++-- include/asm-sparc64/page.h | 2 ++ include/asm-sparc64/pgalloc.h | 19 ++++++++++++++----- include/asm-um/page.h | 2 ++ include/asm-um/pgalloc.h | 12 +++++++++--- include/asm-x86/page_32.h | 2 ++ include/asm-x86/page_64.h | 2 ++ include/asm-x86/pgalloc_32.h | 6 ++++-- include/asm-x86/pgalloc_64.h | 22 +++++++++++++++++----- include/asm-xtensa/page.h | 1 + include/asm-xtensa/pgalloc.h | 17 ++++++++++++----- include/linux/mm.h | 14 +++++++++++++- mm/memory.c | 32 +++++++++++++++----------------- mm/vmalloc.c | 2 +- 53 files changed, 326 insertions(+), 132 deletions(-) (limited to 'include/asm-frv') diff --git a/arch/frv/mm/pgalloc.c b/arch/frv/mm/pgalloc.c index 1a2e5c8d03a..66f616fb486 100644 --- a/arch/frv/mm/pgalloc.c +++ b/arch/frv/mm/pgalloc.c @@ -28,7 +28,7 @@ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) return pte; } -struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *page; @@ -37,9 +37,11 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) #else page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0); #endif - if (page) + if (page) { clear_highpage(page); - flush_dcache_page(page); + pgtable_page_ctor(page); + flush_dcache_page(page); + } return page; } diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c index f80f90c4d58..ac3390f8190 100644 --- a/arch/powerpc/mm/pgtable_32.c +++ b/arch/powerpc/mm/pgtable_32.c @@ -107,19 +107,20 @@ __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long add return pte; } -struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *ptepage; #ifdef CONFIG_HIGHPTE - gfp_t flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT; + gfp_t flags = GFP_KERNEL | __GFP_HIGHMEM | __GFP_REPEAT | __GFP_ZERO; #else - gfp_t flags = GFP_KERNEL | __GFP_REPEAT; + gfp_t flags = GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO; #endif ptepage = alloc_pages(flags, 0); - if (ptepage) - clear_highpage(ptepage); + if (!ptepage) + return NULL; + pgtable_page_ctor(ptepage); return ptepage; } @@ -131,11 +132,12 @@ void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -void pte_free(struct mm_struct *mm, struct page *ptepage) +void pte_free(struct mm_struct *mm, pgtable_t ptepage) { #ifdef CONFIG_SMP hash_page_sync(); #endif + pgtable_page_dtor(ptepage); __free_page(ptepage); } diff --git a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c index 409fcaa4994..03a79bff127 100644 --- a/arch/ppc/mm/pgtable.c +++ b/arch/ppc/mm/pgtable.c @@ -95,7 +95,7 @@ __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long add return pte; } -struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *ptepage; @@ -106,8 +106,10 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) #endif ptepage = alloc_pages(flags, 0); - if (ptepage) + if (ptepage) { clear_highpage(ptepage); + pgtable_page_ctor(ptepage); + } return ptepage; } @@ -119,11 +121,12 @@ void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -void pte_free(struct mm_struct *mm, struct page *ptepage) +void pte_free(struct mm_struct *mm, pgtable_t ptepage) { #ifdef CONFIG_SMP hash_page_sync(); #endif + pgtable_page_dtor(ptepage); __free_page(ptepage); } diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index e60e0ae1340..019f518cd5a 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -78,6 +78,7 @@ unsigned long *page_table_alloc(int noexec) clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE); page->index = (addr_t) table; } + pgtable_page_ctor(page); table = (unsigned long *) page_to_phys(page); clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE); return table; @@ -87,6 +88,7 @@ void page_table_free(unsigned long *table) { unsigned long *shadow = get_shadow_pte(table); + pgtable_page_dtor(virt_to_page(table)); if (shadow) free_page((unsigned long) shadow); free_page((unsigned long) table); diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index dc98e3844a0..23d3291a3e8 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -489,14 +489,17 @@ srmmu_pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) return (pte_t *)srmmu_get_nocache(PTE_SIZE, PTE_SIZE); } -static struct page * +static pgtable_t srmmu_pte_alloc_one(struct mm_struct *mm, unsigned long address) { unsigned long pte; + struct page *page; if ((pte = (unsigned long)srmmu_pte_alloc_one_kernel(mm, address)) == 0) return NULL; - return pfn_to_page( __nocache_pa(pte) >> PAGE_SHIFT ); + page = pfn_to_page( __nocache_pa(pte) >> PAGE_SHIFT ); + pgtable_page_ctor(page); + return page; } static void srmmu_free_pte_fast(pte_t *pte) @@ -504,10 +507,11 @@ static void srmmu_free_pte_fast(pte_t *pte) srmmu_free_nocache((unsigned long)pte, PTE_SIZE); } -static void srmmu_pte_free(struct page *pte) +static void srmmu_pte_free(pgtable_t pte) { unsigned long p; + pgtable_page_dtor(pte); p = (unsigned long)page_address(pte); /* Cached address (for test) */ if (p == 0) BUG(); diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c index 0729305f2f5..c0442e8c4b1 100644 --- a/arch/sparc/mm/sun4c.c +++ b/arch/sparc/mm/sun4c.c @@ -1947,12 +1947,17 @@ static pte_t *sun4c_pte_alloc_one_kernel(struct mm_struct *mm, unsigned long add return pte; } -static struct page *sun4c_pte_alloc_one(struct mm_struct *mm, unsigned long address) +static pgtable_t sun4c_pte_alloc_one(struct mm_struct *mm, unsigned long address) { - pte_t *pte = sun4c_pte_alloc_one_kernel(mm, address); + pte_t *pte; + struct page *page; + + pte = sun4c_pte_alloc_one_kernel(mm, address); if (pte == NULL) return NULL; - return virt_to_page(pte); + page = virt_to_page(pte); + pgtable_page_ctor(page); + return page; } static inline void sun4c_free_pte_fast(pte_t *pte) @@ -1962,8 +1967,9 @@ static inline void sun4c_free_pte_fast(pte_t *pte) pgtable_cache_size++; } -static void sun4c_pte_free(struct page *pte) +static void sun4c_pte_free(pgtable_t pte) { + pgtable_page_dtor(pte); sun4c_free_pte_fast(page_address(pte)); } diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index d872fdce1d7..2627ce82e91 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -354,11 +354,13 @@ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) return pte; } -struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *pte; pte = alloc_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); + if (pte) + pgtable_page_ctor(pte); return pte; } diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c index 6c1914622a8..73aba712520 100644 --- a/arch/x86/mm/pgtable_32.c +++ b/arch/x86/mm/pgtable_32.c @@ -183,7 +183,7 @@ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) return (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); } -struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *pte; @@ -192,6 +192,8 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) #else pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0); #endif + if (pte) + pgtable_page_ctor(pte); return pte; } @@ -365,6 +367,7 @@ void check_pgt_cache(void) void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte) { + pgtable_page_dtor(pte); paravirt_release_pt(page_to_pfn(pte)); tlb_remove_page(tlb, pte); } diff --git a/include/asm-alpha/page.h b/include/asm-alpha/page.h index 05f09f997d8..22ff9762d17 100644 --- a/include/asm-alpha/page.h +++ b/include/asm-alpha/page.h @@ -62,6 +62,8 @@ typedef unsigned long pgprot_t; #endif /* STRICT_MM_TYPECHECKS */ +typedef struct page *pgtable_t; + #ifdef USE_48_BIT_KSEG #define PAGE_OFFSET 0xffff800000000000UL #else diff --git a/include/asm-alpha/pgalloc.h b/include/asm-alpha/pgalloc.h index fdbedacc737..fd090155dcc 100644 --- a/include/asm-alpha/pgalloc.h +++ b/include/asm-alpha/pgalloc.h @@ -11,10 +11,11 @@ */ static inline void -pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte) +pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t pte) { pmd_set(pmd, (pte_t *)(page_to_pa(pte) + PAGE_OFFSET)); } +#define pmd_pgtable(pmd) pmd_page(pmd) static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) @@ -57,18 +58,23 @@ pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -static inline struct page * -pte_alloc_one(struct mm_struct *mm, unsigned long addr) +static inline pgtable_t +pte_alloc_one(struct mm_struct *mm, unsigned long address) { - pte_t *pte = pte_alloc_one_kernel(mm, addr); - if (pte) - return virt_to_page(pte); - return NULL; + pte_t *pte = pte_alloc_one_kernel(mm, address); + struct page *page; + + if (!pte) + return NULL; + page = virt_to_page(pte); + pgtable_page_ctor(page); + return page; } static inline void -pte_free(struct mm_struct *mm, struct page *page) +pte_free(struct mm_struct *mm, pgtable_t page) { + pgtable_page_dtor(page); __free_page(page); } diff --git a/include/asm-arm/page.h b/include/asm-arm/page.h index 31ff12f4ffb..c86f68ee651 100644 --- a/include/asm-arm/page.h +++ b/include/asm-arm/page.h @@ -171,6 +171,8 @@ typedef unsigned long pgprot_t; #endif /* STRICT_MM_TYPECHECKS */ +typedef struct page *pgtable_t; + #endif /* CONFIG_MMU */ #include diff --git a/include/asm-arm/pgalloc.h b/include/asm-arm/pgalloc.h index fb6c6e3222b..163b0305dd7 100644 --- a/include/asm-arm/pgalloc.h +++ b/include/asm-arm/pgalloc.h @@ -66,7 +66,7 @@ pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr) return pte; } -static inline struct page * +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr) { struct page *pte; @@ -75,6 +75,7 @@ pte_alloc_one(struct mm_struct *mm, unsigned long addr) if (pte) { void *page = page_address(pte); clean_dcache_area(page, sizeof(pte_t) * PTRS_PER_PTE); + pgtable_page_ctor(pte); } return pte; @@ -91,8 +92,9 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) } } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } @@ -123,10 +125,11 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep) } static inline void -pmd_populate(struct mm_struct *mm, pmd_t *pmdp, struct page *ptep) +pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep) { __pmd_populate(pmdp, page_to_pfn(ptep) << PAGE_SHIFT | _PAGE_USER_TABLE); } +#define pmd_pgtable(pmd) pmd_page(pmd) #endif /* CONFIG_MMU */ diff --git a/include/asm-avr32/page.h b/include/asm-avr32/page.h index ee23499cec3..5582968feee 100644 --- a/include/asm-avr32/page.h +++ b/include/asm-avr32/page.h @@ -34,6 +34,7 @@ extern void copy_page(void *to, void *from); typedef struct { unsigned long pte; } pte_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 pgd_val(x) ((x).pgd) diff --git a/include/asm-avr32/pgalloc.h b/include/asm-avr32/pgalloc.h index b77e364b4c4..51fc1f6e4b1 100644 --- a/include/asm-avr32/pgalloc.h +++ b/include/asm-avr32/pgalloc.h @@ -17,10 +17,11 @@ set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd, - struct page *pte) + pgtable_t pte) { set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte))); } +#define pmd_pgtable(pmd) pmd_page(pmd) /* * Allocate and free page tables @@ -51,7 +52,9 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm, struct page *pte; pte = alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); - + if (!pte) + return NULL; + pgtable_page_ctor(pte); return pte; } @@ -60,12 +63,17 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } -#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb), pte); \ +} while (0) #define check_pgt_cache() do { } while(0) diff --git a/include/asm-cris/page.h b/include/asm-cris/page.h index 3b0156c4631..c45bb1ef397 100644 --- a/include/asm-cris/page.h +++ b/include/asm-cris/page.h @@ -26,6 +26,7 @@ typedef struct { unsigned long pte; } pte_t; typedef struct { unsigned long pgd; } pgd_t; typedef struct { unsigned long pgprot; } pgprot_t; +typedef struct page *pgtable_t; #endif #define pte_val(x) ((x).pte) diff --git a/include/asm-cris/pgalloc.h b/include/asm-cris/pgalloc.h index 8ddd66f8177..a1ba761d057 100644 --- a/include/asm-cris/pgalloc.h +++ b/include/asm-cris/pgalloc.h @@ -6,6 +6,7 @@ #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, pte) #define pmd_populate(mm, pmd, pte) pmd_set(pmd, page_address(pte)) +#define pmd_pgtable(pmd) pmd_page(pmd) /* * Allocate and free page tables. @@ -27,10 +28,11 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long ad return pte; } -static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *pte; pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0); + pgtable_page_ctor(pte); return pte; } @@ -39,13 +41,17 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } - -#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb), pte); \ +} while (0) #define check_pgt_cache() do { } while (0) diff --git a/include/asm-frv/page.h b/include/asm-frv/page.h index cacc045700d..c2c1e89e747 100644 --- a/include/asm-frv/page.h +++ b/include/asm-frv/page.h @@ -25,6 +25,7 @@ typedef struct { unsigned long ste[64];} pmd_t; typedef struct { pmd_t pue[1]; } pud_t; typedef struct { pud_t pge[1]; } 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).ste[0]) diff --git a/include/asm-frv/pgalloc.h b/include/asm-frv/pgalloc.h index e89620ef08c..971e6addb00 100644 --- a/include/asm-frv/pgalloc.h +++ b/include/asm-frv/pgalloc.h @@ -25,6 +25,7 @@ do { \ __set_pmd((PMD), page_to_pfn(PAGE) << PAGE_SHIFT | _PAGE_TABLE); \ } while(0) +#define pmd_pgtable(pmd) pmd_page(pmd) /* * Allocate and free page tables. @@ -35,19 +36,24 @@ extern void pgd_free(struct mm_struct *mm, pgd_t *); extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); -extern struct page *pte_alloc_one(struct mm_struct *, unsigned long); +extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) { free_page((unsigned long)pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } -#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb),(pte)); \ +} while (0) /* * allocating and freeing a pmd is trivial: the 1-entry pmd is diff --git a/include/asm-ia64/page.h b/include/asm-ia64/page.h index 8a8aa3fd7cd..4999a6c6377 100644 --- a/include/asm-ia64/page.h +++ b/include/asm-ia64/page.h @@ -185,6 +185,7 @@ get_order (unsigned long size) #endif 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) @@ -206,6 +207,7 @@ get_order (unsigned long size) typedef unsigned long pmd_t; typedef unsigned long pgd_t; typedef unsigned long pgprot_t; + typedef struct page *pgtable_t; # endif # define pte_val(x) (x) diff --git a/include/asm-ia64/pgalloc.h b/include/asm-ia64/pgalloc.h index 556d988123a..b9ac1a6fc21 100644 --- a/include/asm-ia64/pgalloc.h +++ b/include/asm-ia64/pgalloc.h @@ -70,10 +70,11 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) #define __pmd_free_tlb(tlb, pmd) pmd_free((tlb)->mm, pmd) static inline void -pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, struct page *pte) +pmd_populate(struct mm_struct *mm, pmd_t * pmd_entry, pgtable_t pte) { pmd_val(*pmd_entry) = page_to_phys(pte); } +#define pmd_pgtable(pmd) pmd_page(pmd) static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte) @@ -81,11 +82,17 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte) pmd_val(*pmd_entry) = __pa(pte); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, - unsigned long addr) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr) { - void *pg = quicklist_alloc(0, GFP_KERNEL, NULL); - return pg ? virt_to_page(pg) : NULL; + struct page *page; + void *pg; + + pg = quicklist_alloc(0, GFP_KERNEL, NULL); + if (!pg) + return NULL; + page = virt_to_page(pg); + pgtable_page_ctor(page); + return page; } static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, @@ -94,8 +101,9 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, return quicklist_alloc(0, GFP_KERNEL, NULL); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); quicklist_free_page(0, NULL, pte); } diff --git a/include/asm-m32r/page.h b/include/asm-m32r/page.h index 05d43bbbf94..8a677f3fca6 100644 --- a/include/asm-m32r/page.h +++ b/include/asm-m32r/page.h @@ -28,6 +28,7 @@ typedef struct { unsigned long pgd; } pgd_t; #define PTE_MASK PAGE_MASK typedef struct { unsigned long pgprot; } pgprot_t; +typedef struct page *pgtable_t; #define pmd_val(x) ((x).pmd) #define pgd_val(x) ((x).pgd) diff --git a/include/asm-m32r/pgalloc.h b/include/asm-m32r/pgalloc.h index e5921adfad1..f11a2b909cd 100644 --- a/include/asm-m32r/pgalloc.h +++ b/include/asm-m32r/pgalloc.h @@ -9,10 +9,11 @@ set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) static __inline__ void pmd_populate(struct mm_struct *mm, pmd_t *pmd, - struct page *pte) + pgtable_t pte) { set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte))); } +#define pmd_pgtable(pmd) pmd_page(pmd) /* * Allocate and free page tables. @@ -37,12 +38,12 @@ static __inline__ pte_t *pte_alloc_one_kernel(struct mm_struct *mm, return pte; } -static __inline__ struct page *pte_alloc_one(struct mm_struct *mm, +static __inline__ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *pte = alloc_page(GFP_KERNEL|__GFP_ZERO); - + pgtable_page_ctor(pte); return pte; } @@ -51,8 +52,9 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } diff --git a/include/asm-m68k/motorola_pgalloc.h b/include/asm-m68k/motorola_pgalloc.h index 500ec9b8b18..d08bf6261df 100644 --- a/include/asm-m68k/motorola_pgalloc.h +++ b/include/asm-m68k/motorola_pgalloc.h @@ -7,7 +7,6 @@ extern pmd_t *get_pointer_table(void); extern int free_pointer_table(pmd_t *); - static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) { pte_t *pte; @@ -28,7 +27,7 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long) pte); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0); pte_t *pte; @@ -43,19 +42,21 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long add nocache_page(pte); } kunmap(pte); - + pgtable_page_ctor(page); return page; } -static inline void pte_free(struct mm_struct *mm, struct page *page) +static inline void pte_free(struct mm_struct *mm, pgtable_t page) { + pgtable_page_dtor(page); cache_page(kmap(page)); kunmap(page); __free_page(page); } -static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *page) +static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t page) { + pgtable_page_dtor(page); cache_page(kmap(page)); kunmap(page); __free_page(page); @@ -94,10 +95,11 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t * pmd_set(pmd, pte); } -static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page) +static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page) { pmd_set(pmd, page_address(page)); } +#define pmd_pgtable(pmd) pmd_page(pmd) static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd) { diff --git a/include/asm-m68k/page.h b/include/asm-m68k/page.h index 3f29e2a03a4..880c2cbff8a 100644 --- a/include/asm-m68k/page.h +++ b/include/asm-m68k/page.h @@ -91,6 +91,7 @@ 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]) diff --git a/include/asm-m68k/sun3_pgalloc.h b/include/asm-m68k/sun3_pgalloc.h index a5a91e72714..d4c83f14381 100644 --- a/include/asm-m68k/sun3_pgalloc.h +++ b/include/asm-m68k/sun3_pgalloc.h @@ -26,12 +26,17 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long) pte); } -static inline void pte_free(struct mm_struct *mm, struct page *page) +static inline void pte_free(struct mm_struct *mm, pgtable_t page) { + pgtable_page_dtor(page); __free_page(page); } -#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb), pte); \ +} while (0) static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) @@ -45,8 +50,8 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, return (pte_t *) (page); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, - unsigned long address) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, + unsigned long address) { struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT, 0); @@ -54,6 +59,7 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm, return NULL; clear_highpage(page); + pgtable_page_ctor(page); return page; } @@ -63,10 +69,11 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t * pmd_val(*pmd) = __pa((unsigned long)pte); } -static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page) +static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page) { pmd_val(*pmd) = __pa((unsigned long)page_address(page)); } +#define pmd_pgtable(pmd) pmd_page(pmd) /* * allocating and freeing a pmd is trivial: the 1-entry pmd is diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h index 635aa44d229..8735aa0b896 100644 --- a/include/asm-mips/page.h +++ b/include/asm-mips/page.h @@ -90,6 +90,7 @@ typedef struct { unsigned long pte; } pte_t; #define pte_val(x) ((x).pte) #define __pte(x) ((pte_t) { (x) } ) #endif +typedef struct page *pgtable_t; /* * For 3-level pagetables we defines these ourselves, for 2-level the diff --git a/include/asm-mips/pgalloc.h b/include/asm-mips/pgalloc.h index c4efeced839..1275831dda2 100644 --- a/include/asm-mips/pgalloc.h +++ b/include/asm-mips/pgalloc.h @@ -20,10 +20,11 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, } static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, - struct page *pte) + pgtable_t pte) { set_pmd(pmd, __pmd((unsigned long)page_address(pte))); } +#define pmd_pgtable(pmd) pmd_page(pmd) /* * Initialize a new pmd table with invalid pointers. @@ -79,9 +80,10 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm, struct page *pte; pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER); - if (pte) + if (pte) { clear_highpage(pte); - + pgtable_page_ctor(pte); + } return pte; } @@ -90,12 +92,17 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_pages((unsigned long)pte, PTE_ORDER); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_pages(pte, PTE_ORDER); } -#define __pte_free_tlb(tlb, pte) tlb_remove_page((tlb), (pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb), pte); \ +} while (0) #ifdef CONFIG_32BIT diff --git a/include/asm-parisc/page.h b/include/asm-parisc/page.h index b08d9151c71..27d50b85954 100644 --- a/include/asm-parisc/page.h +++ b/include/asm-parisc/page.h @@ -91,6 +91,7 @@ typedef unsigned long pgprot_t; #endif /* STRICT_MM_TYPECHECKS */ +typedef struct page *pgtable_t; typedef struct __physmem_range { unsigned long start_pfn; diff --git a/include/asm-parisc/pgalloc.h b/include/asm-parisc/pgalloc.h index aab66f1bea1..3996dfc30a3 100644 --- a/include/asm-parisc/pgalloc.h +++ b/include/asm-parisc/pgalloc.h @@ -115,11 +115,14 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) #define pmd_populate(mm, pmd, pte_page) \ pmd_populate_kernel(mm, pmd, page_address(pte_page)) +#define pmd_pgtable(pmd) pmd_page(pmd) -static inline struct page * +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { struct page *page = alloc_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO); + if (page) + pgtable_page_ctor(page); return page; } @@ -135,7 +138,11 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -#define pte_free(mm, page) pte_free_kernel(page_address(page)) +static inline void pte_free_kernel(struct mm_struct *mm, struct page *pte) +{ + pgtable_page_dtor(pte); + pte_free_kernel(page_address((pte)); +} #define check_pgt_cache() do { } while (0) diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h index 61e3725bbd3..df47bbb6ea1 100644 --- a/include/asm-powerpc/page.h +++ b/include/asm-powerpc/page.h @@ -190,6 +190,8 @@ extern int page_is_ram(unsigned long pfn); struct vm_area_struct; +typedef struct page *pgtable_t; + #include #endif /* __ASSEMBLY__ */ diff --git a/include/asm-powerpc/pgalloc-32.h b/include/asm-powerpc/pgalloc-32.h index c162a4c37b3..58c07147b3e 100644 --- a/include/asm-powerpc/pgalloc-32.h +++ b/include/asm-powerpc/pgalloc-32.h @@ -22,17 +22,19 @@ extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); (pmd_val(*(pmd)) = __pa(pte) | _PMD_PRESENT) #define pmd_populate(mm, pmd, pte) \ (pmd_val(*(pmd)) = (page_to_pfn(pte) << PAGE_SHIFT) | _PMD_PRESENT) +#define pmd_pgtable(pmd) pmd_page(pmd) #else #define pmd_populate_kernel(mm, pmd, pte) \ (pmd_val(*(pmd)) = (unsigned long)pte | _PMD_PRESENT) #define pmd_populate(mm, pmd, pte) \ (pmd_val(*(pmd)) = (unsigned long)lowmem_page_address(pte) | _PMD_PRESENT) +#define pmd_pgtable(pmd) pmd_page(pmd) #endif extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr); -extern struct page *pte_alloc_one(struct mm_struct *mm, unsigned long addr); +extern pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr); extern void pte_free_kernel(struct mm_struct *mm, pte_t *pte); -extern void pte_free(struct mm_struct *mm, struct page *pte); +extern void pte_free(struct mm_struct *mm, pgtable_t pte); #define __pte_free_tlb(tlb, pte) pte_free((tlb)->mm, (pte)) diff --git a/include/asm-powerpc/pgalloc-64.h b/include/asm-powerpc/pgalloc-64.h index 5afae859393..68980990f62 100644 --- a/include/asm-powerpc/pgalloc-64.h +++ b/include/asm-powerpc/pgalloc-64.h @@ -58,6 +58,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) #define pmd_populate(mm, pmd, pte_page) \ pmd_populate_kernel(mm, pmd, page_address(pte_page)) #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte)) +#define pmd_pgtable(pmd) pmd_page(pmd) #else /* CONFIG_PPC_64K_PAGES */ @@ -72,6 +73,7 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, #define pmd_populate(mm, pmd, pte_page) \ pmd_populate_kernel(mm, pmd, page_address(pte_page)) +#define pmd_pgtable(pmd) pmd_page(pmd) #endif /* CONFIG_PPC_64K_PAGES */ @@ -92,11 +94,18 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, - unsigned long address) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, + unsigned long address) { - pte_t *pte = pte_alloc_one_kernel(mm, address); - return pte ? virt_to_page(pte) : NULL; + struct page *page; + pte_t *pte; + + pte = pte_alloc_one_kernel(mm, address); + if (!pte) + return NULL; + page = virt_to_page(pte); + pgtable_page_ctor(page); + return page; } static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) @@ -104,8 +113,9 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -static inline void pte_free(struct mm_struct *mm, struct page *ptepage) +static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage) { + pgtable_page_dtor(ptepage); __free_page(ptepage); } @@ -136,9 +146,12 @@ static inline void pgtable_free(pgtable_free_t pgf) extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf); -#define __pte_free_tlb(tlb, ptepage) \ +#define __pte_free_tlb(tlb,ptepage) \ +do { \ + pgtable_page_dtor(ptepage); \ pgtable_free_tlb(tlb, pgtable_free_cache(page_address(ptepage), \ - PTE_NONCACHE_NUM, PTE_TABLE_SIZE-1)) + PTE_NONCACHE_NUM, PTE_TABLE_SIZE-1)); \ +} while (0) #define __pmd_free_tlb(tlb, pmd) \ pgtable_free_tlb(tlb, pgtable_free_cache(pmd, \ PMD_CACHE_NUM, PMD_TABLE_SIZE-1)) diff --git a/include/asm-ppc/pgalloc.h b/include/asm-ppc/pgalloc.h index 7c39a95829c..fd4d1d74cfb 100644 --- a/include/asm-ppc/pgalloc.h +++ b/include/asm-ppc/pgalloc.h @@ -23,17 +23,19 @@ extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); (pmd_val(*(pmd)) = __pa(pte) | _PMD_PRESENT) #define pmd_populate(mm, pmd, pte) \ (pmd_val(*(pmd)) = (page_to_pfn(pte) << PAGE_SHIFT) | _PMD_PRESENT) +#define pmd_pgtable(pmd) pmd_page(pmd) #else #define pmd_populate_kernel(mm, pmd, pte) \ (pmd_val(*(pmd)) = (unsigned long)pte | _PMD_PRESENT) #define pmd_populate(mm, pmd, pte) \ (pmd_val(*(pmd)) = (unsigned long)lowmem_page_address(pte) | _PMD_PRESENT) +#define pmd_pgtable(pmd) pmd_page(pmd) #endif extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr); -extern struct page *pte_alloc_one(struct mm_struct *mm, unsigned long addr); +extern pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addr); extern void pte_free_kernel(struct mm_struct *mm, pte_t *pte); -extern void pte_free(struct mm_struct *mm, struct page *pte); +extern void pte_free(struct mm_struct *mm, pgtable_t pte); #define __pte_free_tlb(tlb, pte) pte_free((tlb)->mm, (pte)) diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h index a55f9d979df..7f29a981f48 100644 --- a/include/asm-s390/page.h +++ b/include/asm-s390/page.h @@ -109,6 +109,8 @@ typedef struct { unsigned long pgd; } pgd_t; #endif /* __s390x__ */ +typedef struct page *pgtable_t; + #define __pte(x) ((pte_t) { (x) } ) #define __pmd(x) ((pmd_t) { (x) } ) #define __pgd(x) ((pgd_t) { (x) } ) diff --git a/include/asm-s390/pgalloc.h b/include/asm-s390/pgalloc.h index 6f6619ba898..900d44807e1 100644 --- a/include/asm-s390/pgalloc.h +++ b/include/asm-s390/pgalloc.h @@ -132,7 +132,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) } static inline void -pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page) +pmd_populate(struct mm_struct *mm, pmd_t *pmd, pgtable_t page) { pte_t *pte = (pte_t *)page_to_phys(page); pmd_t *shadow_pmd = get_shadow_table(pmd); @@ -142,6 +142,7 @@ pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *page) if (shadow_pmd && shadow_pte) pmd_populate_kernel(mm, shadow_pmd, shadow_pte); } +#define pmd_pgtable(pmd) pmd_page(pmd) /* * page table entry allocation/free routines. diff --git a/include/asm-s390/tlb.h b/include/asm-s390/tlb.h index 985de2b8827..3c8177fa9e0 100644 --- a/include/asm-s390/tlb.h +++ b/include/asm-s390/tlb.h @@ -95,7 +95,7 @@ static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) * pte_free_tlb frees a pte table and clears the CRSTE for the * page table from the tlb. */ -static inline void pte_free_tlb(struct mmu_gather *tlb, struct page *page) +static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t page) { if (!tlb->fullmm) { tlb->array[tlb->nr_ptes++] = page; diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h index e0fe02950f5..134562dc8c4 100644 --- a/include/asm-sh/page.h +++ b/include/asm-sh/page.h @@ -100,6 +100,8 @@ typedef struct { unsigned long pgd; } pgd_t; #define __pgd(x) ((pgd_t) { (x) } ) #define __pgprot(x) ((pgprot_t) { (x) } ) +typedef struct page *pgtable_t; + #endif /* !__ASSEMBLY__ */ /* diff --git a/include/asm-sh/pgalloc.h b/include/asm-sh/pgalloc.h index 59ca16d77a1..84dd2db7104 100644 --- a/include/asm-sh/pgalloc.h +++ b/include/asm-sh/pgalloc.h @@ -14,10 +14,11 @@ static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, } static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, - struct page *pte) + pgtable_t pte) { set_pmd(pmd, __pmd((unsigned long)page_address(pte))); } +#define pmd_pgtable(pmd) pmd_page(pmd) static inline void pgd_ctor(void *x) { @@ -47,11 +48,18 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, return quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, - unsigned long address) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, + unsigned long address) { - void *pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL); - return pg ? virt_to_page(pg) : NULL; + struct page *page; + void *pg; + + pg = quicklist_alloc(QUICK_PT, GFP_KERNEL | __GFP_REPEAT, NULL); + if (!pg) + return NULL; + page = virt_to_page(pg); + pgtable_page_ctor(page); + return page; } static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) @@ -59,12 +67,17 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) quicklist_free(QUICK_PT, NULL, pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); quicklist_free_page(QUICK_PT, NULL, pte); } -#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb), (pte)); \ +} while (0) /* * allocating and freeing a pmd is trivial: the 1-entry pmd is diff --git a/include/asm-sparc/page.h b/include/asm-sparc/page.h index cbc48c0c4e1..39ccf2da297 100644 --- a/include/asm-sparc/page.h +++ b/include/asm-sparc/page.h @@ -123,6 +123,8 @@ typedef unsigned long iopgprot_t; #endif +typedef struct page *pgtable_t; + extern unsigned long sparc_unmapped_base; BTFIXUPDEF_SETHI(sparc_unmapped_base) diff --git a/include/asm-sparc/pgalloc.h b/include/asm-sparc/pgalloc.h index b5fbdd36447..6292cd00e5a 100644 --- a/include/asm-sparc/pgalloc.h +++ b/include/asm-sparc/pgalloc.h @@ -50,10 +50,11 @@ BTFIXUPDEF_CALL(void, free_pmd_fast, pmd_t *) BTFIXUPDEF_CALL(void, pmd_populate, pmd_t *, struct page *) #define pmd_populate(MM, PMD, PTE) BTFIXUP_CALL(pmd_populate)(PMD, PTE) +#define pmd_pgtable(pmd) pmd_page(pmd) BTFIXUPDEF_CALL(void, pmd_set, pmd_t *, pte_t *) #define pmd_populate_kernel(MM, PMD, PTE) BTFIXUP_CALL(pmd_set)(PMD, PTE) -BTFIXUPDEF_CALL(struct page *, pte_alloc_one, struct mm_struct *, unsigned long) +BTFIXUPDEF_CALL(pgtable_t , pte_alloc_one, struct mm_struct *, unsigned long) #define pte_alloc_one(mm, address) BTFIXUP_CALL(pte_alloc_one)(mm, address) BTFIXUPDEF_CALL(pte_t *, pte_alloc_one_kernel, struct mm_struct *, unsigned long) #define pte_alloc_one_kernel(mm, addr) BTFIXUP_CALL(pte_alloc_one_kernel)(mm, addr) @@ -61,7 +62,7 @@ BTFIXUPDEF_CALL(pte_t *, pte_alloc_one_kernel, struct mm_struct *, unsigned long BTFIXUPDEF_CALL(void, free_pte_fast, pte_t *) #define pte_free_kernel(mm, pte) BTFIXUP_CALL(free_pte_fast)(pte) -BTFIXUPDEF_CALL(void, pte_free, struct page *) +BTFIXUPDEF_CALL(void, pte_free, pgtable_t ) #define pte_free(mm, pte) BTFIXUP_CALL(pte_free)(pte) #define __pte_free_tlb(tlb, pte) pte_free((tlb)->mm, pte) diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h index cdf950e017e..e93a482aa24 100644 --- a/include/asm-sparc64/page.h +++ b/include/asm-sparc64/page.h @@ -104,6 +104,8 @@ typedef unsigned long pgprot_t; #endif /* (STRICT_MM_TYPECHECKS) */ +typedef struct page *pgtable_t; + #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \ (_AC(0x0000000070000000,UL)) : \ (_AC(0xfffff80000000000,UL) + (1UL << 32UL))) diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h index b48f73c2274..3ee2d406373 100644 --- a/include/asm-sparc64/pgalloc.h +++ b/include/asm-sparc64/pgalloc.h @@ -43,11 +43,18 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, return quicklist_alloc(0, GFP_KERNEL, NULL); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, - unsigned long address) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, + unsigned long address) { - void *pg = quicklist_alloc(0, GFP_KERNEL, NULL); - return pg ? virt_to_page(pg) : NULL; + struct page *page; + void *pg; + + pg = quicklist_alloc(0, GFP_KERNEL, NULL); + if (!pg) + return NULL; + page = virt_to_page(pg); + pgtable_page_ctor(page); + return page; } static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) @@ -55,8 +62,9 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) quicklist_free(0, NULL, pte); } -static inline void pte_free(struct mm_struct *mm, struct page *ptepage) +static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage) { + pgtable_page_dtor(ptepage); quicklist_free_page(0, NULL, ptepage); } @@ -64,6 +72,7 @@ static inline void pte_free(struct mm_struct *mm, struct page *ptepage) #define pmd_populate_kernel(MM, PMD, PTE) pmd_set(PMD, PTE) #define pmd_populate(MM,PMD,PTE_PAGE) \ pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE)) +#define pmd_pgtable(pmd) pmd_page(pmd) static inline void check_pgt_cache(void) { diff --git a/include/asm-um/page.h b/include/asm-um/page.h index fe2374d705d..381f96b1c82 100644 --- a/include/asm-um/page.h +++ b/include/asm-um/page.h @@ -79,6 +79,8 @@ typedef unsigned long phys_t; typedef struct { unsigned long pgprot; } pgprot_t; +typedef struct page *pgtable_t; + #define pgd_val(x) ((x).pgd) #define pgprot_val(x) ((x).pgprot) diff --git a/include/asm-um/pgalloc.h b/include/asm-um/pgalloc.h index 4f3e62b0286..9062a6e7224 100644 --- a/include/asm-um/pgalloc.h +++ b/include/asm-um/pgalloc.h @@ -18,6 +18,7 @@ set_pmd(pmd, __pmd(_PAGE_TABLE + \ ((unsigned long long)page_to_pfn(pte) << \ (unsigned long long) PAGE_SHIFT))) +#define pmd_pgtable(pmd) pmd_page(pmd) /* * Allocate and free page tables. @@ -26,19 +27,24 @@ extern pgd_t *pgd_alloc(struct mm_struct *); extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); -extern struct page *pte_alloc_one(struct mm_struct *, unsigned long); +extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) { free_page((unsigned long) pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } -#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor(pte); \ + tlb_remove_page((tlb),(pte)); \ +} while (0) #ifdef CONFIG_3_LEVEL_PGTABLES diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h index a6fd10f230d..ba715d9798b 100644 --- a/include/asm-x86/page_32.h +++ b/include/asm-x86/page_32.h @@ -50,6 +50,8 @@ typedef unsigned long phys_addr_t; typedef union { pteval_t pte, pte_low; } pte_t; typedef pte_t boot_pte_t; +typedef struct page *pgtable_t; + #endif /* __ASSEMBLY__ */ #endif /* CONFIG_X86_PAE */ diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h index dcf0c074607..f7393bc516e 100644 --- a/include/asm-x86/page_64.h +++ b/include/asm-x86/page_64.h @@ -71,6 +71,8 @@ typedef unsigned long pgdval_t; typedef unsigned long pgprotval_t; typedef unsigned long phys_addr_t; +typedef struct page *pgtable_t; + typedef struct { pteval_t pte; } pte_t; #define vmemmap ((struct page *)VMEMMAP_START) diff --git a/include/asm-x86/pgalloc_32.h b/include/asm-x86/pgalloc_32.h index bab12718a91..6bea6e5b5ee 100644 --- a/include/asm-x86/pgalloc_32.h +++ b/include/asm-x86/pgalloc_32.h @@ -31,6 +31,7 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *p paravirt_alloc_pt(mm, pfn); set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE)); } +#define pmd_pgtable(pmd) pmd_page(pmd) /* * Allocate and free page tables. @@ -39,15 +40,16 @@ extern pgd_t *pgd_alloc(struct mm_struct *); extern void pgd_free(struct mm_struct *mm, pgd_t *pgd); extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long); -extern struct page *pte_alloc_one(struct mm_struct *, unsigned long); +extern pgtable_t pte_alloc_one(struct mm_struct *, unsigned long); static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) { free_page((unsigned long)pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } diff --git a/include/asm-x86/pgalloc_64.h b/include/asm-x86/pgalloc_64.h index 4f6220db22b..8d6722320dc 100644 --- a/include/asm-x86/pgalloc_64.h +++ b/include/asm-x86/pgalloc_64.h @@ -12,6 +12,8 @@ #define pgd_populate(mm, pgd, pud) \ set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud))) +#define pmd_pgtable(pmd) pmd_page(pmd) + static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte) { set_pmd(pmd, __pmd(_PAGE_TABLE | (page_to_pfn(pte) << PAGE_SHIFT))); @@ -91,12 +93,17 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long ad return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) +static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address) { - void *p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); + struct page *page; + void *p; + + p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); if (!p) return NULL; - return virt_to_page(p); + page = virt_to_page(p); + pgtable_page_ctor(page); + return page; } /* Should really implement gc for free page table pages. This could be @@ -108,12 +115,17 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) free_page((unsigned long)pte); } -static inline void pte_free(struct mm_struct *mm, struct page *pte) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { + pgtable_page_dtor(pte); __free_page(pte); } -#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) +#define __pte_free_tlb(tlb,pte) \ +do { \ + pgtable_page_dtor((pte)); \ + tlb_remove_page((tlb), (pte)); \ +} while (0) #define __pmd_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x)) #define __pud_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x)) diff --git a/include/asm-xtensa/page.h b/include/asm-xtensa/page.h index 1adedbf41d0..80a6ae0dd25 100644 --- a/include/asm-xtensa/page.h +++ b/include/asm-xtensa/page.h @@ -98,6 +98,7 @@ typedef struct { unsigned long pte; } pte_t; /* page table entry */ typedef struct { unsigned long pgd; } pgd_t; /* PGD table entry */ typedef struct { unsigned long pgprot; } pgprot_t; +typedef struct page *pgtable_t; #define pte_val(x) ((x).pte) #define pgd_val(x) ((x).pgd) diff --git a/include/asm-xtensa/pgalloc.h b/include/asm-xtensa/pgalloc.h index 1d51ba5463f..8d1544eb461 100644 --- a/include/asm-xtensa/pgalloc.h +++ b/include/asm-xtensa/pgalloc.h @@ -24,6 +24,7 @@ (pmd_val(*(pmdp)) = ((unsigned long)ptep)) #define pmd_populate(mm, pmdp, page) \ (pmd_val(*(pmdp)) = ((unsigned long)page_to_virt(page))) +#define pmd_pgtable(pmd) pmd_page(pmd) static inline pgd_t* pgd_alloc(struct mm_struct *mm) @@ -46,10 +47,14 @@ static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, return kmem_cache_alloc(pgtable_cache, GFP_KERNEL|__GFP_REPEAT); } -static inline struct page *pte_alloc_one(struct mm_struct *mm, - unsigned long addr) +static inline pte_token_t pte_alloc_one(struct mm_struct *mm, + unsigned long addr) { - return virt_to_page(pte_alloc_one_kernel(mm, addr)); + struct page *page; + + page = virt_to_page(pte_alloc_one_kernel(mm, addr)); + pgtable_page_ctor(page); + return page; } static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) @@ -57,10 +62,12 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) kmem_cache_free(pgtable_cache, pte); } -static inline void pte_free(struct mm_struct *mm, struct page *page) +static inline void pte_free(struct mm_struct *mm, pgtable_t pte) { - kmem_cache_free(pgtable_cache, page_address(page)); + pgtable_page_dtor(pte); + kmem_cache_free(pgtable_cache, page_address(pte)); } +#define pmd_pgtable(pmd) pmd_page(pmd) #endif /* __KERNEL__ */ #endif /* _XTENSA_PGALLOC_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 89d7c691b93..e8abb381420 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -894,6 +894,18 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a #define pte_lockptr(mm, pmd) ({(void)(pmd); &(mm)->page_table_lock;}) #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ +static inline void pgtable_page_ctor(struct page *page) +{ + pte_lock_init(page); + inc_zone_page_state(page, NR_PAGETABLE); +} + +static inline void pgtable_page_dtor(struct page *page) +{ + pte_lock_deinit(page); + dec_zone_page_state(page, NR_PAGETABLE); +} + #define pte_offset_map_lock(mm, pmd, address, ptlp) \ ({ \ spinlock_t *__ptl = pte_lockptr(mm, pmd); \ @@ -1136,7 +1148,7 @@ struct page *follow_page(struct vm_area_struct *, unsigned long address, #define FOLL_GET 0x04 /* do get_page on page */ #define FOLL_ANON 0x08 /* give ZERO_PAGE if no pgtable */ -typedef int (*pte_fn_t)(pte_t *pte, struct page *pmd_page, unsigned long addr, +typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr, void *data); extern int apply_to_page_range(struct mm_struct *mm, unsigned long address, unsigned long size, pte_fn_t fn, void *data); diff --git a/mm/memory.c b/mm/memory.c index 153a54b2013..e5628a5fd67 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -134,11 +134,9 @@ void pmd_clear_bad(pmd_t *pmd) */ static void free_pte_range(struct mmu_gather *tlb, pmd_t *pmd) { - struct page *page = pmd_page(*pmd); + pgtable_t token = pmd_pgtable(*pmd); pmd_clear(pmd); - pte_lock_deinit(page); - pte_free_tlb(tlb, page); - dec_zone_page_state(page, NR_PAGETABLE); + pte_free_tlb(tlb, token); tlb->mm->nr_ptes--; } @@ -309,21 +307,19 @@ void free_pgtables(struct mmu_gather **tlb, struct vm_area_struct *vma, int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address) { - struct page *new = pte_alloc_one(mm, address); + pgtable_t new = pte_alloc_one(mm, address); if (!new) return -ENOMEM; - pte_lock_init(new); spin_lock(&mm->page_table_lock); - if (pmd_present(*pmd)) { /* Another has populated it */ - pte_lock_deinit(new); - pte_free(mm, new); - } else { + if (!pmd_present(*pmd)) { /* Has another populated it ? */ mm->nr_ptes++; - inc_zone_page_state(new, NR_PAGETABLE); pmd_populate(mm, pmd, new); + new = NULL; } spin_unlock(&mm->page_table_lock); + if (new) + pte_free(mm, new); return 0; } @@ -334,11 +330,13 @@ int __pte_alloc_kernel(pmd_t *pmd, unsigned long address) return -ENOMEM; spin_lock(&init_mm.page_table_lock); - if (pmd_present(*pmd)) /* Another has populated it */ - pte_free_kernel(&init_mm, new); - else + if (!pmd_present(*pmd)) { /* Has another populated it ? */ pmd_populate_kernel(&init_mm, pmd, new); + new = NULL; + } spin_unlock(&init_mm.page_table_lock); + if (new) + pte_free_kernel(&init_mm, new); return 0; } @@ -1390,7 +1388,7 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd, { pte_t *pte; int err; - struct page *pmd_page; + pgtable_t token; spinlock_t *uninitialized_var(ptl); pte = (mm == &init_mm) ? @@ -1401,10 +1399,10 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd, BUG_ON(pmd_huge(*pmd)); - pmd_page = pmd_page(*pmd); + token = pmd_pgtable(*pmd); do { - err = fn(pte, pmd_page, addr, data); + err = fn(pte, token, addr, data); if (err) break; } while (pte++, addr += PAGE_SIZE, addr != end); diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 0536dde139d..950c0be9ca8 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -820,7 +820,7 @@ void __attribute__((weak)) vmalloc_sync_all(void) } -static int f(pte_t *pte, struct page *pmd_page, unsigned long addr, void *data) +static int f(pte_t *pte, pgtable_t table, unsigned long addr, void *data) { /* apply_to_page_range() does all the hard work. */ return 0; -- cgit v1.2.3-70-g09d2 From 6784fd5931a58559673f500a333030ceaadb69bb Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 8 Feb 2008 15:00:45 -0800 Subject: Fix FRV cmpxchg_local Fix the FRV cmpxchg_local by breaking the following header dependency loop : linux/kernel.h -> linux/bitops.h -> asm-frv/bitops.h -> asm-frv/atomic.h -> asm-frv/system.h -> asm-generic/cmpxchg_local.h -> typecheck() defined in linux/kernel.h and linux/kernel.h -> linux/bitops.h -> asm-frv/bitops.h -> asm-frv/atomic.h -> asm-generic/cmpxchg_local.h -> typecheck() defined in linux/kernel.h In order to fix this : - Move the atomic_test_and_ *_mask inlines from asm-frv/atomic.h (why are they there at all anyway ? They are not touching atomic_t variables!) to asm-frv/bitops.h. Also fix a build issue with cmpxchg : it does not cast to (unsigned long *) like other architectures, to deal with it in the cmpxchg_local macro. FRV builds fine with this patch. Thanks to Adrian Bunk for spotting this bug. Signed-off-by: Mathieu Desnoyers Cc: Adrian Bunk Cc: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-frv/atomic.h | 81 ---------------------------------------------- include/asm-frv/bitops.h | 83 ++++++++++++++++++++++++++++++++++++++++++++++-- include/asm-frv/system.h | 3 +- 3 files changed, 83 insertions(+), 84 deletions(-) (limited to 'include/asm-frv') diff --git a/include/asm-frv/atomic.h b/include/asm-frv/atomic.h index 6ec494a5bc5..46d696b331e 100644 --- a/include/asm-frv/atomic.h +++ b/include/asm-frv/atomic.h @@ -125,87 +125,6 @@ static inline void atomic_dec(atomic_t *v) #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) #define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0) -#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS -static inline -unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v) -{ - unsigned long old, tmp; - - asm volatile( - "0: \n" - " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ - " ckeq icc3,cc7 \n" - " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */ - " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ - " and%I3 %1,%3,%2 \n" - " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */ - " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */ - " beq icc3,#0,0b \n" - : "+U"(*v), "=&r"(old), "=r"(tmp) - : "NPr"(~mask) - : "memory", "cc7", "cc3", "icc3" - ); - - return old; -} - -static inline -unsigned long atomic_test_and_OR_mask(unsigned long mask, volatile unsigned long *v) -{ - unsigned long old, tmp; - - asm volatile( - "0: \n" - " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ - " ckeq icc3,cc7 \n" - " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */ - " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ - " or%I3 %1,%3,%2 \n" - " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */ - " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */ - " beq icc3,#0,0b \n" - : "+U"(*v), "=&r"(old), "=r"(tmp) - : "NPr"(mask) - : "memory", "cc7", "cc3", "icc3" - ); - - return old; -} - -static inline -unsigned long atomic_test_and_XOR_mask(unsigned long mask, volatile unsigned long *v) -{ - unsigned long old, tmp; - - asm volatile( - "0: \n" - " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ - " ckeq icc3,cc7 \n" - " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */ - " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ - " xor%I3 %1,%3,%2 \n" - " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */ - " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */ - " beq icc3,#0,0b \n" - : "+U"(*v), "=&r"(old), "=r"(tmp) - : "NPr"(mask) - : "memory", "cc7", "cc3", "icc3" - ); - - return old; -} - -#else - -extern unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v); -extern unsigned long atomic_test_and_OR_mask(unsigned long mask, volatile unsigned long *v); -extern unsigned long atomic_test_and_XOR_mask(unsigned long mask, volatile unsigned long *v); - -#endif - -#define atomic_clear_mask(mask, v) atomic_test_and_ANDNOT_mask((mask), (v)) -#define atomic_set_mask(mask, v) atomic_test_and_OR_mask((mask), (v)) - /*****************************************************************************/ /* * exchange value with memory diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h index 5f86b876b29..39456ba0ec1 100644 --- a/include/asm-frv/bitops.h +++ b/include/asm-frv/bitops.h @@ -16,8 +16,6 @@ #include #include -#include -#include #ifdef __KERNEL__ @@ -33,6 +31,87 @@ #define smp_mb__before_clear_bit() barrier() #define smp_mb__after_clear_bit() barrier() +#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS +static inline +unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v) +{ + unsigned long old, tmp; + + asm volatile( + "0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + " and%I3 %1,%3,%2 \n" + " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */ + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */ + " beq icc3,#0,0b \n" + : "+U"(*v), "=&r"(old), "=r"(tmp) + : "NPr"(~mask) + : "memory", "cc7", "cc3", "icc3" + ); + + return old; +} + +static inline +unsigned long atomic_test_and_OR_mask(unsigned long mask, volatile unsigned long *v) +{ + unsigned long old, tmp; + + asm volatile( + "0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + " or%I3 %1,%3,%2 \n" + " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */ + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */ + " beq icc3,#0,0b \n" + : "+U"(*v), "=&r"(old), "=r"(tmp) + : "NPr"(mask) + : "memory", "cc7", "cc3", "icc3" + ); + + return old; +} + +static inline +unsigned long atomic_test_and_XOR_mask(unsigned long mask, volatile unsigned long *v) +{ + unsigned long old, tmp; + + asm volatile( + "0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + " ld.p %M0,%1 \n" /* LD.P/ORCR are atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + " xor%I3 %1,%3,%2 \n" + " cst.p %2,%M0 ,cc3,#1 \n" /* if store happens... */ + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* ... clear ICC3.Z */ + " beq icc3,#0,0b \n" + : "+U"(*v), "=&r"(old), "=r"(tmp) + : "NPr"(mask) + : "memory", "cc7", "cc3", "icc3" + ); + + return old; +} + +#else + +extern unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v); +extern unsigned long atomic_test_and_OR_mask(unsigned long mask, volatile unsigned long *v); +extern unsigned long atomic_test_and_XOR_mask(unsigned long mask, volatile unsigned long *v); + +#endif + +#define atomic_clear_mask(mask, v) atomic_test_and_ANDNOT_mask((mask), (v)) +#define atomic_set_mask(mask, v) atomic_test_and_OR_mask((mask), (v)) + static inline int test_and_clear_bit(int nr, volatile void *addr) { volatile unsigned long *ptr = addr; diff --git a/include/asm-frv/system.h b/include/asm-frv/system.h index 59be5443a68..b400cea8148 100644 --- a/include/asm-frv/system.h +++ b/include/asm-frv/system.h @@ -14,6 +14,7 @@ #include #include +#include struct thread_struct; @@ -276,7 +277,7 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr, { switch (size) { case 4: - return cmpxchg(ptr, old, new); + return cmpxchg((unsigned long *)ptr, old, new); default: return __cmpxchg_local_generic(ptr, old, new, size); } -- cgit v1.2.3-70-g09d2