From: Weinan Liu <wnliu@google.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Weinan Liu <wnliu@google.com>
Subject: [PATCH] x86/reboot: Avoid nmi shutdown all CPUs twice
Date: Mon, 15 Aug 2022 08:45:47 +0000 [thread overview]
Message-ID: <20220815084547.864400-1-wnliu@google.com> (raw)
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/0x2d0
The 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/0x2d0
Fixes: 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 <wnliu@google.com>
---
arch/x86/kernel/reboot.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index c3636ea4aa71..f9890e299750 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -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. */
--
2.37.1.595.g718a3a8f04-goog
reply other threads:[~2022-08-15 8:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220815084547.864400-1-wnliu@google.com \
--to=wnliu@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®