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