extable.c 858 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * linux/arch/x86_64/mm/extable.c
  3. */
  4. #include <linux/config.h>
  5. #include <linux/module.h>
  6. #include <linux/spinlock.h>
  7. #include <linux/init.h>
  8. #include <asm/uaccess.h>
  9. /* Simple binary search */
  10. const struct exception_table_entry *
  11. search_extable(const struct exception_table_entry *first,
  12. const struct exception_table_entry *last,
  13. unsigned long value)
  14. {
  15. /* Work around a B stepping K8 bug */
  16. if ((value >> 32) == 0)
  17. value |= 0xffffffffUL << 32;
  18. while (first <= last) {
  19. const struct exception_table_entry *mid;
  20. long diff;
  21. mid = (last - first) / 2 + first;
  22. diff = mid->insn - value;
  23. if (diff == 0)
  24. return mid;
  25. else if (diff < 0)
  26. first = mid+1;
  27. else
  28. last = mid-1;
  29. }
  30. return NULL;
  31. }