x86: avoid deadlock after a PCI SERR NMI
authorDavid Vrabel <david.vrabel@citrix.com>
Thu, 2 Feb 2012 15:28:58 +0000 (15:28 +0000)
committerDavid Vrabel <david.vrabel@citrix.com>
Thu, 2 Feb 2012 15:28:58 +0000 (15:28 +0000)
If a PCI System Error (SERR) is asserted it causes an NMI. If this NMI
occurs while the CPU is in printk() then Xen may deadlock as
pci_serr_error() calls console_force_unlock() which screws up the
console lock.

printk() isn't safe to call from NMI context so defer the diagnostic
message to a softirq.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Tested-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen/arch/x86/traps.c
xen/include/asm-x86/softirq.h

index 2057ac5c2e4f86369b9e11b7a08c8d98dae11708..286f1a2954c25ade18e38d5a1e55cb79159d26db 100644 (file)
@@ -3173,6 +3173,11 @@ static void nmi_mce_softirq(void)
     st->vcpu = NULL;
 }
 
+static void pci_serr_softirq(void)
+{
+    printk("\n\nNMI - PCI system error (SERR)\n");
+}
+
 void async_exception_cleanup(struct vcpu *curr)
 {
     int trap;
@@ -3259,10 +3264,11 @@ static void nmi_dom0_report(unsigned int reason_idx)
 
 static void pci_serr_error(struct cpu_user_regs *regs)
 {
-    console_force_unlock();
-    printk("\n\nNMI - PCI system error (SERR)\n");
-
     outb((inb(0x61) & 0x0f) | 0x04, 0x61); /* clear-and-disable the PCI SERR error line. */
+
+    /* Would like to print a diagnostic here but can't call printk()
+       from NMI context -- raise a softirq instead. */
+    raise_softirq(PCI_SERR_SOFTIRQ);
 }
 
 static void io_check_error(struct cpu_user_regs *regs)
@@ -3563,6 +3569,7 @@ void __init trap_init(void)
     cpu_init();
 
     open_softirq(NMI_MCE_SOFTIRQ, nmi_mce_softirq);
+    open_softirq(PCI_SERR_SOFTIRQ, pci_serr_softirq);
 }
 
 long register_guest_nmi_callback(unsigned long address)
index 43878039100f93c9d2a8ff3fd5e9434eef05ef91..9d8e2e14ca9fa6d00f3395d30c4adf3b823efca0 100644 (file)
@@ -6,6 +6,7 @@
 #define VCPU_KICK_SOFTIRQ      (NR_COMMON_SOFTIRQS + 2)
 
 #define MACHINE_CHECK_SOFTIRQ  (NR_COMMON_SOFTIRQS + 3)
-#define NR_ARCH_SOFTIRQS       4
+#define PCI_SERR_SOFTIRQ       (NR_COMMON_SOFTIRQS + 4)
+#define NR_ARCH_SOFTIRQS       5
 
 #endif /* __ASM_SOFTIRQ_H__ */