x86/panic: replace smp_send_stop() with kdump friendly version in panic path
PATCH 69/102 x86/panic: replace smp_send_stop() with kdump friendly version in panic path
From: Hidehiro Kawai <[email protected]>
Subject: x86/panic: replace smp_send_stop() with kdump friendly version in panic path
Daniel Walker reported problems which happens when crash_kexec_post_notifiers kernel option is enabled
(https://lkml.org/lkml/2015/6/24/44).
In that case, smp_send_stop() is called before entering kdump routines which assume other CPUs are still online. As the result, for x86, kdump routines fail to save other CPUs' registers and disable virtualization extensions.
To fix this problem, call a new kdump friendly function, crash_smp_send_stop(), instead of the smp_send_stop() when crash_kexec_post_notifiers is enabled. crash_smp_send_stop() is a weak function, and it just call smp_send_stop(). Architecture codes should override it so that kdump can work appropriately. This patch only provides x86-specific version.
For Xen's PV kernel, just keep the current behavior.
NOTES:
- Right solution would be to place crash_smp_send_stop() before __crash_kexec() invocation in all cases and remove smp_send_stop(), but we can't do that until all architectures implement own crash_smp_send_stop()
- crash_smp_send_stop()-like work is still needed by machine_crash_shutdown() because crash_kexec() can be called without entering panic()
---
arch/x86/include/asm/kexec.h | 1 arch/x86/include/asm/smp.h | 1 arch/x86/kernel/crash.c | 22 +++++++++++++-- arch/x86/kernel/smp.c | 5 +++ kernel/panic.c | 47 ++++++++++++++++++++++++++++----- 5 files changed, 66 insertions(+), 10 deletions(-)
arch/x86/include/asm/kexec.h renamed from arch/x86/include/asm/kexec.h~x86-panic-replace-smp_send_stop-with-kdump-friendly-version-in-panic-path +1 -0
@@ -210,6 +210,7 @@ struct kexec_entry64_regs {typedef void crash_vmclear_fn (void );extern crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss; +extern void kdump_nmi_shootdown_cpus (void );#endif /* __ASSEMBLY__ */
arch/x86/include/asm/smp.h renamed from arch/x86/include/asm/smp.h~x86-panic-replace-smp_send_stop-with-kdump-friendly-version-in-panic-path +1 -0
@@ -47,6 +47,7 @@ struct smp_ops {void (*smp_cpus_done)(unsigned max_cpus);void (*stop_other_cpus)(int wait); +void (*crash_stop_other_cpus)(void );void (*smp_send_reschedule)(int cpu);int (*cpu_up)(unsigned cpu,struct task_struct *tidle);
arch/x86/kernel/crash.c renamed from arch/x86/kernel/crash.c~x86-panic-replace-smp_send_stop-with-kdump-friendly-version-in-panic-path +19 -3
@@ -133,15 +133,31 @@ static void kdump_nmi_callback(int cpu, disable_local_APIC(); } -static void kdump_nmi_shootdown_cpus (void ) +void kdump_nmi_shootdown_cpus (void ) {nmi_shootdown_cpus (kdump_nmi_callback);disable_local_APIC (); } +/* Override the weak function in kernel/panic.c */ +void crash_smp_send_stop (void ) +{ +static int cpus_stopped; + +if (cpus_stopped) +return ; + +if (smp_ops.crash_stop_other_cpus) + smp_ops.crash_stop_other_cpus (); +else +smp_send_stop (); + + cpus_stopped =1 ; +} +#else -static void kdump_nmi_shootdown_cpus (void ) +void crash_smp_send_stop (void ) {/* There are no cpus to shootdown */ }
@@ -160,7 +176,7 @@ void native_machine_crash_shutdown(struc/* The kernel is broken so disable interrupts */ local_irq_disable (); -kdump_nmi_shootdown_cpus (); +crash_smp_send_stop ();/* * VMCLEAR VMCSs loaded on this cpu if needed.
arch/x86/kernel/smp.c renamed from arch/x86/kernel/smp.c~x86-panic-replace-smp_send_stop-with-kdump-friendly-version-in-panic-path +5 -0
@@ -32,6 +32,8 @@#include <asm/nmi.h> #include <asm/mce.h> #include <asm/trace/irq_vectors.h> +#include <asm/kexec.h> +/* * Some notes on x86 processor bugs affecting SMP operation: *
@@ -342,6 +344,9 @@ struct smp_ops smp_ops = { .smp_cpus_done = native_smp_cpus_done, .stop_other_cpus = native_stop_other_cpus, +#if defined(CONFIG_KEXEC_CORE) + .crash_stop_other_cpus = kdump_nmi_shootdown_cpus, +#endif .smp_send_reschedule = native_smp_send_reschedule, .cpu_up = native_cpu_up,
kernel/panic.c renamed from kernel/panic.c~x86-panic-replace-smp_send_stop-with-kdump-friendly-version-in-panic-path +40 -7
60 lines not on this page · raw message
_