All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH repost] x86/boot: Add a message about ignored early NMIs
@ 2024-01-12 11:13 NOMURA JUNICHI(野村 淳一)
  2024-01-12 12:06 ` kirill.shutemov
  0 siblings, 1 reply; 9+ messages in thread
From: NOMURA JUNICHI(野村 淳一) @ 2024-01-12 11:13 UTC (permalink / raw)
  To: mingo@redhat.com, tglx@linutronix.de, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org
  Cc: hpa@zytor.com, kirill.shutemov@linux.intel.com, ardb@kernel.org,
	david@redhat.com, nikunj@amd.com, thomas.lendacky@amd.com,
	debarbos@redhat.com, jlelli@redhat.com, lgoncalv@redhat.com,
	dzickus@redhat.com, linux-kernel@vger.kernel.org

Commit 78a509fba9c9 ("x86/boot: Ignore NMIs during very early boot") added
empty handler in early boot stage to avoid boot failure by spurious NMIs.

Add a diagnostic message in case we need to know whether early NMIs have
occurred and/or what happened to them.

Signed-off-by: Jun'ichi Nomura <junichi.nomura@nec.com>
Suggested-by: Borislav Petkov <bp@alien8.de>
Suggested-by: H. Peter Anvin <hpa@zytor.com>
Link: https://lore.kernel.org/lkml/20231130103339.GCZWhlA196uRklTMNF@fat_crate.local/

diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c
--- a/arch/x86/boot/compressed/ident_map_64.c
+++ b/arch/x86/boot/compressed/ident_map_64.c
@@ -387,7 +387,10 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)
 	kernel_add_identity_map(address, end);
 }
 
+extern int spurious_nmi_count;
+
 void do_boot_nmi_trap(struct pt_regs *regs, unsigned long error_code)
 {
 	/* Empty handler to ignore NMI during early boot */
+	spurious_nmi_count++;
 }
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -357,6 +357,8 @@ unsigned long decompress_kernel(unsigned char *outbuf, unsigned long virt_addr,
 	return entry;
 }
 
+int spurious_nmi_count;
+
 /*
  * The compressed kernel image (ZO), has been moved so that its position
  * is against the end of the buffer used to hold the uncompressed kernel
@@ -493,6 +495,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output)
 	/* Disable exception handling before booting the kernel */
 	cleanup_exception_handling();
 
+	if (spurious_nmi_count) {
+		error_putstr("Spurious early NMI ignored. Number of NMIs: 0x");
+		error_puthex(spurious_nmi_count);
+		error_putstr("\n");
+	}
+
 	return output + entry_offset;
 }
 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-02-01 17:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-12 11:13 [PATCH repost] x86/boot: Add a message about ignored early NMIs NOMURA JUNICHI(野村 淳一)
2024-01-12 12:06 ` kirill.shutemov
2024-01-15  8:57   ` [PATCH v2] " NOMURA JUNICHI(野村 淳一)
2024-01-15 10:14     ` kirill.shutemov
2024-01-23 11:26     ` Borislav Petkov
2024-01-24 11:44       ` NOMURA JUNICHI(野村 淳一)
2024-01-25  2:00         ` H. Peter Anvin
2024-01-26  2:15           ` NOMURA JUNICHI(野村 淳一)
2024-02-01 17:22             ` H. Peter Anvin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.