extable.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. bool fixup_exception(struct pt_regs *regs);
  31. #if defined(CONFIG_BPF_JIT) && defined(CONFIG_ARCH_RV64I)
  32. bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs);
  33. #else
  34. static inline bool
  35. ex_handler_bpf(const struct exception_table_entry *ex,
  36. struct pt_regs *regs)
  37. {
  38. return false;
  39. }
  40. #endif
  41. #endif