From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Subject: [PATCH 2/2] DO NOT APPLY - debugging code to lock a pcpu in an NMI loop
Date: Tue, 24 Sep 2013 20:56:53 +0100 [thread overview]
Message-ID: <1380052613-3837-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1380052613-3837-1-git-send-email-andrew.cooper3@citrix.com>
Should be used in combination with the regular NMI watchdog
---
xen/arch/x86/crash.c | 32 ++++++++++++++++++++++++++++++++
xen/arch/x86/x86_64/entry.S | 8 ++++++++
2 files changed, 40 insertions(+)
diff --git a/xen/arch/x86/crash.c b/xen/arch/x86/crash.c
index 5f0f07c..724fc17 100644
--- a/xen/arch/x86/crash.c
+++ b/xen/arch/x86/crash.c
@@ -207,6 +207,38 @@ void machine_crash_shutdown(void)
arch_get_pfn_to_mfn_frame_list_list(dom0);
}
+void __attribute__((noreturn)) do_nmi_loop(struct cpu_user_regs *regs)
+{
+ unsigned int cpu = smp_processor_id();
+ printk("In NMI wedge on cpu%d\n Spinning forever...", cpu);
+ for ( ; ; )
+ halt();
+}
+
+void nmi_loop(void);
+static void nmi_wedge(unsigned char key)
+{
+ unsigned int cpu = smp_processor_id();
+
+ printk("'%c' pressed -> Wedging cpu%d in NMI loop\n", key, cpu);
+
+ _update_gate_addr_lower(&idt_tables[cpu][TRAP_nmi], &nmi_loop);
+}
+
+static struct keyhandler nmi_wedge_keyhandler = {
+ .diagnostic = 1,
+ .u.fn = nmi_wedge,
+ .desc = "Wedge cpu in NMI loop"
+};
+
+static int __init nmi_wedge_key_init(void)
+{
+ printk("Installing NMI wedge keyhandler\n");
+ register_keyhandler('1', &nmi_wedge_keyhandler);
+ return 0;
+}
+__initcall(nmi_wedge_key_init);
+
/*
* Local variables:
* mode: C
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index f64e871..18b77f4 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -666,6 +666,14 @@ ENTRY(nmi_crash)
callq do_nmi_crash /* Does not return */
ud2
+ENTRY(nmi_loop)
+ pushq $0
+ movl $TRAP_nmi,4(%rsp)
+ SAVE_ALL
+ movq %rsp,%rdi
+ callq do_nmi_loop /* Does not return */
+ ud2
+
ENTRY(machine_check)
pushq $0
movl $TRAP_machine_check,4(%rsp)
--
1.7.10.4
next prev parent reply other threads:[~2013-09-24 19:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-24 19:56 [PATCH 1/2] x86/crash: Indicate how well nmi_shootdown_cpus() managed to do Andrew Cooper
2013-09-24 19:56 ` Andrew Cooper [this message]
2013-09-25 5:56 ` Keir Fraser
2013-09-25 7:35 ` Jan Beulich
2013-09-25 10:22 ` [Patch v2] " Andrew Cooper
2013-09-25 11:41 ` Keir Fraser
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=1380052613-3837-2-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.org \
/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).