summaryrefslogtreecommitdiffstats
path: root/arch/x86/lib
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2023-10-09 13:50:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-10-12 16:27:03 +0200
commitdb96abb2cc1b035e4fdcfb62ea4c16ef9f091b43 (patch)
tree23b24b7473a0c9c7ec680c7268a9614c554553a2 /arch/x86/lib
parent5155dc05760174ab7b2d5ff931e3c9dea079b847 (diff)
downloadbarebox-db96abb2cc1b035e4fdcfb62ea4c16ef9f091b43.tar.gz
barebox-db96abb2cc1b035e4fdcfb62ea4c16ef9f091b43.tar.xz
x86: setjmp: set base pointer to zero in initjmp
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@pengutronix.de> Link: https://lore.barebox.org/20231009115051.1931562-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/x86/lib')
-rw-r--r--arch/x86/lib/setjmp_32.S1
-rw-r--r--arch/x86/lib/setjmp_64.S1
2 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/lib/setjmp_32.S b/arch/x86/lib/setjmp_32.S
index 30db5f989a..5814623f94 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 d5cf99a155..bfa1521499 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