mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr()
Date: Thu, 12 Mar 2026 20:20:42 +0100	[thread overview]
Message-ID: <20260312192110.539601-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2026-03-12 19:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 19:20 Ahmad Fatoum [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260312192110.539601-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox