[PATCH] ARM: smp: set current pointer in assembly before jumping into C

Ard Biesheuvel ardb at kernel.org
Sat Aug 1 05:46:25 PDT 2026


Hi Karl,

On Sat, 18 Jul 2026, at 11:16, Karl Mehltretter wrote:
> With CONFIG_KCOV_INSTRUMENT_ALL=y, secondary CPUs fail to come online
> on ARMv6K/ARMv7 SMP:
>
>   CPU1: failed to boot: -38
>
> The compiler inserts a call to __sanitizer_cov_trace_pc() at the entry
> of secondary_start_kernel(), before set_current(task). The KCOV hook
> dereferences current while TPIDRURO is still uninitialized, causing a
> data abort before cpu_init() has installed the exception stacks. The
> secondary CPU consequently never completes startup.
>
> Initialize current in the secondary assembly handoff, as
> __mmap_switched already does for the boot CPU.
>
> Fixes: 50596b7559bf ("ARM: smp: Store current pointer in TPIDRURO 
> register if available")
> Cc: stable at vger.kernel.org
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Karl Mehltretter <kmehltretter at gmail.com>
> ---
> Tested on QEMU vexpress-a15 (mainline and v6.12) and
> realview-eb-mpcore with and without CONFIG_KCOV_INSTRUMENT_ALL.
>
> The head-nommu.S change is untested because no currently reachable
> Kconfig combination enables non-MMU SMP.
>
> The redundant set_current(task) is retained to keep the fix minimal.
>

Please drop the call and the entire function: no need to keep around
redundant code.


>  arch/arm/kernel/head-nommu.S | 1 +
>  arch/arm/kernel/head.S       | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
> index b9d6818f1ee1..f80bbfbd3a6f 100644
> --- a/arch/arm/kernel/head-nommu.S
> +++ b/arch/arm/kernel/head-nommu.S
> @@ -116,6 +116,7 @@ ENTRY(secondary_startup)
>  	ldr	r7, __secondary_data		@ reload r7
>  	ldr	sp, [r7, #12]			@ set up the stack pointer
>  	ldr	r0, [r7, #16]			@ set up task pointer
> +	set_current r0, r1
>  	mov	fp, #0
>  	b	secondary_start_kernel
>  ENDPROC(secondary_startup)
> diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
> index f22c50d4bd41..a22403a629ef 100644
> --- a/arch/arm/kernel/head.S
> +++ b/arch/arm/kernel/head.S
> @@ -442,6 +442,7 @@ ENTRY(__secondary_switched)
>  	adr_l	r7, secondary_data + 12		@ get secondary_data.stack
>  	ldr	sp, [r7]
>  	ldr	r0, [r7, #4]			@ get secondary_data.task
> +	set_current r0, r1
>  	mov	fp, #0
>  	b	secondary_start_kernel
>  ENDPROC(__secondary_switched)
> --
> 2.43.0



More information about the linux-arm-kernel mailing list