0001
0002
0003
0004
0005 #ifndef __ASM_DEBUG_MONITORS_H
0006 #define __ASM_DEBUG_MONITORS_H
0007
0008 #include <linux/errno.h>
0009 #include <linux/types.h>
0010 #include <asm/brk-imm.h>
0011 #include <asm/esr.h>
0012 #include <asm/insn.h>
0013 #include <asm/ptrace.h>
0014
0015
0016 #define DBG_MDSCR_SS (1 << 0)
0017 #define DBG_SPSR_SS (1 << 21)
0018
0019
0020 #define DBG_MDSCR_KDE (1 << 13)
0021 #define DBG_MDSCR_MDE (1 << 15)
0022 #define DBG_MDSCR_MASK ~(DBG_MDSCR_KDE | DBG_MDSCR_MDE)
0023
0024 #define DBG_ESR_EVT(x) (((x) >> 27) & 0x7)
0025
0026
0027 #define DBG_ESR_EVT_HWBP 0x0
0028 #define DBG_ESR_EVT_HWSS 0x1
0029 #define DBG_ESR_EVT_HWWP 0x2
0030 #define DBG_ESR_EVT_BRK 0x6
0031
0032
0033
0034
0035 #define BREAK_INSTR_SIZE AARCH64_INSN_SIZE
0036
0037 #define AARCH64_BREAK_KGDB_DYN_DBG \
0038 (AARCH64_BREAK_MON | (KGDB_DYN_DBG_BRK_IMM << 5))
0039
0040 #define CACHE_FLUSH_IS_SAFE 1
0041
0042
0043 #define BRK64_OPCODE_KPROBES (AARCH64_BREAK_MON | (KPROBES_BRK_IMM << 5))
0044 #define BRK64_OPCODE_KPROBES_SS (AARCH64_BREAK_MON | (KPROBES_BRK_SS_IMM << 5))
0045
0046 #define BRK64_OPCODE_UPROBES (AARCH64_BREAK_MON | (UPROBES_BRK_IMM << 5))
0047
0048
0049 #define DBG_ESR_EVT_BKPT 0x4
0050 #define DBG_ESR_EVT_VECC 0x5
0051
0052 #define AARCH32_BREAK_ARM 0x07f001f0
0053 #define AARCH32_BREAK_THUMB 0xde01
0054 #define AARCH32_BREAK_THUMB2_LO 0xf7f0
0055 #define AARCH32_BREAK_THUMB2_HI 0xa000
0056
0057 #ifndef __ASSEMBLY__
0058 struct task_struct;
0059
0060 #define DBG_ARCH_ID_RESERVED 0
0061
0062 #define DBG_HOOK_HANDLED 0
0063 #define DBG_HOOK_ERROR 1
0064
0065 struct step_hook {
0066 struct list_head node;
0067 int (*fn)(struct pt_regs *regs, unsigned long esr);
0068 };
0069
0070 void register_user_step_hook(struct step_hook *hook);
0071 void unregister_user_step_hook(struct step_hook *hook);
0072
0073 void register_kernel_step_hook(struct step_hook *hook);
0074 void unregister_kernel_step_hook(struct step_hook *hook);
0075
0076 struct break_hook {
0077 struct list_head node;
0078 int (*fn)(struct pt_regs *regs, unsigned long esr);
0079 u16 imm;
0080 u16 mask;
0081 };
0082
0083 void register_user_break_hook(struct break_hook *hook);
0084 void unregister_user_break_hook(struct break_hook *hook);
0085
0086 void register_kernel_break_hook(struct break_hook *hook);
0087 void unregister_kernel_break_hook(struct break_hook *hook);
0088
0089 u8 debug_monitors_arch(void);
0090
0091 enum dbg_active_el {
0092 DBG_ACTIVE_EL0 = 0,
0093 DBG_ACTIVE_EL1,
0094 };
0095
0096 void enable_debug_monitors(enum dbg_active_el el);
0097 void disable_debug_monitors(enum dbg_active_el el);
0098
0099 void user_rewind_single_step(struct task_struct *task);
0100 void user_fastforward_single_step(struct task_struct *task);
0101 void user_regs_reset_single_step(struct user_pt_regs *regs,
0102 struct task_struct *task);
0103
0104 void kernel_enable_single_step(struct pt_regs *regs);
0105 void kernel_disable_single_step(void);
0106 int kernel_active_single_step(void);
0107
0108 #ifdef CONFIG_HAVE_HW_BREAKPOINT
0109 int reinstall_suspended_bps(struct pt_regs *regs);
0110 #else
0111 static inline int reinstall_suspended_bps(struct pt_regs *regs)
0112 {
0113 return -ENODEV;
0114 }
0115 #endif
0116
0117 int aarch32_break_handler(struct pt_regs *regs);
0118
0119 void debug_traps_init(void);
0120
0121 #endif
0122 #endif