1
2#ifndef _LINUX_HW_BREAKPOINT_H
3#define _LINUX_HW_BREAKPOINT_H
4
5#include <linux/perf_event.h>
6#include <uapi/linux/hw_breakpoint.h>
7
8#ifdef CONFIG_HAVE_HW_BREAKPOINT
9
10extern int __init init_hw_breakpoint(void);
11
12static inline void hw_breakpoint_init(struct perf_event_attr *attr)
13{
14 memset(attr, 0, sizeof(*attr));
15
16 attr->type = PERF_TYPE_BREAKPOINT;
17 attr->size = sizeof(*attr);
18
19
20
21
22 attr->pinned = 1;
23 attr->sample_period = 1;
24}
25
26static inline void ptrace_breakpoint_init(struct perf_event_attr *attr)
27{
28 hw_breakpoint_init(attr);
29 attr->exclude_kernel = 1;
30}
31
32static inline unsigned long hw_breakpoint_addr(struct perf_event *bp)
33{
34 return bp->attr.bp_addr;
35}
36
37static inline int hw_breakpoint_type(struct perf_event *bp)
38{
39 return bp->attr.bp_type;
40}
41
42static inline unsigned long hw_breakpoint_len(struct perf_event *bp)
43{
44 return bp->attr.bp_len;
45}
46
47extern struct perf_event *
48register_user_hw_breakpoint(struct perf_event_attr *attr,
49 perf_overflow_handler_t triggered,
50 void *context,
51 struct task_struct *tsk);
52
53
54extern int
55modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *attr);
56extern int
57modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
58 bool check);
59
60
61
62
63extern struct perf_event *
64register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
65 perf_overflow_handler_t triggered,
66 void *context,
67 int cpu);
68
69extern struct perf_event * __percpu *
70register_wide_hw_breakpoint(struct perf_event_attr *attr,
71 perf_overflow_handler_t triggered,
72 void *context);
73
74extern int register_perf_hw_breakpoint(struct perf_event *bp);
75extern int __register_perf_hw_breakpoint(struct perf_event *bp);
76extern void unregister_hw_breakpoint(struct perf_event *bp);
77extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events);
78
79extern int dbg_reserve_bp_slot(struct perf_event *bp);
80extern int dbg_release_bp_slot(struct perf_event *bp);
81extern int reserve_bp_slot(struct perf_event *bp);
82extern void release_bp_slot(struct perf_event *bp);
83int hw_breakpoint_weight(struct perf_event *bp);
84int arch_reserve_bp_slot(struct perf_event *bp);
85void arch_release_bp_slot(struct perf_event *bp);
86void arch_unregister_hw_breakpoint(struct perf_event *bp);
87
88extern void flush_ptrace_hw_breakpoint(struct task_struct *tsk);
89
90static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
91{
92 return &bp->hw.info;
93}
94
95#else
96
97static inline int __init init_hw_breakpoint(void) { return 0; }
98
99static inline struct perf_event *
100register_user_hw_breakpoint(struct perf_event_attr *attr,
101 perf_overflow_handler_t triggered,
102 void *context,
103 struct task_struct *tsk) { return NULL; }
104static inline int
105modify_user_hw_breakpoint(struct perf_event *bp,
106 struct perf_event_attr *attr) { return -ENOSYS; }
107static inline int
108modify_user_hw_breakpoint_check(struct perf_event *bp, struct perf_event_attr *attr,
109 bool check) { return -ENOSYS; }
110
111static inline struct perf_event *
112register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr,
113 perf_overflow_handler_t triggered,
114 void *context,
115 int cpu) { return NULL; }
116static inline struct perf_event * __percpu *
117register_wide_hw_breakpoint(struct perf_event_attr *attr,
118 perf_overflow_handler_t triggered,
119 void *context) { return NULL; }
120static inline int
121register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
122static inline int
123__register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; }
124static inline void unregister_hw_breakpoint(struct perf_event *bp) { }
125static inline void
126unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) { }
127static inline int
128reserve_bp_slot(struct perf_event *bp) {return -ENOSYS; }
129static inline void release_bp_slot(struct perf_event *bp) { }
130
131static inline void flush_ptrace_hw_breakpoint(struct task_struct *tsk) { }
132
133static inline struct arch_hw_breakpoint *counter_arch_bp(struct perf_event *bp)
134{
135 return NULL;
136}
137
138#endif
139#endif
140