extable.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * linux/arch/sparc/mm/extable.c
  3. */
  4. #include <linux/config.h>
  5. #include <linux/module.h>
  6. #include <asm/uaccess.h>
  7. void sort_extable(struct exception_table_entry *start,
  8. struct exception_table_entry *finish)
  9. {
  10. }
  11. /* Caller knows they are in a range if ret->fixup == 0 */
  12. const struct exception_table_entry *
  13. search_extable(const struct exception_table_entry *start,
  14. const struct exception_table_entry *last,
  15. unsigned long value)
  16. {
  17. const struct exception_table_entry *walk;
  18. /* Single insn entries are encoded as:
  19. * word 1: insn address
  20. * word 2: fixup code address
  21. *
  22. * Range entries are encoded as:
  23. * word 1: first insn address
  24. * word 2: 0
  25. * word 3: last insn address + 4 bytes
  26. * word 4: fixup code address
  27. *
  28. * See asm/uaccess.h for more details.
  29. */
  30. /* 1. Try to find an exact match. */
  31. for (walk = start; walk <= last; walk++) {
  32. if (walk->fixup == 0) {
  33. /* A range entry, skip both parts. */
  34. walk++;
  35. continue;
  36. }
  37. if (walk->insn == value)
  38. return walk;
  39. }
  40. /* 2. Try to find a range match. */
  41. for (walk = start; walk <= (last - 1); walk++) {
  42. if (walk->fixup)
  43. continue;
  44. if (walk[0].insn <= value && walk[1].insn > value)
  45. return walk;
  46. walk++;
  47. }
  48. return NULL;
  49. }
  50. /* Special extable search, which handles ranges. Returns fixup */
  51. unsigned long search_extables_range(unsigned long addr, unsigned long *g2)
  52. {
  53. const struct exception_table_entry *entry;
  54. entry = search_exception_tables(addr);
  55. if (!entry)
  56. return 0;
  57. /* Inside range? Fix g2 and return correct fixup */
  58. if (!entry->fixup) {
  59. *g2 = (addr - entry->insn) / 4;
  60. return (entry + 1)->fixup;
  61. }
  62. return entry->fixup;
  63. }