On 2/14/25 15:35, Heinrich Schuchardt wrote:
> On 14.02.25 15:00, Jerome Forissier wrote:
>> Implement initjmp() for Arm.
>
> Could you, please, describe in the commit message what initjmp() good
> for and why it is needed and why it would not be needed for any other
> architectures but ARM.
Sure. If you don't mind, I will update the commit message of "arch:
introduce symbol HAVE_INITJMP" rather than this one, to avoid duplication
for each architecture. I mean, if I update "arm: add initjmp()" then why
not "riscv: add initjmp()".
>
>>
>> Signed-off-by: Jerome Forissier <jerome.foriss...@linaro.org>
>> ---
>> arch/Kconfig | 1 +
>> arch/arm/include/asm/setjmp.h | 1 +
>> arch/arm/lib/setjmp.S | 11 +++++++++++
>> arch/arm/lib/setjmp_aarch64.S | 9 +++++++++
>> 4 files changed, 22 insertions(+)
>>
>> diff --git a/arch/Kconfig b/arch/Kconfig
>> index 8d5b54031b3..57695fada8d 100644
>> --- a/arch/Kconfig
>> +++ b/arch/Kconfig
>> @@ -94,6 +94,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/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
>> index 662bec86321..1ad5b500f2a 100644
>> --- a/arch/arm/include/asm/setjmp.h
>> +++ b/arch/arm/include/asm/setjmp.h
>> @@ -23,5 +23,6 @@ typedef struct jmp_buf_data jmp_buf[1];
>>
>> int setjmp(jmp_buf jmp);
>> void longjmp(jmp_buf jmp, int ret);
>
> Please, always provide a Sphinx description for any new function.
Will do in v2.
>
> Best regards
>
> Heinrich
>
>> +int initjmp(jmp_buf jmp, void __noreturn (*func)(void), void *stack_top);
>>
>> #endif /* _SETJMP_H_ */
>> diff --git a/arch/arm/lib/setjmp.S b/arch/arm/lib/setjmp.S
>> index 2f041aeef01..320ddea85f9 100644
>> --- a/arch/arm/lib/setjmp.S
>> +++ b/arch/arm/lib/setjmp.S
>> @@ -34,3 +34,14 @@ ENTRY(longjmp)
>> ret lr
>> ENDPROC(longjmp)
>> .popsection
>> +
>> +.pushsection .text.initjmp, "ax"
>> +ENTRY(initjmp)
>> + stm a1, {v1-v8}
>> + /* a2: entry point address, a3: stack top */
>> + 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..074320d25fb 100644
>> --- a/arch/arm/lib/setjmp_aarch64.S
>> +++ b/arch/arm/lib/setjmp_aarch64.S
>> @@ -39,3 +39,12 @@ ENTRY(longjmp)
>> ret
>> ENDPROC(longjmp)
>> .popsection
>> +
>> +.pushsection .text.initjmp, "ax"
>> +ENTRY(initjmp)
>> + /* x1: entry point address, x2: stack top */
>> + stp x1, x2, [x0,#88]
>> + mov x0, #0
>> + ret
>> +ENDPROC(initjmp)
>> +.popsection
>
Thanks,
--
Jerome