extable.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * linux/arch/frv/mm/extable.c
  3. */
  4. #include <linux/module.h>
  5. #include <linux/spinlock.h>
  6. #include <asm/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. /*****************************************************************************/
  11. /*
  12. * see if there's a fixup handler available to deal with a kernel fault
  13. */
  14. unsigned long search_exception_table(unsigned long pc)
  15. {
  16. const struct exception_table_entry *extab;
  17. /* determine if the fault lay during a memcpy_user or a memset_user */
  18. if (__frame->lr == (unsigned long) &__memset_user_error_lr &&
  19. (unsigned long) &memset <= pc && pc < (unsigned long) &__memset_end
  20. ) {
  21. /* the fault occurred in a protected memset
  22. * - we search for the return address (in LR) instead of the program counter
  23. * - it was probably during a clear_user()
  24. */
  25. return (unsigned long) &__memset_user_error_handler;
  26. }
  27. if (__frame->lr == (unsigned long) &__memcpy_user_error_lr &&
  28. (unsigned long) &memcpy <= pc && pc < (unsigned long) &__memcpy_end
  29. ) {
  30. /* the fault occurred in a protected memset
  31. * - we search for the return address (in LR) instead of the program counter
  32. * - it was probably during a copy_to/from_user()
  33. */
  34. return (unsigned long) &__memcpy_user_error_handler;
  35. }
  36. extab = search_exception_tables(pc);
  37. if (extab)
  38. return extab->fixup;
  39. return 0;
  40. } /* end search_exception_table() */