]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/frv/mm/extable.c
Merge tag 'mvebu-dt64-4.12-3' of git://git.infradead.org/linux-mvebu into fixes
[karo-tx-linux.git] / arch / frv / mm / extable.c
1 /*
2  * linux/arch/frv/mm/extable.c
3  */
4
5 #include <linux/extable.h>
6 #include <linux/spinlock.h>
7 #include <linux/uaccess.h>
8
9 extern const void __memset_end, __memset_user_error_lr, __memset_user_error_handler;
10 extern const void __memcpy_end, __memcpy_user_error_lr, __memcpy_user_error_handler;
11 extern spinlock_t modlist_lock;
12
13 int fixup_exception(struct pt_regs *regs)
14 {
15         const struct exception_table_entry *extab;
16         unsigned long pc = regs->pc;
17
18         /* determine if the fault lay during a memcpy_user or a memset_user */
19         if (regs->lr == (unsigned long) &__memset_user_error_lr &&
20             (unsigned long) &memset <= pc && pc < (unsigned long) &__memset_end
21             ) {
22                 /* the fault occurred in a protected memset
23                  * - we search for the return address (in LR) instead of the program counter
24                  * - it was probably during a clear_user()
25                  */
26                 regs->pc = (unsigned long) &__memset_user_error_handler;
27                 return 1;
28         }
29
30         if (regs->lr == (unsigned long) &__memcpy_user_error_lr &&
31             (unsigned long) &memcpy <= pc && pc < (unsigned long) &__memcpy_end
32             ) {
33                 /* the fault occurred in a protected memset
34                  * - we search for the return address (in LR) instead of the program counter
35                  * - it was probably during a copy_to/from_user()
36                  */
37                 regs->pc = (unsigned long) &__memcpy_user_error_handler;
38                 return 1;
39         }
40
41         extab = search_exception_tables(pc);
42         if (extab) {
43                 regs->pc = extab->fixup;
44                 return 1;
45         }
46
47         return 0;
48 }