kprobes.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * arch/arm/include/asm/kprobes.h
  4. *
  5. * Copyright (C) 2006, 2007 Motorola Inc.
  6. */
  7. #ifndef _ARM_KPROBES_H
  8. #define _ARM_KPROBES_H
  9. #include <asm-generic/kprobes.h>
  10. #ifdef CONFIG_KPROBES
  11. #include <linux/types.h>
  12. #include <linux/ptrace.h>
  13. #include <linux/notifier.h>
  14. #define __ARCH_WANT_KPROBES_INSN_SLOT
  15. #define MAX_INSN_SIZE 2
  16. #define flush_insn_slot(p) do { } while (0)
  17. #define kretprobe_blacklist_size 0
  18. typedef u32 kprobe_opcode_t;
  19. struct kprobe;
  20. #include <asm/probes.h>
  21. #define arch_specific_insn arch_probes_insn
  22. struct prev_kprobe {
  23. struct kprobe *kp;
  24. unsigned int status;
  25. };
  26. /* per-cpu kprobe control block */
  27. struct kprobe_ctlblk {
  28. unsigned int kprobe_status;
  29. struct prev_kprobe prev_kprobe;
  30. };
  31. void arch_remove_kprobe(struct kprobe *);
  32. int kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr);
  33. int kprobe_exceptions_notify(struct notifier_block *self,
  34. unsigned long val, void *data);
  35. /* optinsn template addresses */
  36. extern __visible kprobe_opcode_t optprobe_template_entry[];
  37. extern __visible kprobe_opcode_t optprobe_template_val[];
  38. extern __visible kprobe_opcode_t optprobe_template_call[];
  39. extern __visible kprobe_opcode_t optprobe_template_end[];
  40. extern __visible kprobe_opcode_t optprobe_template_sub_sp[];
  41. extern __visible kprobe_opcode_t optprobe_template_add_sp[];
  42. extern __visible kprobe_opcode_t optprobe_template_restore_begin[];
  43. extern __visible kprobe_opcode_t optprobe_template_restore_orig_insn[];
  44. extern __visible kprobe_opcode_t optprobe_template_restore_end[];
  45. #define MAX_OPTIMIZED_LENGTH 4
  46. #define MAX_OPTINSN_SIZE \
  47. ((unsigned long)optprobe_template_end - \
  48. (unsigned long)optprobe_template_entry)
  49. #define RELATIVEJUMP_SIZE 4
  50. struct arch_optimized_insn {
  51. /*
  52. * copy of the original instructions.
  53. * Different from x86, ARM kprobe_opcode_t is u32.
  54. */
  55. #define MAX_COPIED_INSN DIV_ROUND_UP(RELATIVEJUMP_SIZE, sizeof(kprobe_opcode_t))
  56. kprobe_opcode_t copied_insn[MAX_COPIED_INSN];
  57. /* detour code buffer */
  58. kprobe_opcode_t *insn;
  59. /*
  60. * We always copy one instruction on ARM,
  61. * so size will always be 4, and unlike x86, there is no
  62. * need for a size field.
  63. */
  64. };
  65. #endif /* CONFIG_KPROBES */
  66. #endif /* _ARM_KPROBES_H */