debug-monitors.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2012 ARM Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __ASM_DEBUG_MONITORS_H
  17. #define __ASM_DEBUG_MONITORS_H
  18. #ifdef __KERNEL__
  19. #define DBG_ESR_EVT(x) (((x) >> 27) & 0x7)
  20. /* AArch64 */
  21. #define DBG_ESR_EVT_HWBP 0x0
  22. #define DBG_ESR_EVT_HWSS 0x1
  23. #define DBG_ESR_EVT_HWWP 0x2
  24. #define DBG_ESR_EVT_BRK 0x6
  25. enum debug_el {
  26. DBG_ACTIVE_EL0 = 0,
  27. DBG_ACTIVE_EL1,
  28. };
  29. /* AArch32 */
  30. #define DBG_ESR_EVT_BKPT 0x4
  31. #define DBG_ESR_EVT_VECC 0x5
  32. #define AARCH32_BREAK_ARM 0x07f001f0
  33. #define AARCH32_BREAK_THUMB 0xde01
  34. #define AARCH32_BREAK_THUMB2_LO 0xf7f0
  35. #define AARCH32_BREAK_THUMB2_HI 0xa000
  36. #ifndef __ASSEMBLY__
  37. struct task_struct;
  38. #define local_dbg_save(flags) \
  39. do { \
  40. typecheck(unsigned long, flags); \
  41. asm volatile( \
  42. "mrs %0, daif // local_dbg_save\n" \
  43. "msr daifset, #8" \
  44. : "=r" (flags) : : "memory"); \
  45. } while (0)
  46. #define local_dbg_restore(flags) \
  47. do { \
  48. typecheck(unsigned long, flags); \
  49. asm volatile( \
  50. "msr daif, %0 // local_dbg_restore\n" \
  51. : : "r" (flags) : "memory"); \
  52. } while (0)
  53. #define DBG_ARCH_ID_RESERVED 0 /* In case of ptrace ABI updates. */
  54. u8 debug_monitors_arch(void);
  55. void enable_debug_monitors(enum debug_el el);
  56. void disable_debug_monitors(enum debug_el el);
  57. void user_rewind_single_step(struct task_struct *task);
  58. void user_fastforward_single_step(struct task_struct *task);
  59. void kernel_enable_single_step(struct pt_regs *regs);
  60. void kernel_disable_single_step(void);
  61. int kernel_active_single_step(void);
  62. #ifdef CONFIG_HAVE_HW_BREAKPOINT
  63. int reinstall_suspended_bps(struct pt_regs *regs);
  64. #else
  65. static inline int reinstall_suspended_bps(struct pt_regs *regs)
  66. {
  67. return -ENODEV;
  68. }
  69. #endif
  70. #endif /* __ASSEMBLY */
  71. #endif /* __KERNEL__ */
  72. #endif /* __ASM_DEBUG_MONITORS_H */