Skip to contentSkip to conversation

Prevent an infinite series of traps

PATCH New John Levon 1 participant 1 message May 23, 2007

lore
Share & tools
lore

John Levon

author
#0 lore raw

PATCH 1/1 Prevent an infinite series of traps

# HG changeset patch
# User [email protected]
# Date 1179888079 25200
# Node ID 16f72321a6fc567d9764faef5729263b5101dbe8 # Parent 01982a3f30dcb842e493e1252d85d970a7055ab2 Prevent an infinite series of traps

In some cases, we can end up in a vicious cycle of fatal_trap()s within fatal_trap()s. Panic after a certain number of attempts.

xen/arch/x86/traps.c +19 -10
@@ -375,16 +375,25 @@ char *trapstr(int trapnr)
  */
 asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs)
 {
-    watchdog_disable();
-    console_start_sync();
-
-    show_execution_state(regs);
-
-    if ( trapnr == TRAP_page_fault )
-    {
-        unsigned long cr2 = read_cr2();
-        printk("Faulting linear address: %p\n", _p(cr2));
-        show_page_walk(cr2);
+    static int depth = 0;
+
+    /*
+     * In some cases, we can end up in a vicious cycle of fatal_trap()s
+     * within fatal_trap()s.  We give the problem a couple of iterations to
+     * bottom out, and then we just panic.
+     */
+    if (depth++ < 3) {
+	watchdog_disable();
+	console_start_sync();
+
+	show_execution_state(regs);
+
+	if ( trapnr == TRAP_page_fault )
+	{
+	    unsigned long cr2 = read_cr2();
+	    printk("Faulting linear address: %p\n", _p(cr2));
+	    show_page_walk(cr2);
+	}
     }
 
     panic("FATAL TRAP: vector = %d (%s)\n"