Skip to contentSkip to conversation

dom0 state dump

RFC PATCH New Jan Beulich 1 participant 1 message Jun 12, 2008

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 dom0 state dump

Since xenctx cannot (for obvious reasons) display the context of dom0's vCPU-s, here are the beginnings of a console based mechanism to achieve the same (useful if dom0 hangs with one or more de-scheduled vCPU-s). The stack handling obviously needs improvement, but the register context should come out fine in all cases.

xen/arch/x86/traps.c +9 -0
Index: 2008-06-12/xen/arch/x86/traps.c
===================================================================
@@ -331,6 +331,15 @@ void show_execution_state(struct cpu_use
     show_stack(regs);
 }
 
+void vcpu_show_execution_state(struct vcpu *v)
+{
+    vcpu_show_registers(v);
+    /* XXX Should rather map the guest's top stack page here... */
+    if ( v->domain == current->domain &&
+         guest_kernel_mode(v, &v->arch.guest_context.user_regs) )
+        show_guest_stack(&v->arch.guest_context.user_regs);
+}
+
 char *trapstr(int trapnr)
 {
     static char *strings[] = { 
xen/arch/x86/x86_32/traps.c +38 -15

71 lines not on this page · raw message

xen/arch/x86/x86_64/traps.c +48 -22

88 lines not on this page · raw message

xen/common/keyhandler.c +26 -0
Index: 2008-06-12/xen/common/keyhandler.c
===================================================================
@@ -130,6 +130,29 @@ static void dump_registers(unsigned char
     printk("\n");
 }
 
+static void dump_dom0_registers(unsigned char key)
+{
+    struct vcpu *v;
+
+    if ( !dom0 )
+        return;
+
+    printk("'%c' pressed -> dumping Dom0's registers\n", key);
+
+    for_each_vcpu ( dom0, v )
+    {
+        printk("*** Dumping Dom0 vcpu#%d state: ***\n", v->vcpu_id);
+        if ( v == current )
+            show_execution_state(guest_cpu_user_regs());
+        else
+        {
+            vcpu_pause(v);
+            vcpu_show_execution_state(v);
+            vcpu_unpause(v);
+        }
+    }
+}
+
 static void halt_machine(unsigned char key, struct cpu_user_regs *regs)
 {
     printk("'%c' pressed -> rebooting machine\n", key);
@@ -315,6 +338,9 @@ void __init initialize_keytable(void)
         'P', perfc_reset,    "reset performance counters");
 #endif
 
+    register_keyhandler(
+        '0', dump_dom0_registers, "dump Dom0 registers");
+
     register_irq_keyhandler('%', do_debug_key,   "Trap to xendbg");
 }
 
xen/include/asm-ia64/xenprocessor.h +2 -1
Index: 2008-06-12/xen/include/asm-ia64/xenprocessor.h
===================================================================
@@ -250,6 +250,7 @@ typedef union {
 	};
 } ia64_pkr_t;
 
-#define dump_execution_state() printk("FIXME: implement ia64 dump_execution_state()\n");
+#define dump_execution_state() printk("FIXME: implement ia64 dump_execution_state()\n")
+#define vcpu_show_execution_state(v) printk("FIXME: implement ia64 vcpu_show_execution_state()\n")
 
 #endif // _ASM_IA64_XENPROCESSOR_H
xen/include/asm-x86/domain.h +3 -0
Index: 2008-06-12/xen/include/asm-x86/domain.h
===================================================================
@@ -352,6 +352,9 @@ struct arch_vcpu
 /* Continue the current hypercall via func(data) on specified cpu. */
 int continue_hypercall_on_cpu(int cpu, long (*func)(void *data), void *data);
 
+void vcpu_show_execution_state(struct vcpu *);
+void vcpu_show_registers(const struct vcpu *);
+
 /* Clean up CR4 bits that are not under guest control. */
 unsigned long pv_guest_cr4_fixup(unsigned long guest_cr4);