Re: [PATCH v2 15/21] arm64: entry: Point SP_EL0 at the overflow stack

From: Catalin Marinas

Date: Mon Sep 21 2026 - 12:10:55 EST


On Fri, Sep 18, 2026 at 05:13:59PM +0100, Will Deacon wrote:
> 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;

raw_cpu_ptr() is using tpidr_el1 and we haven't initialised it yet.
Actually, I think we get away with it because in head.S we initialise it
to 0 (__per_cpu_offsets[0] is still zero at that point for the boot CPU).

> +
> + 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");

Even if this is intentional and we rely in TPIDR_EL1 to be 0, it feels
weird to add the offset to raw_cpu_ptr().

Could we just do (untested):

unsigned long ovf_sp = (unsigned long)per_cpu_ptr(overflow_stack, 0) +
OVERFLOW_STACK_SIZE;

asm volatile(
" msr tpidr_el1, %0\n"
" msr sp_el0, %1"
:
: "r" (per_cpu_offset(0)), "r" (ovf_sp)
: "memory");

with no further arithmetics in asm.

--
Catalin