[PATCH 15/21] arm64: entry: Point SP_EL0 at the overflow stack
Will Deacon
will at kernel.org
Mon Sep 7 09:42:40 PDT 2026
With SP_EL0 now available for use in the kernel, point it at the
overflow stack so that exception entry from EL1h will later be able to
switch to the overflow stack by writing to SPSel.
Cc: Mark Rutland <mark.rutland at arm.com>
Signed-off-by: Will Deacon <will at kernel.org>
---
arch/arm64/kernel/entry.S | 2 ++
arch/arm64/kernel/head.S | 3 +++
arch/arm64/kernel/smp.c | 12 ++++++++++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index a45be0a837c8..6958ee238649 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -227,6 +227,8 @@ alternative_cb_end
mrs x21, sp_el0
ldr_this_cpu tsk, __entry_task, x20
msr tpidrro_el0, tsk
+ adr_this_cpu x19, overflow_stack + OVERFLOW_STACK_SIZE, x20
+ msr sp_el0, x19
/*
* Ensure MDSCR_EL1.SS is clear, since we can unmask debug exceptions
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index c33551ee6572..27a19e1a0ee6 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -210,6 +210,9 @@ SYM_CODE_END(preserve_boot_args)
ldr w\tmp2, [\tsk, #TSK_TI_CPU]
ldr \tmp1, [\tmp1, \tmp2, lsl #3]
set_this_cpu_offset \tmp1
+
+ adr_this_cpu \tmp1, overflow_stack + OVERFLOW_STACK_SIZE, \tmp2
+ msr sp_el0, \tmp1
.endm
/*
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 702dee8d0db5..4c122d6598de 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -51,6 +51,7 @@
#include <asm/processor.h>
#include <asm/smp_plat.h>
#include <asm/sections.h>
+#include <asm/stacktrace.h>
#include <asm/tlbflush.h>
#include <asm/ptrace.h>
#include <asm/virt.h>
@@ -448,8 +449,15 @@ void __init smp_cpus_done(unsigned int max_cpus)
static void __init set_boot_cpu_offset(void)
{
- asm volatile("msr tpidr_el1, %0"
- :: "r" (per_cpu_offset(0)) : "memory");
+ u64 ovf_sp = (u64)raw_cpu_ptr(overflow_stack) + OVERFLOW_STACK_SIZE;
+
+ asm volatile(
+ " msr tpidr_el1, %1\n"
+ " add %0, %0, %1\n"
+ " msr sp_el0, %0" /* Update the overflow stack pointer */
+ : "+r" (ovf_sp)
+ : "r" (per_cpu_offset(0))
+ : "memory");
}
void __init smp_prepare_boot_cpu(void)
--
2.55.0.979.g7e5102b832-goog
More information about the linux-arm-kernel
mailing list