0dbdd82b9dbe4d2d7d7807fb580efed19ba71402
[lttng-modules.git] / include / instrumentation / syscalls / headers / syscalls_pointers_override.h
1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
2
3 #ifndef CREATE_SYSCALL_TABLE
4
5 #define OVERRIDE_32_execve
6 #define OVERRIDE_64_execve
7 SC_LTTNG_TRACEPOINT_EVENT(execve,
8 TP_PROTO(sc_exit(long ret,) const char *filename, char *const *argv, char *const *envp),
9 TP_ARGS(sc_exit(ret,) filename, argv, envp),
10 TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
11 sc_in(ctf_user_string(filename, filename))
12 sc_in(ctf_integer_hex(char *const *, argv, argv))
13 sc_in(ctf_integer_hex(char *const *, envp, envp))
14 )
15 )
16
17 /*
18 * Clone()'s `flags` field has two parts:
19 * 1. exit signal: the least significant byte of the `unsigned long` is
20 * the signal the kernel must send to the parent process on child
21 * exit,
22 * 2. clone options: the remaining bytes of the `unsigned long` is used a
23 * bitwise flag for the clone options.
24 */
25 #define CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS 8
26 #define LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(x) ((x) >> CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS)
27
28 SC_LTTNG_TRACEPOINT_ENUM(lttng_clone_exit_signal_flags,
29 TP_ENUM_VALUES(
30 ctf_enum_value("SIGHUP", SIGHUP)
31 ctf_enum_value("SIGINT", SIGINT)
32 ctf_enum_value("SIGQUIT", SIGQUIT)
33 ctf_enum_value("SIGILL", SIGILL)
34 ctf_enum_value("SIGTRAP", SIGTRAP)
35 ctf_enum_value("SIGABRT", SIGABRT)
36 ctf_enum_value("SIGIOT", SIGIOT)
37 ctf_enum_value("SIGBUS", SIGBUS)
38 #ifdef SIGEMT
39 ctf_enum_value("SIGEMT", SIGEMT)
40 #endif /* #ifdef SIGEMT */
41 ctf_enum_value("SIGFPE", SIGFPE)
42 ctf_enum_value("SIGKILL", SIGKILL)
43 ctf_enum_value("SIGUSR1", SIGUSR1)
44 ctf_enum_value("SIGSEGV", SIGSEGV)
45 ctf_enum_value("SIGUSR2", SIGUSR2)
46 ctf_enum_value("SIGPIPE", SIGPIPE)
47 ctf_enum_value("SIGALRM", SIGALRM)
48 ctf_enum_value("SIGTERM", SIGTERM)
49 #ifdef SIGSTKFLT
50 ctf_enum_value("SIGSTKFLT", SIGSTKFLT)
51 #endif /* #ifdef SIGSTKFLT */
52 ctf_enum_value("SIGCHLD", SIGCHLD)
53 #ifdef SIGCLD
54 ctf_enum_value("SIGCLD", SIGCLD)
55 #endif /* #ifdef SIGCLD */
56 ctf_enum_value("SIGCONT", SIGCONT)
57 ctf_enum_value("SIGSTOP", SIGSTOP)
58 ctf_enum_value("SIGTSTP", SIGTSTP)
59 ctf_enum_value("SIGTTIN", SIGTTIN)
60 ctf_enum_value("SIGTTOU", SIGTTOU)
61 ctf_enum_value("SIGURG", SIGURG)
62 ctf_enum_value("SIGXCPU", SIGXCPU)
63 ctf_enum_value("SIGXFSZ", SIGXFSZ)
64 ctf_enum_value("SIGVTALR", SIGVTALRM)
65 ctf_enum_value("SIGPROF", SIGPROF)
66 ctf_enum_value("SIGWINCH", SIGWINCH)
67 ctf_enum_value("SIGIO", SIGIO)
68 ctf_enum_value("SIGPOLL", SIGPOLL)
69 ctf_enum_value("SIGPWR", SIGPWR)
70 #ifdef SIGINFO
71 ctf_enum_value("SIGINFO", SIGINFO)
72 #endif /* #ifdef SIGINFO */
73 #ifdef SIGLOST
74 ctf_enum_value("SIGLOST", SIGLOST)
75 #endif /* #ifdef SIGLOST */
76 ctf_enum_value("SIGSYS", SIGSYS)
77 #ifdef SIGUNUSED
78 ctf_enum_value("SIGUNUSED", SIGUNUSED)
79 #endif /* #ifdef SIGUNUSED */
80 )
81 )
82
83 SC_LTTNG_TRACEPOINT_ENUM(lttng_clone_option_flags,
84 TP_ENUM_VALUES(
85 ctf_enum_value("CLONE_CHILD_CLEARTID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_CHILD_CLEARTID))
86 ctf_enum_value("CLONE_CHILD_SETTID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_CHILD_SETTID))
87 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0))
88 ctf_enum_value("CLONE_CLEAR_SIGHAND", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_CLEAR_SIGHAND))
89 #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,5,0)) */
90 ctf_enum_value("CLONE_DETACHED", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_DETACHED))
91 ctf_enum_value("CLONE_FILES", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_FILES))
92 ctf_enum_value("CLONE_FS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_FS))
93 ctf_enum_value("CLONE_IO", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_IO))
94 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0))
95 ctf_enum_value("CLONE_NEWCGROUP", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWCGROUP))
96 #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,6,0)) */
97 ctf_enum_value("CLONE_NEWIPC", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWIPC))
98 ctf_enum_value("CLONE_NEWNET", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWNET))
99 ctf_enum_value("CLONE_NEWNS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWNS))
100 ctf_enum_value("CLONE_NEWPID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWPID))
101 ctf_enum_value("CLONE_NEWUSER", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWUSER))
102 ctf_enum_value("CLONE_NEWUTS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_NEWUTS))
103 ctf_enum_value("CLONE_PARENT", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PARENT))
104 ctf_enum_value("CLONE_PARENT_SETTID", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PARENT_SETTID))
105 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0))
106 ctf_enum_value("CLONE_PIDFD", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PIDFD))
107 #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,2,0)) */
108 ctf_enum_value("CLONE_PTRACE", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_PTRACE))
109 ctf_enum_value("CLONE_SETTLS", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_SETTLS))
110 ctf_enum_value("CLONE_SIGHAND", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_SIGHAND))
111 ctf_enum_value("CLONE_SYSVSEM", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_SYSVSEM))
112 ctf_enum_value("CLONE_THREAD", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_THREAD))
113 ctf_enum_value("CLONE_UNTRACED", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_UNTRACED))
114 ctf_enum_value("CLONE_VFORK", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_VFORK))
115 ctf_enum_value("CLONE_VM", LTTNG_CLONE_OPTIONS_FLAGS_TO_CTF(CLONE_VM))
116 )
117 )
118
119 #define LTTNG_CLONE_FLAGS_EXIT_SIGNAL \
120 { \
121 .name = "exit_signal", \
122 .type = { \
123 .type = lttng_kernel_type_enum_nestable, \
124 .u = { \
125 .enum_nestable = { \
126 .desc = &__enum_lttng_clone_exit_signal_flags, \
127 .container_type = __LTTNG_COMPOUND_LITERAL( \
128 struct lttng_type, __type_integer(unsigned long, \
129 CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS, \
130 1, -1, __BYTE_ORDER, 16, none)), \
131 }, \
132 }, \
133 }, \
134 }
135
136 #define LTTNG_CLONE_FLAGS_OPTIONS \
137 { \
138 .name = "options", \
139 .type = { \
140 .type = lttng_kernel_type_enum_nestable, \
141 .u = { \
142 .enum_nestable = { \
143 .desc = &__enum_lttng_clone_option_flags, \
144 .container_type = __LTTNG_COMPOUND_LITERAL( \
145 struct lttng_type, __type_integer(unsigned long,\
146 sizeof(unsigned long) * CHAR_BIT - CLONE_EXIT_SIGNAL_FLAG_RESERVED_BITS, \
147 1, -1, __BYTE_ORDER, 16, none)), \
148 }, \
149 }, \
150 }, \
151 }
152
153 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
154 #define LTTNG_CLONE_FLAGS \
155 [0] = LTTNG_CLONE_FLAGS_EXIT_SIGNAL, \
156 [1] = LTTNG_CLONE_FLAGS_OPTIONS,
157
158 #else
159 #define LTTNG_CLONE_FLAGS \
160 [0] = LTTNG_CLONE_FLAGS_OPTIONS, \
161 [1] = LTTNG_CLONE_FLAGS_EXIT_SIGNAL,
162 #endif
163
164
165 #define OVERRIDE_32_clone
166 #define OVERRIDE_64_clone
167 SC_LTTNG_TRACEPOINT_EVENT(clone,
168 TP_PROTO(sc_exit(long ret,) unsigned long clone_flags, unsigned long newsp,
169 void __user *parent_tid,
170 void __user *child_tid),
171 TP_ARGS(sc_exit(ret,) clone_flags, newsp, parent_tid, child_tid),
172 TP_FIELDS(
173 sc_exit(ctf_integer(long, ret, ret))
174 sc_in(
175 ctf_custom_field(
176 ctf_custom_type(
177 {
178 .type = lttng_kernel_type_struct_nestable,
179 .u.struct_nestable.nr_fields = 2,
180 .u.struct_nestable.fields =
181 __LTTNG_COMPOUND_LITERAL(struct lttng_event_field,
182 LTTNG_CLONE_FLAGS
183 ),
184 .u.struct_nestable.alignment = lttng_alignof(unsigned long) * CHAR_BIT,
185 }
186 ),
187 flags,
188 ctf_custom_code(
189 ctf_integer_type(unsigned long, clone_flags)
190 )
191 )
192 )
193 sc_in(ctf_integer_hex(unsigned long, newsp, newsp))
194 sc_in(ctf_integer_hex(void *, parent_tid, parent_tid))
195 sc_in(ctf_integer_hex(void *, child_tid, child_tid))
196 )
197 )
198
199 /* present in 32, missing in 64 due to old kernel headers */
200 #define OVERRIDE_32_getcpu
201 #define OVERRIDE_64_getcpu
202 SC_LTTNG_TRACEPOINT_EVENT(getcpu,
203 TP_PROTO(sc_exit(long ret,) unsigned __user *cpup, unsigned __user *nodep, void *tcache),
204 TP_ARGS(sc_exit(ret,) cpup, nodep, tcache),
205 TP_FIELDS(
206 sc_exit(ctf_integer(long, ret, ret))
207 sc_out(ctf_integer_hex(unsigned *, cpup, cpup))
208 sc_out(ctf_integer_hex(unsigned *, nodep, nodep))
209 sc_inout(ctf_integer_hex(void *, tcache, tcache))
210 )
211 )
212
213 #define OVERRIDE_32_pipe2
214 #define OVERRIDE_64_pipe2
215 SC_LTTNG_TRACEPOINT_EVENT(pipe2,
216 TP_PROTO(sc_exit(long ret,) int * fildes, int flags),
217 TP_ARGS(sc_exit(ret,) fildes, flags),
218 TP_FIELDS(sc_exit(ctf_integer(long, ret, ret))
219 sc_out(ctf_user_array(int, fildes, fildes, 2))
220 sc_in(ctf_integer(int, flags, flags))
221 )
222 )
223
224 #define LTTNG_SYSCALL_SELECT_locvar \
225 unsigned long *fds_in, *fds_out, *fds_ex; \
226 unsigned long nr_bytes, nr_ulong; \
227 uint8_t overflow;
228
229 #define LTTNG_SYSCALL_SELECT_code_pre \
230 sc_inout( \
231 { \
232 int err; \
233 unsigned int n_in_bytes; \
234 \
235 tp_locvar->fds_in = NULL; \
236 tp_locvar->fds_out = NULL; \
237 tp_locvar->fds_ex = NULL; \
238 tp_locvar->overflow = 0; \
239 \
240 sc_out( \
241 if (ret <= 0) \
242 goto error; \
243 ) \
244 \
245 if (n <= 0) \
246 goto error; \
247 \
248 /* On error or bogus input, don't copy anything. */ \
249 if (n >__FD_SETSIZE) \
250 goto error; \
251 \
252 n_in_bytes = DIV_ROUND_UP((unsigned int) n, BITS_PER_BYTE); \
253 \
254 /* \
255 * Limit atomic memory allocation to one page, since n \
256 * is limited to 1024 and the smallest page size on Linux \
257 * is 4k, this should not happen, don't try to make it work. \
258 */ \
259 if (n_in_bytes > PAGE_SIZE) { \
260 WARN_ON_ONCE(1); \
261 /* Inform the user that we did not output everything. */ \
262 tp_locvar->overflow = 1; \
263 goto error; \
264 } else { \
265 tp_locvar->nr_bytes = n_in_bytes; \
266 tp_locvar->nr_ulong = DIV_ROUND_UP(n_in_bytes, \
267 sizeof(unsigned long)); \
268 } \
269 \
270 if (inp) { \
271 tp_locvar->fds_in = lttng_tp_mempool_alloc( \
272 tp_locvar->nr_ulong * sizeof(unsigned long)); \
273 if (!tp_locvar->fds_in) \
274 goto error; \
275 \
276 err = lib_ring_buffer_copy_from_user_check_nofault( \
277 tp_locvar->fds_in, inp, \
278 tp_locvar->nr_ulong * sizeof(unsigned long)); \
279 if (err != 0) \
280 goto error; \
281 } \
282 if (outp) { \
283 tp_locvar->fds_out = lttng_tp_mempool_alloc( \
284 tp_locvar->nr_ulong * sizeof(unsigned long)); \
285 if (!tp_locvar->fds_out) \
286 goto error; \
287 \
288 err = lib_ring_buffer_copy_from_user_check_nofault( \
289 tp_locvar->fds_out, outp, \
290 tp_locvar->nr_ulong * sizeof(unsigned long)); \
291 if (err != 0) \
292 goto error; \
293 } \
294 if (exp) { \
295 tp_locvar->fds_ex = lttng_tp_mempool_alloc( \
296 tp_locvar->nr_ulong * sizeof(unsigned long)); \
297 if (!tp_locvar->fds_ex) \
298 goto error; \
299 \
300 err = lib_ring_buffer_copy_from_user_check_nofault( \
301 tp_locvar->fds_ex, exp, \
302 tp_locvar->nr_ulong * sizeof(unsigned long)); \
303 if (err != 0) \
304 goto error; \
305 } \
306 goto end; \
307 \
308 error: \
309 tp_locvar->nr_bytes = 0; \
310 tp_locvar->nr_ulong = 0; \
311 end: ; /* Label at end of compound statement. */ \
312 } \
313 )
314
315 #define LTTNG_SYSCALL_SELECT_fds_field_LE(name, input) \
316 ctf_custom_field( \
317 ctf_custom_type( \
318 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none) \
319 ), \
320 _ ## name ## _length, \
321 ctf_custom_code( \
322 if (input) { \
323 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
324 ctf_align(uint8_t) \
325 } else { \
326 ctf_integer_type(uint8_t, 0) \
327 ctf_align(uint8_t) \
328 } \
329 ) \
330 ) \
331 ctf_custom_field( \
332 ctf_custom_type( \
333 { \
334 .type = lttng_kernel_type_sequence_nestable, \
335 .u.sequence_nestable.length_name = "_" #name "_length", \
336 .u.sequence_nestable.elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
337 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 16, none)), \
338 .u.sequence_nestable.alignment = 0, \
339 } \
340 ), \
341 name, \
342 ctf_custom_code( \
343 unsigned int src; \
344 unsigned int nr_bytes_out = 0; \
345 \
346 if (!input) \
347 goto skip_##name; \
348 \
349 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
350 int dst; \
351 for (dst = 0; dst < sizeof(long); dst++) { \
352 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
353 goto skip_##name; \
354 } \
355 ctf_user_integer_type(uint8_t, \
356 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
357 } \
358 } \
359 skip_##name: ; \
360 ) \
361 )
362
363 #define LTTNG_SYSCALL_SELECT_fds_field_BE(name, input) \
364 ctf_custom_field( \
365 ctf_custom_type( \
366 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none) \
367 ), \
368 _ ## name ## _length, \
369 ctf_custom_code( \
370 if (input) { \
371 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
372 ctf_align(uint8_t) \
373 } else { \
374 ctf_integer_type(uint8_t, 0) \
375 ctf_align(uint8_t) \
376 } \
377 ) \
378 ) \
379 ctf_custom_field( \
380 ctf_custom_type( \
381 { \
382 .type = lttng_kernel_type_sequence_nestable, \
383 .u.sequence_nestable.elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
384 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 16, none)), \
385 .u.sequence_nestable.alignment = 0, \
386 } \
387 ), \
388 name, \
389 ctf_custom_code( \
390 unsigned int src, nr_bytes_out = 0; \
391 \
392 if (!input) \
393 goto skip_##name; \
394 \
395 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
396 int dst; \
397 for (dst = sizeof(long); dst >= 0; dst--) { \
398 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
399 goto skip_##name; \
400 } \
401 ctf_user_integer_type(uint8_t, \
402 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
403 } \
404 } \
405 skip_##name: ; \
406 ) \
407 )
408
409 #define LTTNG_SYSCALL_SELECT_code_post \
410 lttng_tp_mempool_free(tp_locvar->fds_in); \
411 lttng_tp_mempool_free(tp_locvar->fds_out); \
412 lttng_tp_mempool_free(tp_locvar->fds_ex);
413
414 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
415 #define OVERRIDE_32_select
416 #define OVERRIDE_64_select
417 SC_LTTNG_TRACEPOINT_EVENT_CODE(select,
418 TP_PROTO(sc_exit(long ret,) int n, fd_set __user *inp, fd_set __user *outp,
419 fd_set __user *exp, struct timeval *tvp),
420 TP_ARGS(sc_exit(ret,) n, inp, outp, exp, tvp),
421 TP_locvar(
422 LTTNG_SYSCALL_SELECT_locvar
423 ),
424 TP_code_pre(
425 LTTNG_SYSCALL_SELECT_code_pre
426 ),
427 TP_FIELDS(
428 sc_exit(ctf_integer(long, ret, ret))
429 sc_in(ctf_integer(int, n, n))
430 sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow))
431 sc_inout(ctf_integer(struct timeval *, tvp, tvp))
432
433 sc_inout(
434 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
435 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds, inp)
436 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds, outp)
437 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds, exp)
438 #else
439 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds, inp)
440 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds, outp)
441 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds, exp)
442 #endif
443 )
444 ),
445 TP_code_post(
446 LTTNG_SYSCALL_SELECT_code_post
447 )
448 )
449 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
450
451 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
452 #define OVERRIDE_32_pselect6
453 #define OVERRIDE_64_pselect6
454 SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6,
455 TP_PROTO(sc_exit(long ret,) int n, fd_set __user * inp, fd_set __user * outp,
456 fd_set __user * exp, struct timeval __user * tvp, void __user * sig),
457 TP_ARGS(sc_exit(ret,) n, inp, outp, exp, tvp, sig),
458 TP_locvar(
459 LTTNG_SYSCALL_SELECT_locvar
460 ),
461 TP_code_pre(
462 LTTNG_SYSCALL_SELECT_code_pre
463 ),
464 TP_FIELDS(
465 sc_exit(ctf_integer(long, ret, ret))
466 sc_in(ctf_integer(int, n, n))
467 sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow))
468 sc_inout(ctf_integer(struct timeval *, tvp, tvp))
469 sc_in(ctf_integer_hex(void *, sig, sig))
470
471 sc_inout(
472 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
473 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds, inp)
474 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds, outp)
475 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds, exp)
476 #else
477 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds, inp)
478 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds, outp)
479 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds, exp)
480 #endif
481 )
482 ),
483 TP_code_post(
484 LTTNG_SYSCALL_SELECT_code_post
485 )
486 )
487 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
488
489 #ifndef ONCE_LTTNG_TRACE_POLL_H
490 #define ONCE_LTTNG_TRACE_POLL_H
491
492 #define LTTNG_POLL_NRFLAGS (POLLNVAL + 1)
493 #define POLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
494 ilog2(LTTNG_POLL_NRFLAGS - 1)
495
496 /*
497 * Only extract the values specified by iBCS2 for now.
498 */
499 static struct lttng_event_field lttng_pollfd_flag_fields[] = {
500 [ilog2(POLLIN)] = {
501 .name = "POLLIN",
502 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
503 },
504 [ilog2(POLLPRI)] = {
505 .name = "POLLPRI",
506 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
507 },
508 [ilog2(POLLOUT)] = {
509 .name = "POLLOUT",
510 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
511 },
512 [ilog2(POLLERR)] = {
513 .name = "POLLERR",
514 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
515 },
516 [ilog2(POLLHUP)] = {
517 .name = "POLLHUP",
518 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
519 },
520 [ilog2(POLLNVAL)] = {
521 .name = "POLLNVAL",
522 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
523 },
524 [ilog2(LTTNG_POLL_NRFLAGS)] = {
525 .name = "padding",
526 .type = __type_integer(int, POLL_FLAGS_PADDING_SIZE, 1, 0,
527 __LITTLE_ENDIAN, 10, none),
528 },
529 };
530
531 static struct lttng_event_field lttng_pollfd_fields[] = {
532 [0] = {
533 .name = "fd",
534 .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 10, none),
535 },
536 [1] = {
537 .name = "raw_events",
538 .type = __type_integer(short, 0, 0, 0, __BYTE_ORDER, 16, none),
539 },
540 [2] = {
541 .name = "events",
542 .type = {
543 .type = lttng_kernel_type_struct_nestable,
544 .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_pollfd_flag_fields),
545 .u.struct_nestable.fields = lttng_pollfd_flag_fields,
546 .u.struct_nestable.alignment = 0,
547 }
548 },
549 };
550
551 static struct lttng_type lttng_pollfd_elem = {
552 .type = lttng_kernel_type_struct_nestable,
553 .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_pollfd_fields),
554 .u.struct_nestable.fields = lttng_pollfd_fields,
555 .u.struct_nestable.alignment = 0,
556 };
557 #endif /* ONCE_LTTNG_TRACE_POLL_H */
558
559 #define LTTNG_SYSCALL_POLL_locvar \
560 unsigned int fds_length, fds_max_len, alloc_fds; \
561 struct pollfd *fds; \
562 uint8_t overflow;
563
564 #define LTTNG_SYSCALL_POLL_code_pre \
565 BUILD_BUG_ON(((ARRAY_SIZE(lttng_pollfd_flag_fields) - 1) + \
566 POLL_FLAGS_PADDING_SIZE) != \
567 sizeof(uint8_t) * BITS_PER_BYTE); \
568 tp_locvar->fds = NULL; \
569 tp_locvar->overflow = 0; \
570 \
571 sc_in( \
572 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
573 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
574 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
575 tp_locvar->overflow = 1; \
576 } else { \
577 tp_locvar->fds_length = nfds; \
578 tp_locvar->fds_max_len = nfds; \
579 } \
580 tp_locvar->alloc_fds = tp_locvar->fds_length * sizeof(struct pollfd); \
581 ) \
582 /* \
583 * On exit, the number of active FDs is determined by ret, \
584 * nfds stays the same as the entry, but we only want to \
585 * output the FDs that are relevant. \
586 */ \
587 sc_out( \
588 if (ret <= 0 || ret > nfds) \
589 goto error; \
590 \
591 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
592 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
593 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
594 tp_locvar->overflow = 1; \
595 } else { \
596 tp_locvar->fds_length = ret; \
597 tp_locvar->fds_max_len = nfds; \
598 } \
599 tp_locvar->alloc_fds = tp_locvar->fds_max_len * sizeof(struct pollfd); \
600 ) \
601 { \
602 int err; \
603 \
604 tp_locvar->fds = lttng_tp_mempool_alloc(tp_locvar->alloc_fds); \
605 if (!tp_locvar->fds) \
606 goto error; \
607 err = lib_ring_buffer_copy_from_user_check_nofault( \
608 tp_locvar->fds, ufds, tp_locvar->alloc_fds); \
609 if (err != 0) \
610 goto error; \
611 } \
612 goto end; \
613 \
614 error: \
615 tp_locvar->fds_length = 0; \
616 tp_locvar->fds_max_len = 0; \
617 end: \
618 ;
619
620 #define LTTNG_SYSCALL_POLL_fds_field \
621 sc_in( \
622 ctf_custom_field( \
623 ctf_custom_type( \
624 { \
625 .type = lttng_kernel_type_sequence_nestable, \
626 .u.sequence_nestable.length_name = "fds_length", \
627 .u.sequence_nestable.elem_type = &lttng_pollfd_elem, \
628 } \
629 ), \
630 fds, \
631 ctf_custom_code( \
632 uint32_t i; \
633 \
634 ctf_align(int) /* Align on largest field in struct. */ \
635 for (i = 0; i < tp_locvar->fds_length; i++) { \
636 ctf_integer_type(int, tp_locvar->fds[i].fd) \
637 ctf_integer_type(short, tp_locvar->fds[i].events) \
638 ctf_integer_bitfield_type(uint8_t, \
639 (uint8_t) tp_locvar->fds[i].events) \
640 } \
641 ) \
642 ) \
643 ) \
644 sc_out( \
645 ctf_custom_field( \
646 ctf_custom_type( \
647 { \
648 .type = lttng_kernel_type_sequence_nestable, \
649 .u.sequence_nestable.length_name = "fds_length", \
650 .u.sequence_nestable.elem_type = &lttng_pollfd_elem, \
651 } \
652 ), \
653 fds, \
654 ctf_custom_code( \
655 unsigned int i, nr = 0; \
656 \
657 ctf_align(int) /* Align on largest field in struct. */ \
658 /* \
659 * Iterate over the complete array, but only output \
660 * "ret" active FDs. \
661 */ \
662 for (i = 0; i < tp_locvar->fds_max_len; i++) { \
663 if (!tp_locvar->fds[i].revents) \
664 continue; \
665 if (nr++ >= tp_locvar->fds_length) \
666 break; \
667 ctf_integer_type(int, tp_locvar->fds[i].fd) \
668 ctf_integer_type(short, tp_locvar->fds[i].revents) \
669 ctf_integer_bitfield_type(uint8_t, \
670 (uint8_t) tp_locvar->fds[i].revents) \
671 } \
672 /* \
673 * If there is a discrepancy between ret and the \
674 * content of revents (e.g. caused by userspace corrupting \
675 * the array from a concurrent thread), we have to output \
676 * zeros to keep the trace readable. \
677 */ \
678 for (i = nr; i < tp_locvar->fds_length; i++) { \
679 ctf_integer_type(int, 0) \
680 ctf_integer_type(short, 0) \
681 ctf_integer_bitfield_type(uint8_t, 0) \
682 } \
683 ) \
684 ) \
685 )
686
687 #define LTTNG_SYSCALL_POLL_code_post \
688 lttng_tp_mempool_free(tp_locvar->fds);
689
690 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
691 #define OVERRIDE_32_poll
692 #define OVERRIDE_64_poll
693 SC_LTTNG_TRACEPOINT_EVENT_CODE(poll,
694 TP_PROTO(sc_exit(long ret,) struct pollfd __user * ufds,
695 unsigned int nfds, int timeout_msecs),
696 TP_ARGS(sc_exit(ret,) ufds, nfds, timeout_msecs),
697 TP_locvar(
698 LTTNG_SYSCALL_POLL_locvar
699 ),
700 TP_code_pre(
701 LTTNG_SYSCALL_POLL_code_pre
702 ),
703 TP_FIELDS(
704 sc_exit(ctf_integer(long, ret, ret))
705 sc_in(ctf_integer(int, timeout_msecs, timeout_msecs))
706 sc_inout(ctf_integer(unsigned int, nfds, nfds))
707 sc_inout(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length))
708 sc_in(ctf_integer(uint8_t, overflow, tp_locvar->overflow))
709 LTTNG_SYSCALL_POLL_fds_field
710 ),
711 TP_code_post(
712 LTTNG_SYSCALL_POLL_code_post
713 )
714 )
715 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
716
717 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
718 #define OVERRIDE_32_ppoll
719 #define OVERRIDE_64_ppoll
720 SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll,
721 TP_PROTO(sc_exit(long ret,) struct pollfd __user * ufds,
722 unsigned int nfds, struct timespec * tsp, const sigset_t * sigmask, size_t sigsetsize),
723 TP_ARGS(sc_exit(ret,) ufds, nfds, tsp, sigmask, sigsetsize),
724 TP_locvar(
725 LTTNG_SYSCALL_POLL_locvar
726 ),
727 TP_code_pre(
728 LTTNG_SYSCALL_POLL_code_pre
729 ),
730 TP_FIELDS(
731 sc_exit(ctf_integer(long, ret, ret))
732 sc_in(ctf_integer(struct timespec *, tsp, tsp))
733 sc_in(ctf_integer(const sigset_t *, sigmask, sigmask))
734 sc_in(ctf_integer(size_t, sigsetsize, sigsetsize))
735 sc_inout(ctf_integer(unsigned int, nfds, nfds))
736 sc_inout(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length))
737 sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow))
738 LTTNG_SYSCALL_POLL_fds_field
739 ),
740 TP_code_post(
741 LTTNG_SYSCALL_POLL_code_post
742 )
743 )
744 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
745
746 #include <linux/eventpoll.h>
747
748 SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op,
749 TP_ENUM_VALUES(
750 ctf_enum_value("EPOLL_CTL_ADD", EPOLL_CTL_ADD)
751 ctf_enum_value("EPOLL_CTL_DEL", EPOLL_CTL_DEL)
752 ctf_enum_value("EPOLL_CTL_MOD", EPOLL_CTL_MOD)
753 )
754 )
755
756 #ifndef ONCE_LTTNG_TRACE_EPOLL_CTL_H
757 #define ONCE_LTTNG_TRACE_EPOLL_CTL_H
758
759 #define LTTNG_EPOLL_NRFLAGS (POLLHUP + 1)
760 #define EPOLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
761 ilog2(LTTNG_EPOLL_NRFLAGS - 1)
762
763 /*
764 * Only extract the values specified by iBCS2 for now.
765 */
766 static struct lttng_event_field lttng_epoll_ctl_events_fields[] = {
767 /* 0x0001 */
768 [ilog2(POLLIN)] = {
769 .name = "EPOLLIN",
770 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
771 },
772 /* 0x0002 */
773 [ilog2(POLLPRI)] = {
774 .name = "EPOLLPRI",
775 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
776 },
777 /* 0x0004 */
778 [ilog2(POLLOUT)] = {
779 .name = "EPOLLOUT",
780 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
781 },
782 /* 0x0008 */
783 [ilog2(POLLERR)] = {
784 .name = "EPOLLERR",
785 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
786 },
787 /* 0x0010 */
788 [ilog2(POLLHUP)] = {
789 .name = "EPOLLHUP",
790 .type = __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN, 10, none),
791 },
792 [ilog2(LTTNG_EPOLL_NRFLAGS)] = {
793 .name = "padding",
794 .type = __type_integer(int, EPOLL_FLAGS_PADDING_SIZE, 1, 0,
795 __LITTLE_ENDIAN, 10, none),
796 },
797
798 };
799
800 static struct lttng_event_field lttng_epoll_data_fields[] = {
801 [0] = {
802 .name = "u64",
803 .type = __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER, 16, none),
804 },
805 [1] = {
806 .name = "fd",
807 .type = __type_integer(int, 0, 0, 0, __BYTE_ORDER, 10, none),
808 },
809 };
810
811 static struct lttng_event_field epoll_ctl_fields[] = {
812 [0] = {
813 .name = "data_union",
814 .type = {
815 .type = lttng_kernel_type_struct_nestable,
816 .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_data_fields),
817 .u.struct_nestable.fields = lttng_epoll_data_fields,
818 .u.struct_nestable.alignment = 0,
819 }
820 },
821 [1] = {
822 .name = "raw_events",
823 .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 16, none),
824 },
825 [2] = {
826 .name = "events",
827 .type = {
828 .type = lttng_kernel_type_struct_nestable,
829 .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_ctl_events_fields),
830 .u.struct_nestable.fields = lttng_epoll_ctl_events_fields,
831 .u.struct_nestable.alignment = 0,
832 }
833 },
834 };
835 #endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */
836
837 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
838 #define OVERRIDE_32_epoll_ctl
839 #define OVERRIDE_64_epoll_ctl
840 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl,
841 TP_PROTO(sc_exit(long ret,) int epfd, int op, int fd,
842 struct epoll_event __user * uevent),
843 TP_ARGS(sc_exit(ret,) epfd, op, fd, uevent),
844 TP_locvar(
845 struct epoll_event event;
846 int err;
847 ),
848 TP_code_pre(
849 tp_locvar->err = lib_ring_buffer_copy_from_user_check_nofault(
850 &tp_locvar->event, uevent, sizeof(struct epoll_event));
851 ),
852 TP_FIELDS(
853 sc_exit(ctf_integer(long, ret, ret))
854 sc_in(ctf_integer(int, epfd, epfd))
855 sc_in(ctf_enum(lttng_epoll_op, int, op_enum, op))
856 sc_in(ctf_integer(int, fd, fd))
857 sc_in(
858 ctf_custom_field(
859 ctf_custom_type(
860 {
861 .type = lttng_kernel_type_struct_nestable,
862 .u.struct_nestable.nr_fields = ARRAY_SIZE(epoll_ctl_fields),
863 .u.struct_nestable.fields = epoll_ctl_fields,
864 .u.struct_nestable.alignment = 0,
865 }
866 ),
867 event,
868 ctf_custom_code(
869 ctf_align(uint64_t)
870 if (!tp_locvar->err) {
871 ctf_integer_type(uint64_t, tp_locvar->event.data)
872 ctf_integer_type(int, tp_locvar->event.data)
873 ctf_integer_bitfield_type(uint32_t,
874 tp_locvar->event.events)
875 ctf_integer_bitfield_type(uint8_t,
876 (uint8_t) tp_locvar->event.events)
877 } else {
878 ctf_integer_type(uint64_t, 0)
879 ctf_integer_type(int, 0)
880 ctf_integer_bitfield_type(uint32_t, 0)
881 ctf_integer_bitfield_type(uint8_t, 0)
882 }
883 )
884 )
885 )
886 ),
887 TP_code_post()
888 )
889 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
890
891 #ifndef ONCE_LTTNG_TRACE_EPOLL_H
892 #define ONCE_LTTNG_TRACE_EPOLL_H
893
894 static struct lttng_event_field lttng_epoll_wait_fields[] = {
895 [0] = {
896 .name = "data_union",
897 .type = {
898 .type = lttng_kernel_type_struct_nestable,
899 .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_data_fields),
900 .u.struct_nestable.fields = lttng_epoll_data_fields,
901 .u.struct_nestable.alignment = 0,
902 }
903 },
904 [1] = {
905 .name = "raw_events",
906 .type = __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER, 16, none),
907 },
908 [2] = {
909 .name = "events",
910 .type = {
911 .type = lttng_kernel_type_struct_nestable,
912 .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_ctl_events_fields),
913 .u.struct_nestable.fields = lttng_epoll_ctl_events_fields,
914 .u.struct_nestable.alignment = 0,
915 }
916 },
917 };
918
919 static struct lttng_type lttng_epoll_wait_elem = {
920 .type = lttng_kernel_type_struct_nestable,
921 .u.struct_nestable.nr_fields = ARRAY_SIZE(lttng_epoll_wait_fields),
922 .u.struct_nestable.fields = lttng_epoll_wait_fields,
923 .u.struct_nestable.alignment = 0,
924 };
925
926 #endif /* ONCE_LTTNG_TRACE_EPOLL_H */
927
928 #define LTTNG_SYSCALL_EPOLL_WAIT_locvar \
929 sc_out( \
930 unsigned int fds_length; \
931 uint8_t overflow; \
932 struct epoll_event *events; \
933 )
934
935 #define LTTNG_SYSCALL_EPOLL_WAIT_code_pre \
936 BUILD_BUG_ON(((ARRAY_SIZE(lttng_epoll_ctl_events_fields) - 1) + \
937 EPOLL_FLAGS_PADDING_SIZE) != \
938 sizeof(uint8_t) * BITS_PER_BYTE); \
939 sc_out({ \
940 int err; \
941 unsigned long maxalloc; \
942 \
943 tp_locvar->fds_length = 0; \
944 tp_locvar->events = NULL; \
945 tp_locvar->overflow = 0; \
946 \
947 if (maxevents <= 0 || ret <= 0 || ret > maxevents) \
948 goto skip_code; \
949 \
950 if (maxevents > PAGE_SIZE / sizeof(struct epoll_event)) { \
951 maxalloc = PAGE_SIZE / sizeof(struct epoll_event); \
952 } else { \
953 maxalloc = maxevents; \
954 } \
955 \
956 if (ret > maxalloc) { \
957 tp_locvar->fds_length = maxalloc; \
958 tp_locvar->overflow = 1; \
959 } else { \
960 tp_locvar->fds_length = ret; \
961 } \
962 \
963 tp_locvar->events = lttng_tp_mempool_alloc( \
964 maxalloc * sizeof(struct epoll_event)); \
965 if (!tp_locvar->events) { \
966 tp_locvar->fds_length = 0; \
967 goto skip_code; \
968 } \
969 \
970 err = lib_ring_buffer_copy_from_user_check_nofault( \
971 tp_locvar->events, uevents, \
972 maxalloc * sizeof(struct epoll_event)); \
973 if (err != 0) \
974 tp_locvar->fds_length = 0; \
975 } \
976 skip_code: \
977 )
978
979 #define LTTNG_SYSCALL_EPOLL_WAIT_fds_field \
980 ctf_custom_field( \
981 ctf_custom_type( \
982 { \
983 .type = lttng_kernel_type_sequence_nestable, \
984 .u.sequence_nestable.length_name = \
985 "fds_length", \
986 .u.sequence_nestable.elem_type = \
987 &lttng_epoll_wait_elem, \
988 } \
989 ), \
990 fds, \
991 ctf_custom_code( \
992 uint32_t i; \
993 \
994 ctf_align(uint64_t) \
995 for (i = 0; i < tp_locvar->fds_length; i++) { \
996 ctf_integer_type(uint64_t, tp_locvar->events[i].data) \
997 ctf_integer_type(int, tp_locvar->events[i].data) \
998 ctf_integer_bitfield_type(uint32_t, \
999 tp_locvar->events[i].events) \
1000 ctf_integer_bitfield_type(uint8_t, \
1001 (uint8_t) tp_locvar->events[i].events) \
1002 } \
1003 ) \
1004 )
1005
1006 #define LTTNG_SYSCALL_EPOLL_WAIT_code_post \
1007 sc_out( \
1008 lttng_tp_mempool_free(tp_locvar->events); \
1009 )
1010
1011
1012 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
1013 #define OVERRIDE_32_epoll_wait
1014 #define OVERRIDE_64_epoll_wait
1015 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_wait,
1016 TP_PROTO(sc_exit(long ret,) int epfd, struct epoll_event __user * uevents,
1017 int maxevents, int timeout),
1018 TP_ARGS(sc_exit(ret,) epfd, uevents, maxevents, timeout),
1019 TP_locvar(
1020 LTTNG_SYSCALL_EPOLL_WAIT_locvar
1021 ),
1022 TP_code_pre(
1023 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
1024 ),
1025 TP_FIELDS(
1026 sc_exit(ctf_integer(long, ret, ret))
1027 sc_in(ctf_integer(int, epfd, epfd))
1028 sc_in(ctf_integer(int, maxevents, maxevents))
1029 sc_in(ctf_integer(int, timeout, timeout))
1030 sc_out(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length))
1031 sc_out(ctf_integer(uint8_t, overflow, tp_locvar->overflow))
1032 sc_out(
1033 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
1034 )
1035 ),
1036 TP_code_post(
1037 LTTNG_SYSCALL_EPOLL_WAIT_code_post
1038 )
1039 )
1040 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
1041
1042 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
1043 #define OVERRIDE_32_epoll_pwait
1044 #define OVERRIDE_64_epoll_pwait
1045 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_pwait,
1046 TP_PROTO(sc_exit(long ret,) int epfd, struct epoll_event __user * uevents,
1047 int maxevents, int timeout, const sigset_t __user * sigmask, size_t sigsetsize),
1048 TP_ARGS(sc_exit(ret,) epfd, uevents, maxevents, timeout, sigmask, sigsetsize),
1049 TP_locvar(
1050 LTTNG_SYSCALL_EPOLL_WAIT_locvar
1051 ),
1052 TP_code_pre(
1053 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
1054 ),
1055 TP_FIELDS(
1056 sc_exit(ctf_integer(long, ret, ret))
1057 sc_in(ctf_integer(int, epfd, epfd))
1058 sc_in(ctf_integer(int, maxevents, maxevents))
1059 sc_in(ctf_integer(int, timeout, timeout))
1060 sc_in(ctf_integer_hex(const sigset_t *, sigmask, sigmask))
1061 sc_in(ctf_integer(size_t, sigsetsize, sigsetsize))
1062 sc_out(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length))
1063 sc_out(ctf_integer(uint8_t, overflow, tp_locvar->overflow))
1064 sc_out(
1065 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
1066 )
1067 ),
1068 TP_code_post(
1069 LTTNG_SYSCALL_EPOLL_WAIT_code_post
1070 )
1071 )
1072 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
1073
1074 #if (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
1075 #define OVERRIDE_32_socketpair
1076 #define OVERRIDE_64_socketpair
1077 SC_LTTNG_TRACEPOINT_EVENT(socketpair,
1078 TP_PROTO(sc_exit(long ret,) int family, int type, int protocol, int *usockvec),
1079 TP_ARGS(sc_exit(ret,) family, type, protocol, usockvec),
1080 TP_FIELDS(
1081 sc_exit(ctf_integer(long, ret, ret))
1082 sc_in(ctf_integer(int, family, family))
1083 sc_in(ctf_integer(int, type, type))
1084 sc_in(ctf_integer(int, protocol, protocol))
1085 sc_out(ctf_user_array(int, socket, usockvec, 2))
1086 )
1087 )
1088 #endif /* (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
1089
1090 /*
1091 * Enumeration of the open flags, as described in the 'open'
1092 * system call man page.
1093 */
1094 SC_LTTNG_TRACEPOINT_ENUM(lttng_file_status_flags,
1095 TP_ENUM_VALUES(
1096 ctf_enum_value("O_RDONLY", O_RDONLY)
1097 ctf_enum_value("O_WRONLY", O_WRONLY)
1098 ctf_enum_value("O_RDWR", O_RDWR)
1099 ctf_enum_value("O_CREAT", O_CREAT)
1100 ctf_enum_value("O_EXCL", O_EXCL)
1101 ctf_enum_value("O_NOCTTY", O_NOCTTY)
1102 ctf_enum_value("O_TRUNC", O_TRUNC)
1103 ctf_enum_value("O_APPEND", O_APPEND)
1104 ctf_enum_value("O_NONBLOCK", O_NONBLOCK)
1105 ctf_enum_value("O_DSYNC", O_DSYNC)
1106 ctf_enum_value("FASYNC", FASYNC)
1107 ctf_enum_value("O_DIRECT", O_DIRECT)
1108 ctf_enum_value("O_LARGEFILE", O_LARGEFILE)
1109 ctf_enum_value("O_DIRECTORY", O_DIRECTORY)
1110 ctf_enum_value("O_NOFOLLOW", O_NOFOLLOW)
1111 ctf_enum_value("O_NOATIME", O_NOATIME)
1112 ctf_enum_value("O_CLOEXEC", O_CLOEXEC)
1113 ctf_enum_value("O_SYNC", __O_SYNC)
1114 ctf_enum_value("O_PATH", O_PATH)
1115 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,11,0))
1116 ctf_enum_value("O_TMPFILE", __O_TMPFILE)
1117 #endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,11,0)) */
1118 )
1119 )
1120
1121 /*
1122 * Enumeration of the open flags, as described in the 'open'
1123 * system call man page.
1124 */
1125 SC_LTTNG_TRACEPOINT_ENUM(lttng_file_mode,
1126 TP_ENUM_VALUES(
1127 ctf_enum_value("S_IRWXU", S_IRWXU)
1128 ctf_enum_value("S_IRUSR", S_IRUSR)
1129 ctf_enum_value("S_IWUSR", S_IWUSR)
1130 ctf_enum_value("S_IXUSR", S_IXUSR)
1131 ctf_enum_value("S_IRWXG", S_IRWXG)
1132 ctf_enum_value("S_IRGRP", S_IRGRP)
1133 ctf_enum_value("S_IWGRP", S_IWGRP)
1134 ctf_enum_value("S_IXGRP", S_IXGRP)
1135 ctf_enum_value("S_IRWXO", S_IRWXO)
1136 ctf_enum_value("S_IROTH", S_IROTH)
1137 ctf_enum_value("S_IWOTH", S_IWOTH)
1138 ctf_enum_value("S_IXOTH", S_IXOTH)
1139 ctf_enum_value("S_ISUID", S_ISUID)
1140 ctf_enum_value("S_ISGID", S_ISGID)
1141 ctf_enum_value("S_ISVTX", S_ISVTX)
1142 )
1143 )
1144
1145 #define OVERRIDE_32_openat
1146 #define OVERRIDE_64_openat
1147 SC_LTTNG_TRACEPOINT_EVENT(openat,
1148 TP_PROTO(sc_exit(long ret,) int dfd, const char * filename, int flags, umode_t mode),
1149 TP_ARGS(sc_exit(ret,) dfd, filename, flags, mode),
1150 TP_FIELDS(
1151 sc_exit(ctf_integer(long, ret, ret))
1152 sc_in(ctf_integer(int, dfd, dfd))
1153 sc_in(ctf_user_string(filename, filename))
1154 sc_in(ctf_enum(lttng_file_status_flags, int, flags, flags))
1155 sc_in(ctf_enum(lttng_file_mode, umode_t, mode, mode))
1156 )
1157 )
1158
1159 #define OVERRIDE_32_open
1160 #define OVERRIDE_64_open
1161 SC_LTTNG_TRACEPOINT_EVENT(open,
1162 TP_PROTO(sc_exit(long ret,) const char * filename, int flags, umode_t mode),
1163 TP_ARGS(sc_exit(ret,) filename, flags, mode),
1164 TP_FIELDS(
1165 sc_exit(ctf_integer(long, ret, ret))
1166 sc_in(ctf_user_string(filename, filename))
1167 sc_in(ctf_enum(lttng_file_status_flags, int, flags, flags))
1168 sc_in(ctf_enum(lttng_file_mode, umode_t, mode, mode))
1169 )
1170 )
1171
1172 #endif /* CREATE_SYSCALL_TABLE */
This page took 0.067706 seconds and 3 git commands to generate.