Skip to content

Commit 26ba735

Browse files
kirylbp3tk0v
authored andcommitted
x86/smp: Add smp_ops.stop_this_cpu() callback
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 <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Acked-by: Kai Huang <[email protected]> Tested-by: Tao Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent db09368 commit 26ba735

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

arch/x86/include/asm/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct smp_ops {
3535
int (*cpu_disable)(void);
3636
void (*cpu_die)(unsigned int cpu);
3737
void (*play_dead)(void);
38+
void (*stop_this_cpu)(void);
3839

3940
void (*send_call_func_ipi)(const struct cpumask *mask);
4041
void (*send_call_func_single_ipi)(int cpu);

arch/x86/kernel/process.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,13 @@ void __noreturn stop_this_cpu(void *dummy)
835835
*/
836836
cpumask_clear_cpu(cpu, &cpus_stop_mask);
837837

838+
#ifdef CONFIG_SMP
839+
if (smp_ops.stop_this_cpu) {
840+
smp_ops.stop_this_cpu();
841+
unreachable();
842+
}
843+
#endif
844+
838845
for (;;) {
839846
/*
840847
* Use native_halt() so that memory contents don't change

arch/x86/kernel/reboot.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,12 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
880880
cpu_emergency_disable_virtualization();
881881

882882
atomic_dec(&waiting_for_crash_ipi);
883+
884+
if (smp_ops.stop_this_cpu) {
885+
smp_ops.stop_this_cpu();
886+
unreachable();
887+
}
888+
883889
/* Assume hlt works */
884890
halt();
885891
for (;;)

0 commit comments

Comments
 (0)