extable.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_EXTABLE_H
  3. #define __ASM_EXTABLE_H
  4. /*
  5. * The exception table consists of pairs of relative offsets: the first
  6. * is the relative offset to an instruction that is allowed to fault,
  7. * and the second is the relative offset at which the program should
  8. * continue. No registers are modified, so it is entirely up to the
  9. * continuation code to figure out what to do.
  10. *
  11. * All the routines below use bits of fixup code that are out of line
  12. * with the main instruction path. This means when everything is well,
  13. * we don't even have to jump over them. Further, they do not intrude
  14. * on our cache or tlb entries.
  15. */
  16. struct exception_table_entry
  17. {
  18. int insn, fixup;
  19. short type, data;
  20. };
  21. #define ARCH_HAS_RELATIVE_EXTABLE
  22. #define swap_ex_entry_fixup(a, b, tmp, delta) \
  23. do { \
  24. (a)->fixup = (b)->fixup + (delta); \
  25. (b)->fixup = (tmp).fixup - (delta); \
  26. (a)->type = (b)->type; \
  27. (b)->type = (tmp).type; \
  28. (a)->data = (b)->data; \
  29. (b)->data = (tmp).data; \
  30. } while (0)
  31. #ifdef CONFIG_BPF_JIT
  32. bool ex_handler_bpf(const struct exception_table_entry *ex,
  33. struct pt_regs *regs);
  34. #else /* !CONFIG_BPF_JIT */
  35. static inline
  36. bool ex_handler_bpf(const struct exception_table_entry *ex,
  37. struct pt_regs *regs)
  38. {
  39. return false;
  40. }
  41. #endif /* !CONFIG_BPF_JIT */
  42. bool fixup_exception(struct pt_regs *regs);
  43. #endif