section name cleanup for powerpc
cover section name cleanup for powerpc
This patch series cleans up the section names on the powerpc architecture. It requires the architecture-independent macro definitions from this patch series:
<http://www.spinics.net/lists/mips/msg33499.html>
The long-term goal here is to add support for building the kernel with -ffunction-sections -fdata-sections. This requires renaming all the magic section names in the kernel of the form .text.foo, .data.foo, .bss.foo, and .rodata.foo to not have collisions with sections generated for code like:
static int nosave = 0; /* -fdata-sections places in .data.nosave */ static void head(); /* -ffunction-sections places in .text.head */
Note that these patches have not been boot-tested (aside from testing the analogous changes on x86), since I don't have access to the appropriate hardware.
-Tim Abbott
Tim Abbott (8):
powerpc: Remove unused __page_aligned macro.
powerpc: share .data output section definition between 32 and 64
bits.
powerpc: Use macros for .data.page_aligned section.
powerpc: use NOSAVE_DATA macro for .data.nosave section.
powerpc: use new macro for .data.cacheline_aligned section.
powerpc: use new macros for .data.init_task.
powerpc: use new macro for .data.read_mostly section.
powerpc: convert to new generic read_mostly support.
arch/powerpc/Kconfig | 3 ++ arch/powerpc/include/asm/cache.h | 4 -- arch/powerpc/include/asm/page_64.h | 8 ---- arch/powerpc/kernel/init_task.c | 3 +- arch/powerpc/kernel/machine_kexec_64.c | 4 +- arch/powerpc/kernel/vdso.c | 3 +- arch/powerpc/kernel/vdso32/vdso32_wrapper.S | 3 +- arch/powerpc/kernel/vdso64/vdso64_wrapper.S | 3 +- arch/powerpc/kernel/vmlinux.lds.S | 47 ++++++-------------------- 9 files changed, 23 insertions(+), 55 deletions(-)
PATCH 1/8 powerpc: Remove unused __page_aligned macro.
--- arch/powerpc/include/asm/page_64.h | 8 -------- 1 files changed, 0 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/page_64.h +0 -8
@@ -152,14 +152,6 @@ do { \#endif /* !CONFIG_HUGETLB_PAGE */ -#ifdef MODULE -#define __page_aligned __attribute__((__aligned__(PAGE_SIZE))) -#else -#define __page_aligned \ - __attribute__((__aligned__(PAGE_SIZE), \ - __section__(".data.page_aligned"))) -#endif -#define VM_DATA_DEFAULT_FLAGS \ (test_thread_flag(TIF_32BIT) ? \ VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
Signature · 1 line
1.6.2.1
PATCH 2/8 powerpc: share .data output section definition between 32 and 64 bits.
Since upcoming changes will add several more common pieces of code between the 32-bit and 64-bit powerpc architectures, it seems best to unify these two blocks.
--- arch/powerpc/kernel/vmlinux.lds.S | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/kernel/vmlinux.lds.S +3 -4
@@ -220,20 +220,19 @@ SECTIONS . = ALIGN(PAGE_SIZE); _sdata = .; -#ifdef CONFIG_PPC32 .data : AT(ADDR(.data) - LOAD_OFFSET) { DATA_DATA +#ifdef CONFIG_PPC32 *(.sdata) *(.got.plt) *(.got) - } #else - .data : AT(ADDR(.data) - LOAD_OFFSET) { - DATA_DATA *(.data.rel*) *(.toc1) *(.branch_lt) +#endif } +#ifndef CONFIG_PPC32 .opd : AT(ADDR(.opd) - LOAD_OFFSET) { *(.opd) }
Signature · 1 line
1.6.2.1
PATCH 3/8 powerpc: Use macros for .data.page_aligned section.
.data.page_aligned should not need a separate output section, so as part of this cleanup I moved into the .data output section in the linker scripts in order to eliminate unnecessary references to the section name.
Note that this change moves the page-aligned data inside _edata. Since it _is_ data, I suspect having page-aligned data outside _edata was a bug. Please comment if it is not.
--- arch/powerpc/kernel/vdso.c | 3 ++- arch/powerpc/kernel/vdso32/vdso32_wrapper.S | 3 ++- arch/powerpc/kernel/vdso64/vdso64_wrapper.S | 3 ++- arch/powerpc/kernel/vmlinux.lds.S | 6 +----- 4 files changed, 7 insertions(+), 8 deletions(-)
arch/powerpc/kernel/vdso.c +2 -1
@@ -1,3 +1,4 @@ +/* * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp. * <[email protected]>
@@ -74,7 +75,7 @@ static int vdso_ready;static union {struct vdso_data data;u8 page[PAGE_SIZE ]; -} vdso_data_store __attribute__((__section__(".data.page_aligned"))); +} vdso_data_store __page_aligned_data;struct vdso_data *vdso_data = &vdso_data_store.data;/* Format of the patch table */
arch/powerpc/kernel/vdso32/vdso32_wrapper.S +2 -1
@@ -1,7 +1,8 @@ #include <linux/init.h> +#include <linux/linkage.h> #include <asm/page.h> - .section ".data.page_aligned" + __PAGE_ALIGNED_DATA .globl vdso32_start, vdso32_end .balign PAGE_SIZE
arch/powerpc/kernel/vdso64/vdso64_wrapper.S +2 -1
@@ -1,7 +1,8 @@ #include <linux/init.h> +#include <linux/linkage.h> #include <asm/page.h> - .section ".data.page_aligned" + __PAGE_ALIGNED_DATA .globl vdso64_start, vdso64_end .balign PAGE_SIZE
arch/powerpc/kernel/vmlinux.lds.S +1 -5
@@ -221,6 +221,7 @@ SECTIONS _sdata = .; .data : AT(ADDR(.data) - LOAD_OFFSET) { + PAGE_ALIGNED_DATA DATA_DATA #ifdef CONFIG_PPC32 *(.sdata)
@@ -258,11 +259,6 @@ SECTIONS *(.data.init_task) } - . = ALIGN(PAGE_SIZE); - .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { - *(.data.page_aligned) - } - .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { *(.data.cacheline_aligned) }
Signature · 1 line
1.6.2.1
PATCH 4/8 powerpc: use NOSAVE_DATA macro for .data.nosave section.
.data.nosave should not need a separate output section; this change moves it into the .data section.
--- arch/powerpc/kernel/vmlinux.lds.S | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
arch/powerpc/kernel/vmlinux.lds.S +1 -8
@@ -222,6 +222,7 @@ SECTIONS .data : AT(ADDR(.data) - LOAD_OFFSET) { PAGE_ALIGNED_DATA + NOSAVE_DATA DATA_DATA #ifdef CONFIG_PPC32 *(.sdata)
@@ -268,14 +269,6 @@ SECTIONS *(.data.read_mostly) } - . = ALIGN(PAGE_SIZE); - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { - __nosave_begin = .; - *(.data.nosave) - . = ALIGN(PAGE_SIZE); - __nosave_end = .; - } - /* * And finally the bss */
Signature · 1 line
1.6.2.1
PATCH 5/8 powerpc: use new macro for .data.cacheline_aligned section.
.data.cacheline_aligned should not need a separate output section; this change moves it into the .data section.
Since there isn't an ALIGN() directive before the .data.cacheline_aligned scetion in the current linker script, I'd like an ack from one of the powerpc maintainers that L1_CACHE_BYTES is the correct alignment here.
--- arch/powerpc/kernel/vmlinux.lds.S | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/powerpc/kernel/vmlinux.lds.S +1 -4
@@ -223,6 +223,7 @@ SECTIONS .data : AT(ADDR(.data) - LOAD_OFFSET) { PAGE_ALIGNED_DATA NOSAVE_DATA + CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) DATA_DATA #ifdef CONFIG_PPC32 *(.sdata)
@@ -260,10 +261,6 @@ SECTIONS *(.data.init_task) } - .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { - *(.data.cacheline_aligned) - } - . = ALIGN(L1_CACHE_BYTES); .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly)
Signature · 1 line
1.6.2.1
PATCH 6/8 powerpc: use new macros for .data.init_task.
.data.init_task should not need a separate output section; this change moves it into the .data section.
This patch uses THREAD_SIZE rather than 8192/16384 for the alignment. This should have the effect of increasing the alignment to 32768 if CONFIG_PPC_256K_PAGES is defined, but it seems that it should be that way. One of the powerpc maintainers should confirm that this is correct, otherwise we can go back to the #ifdef.
--- arch/powerpc/kernel/init_task.c | 3 +-- arch/powerpc/kernel/machine_kexec_64.c | 4 ++-- arch/powerpc/kernel/vmlinux.lds.S | 13 +++---------- 3 files changed, 6 insertions(+), 14 deletions(-)
arch/powerpc/kernel/init_task.c +1 -2
@@ -20,8 +20,7 @@ EXPORT_SYMBOL(init_mm);* way process stacks are handled. This is done by having a special * "init_task" linker map entry.. */ -union thread_union init_thread_union - __attribute__((__section__(".data.init_task"))) = +union thread_union init_thread_union __init_task_data = {INIT_THREAD_INFO (init_task) };/*
arch/powerpc/kernel/machine_kexec_64.c +2 -2
@@ -10,6 +10,7 @@*/ +#include <linux/init_task.h> #include <linux/kexec.h> #include <linux/smp.h> #include <linux/thread_info.h>
@@ -249,8 +250,7 @@ static void kexec_prepare_cpus(void)* We could use a smaller stack if we don't care about anything using * current, but that audit has not been performed. */ -static union thread_union kexec_stack - __attribute__((__section__(".data.init_task"))) = { }; +static union thread_union kexec_stack __init_task_data = { };/* Our assembly helper, in kexec_stub.S */ extern NORET_TYPE void kexec_sequence(void *newstack, unsigned long start,
arch/powerpc/kernel/vmlinux.lds.S +3 -10
@@ -6,6 +6,7 @@ #include <asm/page.h> #include <asm-generic/vmlinux.lds.h> #include <asm/cache.h> +#include <asm/thread_info.h> ENTRY(_stext)
@@ -221,6 +222,8 @@ SECTIONS _sdata = .; .data : AT(ADDR(.data) - LOAD_OFFSET) { + /* The initial task and kernel stack */ + INIT_TASK_DATA(THREAD_SIZE) PAGE_ALIGNED_DATA NOSAVE_DATA CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
@@ -251,16 +254,6 @@ SECTIONS _edata = .; PROVIDE32 (edata = .); - /* The initial task and kernel stack */ -#ifdef CONFIG_PPC32 - . = ALIGN(8192); -#else - . = ALIGN(16384); -#endif - .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { - *(.data.init_task) - } - . = ALIGN(L1_CACHE_BYTES); .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly)
Signature · 1 line
1.6.2.1
PATCH 7/8 powerpc: use new macro for .data.read_mostly section.
.data.read_mostly should not need a separate output section; this change moves it into the .data section.
--- arch/powerpc/kernel/vmlinux.lds.S | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
arch/powerpc/kernel/vmlinux.lds.S +2 -5
@@ -1,3 +1,4 @@ + #ifdef CONFIG_PPC64 #define PROVIDE32(x) PROVIDE(__unused__##x) #else
@@ -227,6 +228,7 @@ SECTIONS PAGE_ALIGNED_DATA NOSAVE_DATA CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) + READ_MOSTLY_DATA(L1_CACHE_BYTES) DATA_DATA #ifdef CONFIG_PPC32 *(.sdata)
@@ -254,11 +256,6 @@ SECTIONS _edata = .; PROVIDE32 (edata = .); - . = ALIGN(L1_CACHE_BYTES); - .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { - *(.data.read_mostly) - } - /* * And finally the bss */
Signature · 1 line
1.6.2.1
PATCH 8/8 powerpc: convert to new generic read_mostly support.
--- arch/powerpc/Kconfig | 3 +++ arch/powerpc/include/asm/cache.h | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/Kconfig +3 -0
@@ -32,6 +32,9 @@ config GENERIC_CMOS_UPDATE config GENERIC_TIME def_bool y +config HAVE_READ_MOSTLY_DATA + def_bool y + config GENERIC_TIME_VSYSCALL def_bool y
arch/powerpc/include/asm/cache.h +0 -4
@@ -37,9 +37,5 @@ struct ppc64_caches {extern struct ppc64_caches ppc64_caches;#endif /* __powerpc64__ && ! __ASSEMBLY__ */ -#if !defined(__ASSEMBLY__) -#define __read_mostly __attribute__((__section__(".data.read_mostly"))) -#endif -#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_CACHE_H */
Signature · 1 line
1.6.2.1
Re: [PATCH 5/8] powerpc: use new macro for .data.cacheline_aligned section.
In reply to Tim AbbottQuoted 7 lines · Tim Abbott
.data.cacheline_aligned should not need a separate output section; this change moves it into the .data section.
Since there isn't an
ALIGN()directive before the .data.cacheline_aligned scetion in the current linker script, I'd like an ack from one of the powerpc maintainers thatL1_CACHE_BYTESis the correct alignment here.
Yes, that's the right size.
Also. that looks like a bug to me in the current stuff. I'm queuing your patch set for .31 but I'll stick a "fix" in .30 for that just in case which unfortunately means your patches will probably need to be rebased.
Cheers,
Ben.
Quoted 31 lines
Signed-off-by Tim Abbott <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Paul Mackerras <[email protected]>--- arch/powerpc/kernel/vmlinux.lds.S | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)arch/powerpc/kernel/vmlinux.lds.S +1
-4@@ -223,6 +223,7 @@ SECTIONS .data : AT(ADDR(.data) - LOAD_OFFSET) { PAGE_ALIGNED_DATA NOSAVE_DATA + CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) DATA_DATA #ifdef CONFIG_PPC32 *(.sdata)@@ -260,10 +261,6 @@ SECTIONS *(.data.init_task) } - .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { - *(.data.cacheline_aligned) - } - . = ALIGN(L1_CACHE_BYTES); .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly)
Re: [PATCH 2/8] powerpc: share .data output section definition between 32 and 64 bits.
In reply to Tim AbbottQuoted 30 lines · Tim Abbott
Since upcoming changes will add several more common pieces of code between the 32-bit and 64-bit powerpc architectures, it seems best to unify these two blocks.
Signed-off-by Tim Abbott <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Paul Mackerras <[email protected]>--- arch/powerpc/kernel/vmlinux.lds.S | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)arch/powerpc/kernel/vmlinux.lds.S +1
-4@@ -220,20 +220,19 @@ SECTIONS . = ALIGN(PAGE_SIZE); _sdata = .; -#ifdef CONFIG_PPC32 .data : AT(ADDR(.data) - LOAD_OFFSET) { DATA_DATA +#ifdef CONFIG_PPC32 *(.sdata) *(.got.plt) *(.got) - } #else - .data : AT(ADDR(.data) - LOAD_OFFSET) { - DATA_DATA
arch/powerpc/kernel/vmlinux.lds.S SECTIONS · line 238
Quoted 10 lines
arch/powerpc/kernel/vmlinux.lds.S +2
-0*(.data.rel*) *(.toc1) *(.branch_lt) +#endif } +#ifndef CONFIG_PPC32 .opd : AT(ADDR(.opd) - LOAD_OFFSET) { *(.opd) }
This would be clearer in the positive, as in #ifdef CONFIG_PPC64.
cheers
Re: [PATCH 2/8] powerpc: share .data output section definition between 32 and 64 bits.
Quoted 4 lines · Michael Ellerman
Quoted 1 line · Tim Abbott
+#ifndef
CONFIG_PPC32This would be clearer in the positive, as in #ifdef
CONFIG_PPC64.
Good point. New version below.
-Tim Abbott
powerpc: share .data output section definition between 32 and 64 bits.
Since upcoming changes will add several more common pieces of code between the 32-bit and 64-bit powerpc architectures, it seems best to unify these two blocks.
--- arch/powerpc/kernel/vmlinux.lds.S | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
arch/powerpc/kernel/vmlinux.lds.S +3 -4
@@ -219,20 +219,19 @@ SECTIONS . = ALIGN(PAGE_SIZE); _sdata = .; -#ifdef CONFIG_PPC32 .data : AT(ADDR(.data) - LOAD_OFFSET) { DATA_DATA +#ifdef CONFIG_PPC32 *(.sdata) *(.got.plt) *(.got) - } #else - .data : AT(ADDR(.data) - LOAD_OFFSET) { - DATA_DATA *(.data.rel*) *(.toc1) *(.branch_lt) +#endif } +#ifdef CONFIG_PPC64 .opd : AT(ADDR(.opd) - LOAD_OFFSET) { *(.opd) }
Signature · 1 line
1.6.2.1