[PATCH 2/2] x86: setjmp: set base pointer to zero in initjmp
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Oct 9 04:50:51 PDT 2023
Initializing the frame points to a known-bad value like zero makes it
easier for code unwinding the stack to know when to stop. Thus
initialize the stack pointer in initjmp-initialized jump buffers to
zero.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
arch/x86/lib/setjmp_32.S | 1 +
arch/x86/lib/setjmp_64.S | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/x86/lib/setjmp_32.S b/arch/x86/lib/setjmp_32.S
index 30db5f989af6..5814623f9478 100644
--- a/arch/x86/lib/setjmp_32.S
+++ b/arch/x86/lib/setjmp_32.S
@@ -54,6 +54,7 @@ ENDPROC(longjmp)
ENTRY(initjmp)
movl %edx, 20(%eax) /* Return address */
+ movl $0, 8(%edx) /* Base pointer */
sub $ASM_SZPTR, %ecx /* ESP - 4 has to be 16-byte aligned on entry */
movl %ecx, 4(%eax) /* Stack top */
xorl %eax, %eax /* Return value */
diff --git a/arch/x86/lib/setjmp_64.S b/arch/x86/lib/setjmp_64.S
index d5cf99a1557f..bfa152149975 100644
--- a/arch/x86/lib/setjmp_64.S
+++ b/arch/x86/lib/setjmp_64.S
@@ -54,6 +54,7 @@ ENDPROC(longjmp)
ENTRY(initjmp)
movq %rsi, (%rdi) /* Return address */
+ movq $0, 16(%rdi) /* Base pointer */
sub $ASM_SZPTR, %rdx /* RSP - 8 has to be 16-byte aligned on entry */
movq %rdx, 8(%rdi) /* Stack top */
xorq %rax, %rax
--
2.39.2
More information about the barebox
mailing list