Commit ac456ca0 authored by NOMURA JUNICHI(野村 淳一)'s avatar NOMURA JUNICHI(野村 淳一) Committed by Borislav Petkov (AMD)

x86/boot: Add a message about ignored early NMIs

Commit

  78a509fb ("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: default avatarBorislav Petkov <bp@alien8.de>
Suggested-by: default avatarH. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarJun'ichi Nomura <junichi.nomura@nec.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://lore.kernel.org/lkml/20231130103339.GCZWhlA196uRklTMNF@fat_crate.local
parent 9ba8ec8e
...@@ -389,5 +389,5 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -389,5 +389,5 @@ void do_boot_page_fault(struct pt_regs *regs, unsigned long error_code)
void do_boot_nmi_trap(struct pt_regs *regs, unsigned long error_code) void do_boot_nmi_trap(struct pt_regs *regs, unsigned long error_code)
{ {
/* Empty handler to ignore NMI during early boot */ spurious_nmi_count++;
} }
...@@ -52,6 +52,7 @@ struct port_io_ops pio_ops; ...@@ -52,6 +52,7 @@ struct port_io_ops pio_ops;
memptr free_mem_ptr; memptr free_mem_ptr;
memptr free_mem_end_ptr; memptr free_mem_end_ptr;
int spurious_nmi_count;
static char *vidmem; static char *vidmem;
static int vidport; static int vidport;
...@@ -506,6 +507,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output) ...@@ -506,6 +507,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output)
/* Disable exception handling before booting the kernel */ /* Disable exception handling before booting the kernel */
cleanup_exception_handling(); cleanup_exception_handling();
if (spurious_nmi_count) {
error_putstr("Spurious early NMIs ignored: ");
error_putdec(spurious_nmi_count);
error_putstr("\n");
}
return output + entry_offset; return output + entry_offset;
} }
......
...@@ -59,6 +59,7 @@ extern char _head[], _end[]; ...@@ -59,6 +59,7 @@ extern char _head[], _end[];
/* misc.c */ /* misc.c */
extern memptr free_mem_ptr; extern memptr free_mem_ptr;
extern memptr free_mem_end_ptr; extern memptr free_mem_end_ptr;
extern int spurious_nmi_count;
void *malloc(int size); void *malloc(int size);
void free(void *where); void free(void *where);
void __putstr(const char *s); void __putstr(const char *s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment