extable.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_RISCV_EXTABLE_H
  3. #define _ASM_RISCV_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. int insn, fixup;
  18. short type, data;
  19. };
  20. #define ARCH_HAS_RELATIVE_EXTABLE
  21. #define swap_ex_entry_fixup(a, b, tmp, delta) \
  22. do { \
  23. (a)->fixup = (b)->fixup + (delta); \
  24. (b)->fixup = (tmp).fixup - (delta); \
  25. (a)->type = (b)->type; \
  26. (b)->type = (tmp).type; \
  27. (a)->data = (b)->data; \
  28. (b)->data = (tmp).data; \
  29. } while (0)
  30. #ifdef CONFIG_MMU
  31. bool fixup_exception(struct pt_regs *regs);
  32. #else
  33. static inline bool fixup_exception(struct pt_regs *regs) { return false; }
  34. #endif
  35. #if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I)
  36. bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs);
  37. #else
  38. static inline bool
  39. ex_handler_bpf(const struct exception_table_entry *ex,
  40. struct pt_regs *regs)
  41. {
  42. return false;
  43. }
  44. #endif
  45. #endif