2009-09-18 20:35:15

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 0/2] Linker script cleanup patches for parisc

This is an updated version of the patch series I sent on September 6
cleaning up the parisc architecture's linker scripts. It differs from
the previous version only in having been rebased on top of Linus'
current master (and is a complete rewrite of the version that got some
review back in May:
<http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-05/msg00095.html>).

This cross-architecture linker script cleanup project is in
preparation for adding support for building the kernel with
-ffunction-sections -fdata-sections, which is a prerequisite for
Ksplice.

-Tim Abbott

Tim Abbott (2):
parisc: Clean up linker script using new linker script macros.
parisc: Remove useless altinstructions code copied from x86.

arch/parisc/kernel/vmlinux.lds.S | 104 ++------------------------------------
1 files changed, 4 insertions(+), 100 deletions(-)


2009-09-18 20:40:10

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 1/2] parisc: Clean up linker script using new linker script macros.

This patch has the (likely harmless) side effect of moving
.data.init_task inside the _edata.

It also changes the alignment of .data.init_task from 16384 to
THREAD_SIZE, which can in some configurations be larger than 16384. I
believe that this change fixes a potential bug on those
configurations.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Cc: Sam Ravnborg <[email protected]>
---
arch/parisc/kernel/vmlinux.lds.S | 79 ++------------------------------------
1 files changed, 4 insertions(+), 75 deletions(-)

diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index aea1784..3fd66d9 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -77,13 +77,7 @@ SECTIONS
*/
. = ALIGN(PAGE_SIZE);
data_start = .;
- . = ALIGN(16);
- /* Exception table */
- __ex_table : {
- __start___ex_table = .;
- *(__ex_table)
- __stop___ex_table = .;
- }
+ EXCEPTION_TABLE(16)

NOTES

@@ -94,23 +88,8 @@ SECTIONS
__stop___unwind = .;
}

- /* rarely changed data like cpu maps */
- . = ALIGN(16);
- .data.read_mostly : {
- *(.data.read_mostly)
- }
-
- . = ALIGN(L1_CACHE_BYTES);
/* Data */
- .data : {
- DATA_DATA
- CONSTRUCTORS
- }
-
- . = ALIGN(L1_CACHE_BYTES);
- .data.cacheline_aligned : {
- *(.data.cacheline_aligned)
- }
+ RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)

/* PA-RISC locks requires 16-byte alignment */
. = ALIGN(16);
@@ -118,17 +97,6 @@ SECTIONS
*(.data.lock_aligned)
}

- /* nosave data is really only used for software suspend...it's here
- * just in case we ever implement it
- */
- . = ALIGN(PAGE_SIZE);
- __nosave_begin = .;
- .data_nosave : {
- *(.data.nosave)
- }
- . = ALIGN(PAGE_SIZE);
- __nosave_end = .;
-
/* End of data section */
_edata = .;

@@ -147,14 +115,6 @@ SECTIONS
}
__bss_stop = .;

-
- /* assembler code expects init_task to be 16k aligned */
- . = ALIGN(16384);
- /* init_task */
- .data.init_task : {
- *(.data.init_task)
- }
-
#ifdef CONFIG_64BIT
. = ALIGN(16);
/* Linkage tables */
@@ -172,31 +132,8 @@ SECTIONS
/* reserve space for interrupt stack by aligning __init* to 16k */
. = ALIGN(16384);
__init_begin = .;
- .init.text : {
- _sinittext = .;
- INIT_TEXT
- _einittext = .;
- }
- .init.data : {
- INIT_DATA
- }
- . = ALIGN(16);
- .init.setup : {
- __setup_start = .;
- *(.init.setup)
- __setup_end = .;
- }
- .initcall.init : {
- __initcall_start = .;
- INITCALLS
- __initcall_end = .;
- }
- .con_initcall.init : {
- __con_initcall_start = .;
- *(.con_initcall.init)
- __con_initcall_end = .;
- }
- SECURITY_INIT
+ INIT_TEXT_SECTION(16384)
+ INIT_DATA_SECTION(16)

