1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) */
3 #ifndef CREATE_SYSCALL_TABLE
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
))
17 #define OVERRIDE_32_clone
18 #define OVERRIDE_64_clone
19 SC_LTTNG_TRACEPOINT_EVENT(clone
,
20 TP_PROTO(sc_exit(long ret
,) unsigned long clone_flags
, unsigned long newsp
,
21 void __user
*parent_tid
,
22 void __user
*child_tid
),
23 TP_ARGS(sc_exit(ret
,) clone_flags
, newsp
, parent_tid
, child_tid
),
25 sc_exit(ctf_integer(long, ret
, ret
))
26 sc_in(ctf_integer_hex(unsigned long, clone_flags
, clone_flags
))
27 sc_in(ctf_integer_hex(unsigned long, newsp
, newsp
))
28 sc_in(ctf_integer_hex(void *, parent_tid
, parent_tid
))
29 sc_in(ctf_integer_hex(void *, child_tid
, child_tid
))
33 /* present in 32, missing in 64 due to old kernel headers */
34 #define OVERRIDE_32_getcpu
35 #define OVERRIDE_64_getcpu
36 SC_LTTNG_TRACEPOINT_EVENT(getcpu
,
37 TP_PROTO(sc_exit(long ret
,) unsigned __user
*cpup
, unsigned __user
*nodep
, void *tcache
),
38 TP_ARGS(sc_exit(ret
,) cpup
, nodep
, tcache
),
40 sc_exit(ctf_integer(long, ret
, ret
))
41 sc_out(ctf_integer_hex(unsigned *, cpup
, cpup
))
42 sc_out(ctf_integer_hex(unsigned *, nodep
, nodep
))
43 sc_inout(ctf_integer_hex(void *, tcache
, tcache
))
47 #define OVERRIDE_32_pipe2
48 #define OVERRIDE_64_pipe2
49 SC_LTTNG_TRACEPOINT_EVENT(pipe2
,
50 TP_PROTO(sc_exit(long ret
,) int * fildes
, int flags
),
51 TP_ARGS(sc_exit(ret
,) fildes
, flags
),
52 TP_FIELDS(sc_exit(ctf_integer(long, ret
, ret
))
53 sc_out(ctf_user_array(int, fildes
, fildes
, 2))
54 sc_in(ctf_integer(int, flags
, flags
))
58 #define LTTNG_SYSCALL_SELECT_locvar \
59 unsigned long *fds_in, *fds_out, *fds_ex; \
60 unsigned long nr_bytes, nr_ulong; \
63 #define LTTNG_SYSCALL_SELECT_code_pre \
67 unsigned int n_in_bytes; \
69 tp_locvar->fds_in = NULL; \
70 tp_locvar->fds_out = NULL; \
71 tp_locvar->fds_ex = NULL; \
72 tp_locvar->overflow = 0; \
82 /* On error or bogus input, don't copy anything. */ \
83 if (n >__FD_SETSIZE) \
86 n_in_bytes = DIV_ROUND_UP((unsigned int) n, BITS_PER_BYTE); \
89 * Limit atomic memory allocation to one page, since n \
90 * is limited to 1024 and the smallest page size on Linux \
91 * is 4k, this should not happen, don't try to make it work. \
93 if (n_in_bytes > PAGE_SIZE) { \
95 /* Inform the user that we did not output everything. */ \
96 tp_locvar->overflow = 1; \
99 tp_locvar->nr_bytes = n_in_bytes; \
100 tp_locvar->nr_ulong = DIV_ROUND_UP(n_in_bytes, \
101 sizeof(unsigned long)); \
105 tp_locvar->fds_in = lttng_tp_mempool_alloc( \
106 tp_locvar->nr_ulong * sizeof(unsigned long)); \
107 if (!tp_locvar->fds_in) \
110 err = lib_ring_buffer_copy_from_user_check_nofault( \
111 tp_locvar->fds_in, inp, \
112 tp_locvar->nr_ulong * sizeof(unsigned long)); \
117 tp_locvar->fds_out = lttng_tp_mempool_alloc( \
118 tp_locvar->nr_ulong * sizeof(unsigned long)); \
119 if (!tp_locvar->fds_out) \
122 err = lib_ring_buffer_copy_from_user_check_nofault( \
123 tp_locvar->fds_out, outp, \
124 tp_locvar->nr_ulong * sizeof(unsigned long)); \
129 tp_locvar->fds_ex = lttng_tp_mempool_alloc( \
130 tp_locvar->nr_ulong * sizeof(unsigned long)); \
131 if (!tp_locvar->fds_ex) \
134 err = lib_ring_buffer_copy_from_user_check_nofault( \
135 tp_locvar->fds_ex, exp, \
136 tp_locvar->nr_ulong * sizeof(unsigned long)); \
143 tp_locvar->nr_bytes = 0; \
144 tp_locvar->nr_ulong = 0; \
145 end: ; /* Label at end of compound statement. */ \
149 #define LTTNG_SYSCALL_SELECT_fds_field_LE(name, input) \
152 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none) \
154 _ ## name ## _length, \
157 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
160 ctf_integer_type(uint8_t, 0) \
168 .atype = atype_sequence_nestable, \
169 .u.sequence_nestable.length_name = "_" #name "_length", \
170 .u.sequence_nestable.elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
171 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 16, none)), \
172 .u.sequence_nestable.alignment = 0, \
178 unsigned int nr_bytes_out = 0; \
183 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
185 for (dst = 0; dst < sizeof(long); dst++) { \
186 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
189 ctf_user_integer_type(uint8_t, \
190 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
197 #define LTTNG_SYSCALL_SELECT_fds_field_BE(name, input) \
200 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none) \
202 _ ## name ## _length, \
205 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
208 ctf_integer_type(uint8_t, 0) \
216 .atype = atype_sequence_nestable, \
217 .u.sequence_nestable.elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
218 __type_integer(uint8_t, 0, 0, 0, __BYTE_ORDER, 16, none)), \
219 .u.sequence_nestable.alignment = 0, \
224 unsigned int src, nr_bytes_out = 0; \
229 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
231 for (dst = sizeof(long); dst >= 0; dst--) { \
232 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
235 ctf_user_integer_type(uint8_t, \
236 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
243 #define LTTNG_SYSCALL_SELECT_code_post \
244 lttng_tp_mempool_free(tp_locvar->fds_in); \
245 lttng_tp_mempool_free(tp_locvar->fds_out); \
246 lttng_tp_mempool_free(tp_locvar->fds_ex);
248 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
249 #define OVERRIDE_32_select
250 #define OVERRIDE_64_select
251 SC_LTTNG_TRACEPOINT_EVENT_CODE(select
,
252 TP_PROTO(sc_exit(long ret
,) int n
, fd_set __user
*inp
, fd_set __user
*outp
,
253 fd_set __user
*exp
, struct timeval
*tvp
),
254 TP_ARGS(sc_exit(ret
,) n
, inp
, outp
, exp
, tvp
),
256 LTTNG_SYSCALL_SELECT_locvar
259 LTTNG_SYSCALL_SELECT_code_pre
262 sc_exit(ctf_integer(long, ret
, ret
))
263 sc_in(ctf_integer(int, n
, n
))
264 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
265 sc_inout(ctf_integer(struct timeval
*, tvp
, tvp
))
268 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
269 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds
, inp
)
270 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds
, outp
)
271 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds
, exp
)
273 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds
, inp
)
274 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds
, outp
)
275 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds
, exp
)
280 LTTNG_SYSCALL_SELECT_code_post
283 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
285 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
286 #define OVERRIDE_32_pselect6
287 #define OVERRIDE_64_pselect6
288 SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6
,
289 TP_PROTO(sc_exit(long ret
,) int n
, fd_set __user
* inp
, fd_set __user
* outp
,
290 fd_set __user
* exp
, struct timeval __user
* tvp
, void __user
* sig
),
291 TP_ARGS(sc_exit(ret
,) n
, inp
, outp
, exp
, tvp
, sig
),
293 LTTNG_SYSCALL_SELECT_locvar
296 LTTNG_SYSCALL_SELECT_code_pre
299 sc_exit(ctf_integer(long, ret
, ret
))
300 sc_in(ctf_integer(int, n
, n
))
301 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
302 sc_inout(ctf_integer(struct timeval
*, tvp
, tvp
))
303 sc_in(ctf_integer_hex(void *, sig
, sig
))
306 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
307 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds
, inp
)
308 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds
, outp
)
309 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds
, exp
)
311 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds
, inp
)
312 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds
, outp
)
313 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds
, exp
)
318 LTTNG_SYSCALL_SELECT_code_post
321 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
323 #ifndef ONCE_LTTNG_TRACE_POLL_H
324 #define ONCE_LTTNG_TRACE_POLL_H
326 #define LTTNG_POLL_NRFLAGS (POLLNVAL + 1)
327 #define POLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
328 ilog2(LTTNG_POLL_NRFLAGS - 1)
331 * Only extract the values specified by iBCS2 for now.
333 static struct lttng_event_field lttng_pollfd_flag_fields
[] = {
336 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
340 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
344 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
348 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
352 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
354 [ilog2(POLLNVAL
)] = {
356 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
358 [ilog2(LTTNG_POLL_NRFLAGS
)] = {
360 .type
= __type_integer(int, POLL_FLAGS_PADDING_SIZE
, 1, 0,
361 __LITTLE_ENDIAN
, 10, none
),
365 static struct lttng_event_field lttng_pollfd_fields
[] = {
368 .type
= __type_integer(int, 0, 0, 0, __BYTE_ORDER
, 10, none
),
371 .name
= "raw_events",
372 .type
= __type_integer(short, 0, 0, 0, __BYTE_ORDER
, 16, none
),
377 .atype
= atype_struct_nestable
,
378 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(lttng_pollfd_flag_fields
),
379 .u
.struct_nestable
.fields
= lttng_pollfd_flag_fields
,
380 .u
.struct_nestable
.alignment
= 0,
385 static struct lttng_type lttng_pollfd_elem
= {
386 .atype
= atype_struct_nestable
,
387 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(lttng_pollfd_fields
),
388 .u
.struct_nestable
.fields
= lttng_pollfd_fields
,
389 .u
.struct_nestable
.alignment
= 0,
391 #endif /* ONCE_LTTNG_TRACE_POLL_H */
393 #define LTTNG_SYSCALL_POLL_locvar \
394 unsigned int fds_length, fds_max_len, alloc_fds; \
395 struct pollfd *fds; \
398 #define LTTNG_SYSCALL_POLL_code_pre \
399 BUILD_BUG_ON(((ARRAY_SIZE(lttng_pollfd_flag_fields) - 1) + \
400 POLL_FLAGS_PADDING_SIZE) != \
401 sizeof(uint8_t) * BITS_PER_BYTE); \
402 tp_locvar->fds = NULL; \
403 tp_locvar->overflow = 0; \
406 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
407 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
408 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
409 tp_locvar->overflow = 1; \
411 tp_locvar->fds_length = nfds; \
412 tp_locvar->fds_max_len = nfds; \
414 tp_locvar->alloc_fds = tp_locvar->fds_length * sizeof(struct pollfd); \
417 * On exit, the number of active FDs is determined by ret, \
418 * nfds stays the same as the entry, but we only want to \
419 * output the FDs that are relevant. \
422 if (ret <= 0 || ret > nfds) \
425 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
426 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
427 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
428 tp_locvar->overflow = 1; \
430 tp_locvar->fds_length = ret; \
431 tp_locvar->fds_max_len = nfds; \
433 tp_locvar->alloc_fds = tp_locvar->fds_max_len * sizeof(struct pollfd); \
438 tp_locvar->fds = lttng_tp_mempool_alloc(tp_locvar->alloc_fds); \
439 if (!tp_locvar->fds) \
441 err = lib_ring_buffer_copy_from_user_check_nofault( \
442 tp_locvar->fds, ufds, tp_locvar->alloc_fds); \
449 tp_locvar->fds_length = 0; \
450 tp_locvar->fds_max_len = 0; \
454 #define LTTNG_SYSCALL_POLL_fds_field \
459 .atype = atype_sequence_nestable, \
460 .u.sequence_nestable.length_name = "fds_length", \
461 .u.sequence_nestable.elem_type = <tng_pollfd_elem, \
468 ctf_align(int) /* Align on largest field in struct. */ \
469 for (i = 0; i < tp_locvar->fds_length; i++) { \
470 ctf_integer_type(int, tp_locvar->fds[i].fd) \
471 ctf_integer_type(short, tp_locvar->fds[i].events) \
472 ctf_integer_bitfield_type(uint8_t, \
473 (uint8_t) tp_locvar->fds[i].events) \
482 .atype = atype_sequence_nestable, \
483 .u.sequence_nestable.length_name = "fds_length", \
484 .u.sequence_nestable.elem_type = <tng_pollfd_elem, \
489 unsigned int i, nr = 0; \
491 ctf_align(int) /* Align on largest field in struct. */ \
493 * Iterate over the complete array, but only output \
494 * "ret" active FDs. \
496 for (i = 0; i < tp_locvar->fds_max_len; i++) { \
497 if (!tp_locvar->fds[i].revents) \
499 if (nr++ >= tp_locvar->fds_length) \
501 ctf_integer_type(int, tp_locvar->fds[i].fd) \
502 ctf_integer_type(short, tp_locvar->fds[i].revents) \
503 ctf_integer_bitfield_type(uint8_t, \
504 (uint8_t) tp_locvar->fds[i].revents) \
507 * If there is a discrepancy between ret and the \
508 * content of revents (e.g. caused by userspace corrupting \
509 * the array from a concurrent thread), we have to output \
510 * zeros to keep the trace readable. \
512 for (i = nr; i < tp_locvar->fds_length; i++) { \
513 ctf_integer_type(int, 0) \
514 ctf_integer_type(short, 0) \
515 ctf_integer_bitfield_type(uint8_t, 0) \
521 #define LTTNG_SYSCALL_POLL_code_post \
522 lttng_tp_mempool_free(tp_locvar->fds);
524 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
525 #define OVERRIDE_32_poll
526 #define OVERRIDE_64_poll
527 SC_LTTNG_TRACEPOINT_EVENT_CODE(poll
,
528 TP_PROTO(sc_exit(long ret
,) struct pollfd __user
* ufds
,
529 unsigned int nfds
, int timeout_msecs
),
530 TP_ARGS(sc_exit(ret
,) ufds
, nfds
, timeout_msecs
),
532 LTTNG_SYSCALL_POLL_locvar
535 LTTNG_SYSCALL_POLL_code_pre
538 sc_exit(ctf_integer(long, ret
, ret
))
539 sc_in(ctf_integer(int, timeout_msecs
, timeout_msecs
))
540 sc_inout(ctf_integer(unsigned int, nfds
, nfds
))
541 sc_inout(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
542 sc_in(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
543 LTTNG_SYSCALL_POLL_fds_field
546 LTTNG_SYSCALL_POLL_code_post
549 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
551 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
552 #define OVERRIDE_32_ppoll
553 #define OVERRIDE_64_ppoll
554 SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll
,
555 TP_PROTO(sc_exit(long ret
,) struct pollfd __user
* ufds
,
556 unsigned int nfds
, struct timespec
* tsp
, const sigset_t
* sigmask
, size_t sigsetsize
),
557 TP_ARGS(sc_exit(ret
,) ufds
, nfds
, tsp
, sigmask
, sigsetsize
),
559 LTTNG_SYSCALL_POLL_locvar
562 LTTNG_SYSCALL_POLL_code_pre
565 sc_exit(ctf_integer(long, ret
, ret
))
566 sc_in(ctf_integer(struct timespec
*, tsp
, tsp
))
567 sc_in(ctf_integer(const sigset_t
*, sigmask
, sigmask
))
568 sc_in(ctf_integer(size_t, sigsetsize
, sigsetsize
))
569 sc_inout(ctf_integer(unsigned int, nfds
, nfds
))
570 sc_inout(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
571 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
572 LTTNG_SYSCALL_POLL_fds_field
575 LTTNG_SYSCALL_POLL_code_post
578 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
580 #include <linux/eventpoll.h>
582 SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op
,
584 ctf_enum_value("EPOLL_CTL_ADD", EPOLL_CTL_ADD
)
585 ctf_enum_value("EPOLL_CTL_DEL", EPOLL_CTL_DEL
)
586 ctf_enum_value("EPOLL_CTL_MOD", EPOLL_CTL_MOD
)
590 #ifndef ONCE_LTTNG_TRACE_EPOLL_CTL_H
591 #define ONCE_LTTNG_TRACE_EPOLL_CTL_H
593 #define LTTNG_EPOLL_NRFLAGS (POLLHUP + 1)
594 #define EPOLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
595 ilog2(LTTNG_EPOLL_NRFLAGS - 1)
598 * Only extract the values specified by iBCS2 for now.
600 static struct lttng_event_field lttng_epoll_ctl_events_fields
[] = {
604 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
609 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
614 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
619 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
624 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
626 [ilog2(LTTNG_EPOLL_NRFLAGS
)] = {
628 .type
= __type_integer(int, EPOLL_FLAGS_PADDING_SIZE
, 1, 0,
629 __LITTLE_ENDIAN
, 10, none
),
634 static struct lttng_event_field lttng_epoll_data_fields
[] = {
637 .type
= __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
641 .type
= __type_integer(int, 0, 0, 0, __BYTE_ORDER
, 10, none
),
645 static struct lttng_event_field epoll_ctl_fields
[] = {
647 .name
= "data_union",
649 .atype
= atype_struct_nestable
,
650 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(lttng_epoll_data_fields
),
651 .u
.struct_nestable
.fields
= lttng_epoll_data_fields
,
652 .u
.struct_nestable
.alignment
= 0,
656 .name
= "raw_events",
657 .type
= __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
662 .atype
= atype_struct_nestable
,
663 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(lttng_epoll_ctl_events_fields
),
664 .u
.struct_nestable
.fields
= lttng_epoll_ctl_events_fields
,
665 .u
.struct_nestable
.alignment
= 0,
669 #endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */
671 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
672 #define OVERRIDE_32_epoll_ctl
673 #define OVERRIDE_64_epoll_ctl
674 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl
,
675 TP_PROTO(sc_exit(long ret
,) int epfd
, int op
, int fd
,
676 struct epoll_event __user
* uevent
),
677 TP_ARGS(sc_exit(ret
,) epfd
, op
, fd
, uevent
),
679 struct epoll_event event
;
683 tp_locvar
->err
= lib_ring_buffer_copy_from_user_check_nofault(
684 &tp_locvar
->event
, uevent
, sizeof(struct epoll_event
));
687 sc_exit(ctf_integer(long, ret
, ret
))
688 sc_in(ctf_integer(int, epfd
, epfd
))
689 sc_in(ctf_enum(lttng_epoll_op
, int, op_enum
, op
))
690 sc_in(ctf_integer(int, fd
, fd
))
695 .atype
= atype_struct_nestable
,
696 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(epoll_ctl_fields
),
697 .u
.struct_nestable
.fields
= epoll_ctl_fields
,
698 .u
.struct_nestable
.alignment
= 0,
704 if (!tp_locvar
->err
) {
705 ctf_integer_type(uint64_t, tp_locvar
->event
.data
)
706 ctf_integer_type(int, tp_locvar
->event
.data
)
707 ctf_integer_bitfield_type(uint32_t,
708 tp_locvar
->event
.events
)
709 ctf_integer_bitfield_type(uint8_t,
710 (uint8_t) tp_locvar
->event
.events
)
712 ctf_integer_type(uint64_t, 0)
713 ctf_integer_type(int, 0)
714 ctf_integer_bitfield_type(uint32_t, 0)
715 ctf_integer_bitfield_type(uint8_t, 0)
723 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
725 #ifndef ONCE_LTTNG_TRACE_EPOLL_H
726 #define ONCE_LTTNG_TRACE_EPOLL_H
728 static struct lttng_event_field lttng_epoll_wait_fields
[] = {
730 .name
= "data_union",
732 .atype
= atype_struct_nestable
,
733 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(lttng_epoll_data_fields
),
734 .u
.struct_nestable
.fields
= lttng_epoll_data_fields
,
735 .u
.struct_nestable
.alignment
= 0,
739 .name
= "raw_events",
740 .type
= __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
745 .atype
= atype_struct_nestable
,
746 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(lttng_epoll_ctl_events_fields
),
747 .u
.struct_nestable
.fields
= lttng_epoll_ctl_events_fields
,
748 .u
.struct_nestable
.alignment
= 0,
753 static struct lttng_type lttng_epoll_wait_elem
= {
754 .atype
= atype_struct_nestable
,
755 .u
.struct_nestable
.nr_fields
= ARRAY_SIZE(lttng_epoll_wait_fields
),
756 .u
.struct_nestable
.fields
= lttng_epoll_wait_fields
,
757 .u
.struct_nestable
.alignment
= 0,
760 #endif /* ONCE_LTTNG_TRACE_EPOLL_H */
762 #define LTTNG_SYSCALL_EPOLL_WAIT_locvar \
764 unsigned int fds_length; \
766 struct epoll_event *events; \
769 #define LTTNG_SYSCALL_EPOLL_WAIT_code_pre \
770 BUILD_BUG_ON(((ARRAY_SIZE(lttng_epoll_ctl_events_fields) - 1) + \
771 EPOLL_FLAGS_PADDING_SIZE) != \
772 sizeof(uint8_t) * BITS_PER_BYTE); \
775 unsigned long maxalloc; \
777 tp_locvar->fds_length = 0; \
778 tp_locvar->events = NULL; \
779 tp_locvar->overflow = 0; \
781 if (maxevents <= 0 || ret <= 0 || ret > maxevents) \
784 if (maxevents > PAGE_SIZE / sizeof(struct epoll_event)) { \
785 maxalloc = PAGE_SIZE / sizeof(struct epoll_event); \
787 maxalloc = maxevents; \
790 if (ret > maxalloc) { \
791 tp_locvar->fds_length = maxalloc; \
792 tp_locvar->overflow = 1; \
794 tp_locvar->fds_length = ret; \
797 tp_locvar->events = lttng_tp_mempool_alloc( \
798 maxalloc * sizeof(struct epoll_event)); \
799 if (!tp_locvar->events) { \
800 tp_locvar->fds_length = 0; \
804 err = lib_ring_buffer_copy_from_user_check_nofault( \
805 tp_locvar->events, uevents, \
806 maxalloc * sizeof(struct epoll_event)); \
808 tp_locvar->fds_length = 0; \
813 #define LTTNG_SYSCALL_EPOLL_WAIT_fds_field \
817 .atype = atype_sequence_nestable, \
818 .u.sequence_nestable.length_name = \
820 .u.sequence_nestable.elem_type = \
821 <tng_epoll_wait_elem, \
828 ctf_align(uint64_t) \
829 for (i = 0; i < tp_locvar->fds_length; i++) { \
830 ctf_integer_type(uint64_t, tp_locvar->events[i].data) \
831 ctf_integer_type(int, tp_locvar->events[i].data) \
832 ctf_integer_bitfield_type(uint32_t, \
833 tp_locvar->events[i].events) \
834 ctf_integer_bitfield_type(uint8_t, \
835 (uint8_t) tp_locvar->events[i].events) \
840 #define LTTNG_SYSCALL_EPOLL_WAIT_code_post \
842 lttng_tp_mempool_free(tp_locvar->events); \
846 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
847 #define OVERRIDE_32_epoll_wait
848 #define OVERRIDE_64_epoll_wait
849 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_wait
,
850 TP_PROTO(sc_exit(long ret
,) int epfd
, struct epoll_event __user
* uevents
,
851 int maxevents
, int timeout
),
852 TP_ARGS(sc_exit(ret
,) epfd
, uevents
, maxevents
, timeout
),
854 LTTNG_SYSCALL_EPOLL_WAIT_locvar
857 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
860 sc_exit(ctf_integer(long, ret
, ret
))
861 sc_in(ctf_integer(int, epfd
, epfd
))
862 sc_in(ctf_integer(int, maxevents
, maxevents
))
863 sc_in(ctf_integer(int, timeout
, timeout
))
864 sc_out(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
865 sc_out(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
867 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
871 LTTNG_SYSCALL_EPOLL_WAIT_code_post
874 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
876 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
877 #define OVERRIDE_32_epoll_pwait
878 #define OVERRIDE_64_epoll_pwait
879 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_pwait
,
880 TP_PROTO(sc_exit(long ret
,) int epfd
, struct epoll_event __user
* uevents
,
881 int maxevents
, int timeout
, const sigset_t __user
* sigmask
, size_t sigsetsize
),
882 TP_ARGS(sc_exit(ret
,) epfd
, uevents
, maxevents
, timeout
, sigmask
, sigsetsize
),
884 LTTNG_SYSCALL_EPOLL_WAIT_locvar
887 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
890 sc_exit(ctf_integer(long, ret
, ret
))
891 sc_in(ctf_integer(int, epfd
, epfd
))
892 sc_in(ctf_integer(int, maxevents
, maxevents
))
893 sc_in(ctf_integer(int, timeout
, timeout
))
894 sc_in(ctf_integer_hex(const sigset_t
*, sigmask
, sigmask
))
895 sc_in(ctf_integer(size_t, sigsetsize
, sigsetsize
))
896 sc_out(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
897 sc_out(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
899 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
903 LTTNG_SYSCALL_EPOLL_WAIT_code_post
906 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
908 #if (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
909 #define OVERRIDE_32_socketpair
910 #define OVERRIDE_64_socketpair
911 SC_LTTNG_TRACEPOINT_EVENT(socketpair
,
912 TP_PROTO(sc_exit(long ret
,) int family
, int type
, int protocol
, int *usockvec
),
913 TP_ARGS(sc_exit(ret
,) family
, type
, protocol
, usockvec
),
915 sc_exit(ctf_integer(long, ret
, ret
))
916 sc_in(ctf_integer(int, family
, family
))
917 sc_in(ctf_integer(int, type
, type
))
918 sc_in(ctf_integer(int, protocol
, protocol
))
919 sc_out(ctf_user_array(int, socket
, usockvec
, 2))
922 #endif /* (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
925 * Enumeration of the open flags, as described in the 'open'
926 * system call man page.
928 SC_LTTNG_TRACEPOINT_ENUM(lttng_file_status_flags
,
930 ctf_enum_value("O_RDONLY", O_RDONLY
)
931 ctf_enum_value("O_WRONLY", O_WRONLY
)
932 ctf_enum_value("O_RDWR", O_RDWR
)
933 ctf_enum_value("O_CREAT", O_CREAT
)
934 ctf_enum_value("O_EXCL", O_EXCL
)
935 ctf_enum_value("O_NOCTTY", O_NOCTTY
)
936 ctf_enum_value("O_TRUNC", O_TRUNC
)
937 ctf_enum_value("O_APPEND", O_APPEND
)
938 ctf_enum_value("O_NONBLOCK", O_NONBLOCK
)
939 ctf_enum_value("O_DSYNC", O_DSYNC
)
940 ctf_enum_value("FASYNC", FASYNC
)
941 ctf_enum_value("O_DIRECT", O_DIRECT
)
942 ctf_enum_value("O_LARGEFILE", O_LARGEFILE
)
943 ctf_enum_value("O_DIRECTORY", O_DIRECTORY
)
944 ctf_enum_value("O_NOFOLLOW", O_NOFOLLOW
)
945 ctf_enum_value("O_NOATIME", O_NOATIME
)
946 ctf_enum_value("O_CLOEXEC", O_CLOEXEC
)
947 ctf_enum_value("O_SYNC", __O_SYNC
)
948 ctf_enum_value("O_PATH", O_PATH
)
949 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
950 ctf_enum_value("O_TMPFILE", __O_TMPFILE
)
951 #endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) */
956 * Enumeration of the open flags, as described in the 'open'
957 * system call man page.
959 SC_LTTNG_TRACEPOINT_ENUM(lttng_file_mode
,
961 ctf_enum_value("S_IRWXU", S_IRWXU
)
962 ctf_enum_value("S_IRUSR", S_IRUSR
)
963 ctf_enum_value("S_IWUSR", S_IWUSR
)
964 ctf_enum_value("S_IXUSR", S_IXUSR
)
965 ctf_enum_value("S_IRWXG", S_IRWXG
)
966 ctf_enum_value("S_IRGRP", S_IRGRP
)
967 ctf_enum_value("S_IWGRP", S_IWGRP
)
968 ctf_enum_value("S_IXGRP", S_IXGRP
)
969 ctf_enum_value("S_IRWXO", S_IRWXO
)
970 ctf_enum_value("S_IROTH", S_IROTH
)
971 ctf_enum_value("S_IWOTH", S_IWOTH
)
972 ctf_enum_value("S_IXOTH", S_IXOTH
)
973 ctf_enum_value("S_ISUID", S_ISUID
)
974 ctf_enum_value("S_ISGID", S_ISGID
)
975 ctf_enum_value("S_ISVTX", S_ISVTX
)
979 #define OVERRIDE_32_openat
980 #define OVERRIDE_64_openat
981 SC_LTTNG_TRACEPOINT_EVENT(openat
,
982 TP_PROTO(sc_exit(long ret
,) int dfd
, const char * filename
, int flags
, umode_t mode
),
983 TP_ARGS(sc_exit(ret
,) dfd
, filename
, flags
, mode
),
985 sc_exit(ctf_integer(long, ret
, ret
))
986 sc_in(ctf_integer(int, dfd
, dfd
))
987 sc_in(ctf_user_string(filename
, filename
))
988 sc_in(ctf_enum(lttng_file_status_flags
, int, flags
, flags
))
989 sc_in(ctf_enum(lttng_file_mode
, umode_t
, mode
, mode
))
993 #define OVERRIDE_32_open
994 #define OVERRIDE_64_open
995 SC_LTTNG_TRACEPOINT_EVENT(open
,
996 TP_PROTO(sc_exit(long ret
,) const char * filename
, int flags
, umode_t mode
),
997 TP_ARGS(sc_exit(ret
,) filename
, flags
, mode
),
999 sc_exit(ctf_integer(long, ret
, ret
))
1000 sc_in(ctf_user_string(filename
, filename
))
1001 sc_in(ctf_enum(lttng_file_status_flags
, int, flags
, flags
))
1002 sc_in(ctf_enum(lttng_file_mode
, umode_t
, mode
, mode
))
1006 #endif /* CREATE_SYSCALL_TABLE */