x86/reboot: Avoid nmi shutdown all CPUs twice
PATCH 1/1 x86/reboot: Avoid nmi shutdown all CPUs twice
For CPU with VMX feature, if there's no crash kernel loaded and crash_kexec_post_notifiers is true, then it will endup call nmi_shootdown_cpus() twice. This will crash the system because it double register the same nmi callback
The first call is:
nmi_shootdown_cpus+0x21/0xc0
kdump_nmi_shootdown_cpus+0x15/0x20
crash_smp_send_stop+0x23/0x40
__panic+0xec/0x2d0The second call is:
nmi_shootdown_cpus+0x21/0xc0
native_machine_emergency_restart+0x7d/0x270
machine_emergency_restart+0x1c/0x20
emergency_restart+0x1a/0x20
__panic+0x231/0x2d0Fixes d176720d34c7 ("x86: disable VMX on all CPUs on reboot")
Fixes 2340b62f77c7 ("kdump: forcibly disable VMX and SVM on machine_crash_shutdown()")
Signed-off-by Weinan Liu <[email protected]>
--- arch/x86/kernel/reboot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/x86/kernel/reboot.c +10 -0
@@ -837,7 +837,17 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)*/ void nmi_shootdown_cpus (nmi_shootdown_cb callback) { +static bool cpus_shutdown;unsigned long msecs; + +/* +* Only shutdown CPUs once. Double register nmi callback will crash the +* system +*/ +if (cpus_shutdown) +return ; + cpus_shutdown = true; +local_irq_disable ();/* Make a note of crashing cpu. Will be used in NMI callback. */
Signature · 1 line
2.37.1.595.g718a3a8f04-goog