Skip to contentSkip to conversation

x86/boot: Add a message about ignored early NMIs

PATCH New NOMURA JUNICHI(野村 淳一) 1 participant 1 message Jan 11, 2024 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/boot: Add a message about ignored early NMIs

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.

arch/x86/boot/compressed/ident_map_64.c +3 -0
@@ -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++;
  }
arch/x86/boot/compressed/misc.c +8 -0
@@ -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;
  }