From: Petr Tesarik <ptesarik@suse.cz>
Subject: hpwdt: handle NMI_SERR and NMI_IO_CHECK
Patch-mainline: v3.5-rc5
References: bnc#777746

hpwdt: handle NMI_SERR and NMI_IO_CHECK

In discussions with Thomas Mingarelli about hpwdt, he explained
to me some issues they were some when using their virtual NMI
button to test the hpwdt driver.

It turns out the virtual NMI button used on HP's machines do no
send unknown NMIs but instead send IO_CHK NMIs.  The way the
kernel code is written, the hpwdt driver can not register itself
against that type of NMI and therefore can not successfully
capture system information before panicking.

To solve this I created two new NMI die chains to allow driver to
register against the IO_CHK and SERR NMIs.  Or in the hpwdt all
three (if you include unknown NMIs too).

The change is straightforward and just mimics what the unknown
NMI does.

NOTE: Mainline commit added two NMI queues to accomplish the job,
because it was implemented after the rewrite of the NMI code.
SLES11 still uses die chains, but the idea is the same.

Reported-and-tested-by: Thomas Mingarelli <thomas.mingarelli@hp.com>
Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/1333051877-15755-3-git-send-email-dzickus@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Automatically created from "patches.drivers/hpwdt_handle-NMI_SERR-and-NMI_IO_CHECK" by xen-port-patches.py

--- sle11sp3.orig/arch/x86/kernel/traps-xen.c	2012-10-19 12:29:44.000000000 +0200
+++ sle11sp3/arch/x86/kernel/traps-xen.c	2013-02-19 15:53:18.000000000 +0100
@@ -321,6 +321,10 @@ __setup("unknown_nmi_panic", setup_unkno
 static notrace __kprobes void
 pci_serr_error(unsigned char reason, struct pt_regs *regs)
 {
+	if (notify_die(DIE_NMISERR, "nmi_serr", regs, reason, 2, SIGINT) ==
+			NOTIFY_STOP)
+		return;
+
 	pr_emerg("NMI: PCI system error (SERR) for reason %02x on CPU %d.\n",
 		 reason, smp_processor_id());
 
@@ -347,6 +351,10 @@ pci_serr_error(unsigned char reason, str
 static notrace __kprobes void
 io_check_error(unsigned char reason, struct pt_regs *regs)
 {
+	if (notify_die(DIE_NMIIOCK, "nmi_iock", regs, reason, 2, SIGINT) ==
+			NOTIFY_STOP)
+		return;
+
 	pr_emerg(
 	"NMI: IOCK error (debug interrupt?) for reason %02x on CPU %d.\n",
 		 reason, smp_processor_id());
