2 * linux/arch/alpha/mm/extable.c
5 #include <linux/config.h>
6 #include <linux/module.h>
7 #include <asm/uaccess.h>
9 extern const struct exception_table_entry __start___ex_table[];
10 extern const struct exception_table_entry __stop___ex_table[];
12 static inline unsigned
13 search_one_table(const struct exception_table_entry *first,
14 const struct exception_table_entry *last,
17 /* Abort early if the search value is out of range. */
18 if (value != (signed int)value)
21 while (first <= last) {
22 const struct exception_table_entry *mid;
25 mid = (last - first) / 2 + first;
26 diff = mid->insn - value;
28 return mid->fixup.unit;
37 register unsigned long gp __asm__("$29");
40 search_exception_table_without_gp(unsigned long addr)
44 #ifndef CONFIG_MODULES
45 /* There is only the kernel to search. */
46 ret = search_one_table(__start___ex_table, __stop___ex_table - 1,
49 extern spinlock_t modlist_lock;
51 /* The kernel is the last "module" -- no need to treat it special. */
55 spin_lock_irqsave(&modlist_lock, flags);
56 for (mp = module_list; mp ; mp = mp->next) {
57 if (!mp->ex_table_start || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING)))
59 ret = search_one_table(mp->ex_table_start,
60 mp->ex_table_end - 1, addr - mp->gp);
64 spin_unlock_irqrestore(&modlist_lock, flags);
71 search_exception_table(unsigned long addr, unsigned long exc_gp)
75 #ifndef CONFIG_MODULES
76 ret = search_one_table(__start___ex_table, __stop___ex_table - 1,
80 extern spinlock_t modlist_lock;
82 /* The kernel is the last "module" -- no need to treat it special. */
86 spin_lock_irqsave(&modlist_lock, flags);
87 for (mp = module_list; mp ; mp = mp->next) {
88 if (!mp->ex_table_start || !(mp->flags&(MOD_RUNNING|MOD_INITIALIZING)))
90 ret = search_one_table(mp->ex_table_start,
91 mp->ex_table_end - 1, addr - exc_gp);
95 spin_unlock_irqrestore(&modlist_lock, flags);
100 * The search failed with the exception gp. To be safe, try the
101 * old method before giving up.
103 ret = search_exception_table_without_gp(addr);
105 printk(KERN_ALERT "%s: [%lx] EX_TABLE search fail with"
106 "exc frame GP, success with raw GP\n",
107 current->comm, addr);