From: John Levon Subject: [PATCH] Prevent an infinite series of traps Date: Wed, 23 May 2007 03:53:32 +0100 Message-ID: <20070523025332.GA17497@totally.trollied.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User john.levon@sun.com # 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. Signed-off-by: Nils Nieuwejaar diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -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"