/* alternate instruction replacement. This is a mechanism x86 uses
* to detect the CPU type and replace generic instruction sequences
@@ -222,14 +159,6 @@ SECTIONS
.exit.data : {
EXIT_DATA
}
-#ifdef CONFIG_BLK_DEV_INITRD
- . = ALIGN(PAGE_SIZE);
- .init.ramfs : {
- __initramfs_start = .;
- *(.init.ramfs)
- __initramfs_end = .;
- }
-#endif

PERCPU(PAGE_SIZE)
. = ALIGN(PAGE_SIZE);
--
1.6.3.3

2009-09-18 20:35:26

by Tim Abbott

[permalink] [raw]
Subject: [PATCH v2 2/2] parisc: Remove useless altinstructions code copied from x86.

Signed-off-by: Tim Abbott <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Cc: Sam Ravnborg <[email protected]>
---
arch/parisc/kernel/vmlinux.lds.S | 25 -------------------------
1 files changed, 0 insertions(+), 25 deletions(-)

diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index 3fd66d9..775be27 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -135,31 +135,6 @@ SECTIONS
INIT_TEXT_SECTION(16384)
INIT_DATA_SECTION(16)

- /* alternate instruction replacement. This is a mechanism x86 uses
- * to detect the CPU type and replace generic instruction sequences
- * with CPU specific ones. We don't currently do this in PA, but
- * it seems like a good idea...
- */
- . = ALIGN(4);
- .altinstructions : {
- __alt_instructions = .;
- *(.altinstructions)
- __alt_instructions_end = .;
- }
- .altinstr_replacement : {
- *(.altinstr_replacement)
- }
-
- /* .exit.text is discard at runtime, not link time, to deal with references
- * from .altinstructions and .eh_frame
- */
- .exit.text : {
- EXIT_TEXT
- }
- .exit.data : {
- EXIT_DATA
- }
-
PERCPU(PAGE_SIZE)
. = ALIGN(PAGE_SIZE);
__init_end = .;
--
1.6.3.3

2009-09-19 08:38:19

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Linker script cleanup patches for parisc

On Fri, Sep 18, 2009 at 04:34:36PM -0400, Tim Abbott wrote:
> This is an updated version of the patch series I sent on September 6
> cleaning up the parisc architecture's linker scripts. It differs from
> the previous version only in having been rebased on top of Linus'
> current master (and is a complete rewrite of the version that got some
> review back in May:
> <http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-05/msg00095.html>).
>
> This cross-architecture linker script cleanup project is in
> preparation for adding support for building the kernel with
> -ffunction-sections -fdata-sections, which is a prerequisite for
> Ksplice.
>
> -Tim Abbott
>
> Tim Abbott (2):
> parisc: Clean up linker script using new linker script macros.
> parisc: Remove useless altinstructions code copied from x86.

Looks good.

Both have my:

Acked-by: Sam Ravnborg <[email protected]>

Sam

2009-09-27 21:02:12

by Helge Deller

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Linker script cleanup patches for parisc

On 09/18/2009 10:34 PM, Tim Abbott wrote:
> This is an updated version of the patch series I sent on September 6
> cleaning up the parisc architecture's linker scripts. [....]
> -Tim Abbott
>
> Tim Abbott (2):
> parisc: Clean up linker script using new linker script macros.
> parisc: Remove useless altinstructions code copied from x86.
>
> arch/parisc/kernel/vmlinux.lds.S | 104 ++------------------------------------
> 1 files changed, 4 insertions(+), 100 deletions(-)

Tim, thanks for your work!

Sadly it broke the parisc build in two places:
a) THREAD_SIZE can't be used in the vmlinux.lds.S file
b) It generates linker errors like "local symbol 0: discarded in section `.exit.text' from kernel/built-in.o".

Attached patch below fixes both issues. Tested with 32- and 64-bit parisc kernel.

Helge

--------
parisc: Fix linker script breakage.

Signed-off-by: Helge Deller <[email protected]>

