mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr()
@ 2026-03-12 19:20 Ahmad Fatoum
  2026-03-12 19:20 ` [PATCH 2/2] fixup! ARM: setup_c: avoid clearing BSS twice Ahmad Fatoum
  2026-03-13 11:17 ` [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr() Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-03-12 19:20 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

When calling relocate_to_adr(), barebox is copied without BSS to a new
place. The new BSS region is not necessarily zeroed, but setupc()
following relocate_to_adr() will take care of that.

With incoming change to make setupc() idempotent, this will become
problematic as the variable in .data will indicate that the BSS is
zeroed, while the new BSS region isn't actually.

We usually have very little BSS in the PBL, so copying it is not much
more effort, so let's just do that.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Please apply before "ARM: setup_c: avoid clearing BSS twice"
---
 arch/arm/cpu/setupc_32.S | 4 ++--
 arch/arm/cpu/setupc_64.S | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/setupc_32.S b/arch/arm/cpu/setupc_32.S
index 61b8152599f1..c5348353b129 100644
--- a/arch/arm/cpu/setupc_32.S
+++ b/arch/arm/cpu/setupc_32.S
@@ -39,12 +39,12 @@ bss_cleared:
 .section .text.relocate_to_adr
 #ifdef __PBL__
 ENTRY(relocate_to_adr_full)
-	ldr	r2, =__image_end
+	ldr	r2, =__image_end	/* include piggy data */
 	b	1f
 #endif
 
 ENTRY(relocate_to_adr)
-	ldr	r2, =__bss_start
+	ldr	r2, =__bss_stop		/* skip piggy data */
 	b	1f
 
 1:
diff --git a/arch/arm/cpu/setupc_64.S b/arch/arm/cpu/setupc_64.S
index 8fd7f2f9b60f..d5a6c0c43a7b 100644
--- a/arch/arm/cpu/setupc_64.S
+++ b/arch/arm/cpu/setupc_64.S
@@ -40,12 +40,12 @@ bss_cleared:
 					/* x0: target address */
 #ifdef __PBL__
 ENTRY(relocate_to_adr_full)
-	adr_l	x2, __image_end
+	adr_l	x2, __image_end		/* include piggy data */
 	b	1f
 #endif
 
 ENTRY(relocate_to_adr)
-	adr_l	x2, __bss_start
+	adr_l	x2, __bss_stop		/* skip piggy data */
 	b	1f
 
 1:
-- 
2.47.3




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

end of thread, other threads:[~2026-03-14  7:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-12 19:20 [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr() Ahmad Fatoum
2026-03-12 19:20 ` [PATCH 2/2] fixup! ARM: setup_c: avoid clearing BSS twice Ahmad Fatoum
2026-03-13 11:17 ` [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr() Sascha Hauer
2026-03-14  7:50   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox