Skip to content

Commit ac456ca

Browse files
nomuranecbp3tk0v
authored andcommitted
x86/boot: Add a message about ignored early NMIs
Commit 78a509f ("x86/boot: Ignore NMIs during very early boot") added an empty handler in early boot stage to avoid boot failure due to spurious NMIs. Add a diagnostic message to show that early NMIs have occurred. [ bp: Touchups. ] [ Committer note: tested by stopping the guest really early and injecting NMIs through qemu's monitor. Result: early console in setup code Spurious early NMIs ignored: 13 ... ] Suggested-by: Borislav Petkov <bp@alien8.de> Suggested-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Jun'ichi Nomura <junichi.nomura@nec.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Link: https://lore.kernel.org/lkml/20231130103339.GCZWhlA196uRklTMNF@fat_crate.local
1 parent 9ba8ec8 commit ac456ca

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

arch/x86/boot/compressed/ident_map_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,5 +389,5 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)
389389

390390
void do_boot_nmi_trap(struct pt_regs *regs, unsigned long error_code)
391391
{
392-
/* Empty handler to ignore NMI during early boot */
392+
spurious_nmi_count++;
393393
}

arch/x86/boot/compressed/misc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct port_io_ops pio_ops;
5252

5353
memptr free_mem_ptr;
5454
memptr free_mem_end_ptr;
55+
int spurious_nmi_count;
5556

5657
static char *vidmem;
5758
static int vidport;
@@ -506,6 +507,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output)
506507
/* Disable exception handling before booting the kernel */
507508
cleanup_exception_handling();
508509

510+
if (spurious_nmi_count) {
511+
error_putstr("Spurious early NMIs ignored: ");
512+
error_putdec(spurious_nmi_count);
513+
error_putstr("\n");
514+
}
515+
509516
return output + entry_offset;
510517
}
511518

arch/x86/boot/compressed/misc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ extern char _head[], _end[];
5959
/* misc.c */
6060
extern memptr free_mem_ptr;
6161
extern memptr free_mem_end_ptr;
62+
extern int spurious_nmi_count;
6263
void *malloc(int size);
6364
void free(void *where);
6465
void __putstr(const char *s);

0 commit comments

Comments
 (0)