linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: Sort exception table at compile time
@ 2012-07-30 21:30 Stephen Boyd
  2012-07-30 21:51 ` Sam Ravnborg
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stephen Boyd @ 2012-07-30 21:30 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-kernel, David Daney

Add the ARM machine identifier to sortextable and select the
config option so that we can sort the exception table at compile
time. sortextable relies on a section named __ex_table existing
in the vmlinux, but ARM's linker script places the exception
table in the data section. Give the exception table its own
section so that sortextable can find it.

This allows us to skip the runtime sorting step during boot.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Cc: David Daney <david.daney@cavium.com>
---

I can't find any information on why the exception table lives in the data
section. If there's a good reason for that, I'll look into changing
sortextable to look for the __start___ex_table symbol.

 arch/arm/Kconfig              |  1 +
 arch/arm/kernel/vmlinux.lds.S | 19 +++++++++----------
 scripts/sortextable.c         |  1 +
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b25c9d3..2af95e6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1,6 +1,7 @@
 config ARM
 	bool
 	default y
+	select BUILDTIME_EXTABLE_SORT if MMU
 	select ARCH_HAVE_CUSTOM_GPIO_H
 	select HAVE_AOUT
 	select HAVE_DMA_API_DEBUG
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 36ff15b..0e3e8b4 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -220,16 +220,6 @@ SECTIONS
 		READ_MOSTLY_DATA(L1_CACHE_BYTES)
 
 		/*
-		 * The exception fixup table (might need resorting at runtime)
-		 */
-		. = ALIGN(4);
-		__start___ex_table = .;
-#ifdef CONFIG_MMU
-		*(__ex_table)
-#endif
-		__stop___ex_table = .;
-
-		/*
 		 * and the usual data section
 		 */
 		DATA_DATA
@@ -239,6 +229,15 @@ SECTIONS
 	}
 	_edata_loc = __data_loc + SIZEOF(.data);
 
+	. = ALIGN(4);
+	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
+		__start___ex_table = .;
+#ifdef CONFIG_MMU
+		*(__ex_table)
+#endif
+		__stop___ex_table = .;
+	}
+
 #ifdef CONFIG_HAVE_TCM
         /*
 	 * We align everything to a page boundary so we can
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index 1ca9ceb..591acb3 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -248,6 +248,7 @@ do_file(char const *const fname)
 		custom_sort = sort_x86_table;
 		break;
 	case EM_MIPS:
+	case EM_ARM:
 		break;
 	}  /* end switch */
 
-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: Sort exception table at compile time
  2012-07-30 21:30 [PATCH] ARM: Sort exception table at compile time Stephen Boyd
@ 2012-07-30 21:51 ` Sam Ravnborg
  2012-07-30 22:19   ` Russell King - ARM Linux
  2012-07-30 21:56 ` Russell King - ARM Linux
  2012-08-22 18:56 ` [PATCHv2] " Stephen Boyd
  2 siblings, 1 reply; 8+ messages in thread
From: Sam Ravnborg @ 2012-07-30 21:51 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: linux-arm-kernel, linux-kernel, David Daney

On Mon, Jul 30, 2012 at 02:30:03PM -0700, Stephen Boyd wrote:
> Add the ARM machine identifier to sortextable and select the
> config option so that we can sort the exception table at compile
> time. sortextable relies on a section named __ex_table existing
> in the vmlinux, but ARM's linker script places the exception
> table in the data section. Give the exception table its own
> section so that sortextable can find it.
> 
> This allows us to skip the runtime sorting step during boot.
> 
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> Cc: David Daney <david.daney@cavium.com>
> ---
> 
> I can't find any information on why the exception table lives in the data
> section. If there's a good reason for that, I'll look into changing
> sortextable to look for the __start___ex_table symbol.
> 
>  arch/arm/Kconfig              |  1 +
>  arch/arm/kernel/vmlinux.lds.S | 19 +++++++++----------
>  scripts/sortextable.c         |  1 +
>  3 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index b25c9d3..2af95e6 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1,6 +1,7 @@
>  config ARM
>  	bool
>  	default y
> +	select BUILDTIME_EXTABLE_SORT if MMU
>  	select ARCH_HAVE_CUSTOM_GPIO_H
>  	select HAVE_AOUT
>  	select HAVE_DMA_API_DEBUG
> diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
> index 36ff15b..0e3e8b4 100644
> --- a/arch/arm/kernel/vmlinux.lds.S
> +++ b/arch/arm/kernel/vmlinux.lds.S
> @@ -220,16 +220,6 @@ SECTIONS
>  		READ_MOSTLY_DATA(L1_CACHE_BYTES)
>  
>  		/*
> -		 * The exception fixup table (might need resorting at runtime)
> -		 */
> -		. = ALIGN(4);
> -		__start___ex_table = .;
> -#ifdef CONFIG_MMU
> -		*(__ex_table)
> -#endif
> -		__stop___ex_table = .;
> -
> -		/*
>  		 * and the usual data section
>  		 */
>  		DATA_DATA
> @@ -239,6 +229,15 @@ SECTIONS
>  	}
>  	_edata_loc = __data_loc + SIZEOF(.data);
>  
> +	. = ALIGN(4);
> +	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
> +		__start___ex_table = .;
> +#ifdef CONFIG_MMU
> +		*(__ex_table)
> +#endif
> +		__stop___ex_table = .;
> +	}
> +

Here you should be able to use the macro EXCEPTION_TABLE from
vmlinux.lds.h.
I cannot see why the ifdef for not NON-MMU case is needed,
but if it is needed the macro is not good...

	Sam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: Sort exception table at compile time
  2012-07-30 21:30 [PATCH] ARM: Sort exception table at compile time Stephen Boyd
  2012-07-30 21:51 ` Sam Ravnborg
