diff mbox series

[v4,02/14] arm: add initjmp()

Message ID 20250318104659.1114340-3-jerome.forissier@linaro.org
State New
Headers show
Series Uthreads | expand

Commit Message

Jerome Forissier March 18, 2025, 10:46 a.m. UTC
Implement initjmp() for Arm.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 arch/Kconfig                  |  1 +
 arch/arm/lib/setjmp.S         | 12 ++++++++++++
 arch/arm/lib/setjmp_aarch64.S | 10 ++++++++++
 3 files changed, 23 insertions(+)

Comments

Ilias Apalodimas March 18, 2025, 11:15 a.m. UTC | #1
On Tue, 18 Mar 2025 at 12:47, Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> Implement initjmp() for Arm.
>
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
>  arch/Kconfig                  |  1 +
>  arch/arm/lib/setjmp.S         | 12 ++++++++++++
>  arch/arm/lib/setjmp_aarch64.S | 10 ++++++++++
>  3 files changed, 23 insertions(+)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 14111ca14fb..7a3141e92b3 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -95,6 +95,7 @@ config ARC
>  config ARM
>         bool "ARM architecture"
>         select HAVE_SETJMP
> +       select HAVE_INITJMP
>         select ARCH_SUPPORTS_LTO
>         select CREATE_ARCH_SYMLINK
>         select HAVE_PRIVATE_LIBGCC if !ARM64
> diff --git a/arch/arm/lib/setjmp.S b/arch/arm/lib/setjmp.S
> index 2f041aeef01..81bef578719 100644
> --- a/arch/arm/lib/setjmp.S
> +++ b/arch/arm/lib/setjmp.S
> @@ -34,3 +34,15 @@ ENTRY(longjmp)
>         ret  lr
>  ENDPROC(longjmp)
>  .popsection
> +
> +.pushsection .text.initjmp, "ax"
> +ENTRY(initjmp)
> +       stm  a1, {v1-v8}
> +       /* a2: entry point address, a3: stack base, a4: stack size */
> +       add  a3, a3, a4
> +       str  a3, [a1, #32]  /* where setjmp would save sp */
> +       str  a2, [a1, #36]  /* where setjmp would save lr */
> +       mov  a1, #0
> +       ret  lr
> +ENDPROC(initjmp)
> +.popsection
> diff --git a/arch/arm/lib/setjmp_aarch64.S b/arch/arm/lib/setjmp_aarch64.S
> index 1b8d000eb48..01193ccc426 100644
> --- a/arch/arm/lib/setjmp_aarch64.S
> +++ b/arch/arm/lib/setjmp_aarch64.S
> @@ -39,3 +39,13 @@ ENTRY(longjmp)
>         ret
>  ENDPROC(longjmp)
>  .popsection
> +
> +.pushsection .text.initjmp, "ax"
> +ENTRY(initjmp)
> +       /* x1: entry point address, x2: stack base, x3: stack size */
> +       add x2, x2, x3
> +       stp x1, x2, [x0,#88]
> +       mov  x0, #0
> +       ret
> +ENDPROC(initjmp)
> +.popsection
> --
> 2.43.0
>

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Fabio Estevam March 18, 2025, 12:28 p.m. UTC | #2
On Tue, Mar 18, 2025 at 7:47 AM Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> Implement initjmp() for Arm.

Please improve the commit log by explaining the motivation for adding
initjmp() for Arm.
Jerome Forissier March 18, 2025, 12:51 p.m. UTC | #3
Hi Fabio,

On 3/18/25 13:28, Fabio Estevam wrote:
> On Tue, Mar 18, 2025 at 7:47 AM Jerome Forissier
> <jerome.forissier@linaro.org> wrote:
>>
>> Implement initjmp() for Arm.
> 
> Please improve the commit log by explaining the motivation for adding
> initjmp() for Arm.

The motivation is described in "[PATCH v4 01/14] arch: introduce initjmp()
and Kconfig symbol HAVE_INITJMP" [1]. Do you think a few words should be
repeated for each and every platform (currently: arm, riscv, sandbox)?

[1] https://lists.denx.de/pipermail/u-boot/2025-March/583830.html

Thanks,
Fabio Estevam March 18, 2025, 12:57 p.m. UTC | #4
Hi Jerome,

On Tue, Mar 18, 2025 at 9:51 AM Jerome Forissier
<jerome.forissier@linaro.org> wrote:

> The motivation is described in "[PATCH v4 01/14] arch: introduce initjmp()
> and Kconfig symbol HAVE_INITJMP" [1]. Do you think a few words should be
> repeated for each and every platform (currently: arm, riscv, sandbox)?

Yes, repeating the explanation for every platform would be better.

Thanks
diff mbox series

Patch

diff --git a/arch/Kconfig b/arch/Kconfig
index 14111ca14fb..7a3141e92b3 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -95,6 +95,7 @@  config ARC
 config ARM
 	bool "ARM architecture"
 	select HAVE_SETJMP
+	select HAVE_INITJMP
 	select ARCH_SUPPORTS_LTO
 	select CREATE_ARCH_SYMLINK
 	select HAVE_PRIVATE_LIBGCC if !ARM64
diff --git a/arch/arm/lib/setjmp.S b/arch/arm/lib/setjmp.S
index 2f041aeef01..81bef578719 100644
--- a/arch/arm/lib/setjmp.S
+++ b/arch/arm/lib/setjmp.S
@@ -34,3 +34,15 @@  ENTRY(longjmp)
 	ret  lr
 ENDPROC(longjmp)
 .popsection
+
+.pushsection .text.initjmp, "ax"
+ENTRY(initjmp)
+	stm  a1, {v1-v8}
+	/* a2: entry point address, a3: stack base, a4: stack size */
+	add  a3, a3, a4
+	str  a3, [a1, #32]  /* where setjmp would save sp */
+	str  a2, [a1, #36]  /* where setjmp would save lr */
+	mov  a1, #0
+	ret  lr
+ENDPROC(initjmp)
+.popsection
diff --git a/arch/arm/lib/setjmp_aarch64.S b/arch/arm/lib/setjmp_aarch64.S
index 1b8d000eb48..01193ccc426 100644
--- a/arch/arm/lib/setjmp_aarch64.S
+++ b/arch/arm/lib/setjmp_aarch64.S
@@ -39,3 +39,13 @@  ENTRY(longjmp)
 	ret
 ENDPROC(longjmp)
 .popsection
+
+.pushsection .text.initjmp, "ax"
+ENTRY(initjmp)
+	/* x1: entry point address, x2: stack base, x3: stack size */
+	add x2, x2, x3
+	stp x1, x2, [x0,#88]
+	mov  x0, #0
+	ret
+ENDPROC(initjmp)
+.popsection