kprobes.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __ASM_LOONGARCH_KPROBES_H
  3. #define __ASM_LOONGARCH_KPROBES_H
  4. #include <asm-generic/kprobes.h>
  5. #ifdef CONFIG_KPROBES
  6. #include <asm/inst.h>
  7. #include <asm/cacheflush.h>
  8. #define __ARCH_WANT_KPROBES_INSN_SLOT
  9. #define MAX_INSN_SIZE 2
  10. #define flush_insn_slot(p) \
  11. do { \
  12. if (p->addr) \
  13. flush_icache_range((unsigned long)p->addr, \
  14. (unsigned long)p->addr + \
  15. (MAX_INSN_SIZE * sizeof(kprobe_opcode_t))); \
  16. } while (0)
  17. #define kretprobe_blacklist_size 0
  18. typedef u32 kprobe_opcode_t;
  19. /* Architecture specific copy of original instruction */
  20. struct arch_specific_insn {
  21. /* copy of the original instruction */
  22. kprobe_opcode_t *insn;
  23. /* restore address after simulation */
  24. unsigned long restore;
  25. };
  26. struct prev_kprobe {
  27. struct kprobe *kp;
  28. unsigned int status;
  29. };
  30. /* per-cpu kprobe control block */
  31. struct kprobe_ctlblk {
  32. unsigned int kprobe_status;
  33. unsigned long saved_status;
  34. struct prev_kprobe prev_kprobe;
  35. };
  36. void arch_remove_kprobe(struct kprobe *p);
  37. bool kprobe_fault_handler(struct pt_regs *regs, int trapnr);
  38. bool kprobe_breakpoint_handler(struct pt_regs *regs);
  39. bool kprobe_singlestep_handler(struct pt_regs *regs);
  40. #else /* !CONFIG_KPROBES */
  41. static inline bool kprobe_breakpoint_handler(struct pt_regs *regs) { return false; }
  42. static inline bool kprobe_singlestep_handler(struct pt_regs *regs) { return false; }
  43. #endif /* CONFIG_KPROBES */
  44. #endif /* __ASM_LOONGARCH_KPROBES_H */