ia64/xen-unstable

changeset 15190:e49b110cbb4a

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>
author kfraser@localhost.localdomain
date Thu May 24 10:39:28 2007 +0100 (2007-05-24)
parents 96915ca8d5f2
children cc60c18247f1
files xen/arch/x86/traps.c
line diff
     1.1 --- a/xen/arch/x86/traps.c	Thu May 24 10:18:55 2007 +0100
     1.2 +++ b/xen/arch/x86/traps.c	Thu May 24 10:39:28 2007 +0100
     1.3 @@ -345,16 +345,26 @@ char *trapstr(int trapnr)
     1.4   */
     1.5  asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs)
     1.6  {
     1.7 -    watchdog_disable();
     1.8 -    console_start_sync();
     1.9 -
    1.10 -    show_execution_state(regs);
    1.11 +    static DEFINE_PER_CPU(char, depth);
    1.12  
    1.13 -    if ( trapnr == TRAP_page_fault )
    1.14 +    /*
    1.15 +     * In some cases, we can end up in a vicious cycle of fatal_trap()s
    1.16 +     * within fatal_trap()s. We give the problem a couple of iterations to
    1.17 +     * bottom out, and then we just panic.
    1.18 +     */
    1.19 +    if ( ++this_cpu(depth) < 3 )
    1.20      {
    1.21 -        unsigned long cr2 = read_cr2();
    1.22 -        printk("Faulting linear address: %p\n", _p(cr2));
    1.23 -        show_page_walk(cr2);
    1.24 +        watchdog_disable();
    1.25 +        console_start_sync();
    1.26 +
    1.27 +        show_execution_state(regs);
    1.28 +
    1.29 +        if ( trapnr == TRAP_page_fault )
    1.30 +        {
    1.31 +            unsigned long cr2 = read_cr2();
    1.32 +            printk("Faulting linear address: %p\n", _p(cr2));
    1.33 +            show_page_walk(cr2);
    1.34 +        }
    1.35      }
    1.36  
    1.37      panic("FATAL TRAP: vector = %d (%s)\n"