1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) */
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 .atype = atype_sequence, \
153 .u.sequence.length_type = __type_integer( \
154 uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none), \
155 .u.sequence.elem_type = __type_integer(uint8_t, 0, 0, 0, \
156 __BYTE_ORDER, 16, none), \
161 unsigned int nr_bytes_out = 0; \
164 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
167 ctf_integer_type(uint8_t, 0) \
172 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
174 for (dst = 0; dst < sizeof(long); dst++) { \
175 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
178 ctf_user_integer_type(uint8_t, \
179 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
186 #define LTTNG_SYSCALL_SELECT_fds_field_BE(name, input) \
189 .atype = atype_sequence, \
190 .u.sequence.length_type = __type_integer( \
191 uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none), \
192 .u.sequence.elem_type = __type_integer(uint8_t, 0, 0, 0, \
193 __BYTE_ORDER, 16, none), \
197 unsigned int src, nr_bytes_out = 0; \
200 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
203 ctf_integer_type(uint8_t, 0) \
208 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
210 for (dst = sizeof(long); dst >= 0; dst--) { \
211 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
214 ctf_user_integer_type(uint8_t, \
215 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
222 #define LTTNG_SYSCALL_SELECT_code_post \
223 lttng_tp_mempool_free(tp_locvar->fds_in); \
224 lttng_tp_mempool_free(tp_locvar->fds_out); \
225 lttng_tp_mempool_free(tp_locvar->fds_ex);
227 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
228 #define OVERRIDE_32_select
229 #define OVERRIDE_64_select
230 SC_LTTNG_TRACEPOINT_EVENT_CODE(select
,
231 TP_PROTO(sc_exit(long ret
,) int n
, fd_set __user
*inp
, fd_set __user
*outp
,
232 fd_set __user
*exp
, struct timeval
*tvp
),
233 TP_ARGS(sc_exit(ret
,) n
, inp
, outp
, exp
, tvp
),
235 LTTNG_SYSCALL_SELECT_locvar
238 LTTNG_SYSCALL_SELECT_code_pre
241 sc_exit(ctf_integer(long, ret
, ret
))
242 sc_in(ctf_integer(int, n
, n
))
243 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
244 sc_inout(ctf_integer(struct timeval
*, tvp
, tvp
))
247 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
248 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds
, inp
)
249 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds
, outp
)
250 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds
, exp
)
252 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds
, inp
)
253 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds
, outp
)
254 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds
, exp
)
259 LTTNG_SYSCALL_SELECT_code_post
262 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
264 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
265 #define OVERRIDE_32_pselect6
266 #define OVERRIDE_64_pselect6
267 SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6
,
268 TP_PROTO(sc_exit(long ret
,) int n
, fd_set __user
* inp
, fd_set __user
* outp
,
269 fd_set __user
* exp
, struct timeval __user
* tvp
, void __user
* sig
),
270 TP_ARGS(sc_exit(ret
,) n
, inp
, outp
, exp
, tvp
, sig
),
272 LTTNG_SYSCALL_SELECT_locvar
275 LTTNG_SYSCALL_SELECT_code_pre
278 sc_exit(ctf_integer(long, ret
, ret
))
279 sc_in(ctf_integer(int, n
, n
))
280 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
281 sc_inout(ctf_integer(struct timeval
*, tvp
, tvp
))
282 sc_in(ctf_integer_hex(void *, sig
, sig
))
285 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
286 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds
, inp
)
287 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds
, outp
)
288 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds
, exp
)
290 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds
, inp
)
291 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds
, outp
)
292 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds
, exp
)
297 LTTNG_SYSCALL_SELECT_code_post
300 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
302 #ifndef ONCE_LTTNG_TRACE_POLL_H
303 #define ONCE_LTTNG_TRACE_POLL_H
305 #define LTTNG_POLL_NRFLAGS (POLLNVAL + 1)
306 #define POLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
307 ilog2(LTTNG_POLL_NRFLAGS - 1)
310 * Only extract the values specified by iBCS2 for now.
312 static struct lttng_event_field lttng_pollfd_flag_fields
[] = {
315 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
319 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
323 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
327 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
331 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
333 [ilog2(POLLNVAL
)] = {
335 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
337 [ilog2(LTTNG_POLL_NRFLAGS
)] = {
339 .type
= __type_integer(int, POLL_FLAGS_PADDING_SIZE
, 1, 0,
340 __LITTLE_ENDIAN
, 10, none
),
344 static struct lttng_event_field lttng_pollfd_fields
[] = {
347 .type
= __type_integer(int, 0, 0, 0, __BYTE_ORDER
, 10, none
),
350 .name
= "raw_events",
351 .type
= __type_integer(short, 0, 0, 0, __BYTE_ORDER
, 16, none
),
356 .atype
= atype_struct
,
357 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_pollfd_flag_fields
),
358 .u
._struct
.fields
= lttng_pollfd_flag_fields
,
363 static struct lttng_type lttng_pollfd_elem
= {
364 .atype
= atype_struct
,
365 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_pollfd_fields
),
366 .u
._struct
.fields
= lttng_pollfd_fields
,
368 #endif /* ONCE_LTTNG_TRACE_POLL_H */
370 #define LTTNG_SYSCALL_POLL_locvar \
371 unsigned int fds_length, fds_max_len, alloc_fds; \
372 struct pollfd *fds; \
375 #define LTTNG_SYSCALL_POLL_code_pre \
376 BUILD_BUG_ON(((ARRAY_SIZE(lttng_pollfd_flag_fields) - 1) + \
377 POLL_FLAGS_PADDING_SIZE) != \
378 sizeof(uint8_t) * BITS_PER_BYTE); \
379 tp_locvar->fds = NULL; \
380 tp_locvar->overflow = 0; \
383 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
384 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
385 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
386 tp_locvar->overflow = 1; \
388 tp_locvar->fds_length = nfds; \
389 tp_locvar->fds_max_len = nfds; \
391 tp_locvar->alloc_fds = tp_locvar->fds_length * sizeof(struct pollfd); \
394 * On exit, the number of active FDs is determined by ret, \
395 * nfds stays the same as the entry, but we only want to \
396 * output the FDs that are relevant. \
399 if (ret <= 0 || ret > nfds) \
402 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
403 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
404 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
405 tp_locvar->overflow = 1; \
407 tp_locvar->fds_length = ret; \
408 tp_locvar->fds_max_len = nfds; \
410 tp_locvar->alloc_fds = tp_locvar->fds_max_len * sizeof(struct pollfd); \
415 tp_locvar->fds = lttng_tp_mempool_alloc(tp_locvar->alloc_fds); \
416 if (!tp_locvar->fds) \
418 err = lib_ring_buffer_copy_from_user_check_nofault( \
419 tp_locvar->fds, ufds, tp_locvar->alloc_fds); \
426 tp_locvar->fds_length = 0; \
427 tp_locvar->fds_max_len = 0; \
431 #define LTTNG_SYSCALL_POLL_fds_field \
435 .atype = atype_sequence_compound, \
436 .u.sequence_compound.length_name = "fds_length", \
437 .u.sequence_compound.elem_type = <tng_pollfd_elem, \
443 ctf_align(int) /* Align on largest field in struct. */ \
444 for (i = 0; i < tp_locvar->fds_length; i++) { \
445 ctf_integer_type(int, tp_locvar->fds[i].fd) \
446 ctf_integer_type(short, tp_locvar->fds[i].events) \
447 ctf_integer_bitfield_type(uint8_t, \
448 (uint8_t) tp_locvar->fds[i].events) \
456 .atype = atype_sequence_compound, \
457 .u.sequence_compound.length_name = "fds_length", \
458 .u.sequence_compound.elem_type = <tng_pollfd_elem, \
462 unsigned int i, nr = 0; \
464 ctf_align(int) /* Align on largest field in struct. */ \
466 * Iterate over the complete array, but only output \
467 * "ret" active FDs. \
469 for (i = 0; i < tp_locvar->fds_max_len; i++) { \
470 if (!tp_locvar->fds[i].revents) \
472 if (nr++ >= tp_locvar->fds_length) \
474 ctf_integer_type(int, tp_locvar->fds[i].fd) \
475 ctf_integer_type(short, tp_locvar->fds[i].revents) \
476 ctf_integer_bitfield_type(uint8_t, \
477 (uint8_t) tp_locvar->fds[i].revents) \
480 * If there is a discrepancy between ret and the \
481 * content of revents (e.g. caused by userspace corrupting \
482 * the array from a concurrent thread), we have to output \
483 * zeros to keep the trace readable. \
485 for (i = nr; i < tp_locvar->fds_length; i++) { \
486 ctf_integer_type(int, 0) \
487 ctf_integer_type(short, 0) \
488 ctf_integer_bitfield_type(uint8_t, 0) \
494 #define LTTNG_SYSCALL_POLL_code_post \
495 lttng_tp_mempool_free(tp_locvar->fds);
497 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
498 #define OVERRIDE_32_poll
499 #define OVERRIDE_64_poll
500 SC_LTTNG_TRACEPOINT_EVENT_CODE(poll
,
501 TP_PROTO(sc_exit(long ret
,) struct pollfd __user
* ufds
,
502 unsigned int nfds
, int timeout_msecs
),
503 TP_ARGS(sc_exit(ret
,) ufds
, nfds
, timeout_msecs
),
505 LTTNG_SYSCALL_POLL_locvar
508 LTTNG_SYSCALL_POLL_code_pre
511 sc_exit(ctf_integer(long, ret
, ret
))
512 sc_in(ctf_integer(int, timeout_msecs
, timeout_msecs
))
513 sc_inout(ctf_integer(unsigned int, nfds
, nfds
))
514 sc_inout(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
515 sc_in(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
516 LTTNG_SYSCALL_POLL_fds_field
519 LTTNG_SYSCALL_POLL_code_post
522 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
524 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
525 #define OVERRIDE_32_ppoll
526 #define OVERRIDE_64_ppoll
527 SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll
,
528 TP_PROTO(sc_exit(long ret
,) struct pollfd __user
* ufds
,
529 unsigned int nfds
, struct timespec
* tsp
, const sigset_t
* sigmask
, size_t sigsetsize
),
530 TP_ARGS(sc_exit(ret
,) ufds
, nfds
, tsp
, sigmask
, sigsetsize
),
532 LTTNG_SYSCALL_POLL_locvar
535 LTTNG_SYSCALL_POLL_code_pre
538 sc_exit(ctf_integer(long, ret
, ret
))
539 sc_in(ctf_integer(struct timespec
*, tsp
, tsp
))
540 sc_in(ctf_integer(const sigset_t
*, sigmask
, sigmask
))
541 sc_in(ctf_integer(size_t, sigsetsize
, sigsetsize
))
542 sc_inout(ctf_integer(unsigned int, nfds
, nfds
))
543 sc_inout(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
544 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
545 LTTNG_SYSCALL_POLL_fds_field
548 LTTNG_SYSCALL_POLL_code_post
551 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
553 #include <linux/eventpoll.h>
555 SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op
,
557 ctf_enum_value("EPOLL_CTL_ADD", EPOLL_CTL_ADD
)
558 ctf_enum_value("EPOLL_CTL_DEL", EPOLL_CTL_DEL
)
559 ctf_enum_value("EPOLL_CTL_MOD", EPOLL_CTL_MOD
)
563 #ifndef ONCE_LTTNG_TRACE_EPOLL_CTL_H
564 #define ONCE_LTTNG_TRACE_EPOLL_CTL_H
566 #define LTTNG_EPOLL_NRFLAGS (POLLHUP + 1)
567 #define EPOLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
568 ilog2(LTTNG_EPOLL_NRFLAGS - 1)
571 * Only extract the values specified by iBCS2 for now.
573 static struct lttng_event_field lttng_epoll_ctl_events_fields
[] = {
577 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
582 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
587 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
592 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
597 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
599 [ilog2(LTTNG_EPOLL_NRFLAGS
)] = {
601 .type
= __type_integer(int, EPOLL_FLAGS_PADDING_SIZE
, 1, 0,
602 __LITTLE_ENDIAN
, 10, none
),
607 static struct lttng_event_field lttng_epoll_data_fields
[] = {
610 .type
= __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
614 .type
= __type_integer(int, 0, 0, 0, __BYTE_ORDER
, 10, none
),
618 static struct lttng_event_field epoll_ctl_fields
[] = {
620 .name
= "data_union",
622 .atype
= atype_struct
,
623 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_data_fields
),
624 .u
._struct
.fields
= lttng_epoll_data_fields
,
628 .name
= "raw_events",
629 .type
= __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
634 .atype
= atype_struct
,
635 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_ctl_events_fields
),
636 .u
._struct
.fields
= lttng_epoll_ctl_events_fields
,
640 #endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */
642 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
643 #define OVERRIDE_32_epoll_ctl
644 #define OVERRIDE_64_epoll_ctl
645 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl
,
646 TP_PROTO(sc_exit(long ret
,) int epfd
, int op
, int fd
,
647 struct epoll_event __user
* uevent
),
648 TP_ARGS(sc_exit(ret
,) epfd
, op
, fd
, uevent
),
650 struct epoll_event event
;
654 tp_locvar
->err
= lib_ring_buffer_copy_from_user_check_nofault(
655 &tp_locvar
->event
, uevent
, sizeof(struct epoll_event
));
658 sc_exit(ctf_integer(long, ret
, ret
))
659 sc_in(ctf_integer(int, epfd
, epfd
))
660 sc_in(ctf_enum(lttng_epoll_op
, int, op_enum
, op
))
661 sc_in(ctf_integer(int, fd
, fd
))
665 .atype
= atype_struct
,
666 .u
._struct
.nr_fields
= ARRAY_SIZE(epoll_ctl_fields
),
667 .u
._struct
.fields
= epoll_ctl_fields
,
672 if (!tp_locvar
->err
) {
673 ctf_integer_type(uint64_t, tp_locvar
->event
.data
)
674 ctf_integer_type(int, tp_locvar
->event
.data
)
675 ctf_integer_bitfield_type(uint32_t,
676 tp_locvar
->event
.events
)
677 ctf_integer_bitfield_type(uint8_t,
678 (uint8_t) tp_locvar
->event
.events
)
680 ctf_integer_type(uint64_t, 0)
681 ctf_integer_type(int, 0)
682 ctf_integer_bitfield_type(uint32_t, 0)
683 ctf_integer_bitfield_type(uint8_t, 0)
691 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
693 #ifndef ONCE_LTTNG_TRACE_EPOLL_H
694 #define ONCE_LTTNG_TRACE_EPOLL_H
696 static struct lttng_event_field lttng_epoll_wait_fields
[] = {
698 .name
= "data_union",
700 .atype
= atype_struct
,
701 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_data_fields
),
702 .u
._struct
.fields
= lttng_epoll_data_fields
,
706 .name
= "raw_events",
707 .type
= __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
712 .atype
= atype_struct
,
713 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_ctl_events_fields
),
714 .u
._struct
.fields
= lttng_epoll_ctl_events_fields
,
719 static struct lttng_type lttng_epoll_wait_elem
= {
720 .atype
= atype_struct
,
721 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_wait_fields
),
722 .u
._struct
.fields
= lttng_epoll_wait_fields
,
725 #endif /* ONCE_LTTNG_TRACE_EPOLL_H */
727 #define LTTNG_SYSCALL_EPOLL_WAIT_locvar \
729 unsigned int fds_length; \
731 struct epoll_event *events; \
734 #define LTTNG_SYSCALL_EPOLL_WAIT_code_pre \
735 BUILD_BUG_ON(((ARRAY_SIZE(lttng_epoll_ctl_events_fields) - 1) + \
736 EPOLL_FLAGS_PADDING_SIZE) != \
737 sizeof(uint8_t) * BITS_PER_BYTE); \
740 unsigned long maxalloc; \
742 tp_locvar->fds_length = 0; \
743 tp_locvar->events = NULL; \
744 tp_locvar->overflow = 0; \
746 if (maxevents <= 0 || ret <= 0 || ret > maxevents) \
749 if (maxevents > PAGE_SIZE / sizeof(struct epoll_event)) { \
750 maxalloc = PAGE_SIZE / sizeof(struct epoll_event); \
752 maxalloc = maxevents; \
755 if (ret > maxalloc) { \
756 tp_locvar->fds_length = maxalloc; \
757 tp_locvar->overflow = 1; \
759 tp_locvar->fds_length = ret; \
762 tp_locvar->events = lttng_tp_mempool_alloc( \
763 maxalloc * sizeof(struct epoll_event)); \
764 if (!tp_locvar->events) { \
765 tp_locvar->fds_length = 0; \
769 err = lib_ring_buffer_copy_from_user_check_nofault( \
770 tp_locvar->events, uevents, \
771 maxalloc * sizeof(struct epoll_event)); \
773 tp_locvar->fds_length = 0; \
778 #define LTTNG_SYSCALL_EPOLL_WAIT_fds_field \
781 .atype = atype_sequence_compound, \
782 .u.sequence_compound.length_name = \
784 .u.sequence_compound.elem_type = \
785 <tng_epoll_wait_elem, \
791 ctf_align(uint64_t) \
792 for (i = 0; i < tp_locvar->fds_length; i++) { \
793 ctf_integer_type(uint64_t, tp_locvar->events[i].data) \
794 ctf_integer_type(int, tp_locvar->events[i].data) \
795 ctf_integer_bitfield_type(uint32_t, \
796 tp_locvar->events[i].events) \
797 ctf_integer_bitfield_type(uint8_t, \
798 (uint8_t) tp_locvar->events[i].events) \
803 #define LTTNG_SYSCALL_EPOLL_WAIT_code_post \
805 lttng_tp_mempool_free(tp_locvar->events); \
809 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM)
810 #define OVERRIDE_32_epoll_wait
811 #define OVERRIDE_64_epoll_wait
812 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_wait
,
813 TP_PROTO(sc_exit(long ret
,) int epfd
, struct epoll_event __user
* uevents
,
814 int maxevents
, int timeout
),
815 TP_ARGS(sc_exit(ret
,) epfd
, uevents
, maxevents
, timeout
),
817 LTTNG_SYSCALL_EPOLL_WAIT_locvar
820 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
823 sc_exit(ctf_integer(long, ret
, ret
))
824 sc_in(ctf_integer(int, epfd
, epfd
))
825 sc_in(ctf_integer(int, maxevents
, maxevents
))
826 sc_in(ctf_integer(int, timeout
, timeout
))
827 sc_out(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
828 sc_out(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
830 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
834 LTTNG_SYSCALL_EPOLL_WAIT_code_post
837 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */
839 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
840 #define OVERRIDE_32_epoll_pwait
841 #define OVERRIDE_64_epoll_pwait
842 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_pwait
,
843 TP_PROTO(sc_exit(long ret
,) int epfd
, struct epoll_event __user
* uevents
,
844 int maxevents
, int timeout
, const sigset_t __user
* sigmask
, size_t sigsetsize
),
845 TP_ARGS(sc_exit(ret
,) epfd
, uevents
, maxevents
, timeout
, sigmask
, sigsetsize
),
847 LTTNG_SYSCALL_EPOLL_WAIT_locvar
850 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
853 sc_exit(ctf_integer(long, ret
, ret
))
854 sc_in(ctf_integer(int, epfd
, epfd
))
855 sc_in(ctf_integer(int, maxevents
, maxevents
))
856 sc_in(ctf_integer(int, timeout
, timeout
))
857 sc_in(ctf_integer_hex(const sigset_t
*, sigmask
, sigmask
))
858 sc_in(ctf_integer(size_t, sigsetsize
, sigsetsize
))
859 sc_out(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
860 sc_out(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
862 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
866 LTTNG_SYSCALL_EPOLL_WAIT_code_post
869 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
871 #if (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
872 #define OVERRIDE_32_socketpair
873 #define OVERRIDE_64_socketpair
874 SC_LTTNG_TRACEPOINT_EVENT(socketpair
,
875 TP_PROTO(sc_exit(long ret
,) int family
, int type
, int protocol
, int *usockvec
),
876 TP_ARGS(sc_exit(ret
,) family
, type
, protocol
, usockvec
),
878 sc_exit(ctf_integer(long, ret
, ret
))
879 sc_in(ctf_integer(int, family
, family
))
880 sc_in(ctf_integer(int, type
, type
))
881 sc_in(ctf_integer(int, protocol
, protocol
))
882 sc_out(ctf_user_array(int, socket
, usockvec
, 2))
885 #endif /* (defined(CONFIG_X86_64) && !defined(LTTNG_SC_COMPAT)) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
887 #endif /* CREATE_SYSCALL_TABLE */