Messages in this thread | | | Date | Wed, 29 Mar 2023 12:09:59 +0100 | Subject | Re: [PATCH v17 2/8] cpu/hotplug: Reset task stack state in _cpu_up() | From | Usama Arif <> |
| |
On 28/03/2023 20:57, Usama Arif wrote: > From: David Woodhouse <dwmw@amazon.co.uk> > > Commit dce1ca0525bf ("sched/scs: Reset task stack state in bringup_cpu()") > ensured that the shadow call stack was reset and KASAN poisoning removed > from a CPU's stack each time that CPU is brought up, not just once. > > This is not incorrect. However, with parallel bringup, an architecture > may obtain the idle thread for a new CPU from a pre-bringup stage, by > calling idle_thread_get() for itself. This would mean that 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> > Reviewed-by: Mark Rutland <mark.rutland@arm.com> > Tested-by: Mark Rutland <mark.rutland@arm.com> [arm64]
Forgot to include my sign-off. Thanks David for pointing it out.
Signed-off-by: Usama Arif <usama.arif@bytedance.com>
> --- > kernel/cpu.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/kernel/cpu.c b/kernel/cpu.c > index 6c0a92ca6bb5..43e0a77f21e8 100644 > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -591,12 +591,6 @@ static int bringup_cpu(unsigned int cpu) > struct task_struct *idle = idle_thread_get(cpu); > int ret; > > - /* > - * Reset stale stack state from the last time this CPU was online. > - */ > - scs_task_reset(idle); > - kasan_unpoison_task_stack(idle); > - > /* > * Some architectures have to walk the irq descriptors to > * setup the vector space for the cpu which comes online. > @@ -1383,6 +1377,12 @@ static int _cpu_up(unsigned int cpu, int tasks_frozen, enum cpuhp_state target) > ret = PTR_ERR(idle); > goto out; > } > + > + /* > + * Reset stale stack state from the last time this CPU was online. > + */ > + scs_task_reset(idle); > + kasan_unpoison_task_stack(idle); > } > > cpuhp_tasks_frozen = tasks_frozen;
| |