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

[Xen-changelog] Debug keyhandlers for triggering an NMI and examine current NMI state.



# HG changeset patch
# User Ian.Campbell@xxxxxxxxxxxxx
# Node ID 903420e4d449433c30d9b623847b29b0c2c765bc
# Parent  e888f9b28a5b9dd2e19326f32b483e1c084704ec
Debug keyhandlers for triggering an NMI and examine current NMI state.

Add 'N' keyhandler to dump the current per CPU NMI counts and the
current NMI mask/pending status.

Add 'n' keyhandler to trigger an NMI by sending an IPI. For some
reason the destination shorthand for self is not valid when used with
the NMI delivery mode so we send the IPI to our own APIC ID
explicitly.

Signed-off-by: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>

diff -r e888f9b28a5b -r 903420e4d449 xen/arch/x86/nmi.c
--- a/xen/arch/x86/nmi.c        Fri Jan 13 14:22:36 2006
+++ b/xen/arch/x86/nmi.c        Fri Jan 13 14:59:40 2006
@@ -23,12 +23,14 @@
 #include <xen/sched.h>
 #include <xen/console.h>
 #include <xen/smp.h>
+#include <xen/keyhandler.h>
 #include <asm/current.h>
 #include <asm/mc146818rtc.h>
 #include <asm/msr.h>
 #include <asm/mpspec.h>
 #include <asm/debugger.h>
 #include <asm/div64.h>
+#include <asm/apic.h>
 
 unsigned int nmi_watchdog = NMI_NONE;
 static spinlock_t   watchdog_lock = SPIN_LOCK_UNLOCKED;
@@ -448,3 +450,26 @@
         write_watchdog_counter(NULL);
     }
 }
+
+/*
+ * For some reason the destination shorthand for self is not valid
+ * when used with the NMI delivery mode. This is documented in Tables
+ * 8-3 and 8-4 in IA32 Reference Manual Volume 3. We send the IPI to
+ * our own APIC ID explicitly which is valid.
+ */
+static void do_nmi_trigger(unsigned char key) {
+    u32 id = apic_read(APIC_ID);
+
+    printk("triggering NMI on APIC ID %x\n", id);
+
+    apic_wait_icr_idle();
+    apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(id));
+    apic_write_around(APIC_ICR, APIC_DM_NMI | APIC_INT_ASSERT);
+}
+
+static __init int register_nmi_trigger(void)
+{
+    register_keyhandler('n', do_nmi_trigger, "trigger an NMI");
+    return 0;
+}
+__initcall(register_nmi_trigger);
diff -r e888f9b28a5b -r 903420e4d449 xen/common/keyhandler.c
--- a/xen/common/keyhandler.c   Fri Jan 13 14:22:36 2006
+++ b/xen/common/keyhandler.c   Fri Jan 13 14:59:40 2006
@@ -185,6 +185,27 @@
                              bit. */
 }
 
+void do_nmi_stats(unsigned char key)
+{
+    int i;
+    struct domain *d;
+    struct vcpu *v;
+    printk("CPU\tNMI\n");
+    for_each_cpu(i)
+        printk("%3d\t%3d\n", i, nmi_count(i));
+
+    if ((d = dom0) == NULL)
+        return;
+    if ((v = d->vcpu[0]) == NULL)
+        return;
+    if (v->vcpu_flags & (VCPUF_nmi_pending|VCPUF_nmi_masked))
+        printk("dom0 vpu0: NMI %s%s\n",
+               v->vcpu_flags & VCPUF_nmi_pending ? "pending " : "",
+               v->vcpu_flags & VCPUF_nmi_masked ? "masked " : "");
+    else
+        printk("dom0 vcpu0: NMI neither pending nor masked\n");
+}
+
 #ifndef NDEBUG
 void debugtrace_key(unsigned char key)
 {
@@ -213,6 +234,7 @@
         'r', dump_runq,      "dump run queues");
     register_irq_keyhandler(
         'R', halt_machine,   "reboot machine"); 
+    register_keyhandler('N', do_nmi_stats,   "NMI statistics");
 
 #ifndef NDEBUG
     register_keyhandler(

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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