mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] PBL: constructor fixes
@ 2026-08-19 14:12 Stefan Kerkmann
  2026-08-19 14:12 ` [PATCH 1/2] ARM/ARM64/RISC-V: pbl: guard constructor support Stefan Kerkmann
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stefan Kerkmann @ 2026-08-19 14:12 UTC (permalink / raw)
  To: Sascha Hauer, open list:BAREBOX; +Cc: Stefan Kerkmann

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
Stefan Kerkmann (2):
      ARM/ARM64/RISC-V: pbl: guard constructor support
      ARM64: setup_c: abi safe link register storage

 arch/arm/Kconfig         | 1 +
 arch/arm/cpu/setupc_64.S | 7 ++++---
 arch/riscv/Kconfig       | 1 +
 pbl/Kconfig              | 3 +++
 pbl/Makefile             | 2 +-
 5 files changed, 10 insertions(+), 4 deletions(-)
---
base-commit: a3b5e97691e58ccea5c597a3fef03429ff078b02
change-id: 20260819-next-17bc0fe12a43

Best regards,
--  
Stefan Kerkmann <s.kerkmann@pengutronix.de>




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

* [PATCH 1/2] ARM/ARM64/RISC-V: pbl: guard constructor support
  2026-08-19 14:12 [PATCH 0/2] PBL: constructor fixes Stefan Kerkmann
@ 2026-08-19 14:12 ` Stefan Kerkmann
  2026-08-19 14:12 ` [PATCH 2/2] ARM64: setup_c: abi safe link register storage Stefan Kerkmann
  2026-08-19 14:16 ` [PATCH 0/2] PBL: constructor fixes Ahmad Fatoum
  2 siblings, 0 replies; 8+ messages in thread
From: Stefan Kerkmann @ 2026-08-19 14:12 UTC (permalink / raw)
  To: Sascha Hauer, open list:BAREBOX; +Cc: Stefan Kerkmann

The PBL ctors source file was compiled and linked for all arches. This
broke compilation for unsupported arches as the references to the
external symbols `__ctors_start` and `__ctors_end` couldn't be resolved
as they are only defined in the PBL linker scripts for ARM/ARM64/RISC-V.

Guard the ctors compilation behind CONFIG_PBL_CONSTRUCTORS and only
enable them for supported arches.

Fixes: bb07ef11d6 ("ARM/ARM64/RISC-V: pbl: add constructor support")
Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
 arch/arm/Kconfig   | 1 +
 arch/riscv/Kconfig | 1 +
 pbl/Kconfig        | 3 +++
 pbl/Makefile       | 2 +-
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fe4fd3f471..ac68f07aa7 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -13,6 +13,7 @@ config ARM
 	select HAVE_PBL_IMAGE
 	select HAVE_PBL_MULTI_IMAGES
 	select RELOCATABLE
+	select PBL_CONSTRUCTORS
 	select PBL_RELOCATABLE
 	select USE_COMPRESSED_DTB
 	select HAVE_ARCH_BOARD_GENERIC_DT if OFDEVICE
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 452e3d6cfc..40a79b6834 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -19,6 +19,7 @@ config RISCV
 	select HAS_KALLSYMS
 	select RISCV_TIMER if RISCV_SBI
 	select HW_HAS_PCI
+	select PBL_CONSTRUCTORS
 	select PBL_IMAGE_ELF
 	select HAVE_ARCH_BOARD_GENERIC_DT
 	select HAVE_ARCH_BOOTM_OFTREE
diff --git a/pbl/Kconfig b/pbl/Kconfig
index 63f29cd613..e6b168c4de 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -74,6 +74,9 @@ config PBL_VERIFY_PIGGY
 	depends on ARM || MIPS || RISCV
 	bool "Verify barebox proper hash before decompression" if COMPILE_TEST
 
+config PBL_CONSTRUCTORS
+	bool
+
 config PBL_CLOCKSOURCE
 	bool
 
diff --git a/pbl/Makefile b/pbl/Makefile
index 7ce8cee077..9cbd481640 100644
--- a/pbl/Makefile
+++ b/pbl/Makefile
@@ -3,7 +3,7 @@
 #
 # only unsed by the pbl
 #
-pbl-y += ctors.o
+pbl-$(CONFIG_PBL_CONSTRUCTORS) += ctors.o
 pbl-y += misc.o
 pbl-y += string.o
 pbl-y += malloc.o

