extable.c 1.4 KB

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