| 1 |
|
| 2 | |
| 3 | * Copyright (C) 2012 ARM Ltd.
|
| 4 |
|
| 5 | #ifndef __ASM_DEBUG_MONITORS_H
|
| 6 | #define __ASM_DEBUG_MONITORS_H
|
| 7 |
|
| 8 | #include <linux/errno.h>
|
| 9 | #include <linux/types.h>
|
| 10 | #include <asm/brk-imm.h>
|
| 11 | #include <asm/esr.h>
|
| 12 | #include <asm/insn.h>
|
| 13 | #include <asm/ptrace.h>
|
| 14 |
|
| 15 |
|
| 16 | #define DBG_SPSR_SS (1 << 21)
|
| 17 |
|
| 18 | #define DBG_ESR_EVT(x) (((x) >> 27) & 0x7)
|
| 19 |
|
| 20 |
|
| 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 |
|
| 26 | |
| 27 | * Break point instruction encoding
|
| 28 |
|
| 29 | #define BREAK_INSTR_SIZE AARCH64_INSN_SIZE
|
| 30 |
|
| 31 | #define AARCH64_BREAK_KGDB_DYN_DBG \
|
| 32 | (AARCH64_BREAK_MON | (KGDB_DYN_DBG_BRK_IMM << 5))
|
| 33 |
|
| 34 | #define CACHE_FLUSH_IS_SAFE 1
|
| 35 |
|
| 36 |
|
| 37 | #define BRK64_OPCODE_KPROBES (AARCH64_BREAK_MON | (KPROBES_BRK_IMM << 5))
|
| 38 | #define BRK64_OPCODE_KPROBES_SS (AARCH64_BREAK_MON | (KPROBES_BRK_SS_IMM << 5))
|
| 39 |
|
| 40 | #define BRK64_OPCODE_UPROBES (AARCH64_BREAK_MON | (UPROBES_BRK_IMM << 5))
|
| 41 |
|
| 42 |
|
| 43 | #define DBG_ESR_EVT_BKPT 0x4
|
| 44 | #define DBG_ESR_EVT_VECC 0x5
|
| 45 |
|
| 46 | #define AARCH32_BREAK_ARM 0x07f001f0
|
| 47 | #define AARCH32_BREAK_THUMB 0xde01
|
| 48 | #define AARCH32_BREAK_THUMB2_LO 0xf7f0
|
| 49 | #define AARCH32_BREAK_THUMB2_HI 0xa000
|
| 50 |
|
| 51 | #ifndef __ASSEMBLER__
|
| 52 | struct task_struct;
|
| 53 |
|
| 54 | #define DBG_ARCH_ID_RESERVED 0
|
| 55 |
|
| 56 | #define DBG_HOOK_HANDLED 0
|
| 57 | #define DBG_HOOK_ERROR 1
|
| 58 |
|
| 59 | u8 debug_monitors_arch(void);
|
| 60 |
|
| 61 | enum dbg_active_el {
|
| 62 | DBG_ACTIVE_EL0 = 0,
|
| 63 | DBG_ACTIVE_EL1,
|
| 64 | };
|
| 65 |
|
| 66 | void enable_debug_monitors(enum dbg_active_el el);
|
| 67 | void disable_debug_monitors(enum dbg_active_el el);
|
| 68 |
|
| 69 | void user_rewind_single_step(struct task_struct *task);
|
| 70 | void user_fastforward_single_step(struct task_struct *task);
|
| 71 | void user_regs_reset_single_step(struct user_pt_regs *regs,
|
| 72 | struct task_struct *task);
|
| 73 |
|
| 74 | void kernel_enable_single_step(struct pt_regs *regs);
|
| 75 | void kernel_disable_single_step(void);
|
| 76 | int kernel_active_single_step(void);
|
| 77 | void kernel_rewind_single_step(struct pt_regs *regs);
|
| 78 | void kernel_fastforward_single_step(struct pt_regs *regs);
|
| 79 |
|
| 80 | #ifdef CONFIG_HAVE_HW_BREAKPOINT
|
| 81 | bool try_step_suspended_breakpoints(struct pt_regs *regs);
|
| 82 | #else
|
| 83 | static inline bool try_step_suspended_breakpoints(struct pt_regs *regs)
|
| 84 | {
|
| 85 | return false;
|
| 86 | }
|
| 87 | #endif
|
| 88 |
|
| 89 | bool try_handle_aarch32_break(struct pt_regs *regs);
|
| 90 |
|
| 91 | #endif
|
| 92 | #endif
|