diff --git a/arch/parisc/kernel/asm-offsets.c b/arch/parisc/kernel/asm-offsets.c
index 699cf8e..7e76f03 100644
--- a/arch/parisc/kernel/asm-offsets.c
+++ b/arch/parisc/kernel/asm-offsets.c
@@ -287,6 +287,8 @@ int main(void)
DEFINE(ASM_PFN_PTE_SHIFT, PFN_PTE_SHIFT);
DEFINE(ASM_PT_INITIAL, PT_INITIAL);
BLANK();
+ DEFINE(ASM_THREAD_SIZE, THREAD_SIZE);
+ BLANK();
DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip));
DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space));
DEFINE(EXCDATA_ADDR, offsetof(struct exception_data, fault_addr));
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index 775be27..8347dfc 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -89,7 +89,7 @@ SECTIONS
}

/* Data */
- RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
+ RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, ASM_THREAD_SIZE)

/* PA-RISC locks requires 16-byte alignment */
. = ALIGN(16);
@@ -135,6 +135,16 @@ SECTIONS
INIT_TEXT_SECTION(16384)
INIT_DATA_SECTION(16)

+ /* we have to discard exit text and such at runtime, not link time */
+ .exit.text :
+ {
+ EXIT_TEXT
+ }
+ .exit.data :
+ {
+ EXIT_DATA
+ }
+
PERCPU(PAGE_SIZE)
. = ALIGN(PAGE_SIZE);
__init_end = .;

2009-09-27 21:25:31

by Tim Abbott

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Linker script cleanup patches for parisc

On Sun, 27 Sep 2009, Helge Deller wrote:

> Tim, thanks for your work!
>
> Sadly it broke the parisc build in two places:
> a) THREAD_SIZE can't be used in the vmlinux.lds.S file
> b) It generates linker errors like "local symbol 0: discarded in section
> `.exit.text' from kernel/built-in.o".

Sorry about that -- I should have tried harder to get someone to test this
one, since parisc is one of the architectures for which I don't have a
cross-compiler.

> Attached patch below fixes both issues. Tested with 32- and 64-bit parisc
> kernel.

The .exit.text change looks fine.

[...]
> b/arch/parisc/kernel/asm-offsets.c
> index 699cf8e..7e76f03 100644
> --- a/arch/parisc/kernel/asm-offsets.c
> +++ b/arch/parisc/kernel/asm-offsets.c
> @@ -287,6 +287,8 @@ int main(void)
> DEFINE(ASM_PFN_PTE_SHIFT, PFN_PTE_SHIFT);
> DEFINE(ASM_PT_INITIAL, PT_INITIAL);
> BLANK();
> + DEFINE(ASM_THREAD_SIZE, THREAD_SIZE);
> + BLANK();
> DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip));
> DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space));
> DEFINE(EXCDATA_ADDR, offsetof(struct exception_data, fault_addr));

Rather than adding a new definition in asm-offsets.c, I think it'll be
better to do something like the following to make the normal THREAD_SIZE
definition available in the linker script and other assembly files:

-Tim Abbott

parisc: Make THREAD_SIZE available to assembly files and linker scripts.

Signed-off-by: Tim Abbott <[email protected]>
---
arch/parisc/include/asm/thread_info.h | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/parisc/include/asm/thread_info.h b/arch/parisc/include/asm/thread_info.h
index ac775a7..51bca20 100644
--- a/arch/parisc/include/asm/thread_info.h
+++ b/arch/parisc/include/asm/thread_info.h
@@ -32,6 +32,11 @@ struct thread_info {
#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

+/* how to get the thread information struct from C */
+#define current_thread_info() ((struct thread_info *)mfctl(30))
+
+#endif /* !__ASSEMBLY */
+
/* thread information allocation */

#define THREAD_SIZE_ORDER 2
@@ -40,11 +45,6 @@ struct thread_info {
#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
#define THREAD_SHIFT (PAGE_SHIFT + THREAD_SIZE_ORDER)

-/* how to get the thread information struct from C */
-#define current_thread_info() ((struct thread_info *)mfctl(30))
-
-#endif /* !__ASSEMBLY */
-
#define PREEMPT_ACTIVE_BIT 28
#define PREEMPT_ACTIVE (1 << PREEMPT_ACTIVE_BIT)

--
1.6.3.3

2009-09-27 22:39:47

by Helge Deller

[permalink] [raw]
Subject: Re: [PATCH v2 0/2] Linker script cleanup patches for parisc

On 09/27/2009 11:25 PM, Tim Abbott wrote:
> On Sun, 27 Sep 2009, Helge Deller wrote:
>
>> Tim, thanks for your work!
>>
>> Sadly it broke the parisc build in two places:
>> a) THREAD_SIZE can't be used in the vmlinux.lds.S file
>> b) It generates linker errors like "local symbol 0: discarded in section
>> `.exit.text' from kernel/built-in.o".
>
> Sorry about that -- I should have tried harder to get someone to test this
> one, since parisc is one of the architectures for which I don't have a
> cross-compiler.

