cpu/hotplug: Reset task stack state in _cpu_up()

JIRA: https://issues.redhat.com/browse/RHEL-1536
Conflicts: Context differences due to not having 6f0621238b7e
    (" cpu/hotplug: Add CPU state tracking and synchronization")

commit 6d712b9b3a58018259fb40ddd498d1f7dfa1f4ec
Author: David Woodhouse <dwmw@amazon.co.uk>
Date:   Fri May 12 23:07:43 2023 +0200

    cpu/hotplug: Reset task stack state in _cpu_up()

    Commit dce1ca0525bf ("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

Signed-off-by: Phil Auld <pauld@redhat.com>
This commit is contained in:
Phil Auld 2023-09-05 11:32:02 -04:00
parent 3363c6964a
commit 1662cc19b7
1 changed files with 6 additions and 6 deletions

View File

@ -580,12 +580,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.
@ -1336,6 +1330,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;