x86: 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 <nils.nieuwejaar@sun.com>

Use a per-cpu depth variable.

Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
kfraser@localhost.localdomain committed 2007-05-24 10:39:28 +01:00
1 parent fab51b46ae
commit d5ab9f9089
1 file changed
+18 -8
+18 -8
View File
@@ -345,16 +345,26 @@ char *trapstr(int trapnr)
*/
asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs)
{
watchdog_disable();
console_start_sync();
static DEFINE_PER_CPU(char, depth);
show_execution_state(regs);
if ( trapnr == TRAP_page_fault )
/*
* 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 ( ++this_cpu(depth) < 3 )
{
unsigned long cr2 = read_cr2();
printk("Faulting linear address: %p\n", _p(cr2));
show_page_walk(cr2);
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"
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.