-- 
2.47.3




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

* [PATCH 2/2] ARM64: setup_c: abi safe link register storage
  2026-08-19 14:12 [PATCH 0/2] PBL: constructor fixes Stefan Kerkmann
  2026-08-19 14:12 ` [PATCH 1/2] ARM/ARM64/RISC-V: pbl: guard constructor support Stefan Kerkmann
@ 2026-08-19 14:12 ` Stefan Kerkmann
  2026-08-19 14:16 ` [PATCH 0/2] PBL: constructor fixes Ahmad Fatoum
  2 siblings, 0 replies; 8+ messages in thread
From: Stefan Kerkmann @ 2026-08-19 14:12 UTC (permalink / raw)
  To: Sascha Hauer, open list:BAREBOX; +Cc: Stefan Kerkmann

The ARM64 setup_c function saved the link register (x30) in the caller
save register (x15). This is fragile as a constructor might use x15,
thus save it on the stack just like ARM32 and RISC-V.

Fixes: bb07ef11d6 ("ARM/ARM64/RISC-V: pbl: add constructor support")
Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
 arch/arm/cpu/setupc_64.S | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/setupc_64.S b/arch/arm/cpu/setupc_64.S
index e3c6149e27..b1cfea47b1 100644
--- a/arch/arm/cpu/setupc_64.S
+++ b/arch/arm/cpu/setupc_64.S
@@ -10,10 +10,10 @@
  * setup_c: clear bss if not yet done
  */
 ENTRY(setup_c)
+	str x30, [sp, #-16]!
 	adr_l	x0, bss_cleared
 	ldr	w1, [x0]
 	cbnz	w1, 1f			/* skip if already done */
-	mov	x15, x30
 	adr_l	x0, __bss_start
 	mov	x1, #0
 	adr_l	x2, __bss_stop
@@ -25,8 +25,9 @@ ENTRY(setup_c)
 #ifdef __PBL__
 	bl	pbl_do_ctors
 #endif
-	mov	x30, x15
-1:	ret
+1:
+	ldr x30, [sp], #16
+	ret
 ENDPROC(setup_c)
 
 .section .data.bss_cleared

-- 
2.47.3




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

* Re: [PATCH 0/2] PBL: constructor fixes
  2026-08-19 14:12 [PATCH 0/2] PBL: constructor fixes Stefan Kerkmann
  2026-08-19 14:12 ` [PATCH 1/2] ARM/ARM64/RISC-V: pbl: guard constructor support Stefan Kerkmann
  2026-08-19 14:12 ` [PATCH 2/2] ARM64: setup_c: abi safe link register storage Stefan Kerkmann
@ 2026-08-19 14:16 ` Ahmad Fatoum
  2026-08-19 15:01   ` Sascha Hauer
  2 siblings, 1 reply; 8+ messages in thread
From: Ahmad Fatoum @ 2026-08-19 14:16 UTC (permalink / raw)
  To: Stefan Kerkmann, Sascha Hauer, open list:BAREBOX

Hi,

On 8/19/26 4:12 PM, Stefan Kerkmann wrote:
> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
> ---
> Stefan Kerkmann (2):
>       ARM/ARM64/RISC-V: pbl: guard constructor support
>       ARM64: setup_c: abi safe link register storage

if these are applied after what's in next, we would have intermittent
breakage when doing a bisect right?

I would suggest either turning these into fixups or just resend the
whole series.

Cheers,
Ahmad

> 
>  arch/arm/Kconfig         | 1 +
>  arch/arm/cpu/setupc_64.S | 7 ++++---
>  arch/riscv/Kconfig       | 1 +
>  pbl/Kconfig              | 3 +++
>  pbl/Makefile             | 2 +-
>  5 files changed, 10 insertions(+), 4 deletions(-)
> ---
> base-commit: a3b5e97691e58ccea5c597a3fef03429ff078b02
> change-id: 20260819-next-17bc0fe12a43
> 
> Best regards,
> --  
> Stefan Kerkmann <s.kerkmann@pengutronix.de>
> 
> 

-- 
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] 8+ messages in thread

* Re: [PATCH 0/2] PBL: constructor fixes
  2026-08-19 14:16 ` [PATCH 0/2] PBL: constructor fixes Ahmad Fatoum