No problem. It was on my todo-list to test your patch, but then it
already got merged :-)

>> Attached patch below fixes both issues. Tested with 32- and 64-bit parisc
>> kernel.
>
> The .exit.text change looks fine.

Good.

> [...]
> Rather than adding a new definition in asm-offsets.c, I think it'll be
> better to do something like the following to make the normal THREAD_SIZE
> definition available in the linker script and other assembly files:
>
> -Tim Abbott
>
> parisc: Make THREAD_SIZE available to assembly files and linker scripts.
>
> Signed-off-by: Tim Abbott<[email protected]>

Yes, much better.
Acked-by: Helge Deller <[email protected]>

But with this change, the vmlinux.lds.S file needs to include
the <asm/thread_info.h> file as well. I've added the adjusted patch
to vmlinux.lds.S below.

> ---
> arch/parisc/include/asm/thread_info.h | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/arch/parisc/include/asm/thread_info.h b/arch/parisc/include/asm/thread_info.h
> index ac775a7..51bca20 100644
> --- a/arch/parisc/include/asm/thread_info.h
> +++ b/arch/parisc/include/asm/thread_info.h
> @@ -32,6 +32,11 @@ struct thread_info {
> #define init_thread_info (init_thread_union.thread_info)
> #define init_stack (init_thread_union.stack)
>
> +/* how to get the thread information struct from C */
> +#define current_thread_info() ((struct thread_info *)mfctl(30))
> +
> +#endif /* !__ASSEMBLY */
> +
> /* thread information allocation */
>
> #define THREAD_SIZE_ORDER 2
> @@ -40,11 +45,6 @@ struct thread_info {
> #define THREAD_SIZE (PAGE_SIZE<< THREAD_SIZE_ORDER)
> #define THREAD_SHIFT (PAGE_SHIFT + THREAD_SIZE_ORDER)
>
> -/* how to get the thread information struct from C */
> -#define current_thread_info() ((struct thread_info *)mfctl(30))
> -
> -#endif /* !__ASSEMBLY */
> -
> #define PREEMPT_ACTIVE_BIT 28
> #define PREEMPT_ACTIVE (1<< PREEMPT_ACTIVE_BIT)
>

Adjusted patch to vmlinux.lds.S:

parisc: Fix linker script breakage.

Signed-off-by: Helge Deller <[email protected]>

diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index 775be27..7fc2c3d 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -28,6 +28,7 @@
#include <asm/cache.h>
#include <asm/page.h>
#include <asm/asm-offsets.h>
+#include <asm/thread_info.h>

/* ld script to make hppa Linux kernel */
#ifndef CONFIG_64BIT
@@ -135,6 +136,16 @@ SECTIONS
INIT_TEXT_SECTION(16384)
INIT_DATA_SECTION(16)

+ /* we have to discard exit text and such at runtime, not link time */
+ .exit.text :
+ {
+ EXIT_TEXT
+ }
+ .exit.data :
+ {
+ EXIT_DATA
+ }
+
PERCPU(PAGE_SIZE)
. = ALIGN(PAGE_SIZE);
__init_end = .;