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