extable.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __S390_EXTABLE_H
  3. #define __S390_EXTABLE_H
  4. #include <asm/ptrace.h>
  5. #include <linux/compiler.h>
  6. /*
  7. * The exception table consists of three addresses:
  8. *
  9. * - Address of an instruction that is allowed to fault.
  10. * - Address at which the program should continue.
  11. * - Optional address of handler that takes pt_regs * argument and runs in
  12. * interrupt context.
  13. *
  14. * No registers are modified, so it is entirely up to the continuation code
  15. * to figure out what to do.
  16. *
  17. * All the routines below use bits of fixup code that are out of line
  18. * with the main instruction path. This means when everything is well,
  19. * we don't even have to jump over them. Further, they do not intrude
  20. * on our cache or tlb entries.
  21. */
  22. struct exception_table_entry
  23. {
  24. int insn, fixup;
  25. short type, data;
  26. };
  27. extern struct exception_table_entry *__start_amode31_ex_table;
  28. extern struct exception_table_entry *__stop_amode31_ex_table;
  29. const struct exception_table_entry *s390_search_extables(unsigned long addr);
  30. static inline unsigned long extable_fixup(const struct exception_table_entry *x)
  31. {
  32. return (unsigned long)&x->fixup + x->fixup;
  33. }
  34. #define ARCH_HAS_RELATIVE_EXTABLE
  35. static inline void swap_ex_entry_fixup(struct exception_table_entry *a,
  36. struct exception_table_entry *b,
  37. struct exception_table_entry tmp,
  38. int delta)
  39. {
  40. a->fixup = b->fixup + delta;
  41. b->fixup = tmp.fixup - delta;
  42. a->type = b->type;
  43. b->type = tmp.type;
  44. a->data = b->data;
  45. b->data = tmp.data;
  46. }
  47. #define swap_ex_entry_fixup swap_ex_entry_fixup
  48. #ifdef CONFIG_BPF_JIT
  49. bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs);
  50. #else /* !CONFIG_BPF_JIT */
  51. static inline bool ex_handler_bpf(const struct exception_table_entry *ex, struct pt_regs *regs)
  52. {
  53. return false;
  54. }
  55. #endif /* CONFIG_BPF_JIT */
  56. bool fixup_exception(struct pt_regs *regs);
  57. #endif