[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/2] DO NOT APPLY - debugging code to lock a pcpu in an NMI loop



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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.