mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race
[linux/fpc-iii.git] / arch / frv / mm / extable.c
blob77c0c5ba88bc1d4e4c96485a96620cc814c253e6
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * linux/arch/frv/mm/extable.c
4 */
6 #include <linux/extable.h>
7 #include <linux/spinlock.h>
8 #include <linux/uaccess.h>
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;
14 int fixup_exception(struct pt_regs *regs)
16 const struct exception_table_entry *extab;
17 unsigned long pc = regs->pc;
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()
27 regs->pc = (unsigned long) &__memset_user_error_handler;
28 return 1;
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()
38 regs->pc = (unsigned long) &__memcpy_user_error_handler;
39 return 1;
42 extab = search_exception_tables(pc);
43 if (extab) {
44 regs->pc = extab->fixup;
45 return 1;
48 return 0;