extable_64.c 832 B

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