Commit fd68505a authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86_64 extable fixes

Make x86-64 compile again after recent extable changes.
parent 94781db5
...@@ -384,8 +384,6 @@ void __init setup_arch(char **cmdline_p) ...@@ -384,8 +384,6 @@ void __init setup_arch(char **cmdline_p)
conswitchp = &dummy_con; conswitchp = &dummy_con;
#endif #endif
#endif #endif
exception_table_check();
} }
#ifndef CONFIG_X86_TSC #ifndef CONFIG_X86_TSC
......
...@@ -397,7 +397,8 @@ static void do_trap(int trapnr, int signr, char *str, ...@@ -397,7 +397,8 @@ static void do_trap(int trapnr, int signr, char *str,
/* kernel trap */ /* kernel trap */
{ {
unsigned long fixup = search_exception_table(regs->rip); const struct exception_table_entry *fixup;
fixup = search_exception_tables(regs->rip);
if (fixup) { if (fixup) {
extern int exception_trace; extern int exception_trace;
if (exception_trace) if (exception_trace)
...@@ -405,7 +406,7 @@ static void do_trap(int trapnr, int signr, char *str, ...@@ -405,7 +406,7 @@ static void do_trap(int trapnr, int signr, char *str,
"%s: fixed kernel exception at %lx err:%ld\n", "%s: fixed kernel exception at %lx err:%ld\n",
current->comm, regs->rip, error_code); current->comm, regs->rip, error_code);
regs->rip = fixup; regs->rip = fixup->fixup;
} else } else
die(str, regs, error_code); die(str, regs, error_code);
return; return;
...@@ -449,8 +450,6 @@ asmlinkage void do_int3(struct pt_regs * regs, long error_code) ...@@ -449,8 +450,6 @@ asmlinkage void do_int3(struct pt_regs * regs, long error_code)
do_trap(3, SIGTRAP, "int3", regs, error_code, NULL); do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
} }
extern void dump_pagetable(unsigned long);
asmlinkage void do_general_protection(struct pt_regs * regs, long error_code) asmlinkage void do_general_protection(struct pt_regs * regs, long error_code)
{ {
#ifdef CONFIG_CHECKING #ifdef CONFIG_CHECKING
...@@ -479,13 +478,12 @@ asmlinkage void do_general_protection(struct pt_regs * regs, long error_code) ...@@ -479,13 +478,12 @@ asmlinkage void do_general_protection(struct pt_regs * regs, long error_code)
/* kernel gp */ /* kernel gp */
{ {
unsigned long fixup; const struct exception_table_entry *fixup;
fixup = search_exception_table(regs->rip); fixup = search_exception_tables(regs->rip);
if (fixup) { if (fixup) {
regs->rip = fixup; regs->rip = fixup->fixup;
return; return;
} }
// dump_pagetable(regs->rip);
die("general protection fault", regs, error_code); die("general protection fault", regs, error_code);
} }
} }
......
...@@ -6,30 +6,10 @@ ...@@ -6,30 +6,10 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/init.h>
extern const struct exception_table_entry __start___ex_table[]; /* Simple binary search */
extern const struct exception_table_entry __stop___ex_table[]; const struct exception_table_entry *
search_extable(const struct exception_table_entry *first,
void __init exception_table_check(void)
{
const struct exception_table_entry *e;
unsigned long prev;
prev = 0;
for (e = __start___ex_table; e < __stop___ex_table; e++) {
if (e->insn < prev) {
panic("unordered exception table at %016lx:%016lx and %016lx:%016lx\n",
prev, e[-1].fixup,
e->insn, e->fixup);
}
prev = e->insn;
}
}
static unsigned long
search_one_table(const struct exception_table_entry *first,
const struct exception_table_entry *last, const struct exception_table_entry *last,
unsigned long value) unsigned long value)
{ {
...@@ -40,42 +20,11 @@ search_one_table(const struct exception_table_entry *first, ...@@ -40,42 +20,11 @@ search_one_table(const struct exception_table_entry *first,
mid = (last - first) / 2 + first; mid = (last - first) / 2 + first;
diff = mid->insn - value; diff = mid->insn - value;
if (diff == 0) if (diff == 0)
return mid->fixup; return mid;
else if (diff < 0) else if (diff < 0)
first = mid+1; first = mid+1;
else else
last = mid-1; last = mid-1;
} }
return 0; return NULL;
}
extern spinlock_t modlist_lock;
unsigned long
search_exception_table(unsigned long addr)
{
unsigned long ret = 0;
unsigned long flags;
#ifndef CONFIG_MODULES
/* There is only the kernel to search. */
return search_one_table(__start___ex_table, __stop___ex_table-1, addr);
#else
/* The kernel is the last "module" -- no need to treat it special. */
struct list_head *i;
spin_lock_irqsave(&modlist_lock, flags);
list_for_each(i, &extables) {
struct exception_table *ex =
list_entry(i,struct exception_table, list);
if (ex->num_entries == 0)
continue;
ret = search_one_table(ex->entry,
ex->entry + ex->num_entries - 1, addr);
if (ret)
break;
}
spin_unlock_irqrestore(&modlist_lock, flags);
return ret;
#endif
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/vt_kern.h> /* For unblank_screen() */ #include <linux/vt_kern.h> /* For unblank_screen() */
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/module.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -101,7 +102,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -101,7 +102,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
struct mm_struct *mm; struct mm_struct *mm;
struct vm_area_struct * vma; struct vm_area_struct * vma;
unsigned long address; unsigned long address;
unsigned long fixup; const struct exception_table_entry *fixup;
int write; int write;
siginfo_t info; siginfo_t info;
...@@ -239,8 +240,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code) ...@@ -239,8 +240,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
no_context: no_context:
/* Are we prepared to handle this kernel fault? */ /* Are we prepared to handle this kernel fault? */
if ((fixup = search_exception_table(regs->rip)) != 0) { fixup = search_exception_tables(regs->rip);
regs->rip = fixup; if (fixup) {
regs->rip = fixup->fixup;
if (0 && exception_trace) if (0 && exception_trace)
printk(KERN_ERR printk(KERN_ERR
"%s: fixed kernel exception at %lx address %lx err:%ld\n", "%s: fixed kernel exception at %lx address %lx err:%ld\n",
......
...@@ -71,9 +71,6 @@ struct exception_table_entry ...@@ -71,9 +71,6 @@ struct exception_table_entry
unsigned long insn, fixup; unsigned long insn, fixup;
}; };
/* Returns 0 if exception not found and fixup otherwise. */
extern unsigned long search_exception_table(unsigned long);
/* /*
* These are the main single-value transfer routines. They automatically * These are the main single-value transfer routines. They automatically
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment