>From f91d4f1cc04d7955587aac3f919fd6696a648f5f Mon Sep 17 00:00:00 2001 From: Sean Christopherson Date: Tue, 3 Sep 2024 10:14:27 -0700 Subject: [PATCH 1/3] x86/reboot: Allow "blindly" calling nmi_shootdown_cpus() without a callback Warn if nmi_shootdown_cpus() is called after the crash IPI has been issued if and only if the caller wants to run a specific callback, and drop the check nmi_shootdown_cpus_on_restart() whose sole purpose was to avoid triggering the warning. This will allow removing the "on restart" variant. Note, the only caller of nmi_shootdown_cpus_on_restart() unconditionally disables IRQs, i.e. doubling down on disabling IRQs when a crash IPI has already been issued doesn't affect the resulting functionality. Signed-off-by: Sean Christopherson --- arch/x86/kernel/reboot.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 615922838c51..25f68952af57 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -915,10 +915,14 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback) /* * Avoid certain doom if a shootdown already occurred; re-registering * the NMI handler will cause list corruption, modifying the callback - * will do who knows what, etc... + * will do who knows what, etc... Blindly attempting a shootdown is + * allowed if the caller's goal is purely to ensure a shootdown occurs, + * i.e. if the caller doesn't want to run a specific callback. */ - if (WARN_ON_ONCE(crash_ipi_issued)) + if (crash_ipi_issued) { + WARN_ON_ONCE(callback); return; + } /* Make a note of crashing cpu. Will be used in NMI callback. */ crashing_cpu = safe_smp_processor_id(); @@ -956,8 +960,7 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback) static inline void nmi_shootdown_cpus_on_restart(void) { - if (!crash_ipi_issued) - nmi_shootdown_cpus(NULL); + nmi_shootdown_cpus(NULL); } /* base-commit: 8cf0b93919e13d1e8d4466eb4080a4c4d9d66d7b -- 2.47.0.rc1.288.g06298d1525-goog