aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/extable.c
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-11-25 11:45:09 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2004-11-25 11:45:09 +0000
commit100723a89eb5f83df26dfdc30cac6a38e2eaec85 (patch)
tree415efb012c918aa456030ae3a32a0e9c8927a2b3 /xen/arch/x86/extable.c
parentbd28987fc41fc2eb29a18673275387ac82eb3a18 (diff)
downloadxen-100723a89eb5f83df26dfdc30cac6a38e2eaec85.tar.gz
xen-100723a89eb5f83df26dfdc30cac6a38e2eaec85.tar.bz2
xen-100723a89eb5f83df26dfdc30cac6a38e2eaec85.zip
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.
Diffstat (limited to 'xen/arch/x86/extable.c')
-rw-r--r--xen/arch/x86/extable.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 54251cc3c5..d3292027e0 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -3,6 +3,36 @@
#include <xen/spinlock.h>
#include <asm/uaccess.h>
+extern struct exception_table_entry __start___ex_table[];
+extern struct exception_table_entry __stop___ex_table[];
+extern struct exception_table_entry __start___pre_ex_table[];
+extern struct exception_table_entry __stop___pre_ex_table[];
+
+static void sort_exception_table(struct exception_table_entry *start,
+ struct exception_table_entry *end)
+{
+ struct exception_table_entry *p, *q, tmp;
+
+ for ( p = start; p < end; p++ )
+ {
+ for ( q = p-1; q > start; q-- )
+ if ( p->insn > q->insn )
+ break;
+ if ( ++q != p )
+ {
+ tmp = *p;
+ memmove(q+1, q, (p-q)*sizeof(*p));
+ *q = tmp;
+ }
+ }
+}
+
+void sort_exception_tables(void)
+{
+ sort_exception_table(__start___ex_table, __stop___ex_table);
+ sort_exception_table(__start___pre_ex_table, __stop___pre_ex_table);
+}
+
static inline unsigned long
search_one_table(const struct exception_table_entry *first,
const struct exception_table_entry *last,
@@ -28,21 +58,15 @@ search_one_table(const struct exception_table_entry *first,
unsigned long
search_exception_table(unsigned long addr)
{
- extern const struct exception_table_entry __start___ex_table[];
- extern const struct exception_table_entry __stop___ex_table[];
return search_one_table(
__start___ex_table, __stop___ex_table-1, addr);
}
-#ifdef __i386__
unsigned long
search_pre_exception_table(unsigned long addr)
{
- extern const struct exception_table_entry __start___pre_ex_table[];
- extern const struct exception_table_entry __stop___pre_ex_table[];
unsigned long fixup = search_one_table(
__start___pre_ex_table, __stop___pre_ex_table-1, addr);
DPRINTK("Pre-exception: %08lx -> %08lx\n", addr, fixup);
return fixup;
}
-#endif