@ 2012-07-30 21:56 ` Russell King - ARM Linux
  2012-07-30 22:38   ` Stephen Boyd
  2012-08-22 18:56 ` [PATCHv2] " Stephen Boyd
  2 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2012-07-30 21:56 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: linux-arm-kernel, linux-kernel, David Daney

On Mon, Jul 30, 2012 at 02:30:03PM -0700, Stephen Boyd wrote:
> Add the ARM machine identifier to sortextable and select the
> config option so that we can sort the exception table at compile
> time. sortextable relies on a section named __ex_table existing
> in the vmlinux, but ARM's linker script places the exception
> table in the data section. Give the exception table its own
> section so that sortextable can find it.
> 
> This allows us to skip the runtime sorting step during boot.
> 
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> Cc: David Daney <david.daney@cavium.com>
> ---
> 
> I can't find any information on why the exception table lives in the data
> section. If there's a good reason for that, I'll look into changing
> sortextable to look for the __start___ex_table symbol.

Be careful about the placement of this, especially with XIP.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: Sort exception table at compile time
  2012-07-30 21:51 ` Sam Ravnborg
@ 2012-07-30 22:19   ` Russell King - ARM Linux
  2012-07-30 22:40     ` Stephen Boyd
  0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2012-07-30 22:19 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Stephen Boyd, linux-kernel, linux-arm-kernel, David Daney

On Mon, Jul 30, 2012 at 11:51:18PM +0200, Sam Ravnborg wrote:
> Here you should be able to use the macro EXCEPTION_TABLE from
> vmlinux.lds.h.
> I cannot see why the ifdef for not NON-MMU case is needed,
> but if it is needed the macro is not good...

Because you can not mention the same input section in two different
places and end up with predictable output from the linker.

We discard the __ex_table for noMMU, but I think the start/stop
symbols are still referenced somewhere.  Dunno, I don't have much to
do with noMMU ARM, and the only platform I'd be interested in never
got merged.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: Sort exception table at compile time
  2012-07-30 21:56 ` Russell King - ARM Linux
@ 2012-07-30 22:38   ` Stephen Boyd
  2012-07-31 20:01     ` Stephen Boyd
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Boyd @ 2012-07-30 22:38 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: linux-arm-kernel, linux-kernel, David Daney

On 07/30/12 14:56, Russell King - ARM Linux wrote:
> On Mon, Jul 30, 2012 at 02:30:03PM -0700, Stephen Boyd wrote:
>> Add the ARM machine identifier to sortextable and select the
>> config option so that we can sort the exception table at compile
>> time. sortextable relies on a section named __ex_table existing
>> in the vmlinux, but ARM's linker script places the exception
>> table in the data section. Give the exception table its own
>> section so that sortextable can find it.
>>
>> This allows us to skip the runtime sorting step during boot.
>>
>> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
>> Cc: David Daney <david.daney@cavium.com>
>> ---
>>
>> I can't find any information on why the exception table lives in the data
>> section. If there's a good reason for that, I'll look into changing
>> sortextable to look for the __start___ex_table symbol.
> Be careful about the placement of this, especially with XIP.
>

Thanks for the hint. I'm unfamiliar with how XIP works so I'll take a
closer look there.

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: Sort exception table at compile time
  2012-07-30 22:19   ` Russell King - ARM Linux
@ 2012-07-30 22:40     ` Stephen Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2012-07-30 22:40 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Sam Ravnborg, linux-kernel, linux-arm-kernel, David Daney

On 07/30/12 15:19, Russell King - ARM Linux wrote:
> On Mon, Jul 30, 2012 at 11:51:18PM +0200, Sam Ravnborg wrote:
>> Here you should be able to use the macro EXCEPTION_TABLE from
>> vmlinux.lds.h.
>> I cannot see why the ifdef for not NON-MMU case is needed,
>> but if it is needed the macro is not good...
> Because you can not mention the same input section in two different
> places and end up with predictable output from the linker.
>
> We discard the __ex_table for noMMU, but I think the start/stop
> symbols are still referenced somewhere.  Dunno, I don't have much to
> do with noMMU ARM, and the only platform I'd be interested in never
> got merged.

I was thinking, perhaps we can ifdef out the exception fixup sections in
the places where they're added? Then we can just use the EXCEPTION_TABLE
macro from vmlinux.lds.h knowing that there are no __ex_table sections
in the input object files?

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] ARM: Sort exception table at compile time
  2012-07-30 22:38   ` Stephen Boyd
