[PATCHv5,14/16] x86/smp: Add smp_ops.stop_this_cpu() callback
Commit Message
If the helper is defined, it is called instead of halt() to stop the CPU
at the end of stop_this_cpu() and on crash CPU shutdown.
ACPI MADT will use it to hand over the CPU to BIOS in order to be able
to wake it up again after kexec.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
arch/x86/include/asm/smp.h | 1 +
arch/x86/kernel/process.c | 20 +++++++++++++-------
arch/x86/kernel/reboot.c | 12 ++++++++----
3 files changed, 22 insertions(+), 11 deletions(-)
@@ -38,6 +38,7 @@ struct smp_ops {
int (*cpu_disable)(void);
void (*cpu_die)(unsigned int cpu);
void (*play_dead)(void);
+ void (*stop_this_cpu)(void);
void (*send_call_func_ipi)(const struct cpumask *mask);
void (*send_call_func_single_ipi)(int cpu);
@@ -835,13 +835,19 @@ void __noreturn stop_this_cpu(void *dummy)
*/
cpumask_clear_cpu(cpu, &cpus_stop_mask);
- for (;;) {
- /*
- * Use native_halt() so that memory contents don't change
- * (stack usage and variables) after possibly issuing the
- * native_wbinvd() above.
- */
- native_halt();
+ if (smp_ops.stop_this_cpu) {
+ smp_ops.stop_this_cpu();
+ unreachable();
+ } else {
+
+ for (;;) {
+ /*
+ * Use native_halt() so that memory contents don't
+ * change (stack usage and variables) after possibly
+ * issuing the native_wbinvd() above.
+ */
+ native_halt();
+ }
}
}
@@ -881,10 +881,14 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
cpu_emergency_disable_virtualization();
atomic_dec(&waiting_for_crash_ipi);
- /* Assume hlt works */
- halt();
- for (;;)
- cpu_relax();
+
+ if (smp_ops.stop_this_cpu) {
+ smp_ops.stop_this_cpu();
+ } else {
+ halt();
+ for (;;)
+ cpu_relax();
+ }
return NMI_HANDLED;
}