ia64/xen-unstable

changeset 3120:200d7360c68b

bitkeeper revision 1.1159.194.1 (41a5c5c5J8BRAOOMMsDGqEcd_8brmg)

Sort exception tables during Xen boot. This will fix some nasty crashes
that some people have seen in the last day or so.
author kaf24@scramble.cl.cam.ac.uk
date Thu Nov 25 11:45:09 2004 +0000 (2004-11-25)
parents 85d6a1145160
children 8b68f9377c74 733fc4c2fdcd 9aca3607909f 322f719e79a6
files xen/arch/x86/extable.c xen/arch/x86/setup.c xen/include/asm-x86/x86_32/uaccess.h
line diff
     1.1 --- a/xen/arch/x86/extable.c	Wed Nov 24 19:29:50 2004 +0000
     1.2 +++ b/xen/arch/x86/extable.c	Thu Nov 25 11:45:09 2004 +0000
     1.3 @@ -3,6 +3,36 @@
     1.4  #include <xen/spinlock.h>
     1.5  #include <asm/uaccess.h>
     1.6  
     1.7 +extern struct exception_table_entry __start___ex_table[];
     1.8 +extern struct exception_table_entry __stop___ex_table[];
     1.9 +extern struct exception_table_entry __start___pre_ex_table[];
    1.10 +extern struct exception_table_entry __stop___pre_ex_table[];
    1.11 +
    1.12 +static void sort_exception_table(struct exception_table_entry *start,
    1.13 +                                 struct exception_table_entry *end)
    1.14 +{
    1.15 +    struct exception_table_entry *p, *q, tmp;
    1.16 +
    1.17 +    for ( p = start; p < end; p++ )
    1.18 +    {
    1.19 +        for ( q = p-1; q > start; q-- )
    1.20 +            if ( p->insn > q->insn )
    1.21 +                break;
    1.22 +        if ( ++q != p )
    1.23 +        {
    1.24 +            tmp = *p;
    1.25 +            memmove(q+1, q, (p-q)*sizeof(*p));
    1.26 +            *q = tmp;
    1.27 +        }
    1.28 +    }
    1.29 +}
    1.30 +
    1.31 +void sort_exception_tables(void)
    1.32 +{
    1.33 +    sort_exception_table(__start___ex_table, __stop___ex_table);
    1.34 +    sort_exception_table(__start___pre_ex_table, __stop___pre_ex_table);
    1.35 +}
    1.36 +
    1.37  static inline unsigned long
    1.38  search_one_table(const struct exception_table_entry *first,
    1.39  		 const struct exception_table_entry *last,
    1.40 @@ -28,21 +58,15 @@ search_one_table(const struct exception_
    1.41  unsigned long
    1.42  search_exception_table(unsigned long addr)
    1.43  {
    1.44 -    extern const struct exception_table_entry __start___ex_table[];
    1.45 -    extern const struct exception_table_entry __stop___ex_table[];
    1.46      return search_one_table(
    1.47          __start___ex_table, __stop___ex_table-1, addr);
    1.48  }
    1.49  
    1.50 -#ifdef __i386__
    1.51  unsigned long
    1.52  search_pre_exception_table(unsigned long addr)
    1.53  {
    1.54 -    extern const struct exception_table_entry __start___pre_ex_table[];
    1.55 -    extern const struct exception_table_entry __stop___pre_ex_table[];
    1.56      unsigned long fixup = search_one_table(
    1.57          __start___pre_ex_table, __stop___pre_ex_table-1, addr);
    1.58      DPRINTK("Pre-exception: %08lx -> %08lx\n", addr, fixup);
    1.59      return fixup;
    1.60  }
    1.61 -#endif
     2.1 --- a/xen/arch/x86/setup.c	Wed Nov 24 19:29:50 2004 +0000
     2.2 +++ b/xen/arch/x86/setup.c	Thu Nov 25 11:45:09 2004 +0000
     2.3 @@ -326,6 +326,8 @@ void __init start_of_day(void)
     2.4      if ( opt_watchdog ) 
     2.5          nmi_watchdog = NMI_LOCAL_APIC;
     2.6  
     2.7 +    sort_exception_tables();
     2.8 +
     2.9      /* Tell the PCI layer not to allocate too close to the RAM area.. */
    2.10      low_mem_size = ((max_page << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
    2.11      if ( low_mem_size > pci_mem_start ) pci_mem_start = low_mem_size;
     3.1 --- a/xen/include/asm-x86/x86_32/uaccess.h	Wed Nov 24 19:29:50 2004 +0000
     3.2 +++ b/xen/include/asm-x86/x86_32/uaccess.h	Thu Nov 25 11:45:09 2004 +0000
     3.3 @@ -85,6 +85,7 @@ struct exception_table_entry
     3.4  };
     3.5  
     3.6  extern unsigned long search_exception_table(unsigned long);
     3.7 +extern void sort_exception_tables(void);
     3.8  
     3.9  /**
    3.10   * get_user: - Get a simple variable from user space.