2 * linux/arch/frv/mm/extable.c
5 #include <linux/config.h>
6 #include <linux/module.h>
7 #include <linux/spinlock.h>
8 #include <asm/uaccess.h>
10 extern const struct exception_table_entry
__attribute__((aligned(8))) __start___ex_table
[];
11 extern const struct exception_table_entry
__attribute__((aligned(8))) __stop___ex_table
[];
12 extern const void __memset_end
, __memset_user_error_lr
, __memset_user_error_handler
;
13 extern const void __memcpy_end
, __memcpy_user_error_lr
, __memcpy_user_error_handler
;
14 extern spinlock_t modlist_lock
;
16 /*****************************************************************************/
20 static inline unsigned long search_one_table(const struct exception_table_entry
*first
,
21 const struct exception_table_entry
*last
,
24 while (first
<= last
) {
25 const struct exception_table_entry
__attribute__((aligned(8))) *mid
;
28 mid
= (last
- first
) / 2 + first
;
29 diff
= mid
->insn
- value
;
38 } /* end search_one_table() */
40 /*****************************************************************************/
42 * see if there's a fixup handler available to deal with a kernel fault
44 unsigned long search_exception_table(unsigned long pc
)
46 unsigned long ret
= 0;
48 /* determine if the fault lay during a memcpy_user or a memset_user */
49 if (__frame
->lr
== (unsigned long) &__memset_user_error_lr
&&
50 (unsigned long) &memset
<= pc
&& pc
< (unsigned long) &__memset_end
52 /* the fault occurred in a protected memset
53 * - we search for the return address (in LR) instead of the program counter
54 * - it was probably during a clear_user()
56 return (unsigned long) &__memset_user_error_handler
;
58 else if (__frame
->lr
== (unsigned long) &__memcpy_user_error_lr
&&
59 (unsigned long) &memcpy
<= pc
&& pc
< (unsigned long) &__memcpy_end
61 /* the fault occurred in a protected memset
62 * - we search for the return address (in LR) instead of the program counter
63 * - it was probably during a copy_to/from_user()
65 return (unsigned long) &__memcpy_user_error_handler
;
68 #ifndef CONFIG_MODULES
69 /* there is only the kernel to search. */
70 ret
= search_one_table(__start___ex_table
, __stop___ex_table
- 1, pc
);
74 /* the kernel is the last "module" -- no need to treat it special */
78 spin_lock_irqsave(&modlist_lock
, flags
);
80 for (mp
= module_list
; mp
!= NULL
; mp
= mp
->next
) {
81 if (mp
->ex_table_start
== NULL
|| !(mp
->flags
& (MOD_RUNNING
| MOD_INITIALIZING
)))
83 ret
= search_one_table(mp
->ex_table_start
, mp
->ex_table_end
- 1, pc
);
88 spin_unlock_irqrestore(&modlist_lock
, flags
);
91 } /* end search_exception_table() */