- Subject: [PATCH 3/3] boot: add early NMI counter
- From: Fernando Luis Vázquez Cao <fernando@xxxxxxxxxxxxx>
- Date: Fri, 09 Mar 2012 19:01:52 +0900
- Cc: Don Zickus <dzickus@xxxxxxxxxx>, akpm@xxxxxxxxxxxxxxxxxxxx, linux-tip-commits@xxxxxxxxxxxxxxx, Yinghai Lu <yinghai@xxxxxxxxxx>, kexec@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, mingo@xxxxxxxxxx, hpa@xxxxxxxxx, tglx@xxxxxxxxxxxxx, torvalds@xxxxxxxxxxxxxxxxxxxx, mingo@xxxxxxx, vgoyal@xxxxxxxxxx
- In-reply-to: <4F59D380.6040404@oss.ntt.co.jp>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
Subject: [PATCH 3/3] boot: add early NMI counter
From: Fernando Luis Vazquez Cao <fernando@xxxxxxxxxxxxx>
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, whose count is moved over to
the per-cpu NMI counter before the kernel frees the init sections.
Signed-off-by: Fernando Luis Vazquez Cao <fernando@xxxxxxxxxxxxx>
---
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-09 17:48:04.547492663 +0900
+++ linux-3.3-rc6/arch/x86/include/asm/processor.h 2012-03-09 18:37:32.060194673 +0900
@@ -402,6 +402,11 @@ 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);
+/*
+ * early_nmi_count is in the .init.text ELF section so it can only be accessed
+ * before the init sections are freed by the kernel.
+ */
+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-09 18:36:18.051281524 +0900
+++ linux-3.3-rc6/arch/x86/kernel/head_64.S 2012-03-09 18:38:47.673129036 +0900
@@ -340,6 +340,7 @@ early_exception_handler:
jmp 1b
early_nmi_handler:
+ incl early_nmi_count(%rip)
iretq
#ifdef CONFIG_EARLY_PRINTK
@@ -351,6 +352,9 @@ early_idt_msg:
early_idt_ripmsg:
.asciz "RIP %s\n"
#endif /* CONFIG_EARLY_PRINTK */
+ .globl early_nmi_count
+early_nmi_count:
+ .long 0
.previous
#define NEXT_PAGE(name) \
diff -urNp linux-3.3-rc6-orig/arch/x86/kernel/traps.c linux-3.3-rc6/arch/x86/kernel/traps.c
--- linux-3.3-rc6-orig/arch/x86/kernel/traps.c 2012-03-09 17:48:04.567492912 +0900
+++ linux-3.3-rc6/arch/x86/kernel/traps.c 2012-03-09 18:39:23.665574123 +0900
@@ -719,6 +719,7 @@ void __init trap_init(void)
x86_init.irqs.trap_init();
#ifdef CONFIG_X86_64
+ percpu_add(irq_stat.__nmi_count, early_nmi_count);
memcpy(&nmi_idt_table, &idt_table, IDT_ENTRIES * 16);
set_nmi_gate(1, &debug);
set_nmi_gate(3, &int3);
[Linux USB Devel]
[Linux Video &Media]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Free Online Dating]
[Linux Kernel]
[Linux SCSI]
[XFree86]