FAILED: patch "[PATCH] ARM: 9488/1: smp: set current pointer in assembly before jumping into C" failed to apply to 6.1-stable tree
Subsystems (2)
Sasha Levin
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x f6e551e7d515579b952422c93415470fb672d848
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From f6e551e7d515579b952422c93415470fb672d848 Mon Sep 17 00:00:00 2001
From: Karl Mehltretter <[email protected]>
Date: Sat, 8 Aug 2026 22:08:26 +0100
Subject: [PATCH] ARM: 9488/1: smp: set current pointer in assembly before
jumping into C
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.
With current set in assembly, the set_current() call in secondary_start_kernel() is redundant. Drop it together with the function and the task argument. The hotplug resuscitate path in arch_cpu_idle_dead() needs no hand-off either, as smp_ops.cpu_die() can only return if the CPU kept its register state, TPIDRURO included.
--- arch/arm/include/asm/smp.h | 2 +- arch/arm/kernel/head-nommu.S | 1 + arch/arm/kernel/head.S | 1 + arch/arm/kernel/smp.c | 15 ++------------- 4 files changed, 5 insertions(+), 14 deletions(-)
arch/arm/include/asm/smp.h +1 -1
@@ -43,7 +43,7 @@ extern void set_smp_ipi_range(int ipi_base, int nr_ipi);* Called from platform specific assembly code, this is the * secondary CPU entry point. */ -asmlinkage void secondary_start_kernel(struct task_struct *task); +asmlinkage void secondary_start_kernel(void);/*
arch/arm/kernel/head-nommu.S +1 -0
@@ -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)
arch/arm/kernel/head.S +1 -0
@@ -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)
arch/arm/kernel/smp.c +2 -13
@@ -371,12 +371,9 @@ void __noreturn arch_cpu_idle_dead(void)*/ __asm__("mov sp, %0\n" " mov fp, #0\n" -" mov r0, %1\n" " b secondary_start_kernel" : - :"r" (task_stack_page (current) +THREAD_SIZE -8 ), -"r" (current) - :"r0" ); + :"r" (task_stack_page (current) +THREAD_SIZE -8 ));unreachable (); }
@@ -397,23 +394,15 @@ static void smp_store_cpu_info(unsigned int cpuid)check_cpu_icache_size (cpuid); } -static void set_current (struct task_struct *cur) -{ -/* Set TPIDRURO */ - asm("mcr p15, 0, %0, c13, c0, 3" ::"r" (cur) :"memory" ); -} -/* * This is the secondary CPU boot entry. We're using this CPUs * idle thread stack, but a set of temporary page tables. */ -asmlinkage void secondary_start_kernel(struct task_struct *task) +asmlinkage void secondary_start_kernel(void) {struct mm_struct *mm = &init_mm;unsigned int cpu; -set_current (task); -secondary_biglittle_init ();/*
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 ARM: 9488/1: smp: set current pointer in assembly before jumping into C
From: Karl Mehltretter <[email protected]>
[ Upstream commit f6e551e7d515579b952422c93415470fb672d848 ]
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.
With current set in assembly, the set_current() call in secondary_start_kernel() is redundant. Drop it together with the function and the task argument. The hotplug resuscitate path in arch_cpu_idle_dead() needs no hand-off either, as smp_ops.cpu_die() can only return if the CPU kept its register state, TPIDRURO included.
--- arch/arm/include/asm/smp.h | 2 +- arch/arm/kernel/head-nommu.S | 1 + arch/arm/kernel/head.S | 1 + arch/arm/kernel/smp.c | 15 ++------------- 4 files changed, 5 insertions(+), 14 deletions(-)
arch/arm/include/asm/smp.h +1 -1
@@ -43,7 +43,7 @@ extern void set_smp_ipi_range(int ipi_base, int nr_ipi);* Called from platform specific assembly code, this is the * secondary CPU entry point. */ -asmlinkage void secondary_start_kernel(struct task_struct *task); +asmlinkage void secondary_start_kernel(void);/*
arch/arm/kernel/head-nommu.S +1 -0
@@ -117,6 +117,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)
arch/arm/kernel/head.S +1 -0
@@ -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)
arch/arm/kernel/smp.c +2 -13
@@ -376,12 +376,9 @@ void arch_cpu_idle_dead(void)*/ __asm__("mov sp, %0\n" " mov fp, #0\n" -" mov r0, %1\n" " b secondary_start_kernel" : - :"r" (task_stack_page (current) +THREAD_SIZE -8 ), -"r" (current) - : "r0"); + : "r" (task_stack_page(current) + THREAD_SIZE - 8)); }#endif /* CONFIG_HOTPLUG_CPU */
@@ -400,23 +397,15 @@ static void smp_store_cpu_info(unsigned int cpuid)check_cpu_icache_size (cpuid); } -static void set_current (struct task_struct *cur) -{ -/* Set TPIDRURO */ - asm("mcr p15, 0, %0, c13, c0, 3" ::"r" (cur) :"memory" ); -} -/* * This is the secondary CPU boot entry. We're using this CPUs * idle thread stack, but a set of temporary page tables. */ -asmlinkage void secondary_start_kernel(struct task_struct *task) +asmlinkage void secondary_start_kernel(void) {struct mm_struct *mm = &init_mm;unsigned int cpu; -set_current (task); -secondary_biglittle_init ();/*
Signature · 1 line
2.53.0