ia64/xen-unstable

changeset 10070:aab3cd33d2ba

[MINIOS] Fix the pagefault handler to detect recursive faults.
Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
author kaf24@firebug.cl.cam.ac.uk
date Tue May 16 16:34:27 2006 +0100 (2006-05-16)
parents 3dca5b4add2b
children 7fdc4a8b782b
files extras/mini-os/console/console.c extras/mini-os/traps.c
line diff
     1.1 --- a/extras/mini-os/console/console.c	Tue May 16 14:07:56 2006 +0100
     1.2 +++ b/extras/mini-os/console/console.c	Tue May 16 16:34:27 2006 +0100
     1.3 @@ -45,6 +45,10 @@
     1.4  #include <xen/io/console.h>
     1.5  
     1.6  
     1.7 +/* Copies all print output to the Xen emergency console apart
     1.8 +   of standard dom0 handled console */
     1.9 +#define USE_XEN_CONSOLE
    1.10 +
    1.11  /* Low level functions defined in xencons_ring.c */
    1.12  extern int xencons_ring_init(void);
    1.13  extern int xencons_ring_send(const char *data, unsigned len);
    1.14 @@ -117,7 +121,9 @@ void print(int direct, const char *fmt, 
    1.15          (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
    1.16          return;
    1.17      } else {
    1.18 -        if(!console_initialised)
    1.19 +#ifndef USE_XEN_CONSOLE
    1.20 +    if(!console_initialised)
    1.21 +#endif    
    1.22              (void)HYPERVISOR_console_io(CONSOLEIO_write, strlen(buf), buf);
    1.23          
    1.24          console_print(buf, strlen(buf));
    1.25 @@ -128,7 +134,7 @@ void printk(const char *fmt, ...)
    1.26  {
    1.27      va_list       args;
    1.28      va_start(args, fmt);
    1.29 -    print(1, fmt, args);
    1.30 +    print(0, fmt, args);
    1.31      va_end(args);        
    1.32  }
    1.33  
     2.1 --- a/extras/mini-os/traps.c	Tue May 16 14:07:56 2006 +0100
     2.2 +++ b/extras/mini-os/traps.c	Tue May 16 16:34:27 2006 +0100
     2.3 @@ -120,9 +120,21 @@ void page_walk(unsigned long virt_addres
     2.4  #define read_cr2() \
     2.5          (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)
     2.6  
     2.7 +static int handling_pg_fault = 0;
     2.8 +
     2.9  void do_page_fault(struct pt_regs *regs, unsigned long error_code)
    2.10  {
    2.11      unsigned long addr = read_cr2();
    2.12 +    /* If we are already handling a page fault, and got another one
    2.13 +       that means we faulted in pagetable walk. Continuing here would cause
    2.14 +       a recursive fault */       
    2.15 +    if(handling_pg_fault) 
    2.16 +    {
    2.17 +        printk("Page fault in pagetable walk (access to invalid memory?).\n"); 
    2.18 +        do_exit();
    2.19 +    }
    2.20 +    handling_pg_fault = 1;
    2.21 +
    2.22  #if defined(__x86_64__)
    2.23      printk("Page fault at linear address %p, rip %p, code %lx\n",
    2.24             addr, regs->rip, error_code);
    2.25 @@ -130,9 +142,12 @@ void do_page_fault(struct pt_regs *regs,
    2.26      printk("Page fault at linear address %p, eip %p, code %lx\n",
    2.27             addr, regs->eip, error_code);
    2.28  #endif
    2.29 +
    2.30      dump_regs(regs);
    2.31      page_walk(addr);
    2.32      do_exit();
    2.33 +    /* We should never get here ... but still */
    2.34 +    handling_pg_fault = 0;
    2.35  }
    2.36  
    2.37  void do_general_protection(struct pt_regs *regs, long error_code)