Commit 8afe742b authored by Anton Blanchard's avatar Anton Blanchard

ppc64: clean up exception table code, we werent taking the modlist_lock

parent 77d3065b
/* /*
* linux/arch/ppc/mm/extable.c * linux/arch/ppc64/mm/extable.c
* *
* from linux/arch/i386/mm/extable.c * from linux/arch/i386/mm/extable.c
* *
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
extern struct exception_table_entry __start___ex_table[]; extern struct exception_table_entry __start___ex_table[];
...@@ -19,8 +20,7 @@ extern struct exception_table_entry __stop___ex_table[]; ...@@ -19,8 +20,7 @@ extern struct exception_table_entry __stop___ex_table[];
/* /*
* The exception table needs to be sorted because we use the macros * The exception table needs to be sorted because we use the macros
* which put things into the exception table in a variety of segments * which put things into the exception table in a variety of segments
* such as the prep, pmac, chrp, etc. segments as well as the init * as well as the init segment and the main kernel text segment.
* segment and the main kernel text segment.
*/ */
static inline void static inline void
sort_ex_table(struct exception_table_entry *start, sort_ex_table(struct exception_table_entry *start,
...@@ -56,43 +56,48 @@ search_one_table(const struct exception_table_entry *first, ...@@ -56,43 +56,48 @@ 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)
{ {
while (first <= last) { while (first <= last) {
const struct exception_table_entry *mid; const struct exception_table_entry *mid;
long diff; long diff;
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->fixup;
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 0;
} }
extern spinlock_t modlist_lock;
unsigned long unsigned long
search_exception_table(unsigned long addr) search_exception_table(unsigned long addr)
{ {
unsigned long ret; unsigned long ret = 0;
#ifndef CONFIG_MODULES #ifndef CONFIG_MODULES
/* There is only the kernel to search. */ /* There is only the kernel to search. */
ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr); ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr);
if (ret) return ret; return ret;
#else #else
unsigned long flags;
/* The kernel is the last "module" -- no need to treat it special. */ /* The kernel is the last "module" -- no need to treat it special. */
struct module *mp; struct module *mp;
spin_lock_irqsave(&modlist_lock, flags);
for (mp = module_list; mp != NULL; mp = mp->next) { for (mp = module_list; mp != NULL; mp = mp->next) {
if (mp->ex_table_start == NULL) if (mp->ex_table_start == NULL || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING)))
continue; continue;
ret = search_one_table(mp->ex_table_start, ret = search_one_table(mp->ex_table_start,
mp->ex_table_end - 1, addr); mp->ex_table_end - 1, addr);
if (ret) if (ret)
return ret; break;
} }
spin_unlock_irqrestore(&modlist_lock, flags);
return ret;
#endif #endif
return 0;
} }
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