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(-)
.data.read_mostly should not need a separate output section; this
change moves it into the .data section.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/kernel/vmlinux.lds.S | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index f91d7c1..c982827 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -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
*/
--
1.6.2.1
.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.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
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(-)
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index ad06d5c..f075591 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -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 */
diff --git a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
index 556f0ca..6e8f507 100644
--- a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
+++ b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
@@ -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
diff --git a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
index 0529cb9..b8553d6 100644
--- a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
+++ b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
@@ -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
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 47899b0..d3dcea0 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -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)
}
--
1.6.2.1
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/include/asm/page_64.h | 8 --------
1 files changed, 0 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
index 043bfdf..20f9c74 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -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)
--
1.6.2.1
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]>
Cc: [email protected]
---
arch/powerpc/kernel/vmlinux.lds.S | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index a047a6c..47899b0 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -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)
}
--
1.6.2.1
.data.nosave should not need a separate output section; this change
moves it into the .data section.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/kernel/vmlinux.lds.S | 9 +--------
1 files changed, 1 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index d3dcea0..4223892 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -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
*/
--
1.6.2.1
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/Kconfig | 3 +++
arch/powerpc/include/asm/cache.h | 4 ----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 4c78045..d29ea59 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -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
diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
index 81de6eb..1843a11 100644
--- a/arch/powerpc/include/asm/cache.h
+++ b/arch/powerpc/include/asm/cache.h
@@ -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 */
--
1.6.2.1
.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.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/kernel/vmlinux.lds.S | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 4223892..e769717 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -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)
--
1.6.2.1
.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.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
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(-)
diff --git a/arch/powerpc/kernel/init_task.c b/arch/powerpc/kernel/init_task.c
index 688b329..a4eb25d 100644
--- a/arch/powerpc/kernel/init_task.c
+++ b/arch/powerpc/kernel/init_task.c
@@ -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) };
/*
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 49e705f..3761f76 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -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,
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index e769717..f91d7c1 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -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)
--
1.6.2.1
On Thu, 2009-04-30 at 19:56 -0400, Tim Abbott wrote:
> 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]>
> Cc: [email protected]
> ---
> arch/powerpc/kernel/vmlinux.lds.S | 7 +++----
> 1 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
> index a047a6c..47899b0 100644
> --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -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)
> }
This would be clearer in the positive, as in #ifdef CONFIG_PPC64.
cheers
On Fri, 1 May 2009, Michael Ellerman wrote:
> On Thu, 2009-04-30 at 19:56 -0400, Tim Abbott wrote:
> > +#ifndef CONFIG_PPC32
>
> This 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.
Signed-off-by: Tim Abbott <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: [email protected]
---
arch/powerpc/kernel/vmlinux.lds.S | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index b9ef164..de80f89 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -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)
}
--
1.6.2.1