Subject: [PATCH] boot: add early NMI counter From: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> We currently ignore early NMIs but it would be nice to be able to know whether they actually occurred. This patch adds an early NMI counter and exports it trough /proc/interrupts with the name of ENM (Early NMI). Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp> --- diff -urNp linux-3.3-rc6-orig/arch/x86/include/asm/processor.h linux-3.3-rc6/arch/x86/include/asm/processor.h --- linux-3.3-rc6-orig/arch/x86/include/asm/processor.h 2012-03-07 15:49:01.826241682 +0900 +++ linux-3.3-rc6/arch/x86/include/asm/processor.h 2012-03-07 18:52:27.668054122 +0900 @@ -402,6 +402,7 @@ DECLARE_PER_CPU(char *, irq_stack_ptr); DECLARE_PER_CPU(unsigned int, irq_count); extern unsigned long kernel_eflags; extern asmlinkage void ignore_sysret(void); +extern unsigned int early_nmi_count; #else /* X86_64 */ #ifdef CONFIG_CC_STACKPROTECTOR /* diff -urNp linux-3.3-rc6-orig/arch/x86/kernel/head_64.S linux-3.3-rc6/arch/x86/kernel/head_64.S --- linux-3.3-rc6-orig/arch/x86/kernel/head_64.S 2012-03-07 18:51:17.583160114 +0900 +++ linux-3.3-rc6/arch/x86/kernel/head_64.S 2012-03-07 18:54:37.205699422 +0900 @@ -327,6 +327,7 @@ early_exception_handler: jmp 1b early_nmi_handler: + incl early_nmi_count(%rip) # exported as ENM in /proc/interrupts iretq #ifdef CONFIG_EARLY_PRINTK @@ -340,6 +341,10 @@ early_idt_ripmsg: #endif /* CONFIG_EARLY_PRINTK */ .previous + .globl early_nmi_count +early_nmi_count: + .long 0 + #define NEXT_PAGE(name) \ .balign PAGE_SIZE; \ ENTRY(name) diff -urNp linux-3.3-rc6-orig/arch/x86/kernel/irq.c linux-3.3-rc6/arch/x86/kernel/irq.c --- linux-3.3-rc6-orig/arch/x86/kernel/irq.c 2012-03-07 15:49:01.838241839 +0900 +++ linux-3.3-rc6/arch/x86/kernel/irq.c 2012-03-07 18:55:14.078179448 +0900 @@ -125,6 +125,7 @@ int arch_show_interrupts(struct seq_file #if defined(CONFIG_X86_IO_APIC) seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count)); #endif + seq_printf(p, "%*s: %10u\n", prec, "ENM", early_nmi_count); return 0; }