extable.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. bool insn_may_access_user(unsigned long addr, unsigned long esr);
  32. #ifdef CONFIG_BPF_JIT
  33. bool ex_handler_bpf(const struct exception_table_entry *ex,
  34. struct pt_regs *regs);
  35. #else /* !CONFIG_BPF_JIT */
  36. static inline
  37. bool ex_handler_bpf(const struct exception_table_entry *ex,
  38. struct pt_regs *regs)
  39. {
  40. return false;
  41. }
  42. #endif /* !CONFIG_BPF_JIT */
  43. bool fixup_exception(struct pt_regs *regs, unsigned long esr);
  44. #endif