@ 2026-08-19 15:01   ` Sascha Hauer
  2026-08-20  7:14     ` Stefan Kerkmann
  0 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2026-08-19 15:01 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: open list:BAREBOX, Stefan Kerkmann

On 2026-08-19 16:16, Ahmad Fatoum wrote:
> Hi,
> 
> On 8/19/26 4:12 PM, Stefan Kerkmann wrote:
> > Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
> > ---
> > Stefan Kerkmann (2):
> >       ARM/ARM64/RISC-V: pbl: guard constructor support
> >       ARM64: setup_c: abi safe link register storage
> 
> if these are applied after what's in next, we would have intermittent
> breakage when doing a bisect right?
> 
> I would suggest either turning these into fixups or just resend the
> whole series.

I just squashed them into the original commit. But next time, yes, you
can send --fixup patches for patches in next.

I just learned there's also --fixup=amend:<commit> for replacing the
original commit message along with the fixup. There's even
--fixup=reword:<commit> for just rewording the commit message without
changing the patch content.

Sascha

--
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] 8+ messages in thread

* Re: [PATCH 0/2] PBL: constructor fixes
  2026-08-19 15:01   ` Sascha Hauer
@ 2026-08-20  7:14     ` Stefan Kerkmann
  2026-08-20  7:18       ` Sascha Hauer
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Kerkmann @ 2026-08-20  7:14 UTC (permalink / raw)
  To: Sascha Hauer, Ahmad Fatoum; +Cc: open list:BAREBOX

Hi,

On 8/19/26 17:01, Sascha Hauer wrote:
> On 2026-08-19 16:16, Ahmad Fatoum wrote:
>> Hi,
>>
>> On 8/19/26 4:12 PM, Stefan Kerkmann wrote:
>>> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
>>> ---
>>> Stefan Kerkmann (2):
>>>       ARM/ARM64/RISC-V: pbl: guard constructor support
>>>       ARM64: setup_c: abi safe link register storage
>>
>> if these are applied after what's in next, we would have intermittent
>> breakage when doing a bisect right?
>>
>> I would suggest either turning these into fixups or just resend the
>> whole series.
> 
> I just squashed them into the original commit. But next time, yes, you
> can send --fixup patches for patches in next.
> 

Thanks, I missed the bisectability requirement for this series. For the setup_c
patch I actually send an amend patch to include it in the original series with:

git send-email HEAD^ --to="Sascha Hauer <s.hauer@pengutronix.de>" --to="\"open
list:BAREBOX\" <barebox@lists.infradead.org>" --cc="Stefan Kerkmann
<s.kerkmann@pengutronix.de>"
--in-reply-to="<20260817-feature-pbl-get-time-ns-v3-2-9874c1438855@pengutronix.de>"

But it maybe wasn't picked up by b4 at the time the original merge happened?

> I just learned there's also --fixup=amend:<commit> for replacing the
> original commit message along with the fixup. There's even
> --fixup=reword:<commit> for just rewording the commit message without
> changing the patch content.
> 
> Sascha
> 
> --
> 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 |
> 
> 

Best regards,
Stefan

-- 
Pengutronix e.K.                       | Stefan Kerkmann             |
Steuerwalder Str. 21                   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany              | Phone: +49-5121-206917-128  |
Amtsgericht Hildesheim, HRA 2686       | Fax:   +49-5121-206917-9    |




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

* Re: [PATCH 0/2] PBL: constructor fixes
  2026-08-20  7:14     ` Stefan Kerkmann
@ 2026-08-20  7:18       ` Sascha Hauer
  2026-08-20  7:24         ` Stefan Kerkmann
  0 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2026-08-20  7:18 UTC (permalink / raw)
  To: Stefan Kerkmann; +Cc: open list:BAREBOX, Ahmad Fatoum

