[PATCH v7 10/10] x86/nmi: Print source information with the unknown NMI console message

From: Sohil Mehta
Date: Thu Jun 12 2025 - 17:53:56 EST


The NMI-source bitmap is a useful piece of information provided by the
NMI-source reporting feature. It is very helpful for debugging unknown
NMIs, as it can pinpoint the exact source that caused the NMI.

Print the complete source bitmap along with the "unknown NMI" kernel log
message, since unexpected sources might have triggered the NMI.

Signed-off-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>
---
v7: No change.

v6: Drop the tracepoint modification part for now.

v5: New patch
---
arch/x86/kernel/nmi.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 3d2b636e9379..0b5bb20c5eb7 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -379,6 +379,9 @@ unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
pr_emerg_ratelimited("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
reason, smp_processor_id());

+ if (cpu_feature_enabled(X86_FEATURE_NMI_SOURCE))
+ pr_emerg_ratelimited("NMI-source bitmap is 0x%lx\n", fred_event_data(regs));
+
if (unknown_nmi_panic || panic_on_unrecovered_nmi)
nmi_panic(regs, "NMI: Not continuing");

--
2.43.0