1 #ifndef _LINUX_HW_BREAKPOINT_H
2 #define _LINUX_HW_BREAKPOINT_H
5 HW_BREAKPOINT_LEN_1
= 1,
6 HW_BREAKPOINT_LEN_2
= 2,
7 HW_BREAKPOINT_LEN_4
= 4,
8 HW_BREAKPOINT_LEN_8
= 8,
12 HW_BREAKPOINT_EMPTY
= 0,
15 HW_BREAKPOINT_RW
= HW_BREAKPOINT_R
| HW_BREAKPOINT_W
,
17 HW_BREAKPOINT_INVALID
= HW_BREAKPOINT_RW
| HW_BREAKPOINT_X
,
22 #ifdef CONFIG_HAVE_MIXED_BREAKPOINTS_REGS
32 #include <linux/perf_event.h>
34 #ifdef CONFIG_HAVE_HW_BREAKPOINT
36 extern int __init
init_hw_breakpoint(void);
38 static inline void hw_breakpoint_init(struct perf_event_attr
*attr
)
40 memset(attr
, 0, sizeof(*attr
));
42 attr
->type
= PERF_TYPE_BREAKPOINT
;
43 attr
->size
= sizeof(*attr
);
45 * As it's for in-kernel or ptrace use, we want it to be pinned
46 * and to call its callback every hits.
49 attr
->sample_period
= 1;
52 static inline void ptrace_breakpoint_init(struct perf_event_attr
*attr
)
54 hw_breakpoint_init(attr
);
55 attr
->exclude_kernel
= 1;
58 static inline unsigned long hw_breakpoint_addr(struct perf_event
*bp
)
60 return bp
->attr
.bp_addr
;
63 static inline int hw_breakpoint_type(struct perf_event
*bp
)
65 return bp
->attr
.bp_type
;
68 static inline unsigned long hw_breakpoint_len(struct perf_event
*bp
)
70 return bp
->attr
.bp_len
;
73 extern struct perf_event
*
74 register_user_hw_breakpoint(struct perf_event_attr
*attr
,
75 perf_overflow_handler_t triggered
,
76 struct task_struct
*tsk
);
78 /* FIXME: only change from the attr, and don't unregister */
80 modify_user_hw_breakpoint(struct perf_event
*bp
, struct perf_event_attr
*attr
);
83 * Kernel breakpoints are not associated with any particular thread.
85 extern struct perf_event
*
86 register_wide_hw_breakpoint_cpu(struct perf_event_attr
*attr
,
87 perf_overflow_handler_t triggered
,
90 extern struct perf_event
* __percpu
*
91 register_wide_hw_breakpoint(struct perf_event_attr
*attr
,
92 perf_overflow_handler_t triggered
);
94 extern int register_perf_hw_breakpoint(struct perf_event
*bp
);
95 extern int __register_perf_hw_breakpoint(struct perf_event
*bp
);
96 extern void unregister_hw_breakpoint(struct perf_event
*bp
);
97 extern void unregister_wide_hw_breakpoint(struct perf_event
* __percpu
*cpu_events
);
99 extern int dbg_reserve_bp_slot(struct perf_event
*bp
);
100 extern int dbg_release_bp_slot(struct perf_event
*bp
);
101 extern int reserve_bp_slot(struct perf_event
*bp
);
102 extern void release_bp_slot(struct perf_event
*bp
);
104 extern void flush_ptrace_hw_breakpoint(struct task_struct
*tsk
);
106 static inline struct arch_hw_breakpoint
*counter_arch_bp(struct perf_event
*bp
)
111 #else /* !CONFIG_HAVE_HW_BREAKPOINT */
113 static inline int __init
init_hw_breakpoint(void) { return 0; }
115 static inline struct perf_event
*
116 register_user_hw_breakpoint(struct perf_event_attr
*attr
,
117 perf_overflow_handler_t triggered
,
118 struct task_struct
*tsk
) { return NULL
; }
120 modify_user_hw_breakpoint(struct perf_event
*bp
,
121 struct perf_event_attr
*attr
) { return -ENOSYS
; }
122 static inline struct perf_event
*
123 register_wide_hw_breakpoint_cpu(struct perf_event_attr
*attr
,
124 perf_overflow_handler_t triggered
,
125 int cpu
) { return NULL
; }
126 static inline struct perf_event
* __percpu
*
127 register_wide_hw_breakpoint(struct perf_event_attr
*attr
,
128 perf_overflow_handler_t triggered
) { return NULL
; }
130 register_perf_hw_breakpoint(struct perf_event
*bp
) { return -ENOSYS
; }
132 __register_perf_hw_breakpoint(struct perf_event
*bp
) { return -ENOSYS
; }
133 static inline void unregister_hw_breakpoint(struct perf_event
*bp
) { }
135 unregister_wide_hw_breakpoint(struct perf_event
* __percpu
*cpu_events
) { }
137 reserve_bp_slot(struct perf_event
*bp
) {return -ENOSYS
; }
138 static inline void release_bp_slot(struct perf_event
*bp
) { }
140 static inline void flush_ptrace_hw_breakpoint(struct task_struct
*tsk
) { }
142 static inline struct arch_hw_breakpoint
*counter_arch_bp(struct perf_event
*bp
)
147 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
148 #endif /* __KERNEL__ */
150 #endif /* _LINUX_HW_BREAKPOINT_H */