* [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
* [PATCH 2/2] fixup! ARM: setup_c: avoid clearing BSS twice
2026-03-12 19:20 [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr() Ahmad Fatoum
@ 2026-03-12 19:20 ` Ahmad Fatoum
2026-03-13 11:17 ` [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr() Sascha Hauer
1 sibling, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-03-12 19:20 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
ARM: setup_c: ensure 4-byte alignment for bss_cleared
Out of abundance of caution, avoid the variable ending up being
misaligned.
I did not observe this happening.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/cpu/setupc_32.S | 1 +
arch/arm/cpu/setupc_64.S | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/arm/cpu/setupc_32.S b/arch/arm/cpu/setupc_32.S
index c5348353b129..fadfc28ae155 100644
--- a/arch/arm/cpu/setupc_32.S
+++ b/arch/arm/cpu/setupc_32.S
@@ -27,6 +27,7 @@ ENTRY(setup_c)
ENDPROC(setup_c)
.section .data.bss_cleared
+.balign 4
bss_cleared:
.word 0
diff --git a/arch/arm/cpu/setupc_64.S b/arch/arm/cpu/setupc_64.S
index d5a6c0c43a7b..a0767c5136e0 100644
--- a/arch/arm/cpu/setupc_64.S
+++ b/arch/arm/cpu/setupc_64.S
@@ -27,6 +27,7 @@ ENTRY(setup_c)
ENDPROC(setup_c)
.section .data.bss_cleared
+.balign 4
bss_cleared:
.word 0
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr()
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 ` Sascha Hauer
2026-03-14 7:50 ` Ahmad Fatoum
1 sibling, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2026-03-13 11:17 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Thu, 12 Mar 2026 20:20:42 +0100, Ahmad Fatoum wrote:
> 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.
>
> [...]
Applied, thanks!
[1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr()
https://git.pengutronix.de/cgit/barebox/commit/?id=d443585bcce6 (link may not be stable)
[2/2] fixup! ARM: setup_c: avoid clearing BSS twice
(no commit info)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr()
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
0 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2026-03-14 7:50 UTC (permalink / raw)
To: Sascha Hauer, barebox
Hello Sascha,
On 3/13/26 12:17, Sascha Hauer wrote:
>
> On Thu, 12 Mar 2026 20:20:42 +0100, Ahmad Fatoum wrote:
>> 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.
>>
>> [...]
>
> Applied, thanks!
>
> [1/2] ARM: cpu: setupc: relocate BSS in relocate_to_adr()
> https://git.pengutronix.de/cgit/barebox/commit/?id=d443585bcce6 (link may not be stable)
> [2/2] fixup! ARM: setup_c: avoid clearing BSS twice
Please reorder "ARM: cpu: setupc: relocate BSS in relocate_to_adr" before "ARM: setup_c: avoid clearing BSS twice" to keep bisection possible without intermittent breakage.
Thanks,
Ahmad
> (no commit info)
>
> Best regards,
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ 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