kprobes.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * arch/arm/kernel/kprobes.h
  3. *
  4. * Contents moved from arch/arm/include/asm/kprobes.h which is
  5. * Copyright (C) 2006, 2007 Motorola Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. */
  16. #ifndef _ARM_KERNEL_KPROBES_H
  17. #define _ARM_KERNEL_KPROBES_H
  18. /*
  19. * These undefined instructions must be unique and
  20. * reserved solely for kprobes' use.
  21. */
  22. #define KPROBE_ARM_BREAKPOINT_INSTRUCTION 0x07f001f8
  23. #define KPROBE_THUMB16_BREAKPOINT_INSTRUCTION 0xde18
  24. #define KPROBE_THUMB32_BREAKPOINT_INSTRUCTION 0xf7f0a018
  25. enum kprobe_insn {
  26. INSN_REJECTED,
  27. INSN_GOOD,
  28. INSN_GOOD_NO_SLOT
  29. };
  30. typedef enum kprobe_insn (kprobe_decode_insn_t)(kprobe_opcode_t,
  31. struct arch_specific_insn *);
  32. #ifdef CONFIG_THUMB2_KERNEL
  33. enum kprobe_insn thumb16_kprobe_decode_insn(kprobe_opcode_t,
  34. struct arch_specific_insn *);
  35. enum kprobe_insn thumb32_kprobe_decode_insn(kprobe_opcode_t,
  36. struct arch_specific_insn *);
  37. #else /* !CONFIG_THUMB2_KERNEL */
  38. enum kprobe_insn arm_kprobe_decode_insn(kprobe_opcode_t,
  39. struct arch_specific_insn *);
  40. #endif
  41. void __init arm_kprobe_decode_init(void);
  42. extern kprobe_check_cc * const kprobe_condition_checks[16];
  43. #if __LINUX_ARM_ARCH__ >= 7
  44. /* str_pc_offset is architecturally defined from ARMv7 onwards */
  45. #define str_pc_offset 8
  46. #define find_str_pc_offset()
  47. #else /* __LINUX_ARM_ARCH__ < 7 */
  48. /* We need a run-time check to determine str_pc_offset */
  49. extern int str_pc_offset;
  50. void __init find_str_pc_offset(void);
  51. #endif
  52. /*
  53. * Update ITSTATE after normal execution of an IT block instruction.
  54. *
  55. * The 8 IT state bits are split into two parts in CPSR:
  56. * ITSTATE<1:0> are in CPSR<26:25>
  57. * ITSTATE<7:2> are in CPSR<15:10>
  58. */
  59. static inline unsigned long it_advance(unsigned long cpsr)
  60. {
  61. if ((cpsr & 0x06000400) == 0) {
  62. /* ITSTATE<2:0> == 0 means end of IT block, so clear IT state */
  63. cpsr &= ~PSR_IT_MASK;
  64. } else {
  65. /* We need to shift left ITSTATE<4:0> */
  66. const unsigned long mask = 0x06001c00; /* Mask ITSTATE<4:0> */
  67. unsigned long it = cpsr & mask;
  68. it <<= 1;
  69. it |= it >> (27 - 10); /* Carry ITSTATE<2> to correct place */
  70. it &= mask;
  71. cpsr &= ~mask;
  72. cpsr |= it;
  73. }
  74. return cpsr;
  75. }
  76. /*
  77. * Test if load/store instructions writeback the address register.
  78. * if P (bit 24) == 0 or W (bit 21) == 1
  79. */
  80. #define is_writeback(insn) ((insn ^ 0x01000000) & 0x01200000)
  81. #endif /* _ARM_KERNEL_KPROBES_H */