On 2026-08-20 09:14, Stefan Kerkmann wrote:
> Hi,
> 
> On 8/19/26 17:01, Sascha Hauer wrote:
> > On 2026-08-19 16:16, Ahmad Fatoum wrote:
> >> Hi,
> >>
> >> On 8/19/26 4:12 PM, Stefan Kerkmann wrote:
> >>> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
> >>> ---
> >>> Stefan Kerkmann (2):
> >>>       ARM/ARM64/RISC-V: pbl: guard constructor support
> >>>       ARM64: setup_c: abi safe link register storage
> >>
> >> if these are applied after what's in next, we would have intermittent
> >> breakage when doing a bisect right?
> >>
> >> I would suggest either turning these into fixups or just resend the
> >> whole series.
> > 
> > I just squashed them into the original commit. But next time, yes, you
> > can send --fixup patches for patches in next.
> > 
> 
> Thanks, I missed the bisectability requirement for this series. For the setup_c
> patch I actually send an amend patch to include it in the original series with:
> 
> git send-email HEAD^ --to="Sascha Hauer <s.hauer@pengutronix.de>" --to="\"open
> list:BAREBOX\" <barebox@lists.infradead.org>" --cc="Stefan Kerkmann
> <s.kerkmann@pengutronix.de>"
> --in-reply-to="<20260817-feature-pbl-get-time-ns-v3-2-9874c1438855@pengutronix.de>"
> 
> But it maybe wasn't picked up by b4 at the time the original merge happened?

It picked it up.

Sascha

--
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] 8+ messages in thread

* Re: [PATCH 0/2] PBL: constructor fixes
  2026-08-20  7:18       ` Sascha Hauer
@ 2026-08-20  7:24         ` Stefan Kerkmann
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Kerkmann @ 2026-08-20  7:24 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: open list:BAREBOX, Ahmad Fatoum

Hi Sascha,

On 8/20/26 09:18, Sascha Hauer wrote:
> On 2026-08-20 09:14, Stefan Kerkmann wrote:
>> Hi,
>>
>> On 8/19/26 17:01, Sascha Hauer wrote:
>>> On 2026-08-19 16:16, Ahmad Fatoum wrote:
>>>> Hi,
>>>>
>>>> On 8/19/26 4:12 PM, Stefan Kerkmann wrote:
>>>>> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
>>>>> ---
>>>>> Stefan Kerkmann (2):
>>>>>       ARM/ARM64/RISC-V: pbl: guard constructor support
>>>>>       ARM64: setup_c: abi safe link register storage
>>>>
>>>> if these are applied after what's in next, we would have intermittent
>>>> breakage when doing a bisect right?
>>>>
>>>> I would suggest either turning these into fixups or just resend the
>>>> whole series.
>>>
>>> I just squashed them into the original commit. But next time, yes, you
>>> can send --fixup patches for patches in next.
>>>
>>
>> Thanks, I missed the bisectability requirement for this series. For the setup_c
>> patch I actually send an amend patch to include it in the original series with:
>>
>> git send-email HEAD^ --to="Sascha Hauer <s.hauer@pengutronix.de>" --to="\"open
>> list:BAREBOX\" <barebox@lists.infradead.org>" --cc="Stefan Kerkmann
>> <s.kerkmann@pengutronix.de>"
>> --in-reply-to="<20260817-feature-pbl-get-time-ns-v3-2-9874c1438855@pengutronix.de>"
>>
>> But it maybe wasn't picked up by b4 at the time the original merge happened?
> 
> It picked it up.
> 

Huh, I was fairly sure that I enrolled the series on top of next after the merge
and the patch applied, strange. But good to know that it worked!

> Sascha
> 
> --
> 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 |
> 
> 

Best regards,
Stefan

-- 
Pengutronix e.K.                       | Stefan Kerkmann             |
Steuerwalder Str. 21                   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany              | Phone: +49-5121-206917-128  |
Amtsgericht Hildesheim, HRA 2686       | Fax:   +49-5121-206917-9    |




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

end of thread, other threads:[~2026-08-20  8:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-19 14:12 [PATCH 0/2] PBL: constructor fixes Stefan Kerkmann
2026-08-19 14:12 ` [PATCH 1/2] ARM/ARM64/RISC-V: pbl: guard constructor support Stefan Kerkmann
2026-08-19 14:12 ` [PATCH 2/2] ARM64: setup_c: abi safe link register storage Stefan Kerkmann
2026-08-19 14:16 ` [PATCH 0/2] PBL: constructor fixes Ahmad Fatoum
2026-08-19 15:01   ` Sascha Hauer
2026-08-20  7:14     ` Stefan Kerkmann
2026-08-20  7:18       ` Sascha Hauer
2026-08-20  7:24         ` Stefan Kerkmann

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