Skip to content

Commit 6d712b9

Browse files
dwmw2Peter Zijlstra
authored andcommitted
cpu/hotplug: Reset task stack state in _cpu_up()
Commit dce1ca0 ("sched/scs: Reset task stack state in bringup_cpu()") ensured that the shadow call stack and KASAN poisoning were removed from a CPU's stack each time that CPU is brought up, not just once. This is not incorrect. However, with parallel bringup the idle thread setup will happen at a different step. As a consequence the cleanup in bringup_cpu() would be too late. Move the SCS/KASAN cleanup to the generic _cpu_up() function instead, which already ensures that the new CPU's stack is available, purely to allow for early failure. This occurs when the CPU to be brought up is in the CPUHP_OFFLINE state, which should correctly do the cleanup any time the CPU has been taken down to the point where such is needed. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Tested-by: Mark Rutland <mark.rutland@arm.com> Tested-by: Michael Kelley <mikelley@microsoft.com> Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name> Tested-by: Helge Deller <deller@gmx.de> # parisc Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com> # Steam Deck Link: https://lore.kernel.org/r/20230512205257.027075560@linutronix.de
1 parent bc088f9 commit 6d712b9

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

kernel/cpu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,12 +770,6 @@ static int bringup_cpu(unsigned int cpu)
770770
if (!cpuhp_can_boot_ap(cpu))
771771
return -EAGAIN;
772772

773-
/*
774-
* Reset stale stack state from the last time this CPU was online.
775-
*/
776-
scs_task_reset(idle);
777-
kasan_unpoison_task_stack(idle);
778-
779773
/*
780774
* Some architectures have to walk the irq descriptors to
781775
* setup the vector space for the cpu which comes online.
@@ -1587,6 +1581,12 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target)
15871581
ret = PTR_ERR(idle);
15881582
goto out;
15891583
}
1584+
1585+
/*
1586+
* Reset stale stack state from the last time this CPU was online.
1587+
*/
1588+
scs_task_reset(idle);
1589+
kasan_unpoison_task_stack(idle);
15901590
}
15911591

15921592
cpuhp_tasks_frozen = tasks_frozen;

0 commit comments

Comments
 (0)