kprobes.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _ASM_POWERPC_KPROBES_H
  3. #define _ASM_POWERPC_KPROBES_H
  4. #include <asm-generic/kprobes.h>
  5. #ifdef __KERNEL__
  6. /*
  7. * Kernel Probes (KProbes)
  8. *
  9. * Copyright (C) IBM Corporation, 2002, 2004
  10. *
  11. * 2002-Oct Created by Vamsi Krishna S <[email protected]> Kernel
  12. * Probes initial implementation ( includes suggestions from
  13. * Rusty Russell).
  14. * 2004-Nov Modified for PPC64 by Ananth N Mavinakayanahalli
  15. * <[email protected]>
  16. */
  17. #include <linux/types.h>
  18. #include <linux/ptrace.h>
  19. #include <linux/percpu.h>
  20. #include <linux/module.h>
  21. #include <asm/probes.h>
  22. #include <asm/code-patching.h>
  23. #ifdef CONFIG_KPROBES
  24. #define __ARCH_WANT_KPROBES_INSN_SLOT
  25. struct pt_regs;
  26. struct kprobe;
  27. typedef u32 kprobe_opcode_t;
  28. extern kprobe_opcode_t optinsn_slot;
  29. /* Optinsn template address */
  30. extern kprobe_opcode_t optprobe_template_entry[];
  31. extern kprobe_opcode_t optprobe_template_op_address[];
  32. extern kprobe_opcode_t optprobe_template_call_handler[];
  33. extern kprobe_opcode_t optprobe_template_insn[];
  34. extern kprobe_opcode_t optprobe_template_call_emulate[];
  35. extern kprobe_opcode_t optprobe_template_ret[];
  36. extern kprobe_opcode_t optprobe_template_end[];
  37. /* Fixed instruction size for powerpc */
  38. #define MAX_INSN_SIZE 2
  39. #define MAX_OPTIMIZED_LENGTH sizeof(kprobe_opcode_t) /* 4 bytes */
  40. #define MAX_OPTINSN_SIZE (optprobe_template_end - optprobe_template_entry)
  41. #define RELATIVEJUMP_SIZE sizeof(kprobe_opcode_t) /* 4 bytes */
  42. #define flush_insn_slot(p) do { } while (0)
  43. #define kretprobe_blacklist_size 0
  44. void __kretprobe_trampoline(void);
  45. extern void arch_remove_kprobe(struct kprobe *p);
  46. /* Architecture specific copy of original instruction */
  47. struct arch_specific_insn {
  48. /* copy of original instruction */
  49. kprobe_opcode_t *insn;
  50. /*
  51. * Set in kprobes code, initially to 0. If the instruction can be
  52. * eumulated, this is set to 1, if not, to -1.
  53. */
  54. int boostable;
  55. };
  56. struct prev_kprobe {
  57. struct kprobe *kp;
  58. unsigned long status;
  59. unsigned long saved_msr;
  60. };
  61. /* per-cpu kprobe control block */
  62. struct kprobe_ctlblk {
  63. unsigned long kprobe_status;
  64. unsigned long kprobe_saved_msr;
  65. struct prev_kprobe prev_kprobe;
  66. };
  67. struct arch_optimized_insn {
  68. kprobe_opcode_t copied_insn[1];
  69. /* detour buffer */
  70. kprobe_opcode_t *insn;
  71. };
  72. extern int kprobe_exceptions_notify(struct notifier_block *self,
  73. unsigned long val, void *data);
  74. extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
  75. extern int kprobe_handler(struct pt_regs *regs);
  76. extern int kprobe_post_handler(struct pt_regs *regs);
  77. #else
  78. static inline int kprobe_handler(struct pt_regs *regs) { return 0; }
  79. static inline int kprobe_post_handler(struct pt_regs *regs) { return 0; }
  80. #endif /* CONFIG_KPROBES */
  81. #endif /* __KERNEL__ */
  82. #endif /* _ASM_POWERPC_KPROBES_H */