Commit | Line | Data |
---|---|---|
93128a92 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
21cf9b6b | 3 | * Copyright (C) 2011 EfficiOS Inc. |
93128a92 | 4 | * |
ab5be9fa | 5 | * SPDX-License-Identifier: GPL-2.0-only |
93128a92 | 6 | * |
93128a92 DG |
7 | */ |
8 | ||
9 | #ifndef _LTTNG_KERNEL_H | |
10 | #define _LTTNG_KERNEL_H | |
11 | ||
e848fc76 | 12 | #include <stdint.h> |
c9e313bc | 13 | #include <common/macros.hpp> |
0ef03255 FD |
14 | #include <lttng/constant.h> |
15 | #include <lttng/event.h> | |
e848fc76 | 16 | |
b8e2fb80 FD |
17 | #define LTTNG_KERNEL_ABI_SYM_NAME_LEN 256 |
18 | #define LTTNG_KERNEL_ABI_MAX_UPROBE_NUM 32 | |
19 | #define LTTNG_KERNEL_ABI_SESSION_NAME_LEN 256 | |
20 | #define LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN 26 | |
9cb98350 | 21 | |
7d29a247 DG |
22 | /* |
23 | * LTTng DebugFS ABI structures. | |
24 | * | |
25 | * This is the kernel ABI copied from lttng-modules tree. | |
26 | */ | |
27 | ||
b8e2fb80 FD |
28 | enum lttng_kernel_abi_instrumentation { |
29 | LTTNG_KERNEL_ABI_ALL = -1, /* Used within lttng-tools */ | |
30 | LTTNG_KERNEL_ABI_TRACEPOINT = 0, | |
31 | LTTNG_KERNEL_ABI_KPROBE = 1, | |
32 | LTTNG_KERNEL_ABI_FUNCTION = 2, | |
33 | LTTNG_KERNEL_ABI_KRETPROBE = 3, | |
34 | LTTNG_KERNEL_ABI_NOOP = 4, /* not hooked */ | |
35 | LTTNG_KERNEL_ABI_SYSCALL = 5, | |
36 | LTTNG_KERNEL_ABI_UPROBE = 6, | |
e6ddca71 DG |
37 | }; |
38 | ||
b8e2fb80 FD |
39 | enum lttng_kernel_abi_context_type { |
40 | LTTNG_KERNEL_ABI_CONTEXT_PID = 0, | |
41 | LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER = 1, | |
42 | LTTNG_KERNEL_ABI_CONTEXT_PROCNAME = 2, | |
43 | LTTNG_KERNEL_ABI_CONTEXT_PRIO = 3, | |
44 | LTTNG_KERNEL_ABI_CONTEXT_NICE = 4, | |
45 | LTTNG_KERNEL_ABI_CONTEXT_VPID = 5, | |
46 | LTTNG_KERNEL_ABI_CONTEXT_TID = 6, | |
47 | LTTNG_KERNEL_ABI_CONTEXT_VTID = 7, | |
48 | LTTNG_KERNEL_ABI_CONTEXT_PPID = 8, | |
49 | LTTNG_KERNEL_ABI_CONTEXT_VPPID = 9, | |
50 | LTTNG_KERNEL_ABI_CONTEXT_HOSTNAME = 10, | |
51 | LTTNG_KERNEL_ABI_CONTEXT_CPU_ID = 11, | |
52 | LTTNG_KERNEL_ABI_CONTEXT_INTERRUPTIBLE = 12, | |
53 | LTTNG_KERNEL_ABI_CONTEXT_PREEMPTIBLE = 13, | |
54 | LTTNG_KERNEL_ABI_CONTEXT_NEED_RESCHEDULE = 14, | |
55 | LTTNG_KERNEL_ABI_CONTEXT_MIGRATABLE = 15, | |
56 | LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_KERNEL = 16, | |
57 | LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_USER = 17, | |
58 | LTTNG_KERNEL_ABI_CONTEXT_CGROUP_NS = 18, | |
59 | LTTNG_KERNEL_ABI_CONTEXT_IPC_NS = 19, | |
60 | LTTNG_KERNEL_ABI_CONTEXT_MNT_NS = 20, | |
61 | LTTNG_KERNEL_ABI_CONTEXT_NET_NS = 21, | |
62 | LTTNG_KERNEL_ABI_CONTEXT_PID_NS = 22, | |
63 | LTTNG_KERNEL_ABI_CONTEXT_USER_NS = 23, | |
64 | LTTNG_KERNEL_ABI_CONTEXT_UTS_NS = 24, | |
65 | LTTNG_KERNEL_ABI_CONTEXT_UID = 25, | |
66 | LTTNG_KERNEL_ABI_CONTEXT_EUID = 26, | |
67 | LTTNG_KERNEL_ABI_CONTEXT_SUID = 27, | |
68 | LTTNG_KERNEL_ABI_CONTEXT_GID = 28, | |
69 | LTTNG_KERNEL_ABI_CONTEXT_EGID = 29, | |
70 | LTTNG_KERNEL_ABI_CONTEXT_SGID = 30, | |
71 | LTTNG_KERNEL_ABI_CONTEXT_VUID = 31, | |
72 | LTTNG_KERNEL_ABI_CONTEXT_VEUID = 32, | |
73 | LTTNG_KERNEL_ABI_CONTEXT_VSUID = 33, | |
74 | LTTNG_KERNEL_ABI_CONTEXT_VGID = 34, | |
75 | LTTNG_KERNEL_ABI_CONTEXT_VEGID = 35, | |
76 | LTTNG_KERNEL_ABI_CONTEXT_VSGID = 36, | |
77 | LTTNG_KERNEL_ABI_CONTEXT_TIME_NS = 37, | |
7d29a247 DG |
78 | }; |
79 | ||
80 | /* Perf counter attributes */ | |
b8e2fb80 | 81 | struct lttng_kernel_abi_perf_counter_ctx { |
7d29a247 DG |
82 | uint32_t type; |
83 | uint64_t config; | |
b8e2fb80 | 84 | char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; |
113373e4 | 85 | } LTTNG_PACKED; |
7d29a247 DG |
86 | |
87 | /* Event/Channel context */ | |
b8e2fb80 FD |
88 | #define LTTNG_KERNEL_ABI_CONTEXT_PADDING1 16 |
89 | #define LTTNG_KERNEL_ABI_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32 | |
90 | struct lttng_kernel_abi_context { | |
91 | enum lttng_kernel_abi_context_type ctx; | |
92 | char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING1]; | |
dbbb3ec5 | 93 | |
7d29a247 | 94 | union { |
b8e2fb80 FD |
95 | struct lttng_kernel_abi_perf_counter_ctx perf_counter; |
96 | char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING2]; | |
7d29a247 | 97 | } u; |
113373e4 | 98 | } LTTNG_PACKED; |
9cb98350 | 99 | |
b8e2fb80 | 100 | struct lttng_kernel_abi_kretprobe { |
8f0d098b MD |
101 | uint64_t addr; |
102 | ||
103 | uint64_t offset; | |
b8e2fb80 | 104 | char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; |
113373e4 | 105 | } LTTNG_PACKED; |
8f0d098b | 106 | |
93128a92 | 107 | /* |
7d29a247 | 108 | * Either addr is used, or symbol_name and offset. |
93128a92 | 109 | */ |
b8e2fb80 | 110 | struct lttng_kernel_abi_kprobe { |
7d29a247 DG |
111 | uint64_t addr; |
112 | ||
113 | uint64_t offset; | |
b8e2fb80 | 114 | char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; |
113373e4 | 115 | } LTTNG_PACKED; |
9cb98350 | 116 | |
b8e2fb80 | 117 | struct lttng_kernel_abi_uprobe { |
1ab8c2ad FD |
118 | int fd; |
119 | } LTTNG_PACKED; | |
120 | ||
b8e2fb80 | 121 | struct lttng_kernel_abi_event_callsite_uprobe { |
1ab8c2ad FD |
122 | uint64_t offset; |
123 | } LTTNG_PACKED; | |
124 | ||
b8e2fb80 | 125 | struct lttng_kernel_abi_event_callsite { |
1ab8c2ad | 126 | union { |
b8e2fb80 | 127 | struct lttng_kernel_abi_event_callsite_uprobe uprobe; |
1ab8c2ad FD |
128 | } u; |
129 | } LTTNG_PACKED; | |
130 | ||
b8e2fb80 FD |
131 | enum lttng_kernel_abi_syscall_entryexit { |
132 | LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT = 0, | |
133 | LTTNG_KERNEL_ABI_SYSCALL_ENTRY = 1, | |
134 | LTTNG_KERNEL_ABI_SYSCALL_EXIT = 2, | |
c863e5a6 FD |
135 | }; |
136 | ||
b8e2fb80 FD |
137 | enum lttng_kernel_abi_syscall_abi { |
138 | LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL = 0, | |
139 | LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE = 1, | |
140 | LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT = 2, | |
c863e5a6 FD |
141 | }; |
142 | ||
b8e2fb80 FD |
143 | enum lttng_kernel_abi_syscall_match { |
144 | LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME = 0, | |
145 | LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR = 1, | |
c863e5a6 FD |
146 | }; |
147 | ||
b8e2fb80 FD |
148 | struct lttng_kernel_abi_syscall { |
149 | uint8_t entryexit; /* enum lttng_kernel_abi_syscall_entryexit */ | |
150 | uint8_t abi; /* enum lttng_kernel_abi_syscall_abi */ | |
151 | uint8_t match; /* enum lttng_kernel_abi_syscall_match */ | |
c863e5a6 FD |
152 | uint8_t padding; |
153 | uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */ | |
154 | } LTTNG_PACKED; | |
155 | ||
f05b5f07 | 156 | /* Function tracer */ |
b8e2fb80 FD |
157 | struct lttng_kernel_abi_function { |
158 | char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; | |
113373e4 | 159 | } LTTNG_PACKED; |
93128a92 | 160 | |
b8e2fb80 FD |
161 | #define LTTNG_KERNEL_ABI_EVENT_PADDING1 8 |
162 | #define LTTNG_KERNEL_ABI_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32 | |
163 | struct lttng_kernel_abi_event { | |
164 | char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN]; | |
165 | enum lttng_kernel_abi_instrumentation instrumentation; | |
8e49ca12 | 166 | uint64_t token; |
b8e2fb80 | 167 | char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1]; |
dbbb3ec5 | 168 | |
9cb98350 JD |
169 | /* Per instrumentation type configuration */ |
170 | union { | |
b8e2fb80 FD |
171 | struct lttng_kernel_abi_kretprobe kretprobe; |
172 | struct lttng_kernel_abi_kprobe kprobe; | |
173 | struct lttng_kernel_abi_function ftrace; | |
174 | struct lttng_kernel_abi_uprobe uprobe; | |
175 | struct lttng_kernel_abi_syscall syscall; | |
176 | char padding[LTTNG_KERNEL_ABI_EVENT_PADDING2]; | |
9cb98350 | 177 | } u; |
113373e4 | 178 | } LTTNG_PACKED; |
93128a92 | 179 | |
b8e2fb80 FD |
180 | #define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING 32 |
181 | struct lttng_kernel_abi_event_notifier { | |
182 | struct lttng_kernel_abi_event event; | |
90aa04a1 FD |
183 | uint64_t error_counter_idx; |
184 | ||
b8e2fb80 | 185 | char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING]; |
cfb1c9bc JR |
186 | } LTTNG_PACKED; |
187 | ||
b8e2fb80 | 188 | #define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX 4 |
90aa04a1 | 189 | |
b8e2fb80 FD |
190 | enum lttng_kernel_abi_counter_arithmetic { |
191 | LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0, | |
90aa04a1 FD |
192 | }; |
193 | ||
b8e2fb80 FD |
194 | enum lttng_kernel_abi_counter_bitness { |
195 | LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 = 0, | |
196 | LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1, | |
90aa04a1 FD |
197 | }; |
198 | ||
b8e2fb80 | 199 | struct lttng_kernel_abi_counter_dimension { |
90aa04a1 FD |
200 | uint64_t size; |
201 | uint64_t underflow_index; | |
202 | uint64_t overflow_index; | |
203 | uint8_t has_underflow; | |
204 | uint8_t has_overflow; | |
205 | } LTTNG_PACKED; | |
206 | ||
b8e2fb80 FD |
207 | #define LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1 67 |
208 | struct lttng_kernel_abi_counter_conf { | |
209 | uint32_t arithmetic; /* enum lttng_kernel_abi_counter_arithmetic */ | |
210 | uint32_t bitness; /* enum lttng_kernel_abi_counter_bitness */ | |
90aa04a1 FD |
211 | uint32_t number_dimensions; |
212 | int64_t global_sum_step; | |
b8e2fb80 | 213 | struct lttng_kernel_abi_counter_dimension dimensions[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX]; |
90aa04a1 | 214 | uint8_t coalesce_hits; |
b8e2fb80 | 215 | char padding[LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1]; |
90aa04a1 FD |
216 | } LTTNG_PACKED; |
217 | ||
b8e2fb80 | 218 | struct lttng_kernel_abi_counter_index { |
90aa04a1 | 219 | uint32_t number_dimensions; |
b8e2fb80 | 220 | uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX]; |
90aa04a1 FD |
221 | } LTTNG_PACKED; |
222 | ||
b8e2fb80 | 223 | struct lttng_kernel_abi_counter_value { |
90aa04a1 FD |
224 | int64_t value; |
225 | uint8_t underflow; | |
226 | uint8_t overflow; | |
227 | } LTTNG_PACKED; | |
228 | ||
b8e2fb80 FD |
229 | #define LTTNG_KERNEL_ABI_COUNTER_READ_PADDING 32 |
230 | struct lttng_kernel_abi_counter_read { | |
231 | struct lttng_kernel_abi_counter_index index; | |
90aa04a1 | 232 | int32_t cpu; /* -1 for global counter, >= 0 for specific cpu. */ |
b8e2fb80 FD |
233 | struct lttng_kernel_abi_counter_value value; /* output */ |
234 | char padding[LTTNG_KERNEL_ABI_COUNTER_READ_PADDING]; | |
90aa04a1 FD |
235 | } LTTNG_PACKED; |
236 | ||
b8e2fb80 FD |
237 | #define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING 32 |
238 | struct lttng_kernel_abi_counter_aggregate { | |
239 | struct lttng_kernel_abi_counter_index index; | |
240 | struct lttng_kernel_abi_counter_value value; /* output */ | |
241 | char padding[LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING]; | |
90aa04a1 FD |
242 | } LTTNG_PACKED; |
243 | ||
b8e2fb80 FD |
244 | #define LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING 32 |
245 | struct lttng_kernel_abi_counter_clear { | |
246 | struct lttng_kernel_abi_counter_index index; | |
247 | char padding[LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING]; | |
90aa04a1 FD |
248 | } LTTNG_PACKED; |
249 | ||
b8e2fb80 FD |
250 | #define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32 |
251 | struct lttng_kernel_abi_event_notifier_notification { | |
cfb1c9bc | 252 | uint64_t token; |
bbd6675c | 253 | uint16_t capture_buf_size; |
b8e2fb80 | 254 | char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING]; |
cfb1c9bc JR |
255 | } LTTNG_PACKED; |
256 | ||
b8e2fb80 FD |
257 | #define LTTNG_KERNEL_ABI_CAPTURE_BYTECODE_MAX_LEN 65536 |
258 | struct lttng_kernel_abi_capture_bytecode { | |
bbd6675c JR |
259 | uint32_t len; |
260 | uint32_t reloc_offset; | |
261 | uint64_t seqnum; | |
262 | char data[0]; | |
263 | } LTTNG_PACKED; | |
264 | ||
b8e2fb80 | 265 | struct lttng_kernel_abi_tracer_version { |
a62a6556 MD |
266 | uint32_t major; |
267 | uint32_t minor; | |
9cb98350 | 268 | uint32_t patchlevel; |
113373e4 | 269 | } LTTNG_PACKED; |
93128a92 | 270 | |
b8e2fb80 | 271 | struct lttng_kernel_abi_tracer_abi_version { |
c052142c MD |
272 | uint32_t major; |
273 | uint32_t minor; | |
274 | } LTTNG_PACKED; | |
275 | ||
b8e2fb80 | 276 | struct lttng_kernel_abi_syscall_mask { |
46820c8b | 277 | uint32_t len; /* in bits */ |
e80c3634 MD |
278 | char mask[]; |
279 | } LTTNG_PACKED; | |
280 | ||
4dbc372b JD |
281 | /* |
282 | * kernel channel | |
283 | */ | |
b8e2fb80 FD |
284 | #define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 |
285 | struct lttng_kernel_abi_channel { | |
4dbc372b JD |
286 | uint64_t subbuf_size; /* bytes */ |
287 | uint64_t num_subbuf; /* power of 2 */ | |
288 | unsigned int switch_timer_interval; /* usec */ | |
289 | unsigned int read_timer_interval; /* usec */ | |
290 | enum lttng_event_output output; /* splice, mmap */ | |
291 | ||
292 | int overwrite; /* 1: overwrite, 0: discard */ | |
b8e2fb80 | 293 | char padding[LTTNG_KERNEL_ABI_CHANNEL_PADDING1]; |
113373e4 | 294 | } LTTNG_PACKED; |
d0254c7c | 295 | |
00a62084 | 296 | #define KERNEL_FILTER_BYTECODE_MAX_LEN 65536 |
b8e2fb80 | 297 | struct lttng_kernel_abi_filter_bytecode { |
00a62084 MD |
298 | uint32_t len; |
299 | uint32_t reloc_offset; | |
300 | uint64_t seqnum; | |
301 | char data[0]; | |
302 | } LTTNG_PACKED; | |
303 | ||
8ff4109e JR |
304 | /* |
305 | * kernel session name | |
306 | */ | |
b8e2fb80 FD |
307 | struct lttng_kernel_abi_session_name { |
308 | char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN]; | |
8ff4109e JR |
309 | } LTTNG_PACKED; |
310 | ||
e04b2181 JR |
311 | /* |
312 | * kernel session creation datetime | |
313 | */ | |
b8e2fb80 FD |
314 | struct lttng_kernel_abi_session_creation_time { |
315 | char iso8601[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN]; | |
e04b2181 JR |
316 | } LTTNG_PACKED; |
317 | ||
b8e2fb80 FD |
318 | enum lttng_kernel_abi_tracker_type { |
319 | LTTNG_KERNEL_ABI_TRACKER_UNKNOWN = -1, | |
d01c0e56 | 320 | |
b8e2fb80 FD |
321 | LTTNG_KERNEL_ABI_TRACKER_PID = 0, |
322 | LTTNG_KERNEL_ABI_TRACKER_VPID = 1, | |
323 | LTTNG_KERNEL_ABI_TRACKER_UID = 2, | |
324 | LTTNG_KERNEL_ABI_TRACKER_VUID = 3, | |
325 | LTTNG_KERNEL_ABI_TRACKER_GID = 4, | |
326 | LTTNG_KERNEL_ABI_TRACKER_VGID = 5, | |
d01c0e56 MD |
327 | }; |
328 | ||
b8e2fb80 FD |
329 | struct lttng_kernel_abi_tracker_args { |
330 | enum lttng_kernel_abi_tracker_type type; | |
d01c0e56 MD |
331 | int32_t id; |
332 | }; | |
333 | ||
93128a92 | 334 | #endif /* _LTTNG_KERNEL_H */ |