All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] armv8: Skip PIE in SPL due to load alignment fault.
@ 2023-08-03  8:12 Kevin Chen
  2023-08-18 17:49 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Chen @ 2023-08-03  8:12 UTC (permalink / raw)
  To: kabel, sjg, u-boot; +Cc: Kevin Chen

When PIE is enabled in start.S, u-boot/-spl use __rel_dyn_start
and _rel_dyn_end symbol to be loaded to and executed at a
different address than it was linked at.

u-boot-spl.lds is used in SPL build, but relocation information
section(.rela*) were discarded.
In line number 80 in arch/arm/cpu/armv8/u-boot-spl.lds
 /DISCARD/ : { *(.rela*) }

If PIE enabled in SPL, __rel_dyn_start which is defined as
.rel_dyn_start in sections.c will be apended to the end of
.bss section.

In our ASPEED case, size of .bss section would let .rel_dyn_start
without 8-byte alignment, leading to alignment fault when
executing ldp instuction in pie_fix_loop.

Signed-off-by: Kevin Chen <kevin_chen@aspeedtech.com>
---
 arch/arm/cpu/armv8/start.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index f3ea858577..6cc1d26e5e 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -58,7 +58,7 @@ reset:
 .globl	save_boot_params_ret
 save_boot_params_ret:
 
-#if CONFIG_POSITION_INDEPENDENT
+#if CONFIG_POSITION_INDEPENDENT && !defined(CONFIG_SPL_BUILD)
 	/* Verify that we're 4K aligned.  */
 	adr	x0, _start
 	ands	x0, x0, #0xfff
-- 
2.41.0


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

* Re: [PATCH] armv8: Skip PIE in SPL due to load alignment fault.
  2023-08-03  8:12 [PATCH] armv8: Skip PIE in SPL due to load alignment fault Kevin Chen
@ 2023-08-18 17:49 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2023-08-18 17:49 UTC (permalink / raw)
  To: Kevin Chen; +Cc: kabel, sjg, u-boot

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

On Thu, Aug 03, 2023 at 04:12:18PM +0800, Kevin Chen wrote:

> When PIE is enabled in start.S, u-boot/-spl use __rel_dyn_start
> and _rel_dyn_end symbol to be loaded to and executed at a
> different address than it was linked at.
> 
> u-boot-spl.lds is used in SPL build, but relocation information
> section(.rela*) were discarded.
> In line number 80 in arch/arm/cpu/armv8/u-boot-spl.lds
>  /DISCARD/ : { *(.rela*) }
> 
> If PIE enabled in SPL, __rel_dyn_start which is defined as
> .rel_dyn_start in sections.c will be apended to the end of
> .bss section.
> 
> In our ASPEED case, size of .bss section would let .rel_dyn_start
> without 8-byte alignment, leading to alignment fault when
> executing ldp instuction in pie_fix_loop.
> 
> Signed-off-by: Kevin Chen <kevin_chen@aspeedtech.com>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2023-08-18 17:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-03  8:12 [PATCH] armv8: Skip PIE in SPL due to load alignment fault Kevin Chen
2023-08-18 17:49 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.