From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xensource.com
Cc: David Vrabel <david.vrabel@citrix.com>
Subject: [PATCH] x86: avoid deadlock after a PCI SERR NMI
Date: Wed, 1 Feb 2012 13:02:16 +0000 [thread overview]
Message-ID: <1328101336-9370-1-git-send-email-david.vrabel@citrix.com> (raw)
From: David Vrabel <david.vrabel@citrix.com>
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>
---
xen/arch/x86/traps.c | 13 ++++++++++---
xen/include/asm-x86/softirq.h | 3 ++-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index b6f7b9a..35c17f2 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -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)
diff --git a/xen/include/asm-x86/softirq.h b/xen/include/asm-x86/softirq.h
index 4387803..9d8e2e1 100644
--- a/xen/include/asm-x86/softirq.h
+++ b/xen/include/asm-x86/softirq.h
@@ -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__ */
--
1.7.2.5
reply other threads:[~2012-02-01 13:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328101336-9370-1-git-send-email-david.vrabel@citrix.com \
--to=david.vrabel@citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).