@ 2012-07-31 20:01     ` Stephen Boyd
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2012-07-31 20:01 UTC (permalink / raw)
  To: Russell King - ARM Linux; +Cc: linux-arm-kernel, linux-kernel, David Daney

On 07/30/12 15:38, Stephen Boyd wrote:
> On 07/30/12 14:56, Russell King - ARM Linux wrote:
>> On Mon, Jul 30, 2012 at 02:30:03PM -0700, Stephen Boyd wrote:
>>> Add the ARM machine identifier to sortextable and select the
>>> config option so that we can sort the exception table at compile
>>> time. sortextable relies on a section named __ex_table existing
>>> in the vmlinux, but ARM's linker script places the exception
>>> table in the data section. Give the exception table its own
>>> section so that sortextable can find it.
>>>
>>> This allows us to skip the runtime sorting step during boot.
>>>
>>> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
>>> Cc: David Daney <david.daney@cavium.com>
>>> ---
>>>
>>> I can't find any information on why the exception table lives in the data
>>> section. If there's a good reason for that, I'll look into changing
>>> sortextable to look for the __start___ex_table symbol.
>> Be careful about the placement of this, especially with XIP.
>>
> Thanks for the hint. I'm unfamiliar with how XIP works so I'll take a
> closer look there.
>

Ok. It looks like the exception table is placed in the data section so
that XIP kernels can boot up and sort the exception table (otherwise the
exception table would be in read-only flash). Now that the exception
table is sorted at compile time, we should be able to place the
exception table in the rodata area, essentially placing the table in the
non-volatile storage on XIP kernels.

I propose we move the exception table right after the rodata. Other
arches (x86/mips) may actually want to put the exception table into the
rodata, but that looks like a larger change.

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv2] ARM: Sort exception table at compile time
  2012-07-30 21:30 [PATCH] ARM: Sort exception table at compile time Stephen Boyd
  2012-07-30 21:51 ` Sam Ravnborg
  2012-07-30 21:56 ` Russell King - ARM Linux
@ 2012-08-22 18:56 ` Stephen Boyd
  2 siblings, 0 replies; 8+ messages in thread
From: Stephen Boyd @ 2012-08-22 18:56 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-kernel, Russell King - ARM Linux, Sam Ravnborg, David Daney

Add the ARM machine identifier to sortextable and select the
config option so that we can sort the exception table at compile
time. sortextable relies on a section named __ex_table existing
in the vmlinux, but ARM's linker script places the exception
table in the data section. Give the exception table its own
section so that sortextable can find it.

This allows us to skip the sorting step during boot.

Cc: David Daney <david.daney@cavium.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---

Changes since v1:
 * Moved exception table next to RO data for XIP builds

 arch/arm/Kconfig              |  1 +
 arch/arm/kernel/vmlinux.lds.S | 19 +++++++++----------
 scripts/sortextable.c         |  1 +
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 6d6e18f..ccf830b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1,6 +1,7 @@
 config ARM
 	bool
 	default y
+	select BUILDTIME_EXTABLE_SORT if MMU
 	select ARCH_HAVE_CUSTOM_GPIO_H
 	select HAVE_AOUT
 	select HAVE_DMA_API_DEBUG
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
index 36ff15b..b9f38e3 100644
--- a/arch/arm/kernel/vmlinux.lds.S
+++ b/arch/arm/kernel/vmlinux.lds.S
@@ -114,6 +114,15 @@ SECTIONS
 
 	RO_DATA(PAGE_SIZE)
 
+	. = ALIGN(4);
+	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
+		__start___ex_table = .;
+#ifdef CONFIG_MMU
+		*(__ex_table)
+#endif
+		__stop___ex_table = .;
+	}
+
 #ifdef CONFIG_ARM_UNWIND
 	/*
 	 * Stack unwinding tables
@@ -220,16 +229,6 @@ SECTIONS
 		READ_MOSTLY_DATA(L1_CACHE_BYTES)
 
 		/*
-		 * The exception fixup table (might need resorting at runtime)
-		 */
-		. = ALIGN(4);
-		__start___ex_table = .;
-#ifdef CONFIG_MMU
-		*(__ex_table)
-#endif
-		__stop___ex_table = .;
-
-		/*
 		 * and the usual data section
 		 */
 		DATA_DATA
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index 6acf834..ba8f7c1 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -247,6 +247,7 @@ do_file(char const *const fname)
 	case EM_X86_64:
 		custom_sort = sort_x86_table;
 		break;
+	case EM_ARM:
 	case EM_S390:
 	case EM_MIPS:
 		break;
-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-08-22 18:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-30 21:30 [PATCH] ARM: Sort exception table at compile time Stephen Boyd
2012-07-30 21:51 ` Sam Ravnborg
2012-07-30 22:19   ` Russell King - ARM Linux
2012-07-30 22:40     ` Stephen Boyd
2012-07-30 21:56 ` Russell King - ARM Linux
2012-07-30 22:38   ` Stephen Boyd
2012-07-31 20:01     ` Stephen Boyd
2012-08-22 18:56 ` [PATCHv2] " Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).