extable.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_LOONGARCH_EXTABLE_H
  3. #define _ASM_LOONGARCH_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_BPF_JIT
  31. bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs);
  32. #else
  33. static inline
  34. bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs)
  35. {
  36. return false;
  37. }
  38. #endif /* !CONFIG_BPF_JIT */
  39. bool fixup_exception(struct pt_regs *regs);
  40. #endif