1 #ifndef CREATE_SYSCALL_TABLE
3 #define OVERRIDE_32_execve
4 #define OVERRIDE_64_execve
5 SC_LTTNG_TRACEPOINT_EVENT(execve
,
6 TP_PROTO(sc_exit(long ret
,) const char *filename
, char *const *argv
, char *const *envp
),
7 TP_ARGS(sc_exit(ret
,) filename
, argv
, envp
),
8 TP_FIELDS(sc_exit(ctf_integer(long, ret
, ret
))
9 sc_in(ctf_user_string(filename
, filename
))
10 sc_in(ctf_integer_hex(char *const *, argv
, argv
))
11 sc_in(ctf_integer_hex(char *const *, envp
, envp
))
15 #define OVERRIDE_32_clone
16 #define OVERRIDE_64_clone
17 SC_LTTNG_TRACEPOINT_EVENT(clone
,
18 TP_PROTO(sc_exit(long ret
,) unsigned long clone_flags
, unsigned long newsp
,
19 void __user
*parent_tid
,
20 void __user
*child_tid
),
21 TP_ARGS(sc_exit(ret
,) clone_flags
, newsp
, parent_tid
, child_tid
),
23 sc_exit(ctf_integer(long, ret
, ret
))
24 sc_in(ctf_integer_hex(unsigned long, clone_flags
, clone_flags
))
25 sc_in(ctf_integer_hex(unsigned long, newsp
, newsp
))
26 sc_in(ctf_integer_hex(void *, parent_tid
, parent_tid
))
27 sc_in(ctf_integer_hex(void *, child_tid
, child_tid
))
31 /* present in 32, missing in 64 due to old kernel headers */
32 #define OVERRIDE_32_getcpu
33 #define OVERRIDE_64_getcpu
34 SC_LTTNG_TRACEPOINT_EVENT(getcpu
,
35 TP_PROTO(sc_exit(long ret
,) unsigned __user
*cpup
, unsigned __user
*nodep
, void *tcache
),
36 TP_ARGS(sc_exit(ret
,) cpup
, nodep
, tcache
),
38 sc_exit(ctf_integer(long, ret
, ret
))
39 sc_out(ctf_integer_hex(unsigned *, cpup
, cpup
))
40 sc_out(ctf_integer_hex(unsigned *, nodep
, nodep
))
41 sc_inout(ctf_integer_hex(void *, tcache
, tcache
))
45 #define OVERRIDE_32_pipe2
46 #define OVERRIDE_64_pipe2
47 SC_LTTNG_TRACEPOINT_EVENT(pipe2
,
48 TP_PROTO(sc_exit(long ret
,) int * fildes
, int flags
),
49 TP_ARGS(sc_exit(ret
,) fildes
, flags
),
50 TP_FIELDS(sc_exit(ctf_integer(long, ret
, ret
))
51 sc_out(ctf_user_array(int, fildes
, fildes
, 2))
52 sc_in(ctf_integer(int, flags
, flags
))
56 #define LTTNG_SYSCALL_SELECT_locvar \
57 unsigned long *fds_in, *fds_out, *fds_ex; \
58 unsigned long nr_bytes, nr_ulong; \
61 #define LTTNG_SYSCALL_SELECT_code_pre \
65 unsigned int n_in_bytes; \
67 tp_locvar->fds_in = NULL; \
68 tp_locvar->fds_out = NULL; \
69 tp_locvar->fds_ex = NULL; \
70 tp_locvar->overflow = 0; \
80 /* On error or bogus input, don't copy anything. */ \
81 if (n >__FD_SETSIZE) \
84 n_in_bytes = DIV_ROUND_UP((unsigned int) n, BITS_PER_BYTE); \
87 * Limit atomic memory allocation to one page, since n \
88 * is limited to 1024 and the smallest page size on Linux \
89 * is 4k, this should not happen, don't try to make it work. \
91 if (n_in_bytes > PAGE_SIZE) { \
93 /* Inform the user that we did not output everything. */ \
94 tp_locvar->overflow = 1; \
97 tp_locvar->nr_bytes = n_in_bytes; \
98 tp_locvar->nr_ulong = DIV_ROUND_UP(n_in_bytes, \
99 sizeof(unsigned long)); \
103 tp_locvar->fds_in = kmalloc( \
104 tp_locvar->nr_ulong * sizeof(unsigned long), \
105 GFP_ATOMIC | GFP_NOWAIT); \
106 if (!tp_locvar->fds_in) \
109 err = lib_ring_buffer_copy_from_user_check_nofault( \
110 tp_locvar->fds_in, inp, \
111 tp_locvar->nr_ulong * sizeof(unsigned long)); \
116 tp_locvar->fds_out = kmalloc( \
117 tp_locvar->nr_ulong * sizeof(unsigned long), \
118 GFP_ATOMIC | GFP_NOWAIT); \
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 = kmalloc( \
130 tp_locvar->nr_ulong * sizeof(unsigned long), \
131 GFP_ATOMIC | GFP_NOWAIT); \
132 if (!tp_locvar->fds_ex) \
135 err = lib_ring_buffer_copy_from_user_check_nofault( \
136 tp_locvar->fds_ex, exp, \
137 tp_locvar->nr_ulong * sizeof(unsigned long)); \
144 tp_locvar->nr_bytes = 0; \
145 tp_locvar->nr_ulong = 0; \
146 end: ; /* Label at end of compound statement. */ \
150 #define LTTNG_SYSCALL_SELECT_fds_field_LE(name, input) \
153 .atype = atype_sequence, \
154 .u.sequence.length_type = __type_integer( \
155 uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none), \
156 .u.sequence.elem_type = __type_integer(uint8_t, 0, 0, 0, \
157 __BYTE_ORDER, 16, none), \
162 unsigned int nr_bytes_out = 0; \
165 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
168 ctf_integer_type(uint8_t, 0) \
173 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
175 for (dst = 0; dst < sizeof(long); dst++) { \
176 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
179 ctf_user_integer_type(uint8_t, \
180 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
187 #define LTTNG_SYSCALL_SELECT_fds_field_BE(name, input) \
190 .atype = atype_sequence, \
191 .u.sequence.length_type = __type_integer( \
192 uint8_t, 0, 0, 0, __BYTE_ORDER, 10, none), \
193 .u.sequence.elem_type = __type_integer(uint8_t, 0, 0, 0, \
194 __BYTE_ORDER, 16, none), \
198 unsigned int src, nr_bytes_out = 0; \
201 ctf_integer_type(uint8_t, tp_locvar->nr_bytes) \
204 ctf_integer_type(uint8_t, 0) \
209 for (src = 0; src < tp_locvar->nr_ulong; src++) { \
211 for (dst = sizeof(long); dst >= 0; dst--) { \
212 if (nr_bytes_out++ >= tp_locvar->nr_bytes) { \
215 ctf_user_integer_type(uint8_t, \
216 ((uint8_t __user *) (input->fds_bits + src))[dst]); \
223 #define LTTNG_SYSCALL_SELECT_code_post \
224 kfree(tp_locvar->fds_in); \
225 kfree(tp_locvar->fds_out); \
226 kfree(tp_locvar->fds_ex);
228 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
229 #define OVERRIDE_32_select
230 #define OVERRIDE_64_select
231 SC_LTTNG_TRACEPOINT_EVENT_CODE(select
,
232 TP_PROTO(sc_exit(long ret
,) int n
, fd_set __user
*inp
, fd_set __user
*outp
,
233 fd_set __user
*exp
, struct timeval
*tvp
),
234 TP_ARGS(sc_exit(ret
,) n
, inp
, outp
, exp
, tvp
),
236 LTTNG_SYSCALL_SELECT_locvar
239 LTTNG_SYSCALL_SELECT_code_pre
242 sc_exit(ctf_integer(long, ret
, ret
))
243 sc_in(ctf_integer(int, n
, n
))
244 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
245 sc_inout(ctf_integer(struct timeval
*, tvp
, tvp
))
248 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
249 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds
, inp
)
250 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds
, outp
)
251 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds
, exp
)
253 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds
, inp
)
254 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds
, outp
)
255 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds
, exp
)
260 LTTNG_SYSCALL_SELECT_code_post
263 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) */
265 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
266 #define OVERRIDE_32_pselect6
267 #define OVERRIDE_64_pselect6
268 SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6
,
269 TP_PROTO(sc_exit(long ret
,) int n
, fd_set __user
* inp
, fd_set __user
* outp
,
270 fd_set __user
* exp
, struct timeval __user
* tvp
, void __user
* sig
),
271 TP_ARGS(sc_exit(ret
,) n
, inp
, outp
, exp
, tvp
, sig
),
273 LTTNG_SYSCALL_SELECT_locvar
276 LTTNG_SYSCALL_SELECT_code_pre
279 sc_exit(ctf_integer(long, ret
, ret
))
280 sc_in(ctf_integer(int, n
, n
))
281 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
282 sc_inout(ctf_integer(struct timeval
*, tvp
, tvp
))
283 sc_in(ctf_integer_hex(void *, sig
, sig
))
286 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
287 LTTNG_SYSCALL_SELECT_fds_field_LE(readfds
, inp
)
288 LTTNG_SYSCALL_SELECT_fds_field_LE(writefds
, outp
)
289 LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds
, exp
)
291 LTTNG_SYSCALL_SELECT_fds_field_BE(readfds
, inp
)
292 LTTNG_SYSCALL_SELECT_fds_field_BE(writefds
, outp
)
293 LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds
, exp
)
298 LTTNG_SYSCALL_SELECT_code_post
301 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
303 #ifndef ONCE_LTTNG_TRACE_POLL_H
304 #define ONCE_LTTNG_TRACE_POLL_H
306 #define LTTNG_POLL_NRFLAGS (POLLNVAL + 1)
307 #define POLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
308 ilog2(LTTNG_POLL_NRFLAGS - 1)
311 * Only extract the values specified by iBCS2 for now.
313 static struct lttng_event_field lttng_pollfd_flag_fields
[] = {
316 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
320 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
324 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
328 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
332 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
334 [ilog2(POLLNVAL
)] = {
336 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
338 [ilog2(LTTNG_POLL_NRFLAGS
)] = {
340 .type
= __type_integer(int, POLL_FLAGS_PADDING_SIZE
, 1, 0,
341 __LITTLE_ENDIAN
, 10, none
),
345 static struct lttng_event_field lttng_pollfd_fields
[] = {
348 .type
= __type_integer(int, 0, 0, 0, __BYTE_ORDER
, 10, none
),
351 .name
= "raw_events",
352 .type
= __type_integer(short, 0, 0, 0, __BYTE_ORDER
, 16, none
),
357 .atype
= atype_struct
,
358 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_pollfd_flag_fields
),
359 .u
._struct
.fields
= lttng_pollfd_flag_fields
,
364 static struct lttng_type lttng_pollfd_elem
= {
365 .atype
= atype_struct
,
366 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_pollfd_fields
),
367 .u
._struct
.fields
= lttng_pollfd_fields
,
369 #endif /* ONCE_LTTNG_TRACE_POLL_H */
371 #define LTTNG_SYSCALL_POLL_locvar \
372 unsigned int fds_length, fds_max_len, alloc_fds; \
373 struct pollfd *fds; \
376 #define LTTNG_SYSCALL_POLL_code_pre \
377 BUILD_BUG_ON(((ARRAY_SIZE(lttng_pollfd_flag_fields) - 1) + \
378 POLL_FLAGS_PADDING_SIZE) != \
379 sizeof(uint8_t) * BITS_PER_BYTE); \
380 tp_locvar->fds = NULL; \
381 tp_locvar->overflow = 0; \
384 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
385 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
386 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
387 tp_locvar->overflow = 1; \
389 tp_locvar->fds_length = nfds; \
390 tp_locvar->fds_max_len = nfds; \
392 tp_locvar->alloc_fds = tp_locvar->fds_length * sizeof(struct pollfd); \
395 * On exit, the number of active FDs is determined by ret, \
396 * nfds stays the same as the entry, but we only want to \
397 * output the FDs that are relevant. \
400 if (ret <= 0 || ret > nfds) \
403 if (nfds > PAGE_SIZE / sizeof(struct pollfd)) { \
404 tp_locvar->fds_length = PAGE_SIZE / sizeof(struct pollfd); \
405 tp_locvar->fds_max_len = PAGE_SIZE / sizeof(struct pollfd); \
406 tp_locvar->overflow = 1; \
408 tp_locvar->fds_length = ret; \
409 tp_locvar->fds_max_len = nfds; \
411 tp_locvar->alloc_fds = tp_locvar->fds_max_len * sizeof(struct pollfd); \
416 tp_locvar->fds = kmalloc(tp_locvar->alloc_fds, \
417 GFP_ATOMIC | GFP_NOWAIT); \
418 if (!tp_locvar->fds) \
420 err = lib_ring_buffer_copy_from_user_check_nofault( \
421 tp_locvar->fds, ufds, \
422 nfds * sizeof(struct pollfd)); \
429 tp_locvar->fds_length = 0; \
430 tp_locvar->fds_max_len = 0; \
434 #define LTTNG_SYSCALL_POLL_fds_field \
438 .atype = atype_sequence_compound, \
439 .u.sequence_compound.length_name = "fds_length", \
440 .u.sequence_compound.elem_type = <tng_pollfd_elem, \
446 ctf_align(int) /* Align on largest field in struct. */ \
447 for (i = 0; i < tp_locvar->fds_length; i++) { \
448 ctf_integer_type(int, tp_locvar->fds[i].fd) \
449 ctf_integer_type(short, tp_locvar->fds[i].events) \
450 ctf_integer_bitfield_type(uint8_t, \
451 (uint8_t) tp_locvar->fds[i].events) \
459 .atype = atype_sequence_compound, \
460 .u.sequence_compound.length_name = "fds_length", \
461 .u.sequence_compound.elem_type = <tng_pollfd_elem, \
465 unsigned int i, nr = 0; \
467 ctf_align(int) /* Align on largest field in struct. */ \
469 * Iterate over the complete array, but only output \
470 * "ret" active FDs. \
472 for (i = 0; i < tp_locvar->fds_max_len; i++) { \
473 if (!tp_locvar->fds[i].revents) \
475 if (nr++ >= tp_locvar->fds_length) \
477 ctf_integer_type(int, tp_locvar->fds[i].fd) \
478 ctf_integer_type(short, tp_locvar->fds[i].revents) \
479 ctf_integer_bitfield_type(uint8_t, \
480 (uint8_t) tp_locvar->fds[i].revents) \
483 * If there is a discrepancy between ret and the \
484 * content of revents (e.g. caused by userspace corrupting \
485 * the array from a concurrent thread), we have to output \
486 * zeros to keep the trace readable. \
488 for (i = nr; i < tp_locvar->fds_length; i++) { \
489 ctf_integer_type(int, 0) \
490 ctf_integer_type(short, 0) \
491 ctf_integer_bitfield_type(uint8_t, 0) \
497 #define LTTNG_SYSCALL_POLL_code_post \
498 kfree(tp_locvar->fds);
500 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
501 #define OVERRIDE_32_poll
502 #define OVERRIDE_64_poll
503 SC_LTTNG_TRACEPOINT_EVENT_CODE(poll
,
504 TP_PROTO(sc_exit(long ret
,) struct pollfd __user
* ufds
,
505 unsigned int nfds
, int timeout_msecs
),
506 TP_ARGS(sc_exit(ret
,) ufds
, nfds
, timeout_msecs
),
508 LTTNG_SYSCALL_POLL_locvar
511 LTTNG_SYSCALL_POLL_code_pre
514 sc_exit(ctf_integer(long, ret
, ret
))
515 sc_in(ctf_integer(int, timeout_msecs
, timeout_msecs
))
516 sc_inout(ctf_integer(unsigned int, nfds
, nfds
))
517 sc_inout(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
518 sc_in(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
519 LTTNG_SYSCALL_POLL_fds_field
522 LTTNG_SYSCALL_POLL_code_post
525 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) */
527 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
528 #define OVERRIDE_32_ppoll
529 #define OVERRIDE_64_ppoll
530 SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll
,
531 TP_PROTO(sc_exit(long ret
,) struct pollfd __user
* ufds
,
532 unsigned int nfds
, struct timespec
* tsp
, const sigset_t
* sigmask
, size_t sigsetsize
),
533 TP_ARGS(sc_exit(ret
,) ufds
, nfds
, tsp
, sigmask
, sigsetsize
),
535 LTTNG_SYSCALL_POLL_locvar
538 LTTNG_SYSCALL_POLL_code_pre
541 sc_exit(ctf_integer(long, ret
, ret
))
542 sc_in(ctf_integer(struct timespec
*, tsp
, tsp
))
543 sc_in(ctf_integer(const sigset_t
*, sigmask
, sigmask
))
544 sc_in(ctf_integer(size_t, sigsetsize
, sigsetsize
))
545 sc_inout(ctf_integer(unsigned int, nfds
, nfds
))
546 sc_inout(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
547 sc_inout(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
548 LTTNG_SYSCALL_POLL_fds_field
551 LTTNG_SYSCALL_POLL_code_post
554 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
556 #include <linux/eventpoll.h>
558 SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op
,
560 ctf_enum_value("EPOLL_CTL_ADD", EPOLL_CTL_ADD
)
561 ctf_enum_value("EPOLL_CTL_DEL", EPOLL_CTL_DEL
)
562 ctf_enum_value("EPOLL_CTL_MOD", EPOLL_CTL_MOD
)
566 #ifndef ONCE_LTTNG_TRACE_EPOLL_CTL_H
567 #define ONCE_LTTNG_TRACE_EPOLL_CTL_H
569 #define LTTNG_EPOLL_NRFLAGS (POLLHUP + 1)
570 #define EPOLL_FLAGS_PADDING_SIZE (sizeof(uint8_t) * BITS_PER_BYTE) - \
571 ilog2(LTTNG_EPOLL_NRFLAGS - 1)
574 * Only extract the values specified by iBCS2 for now.
576 static struct lttng_event_field lttng_epoll_ctl_events_fields
[] = {
580 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
585 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
590 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
595 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
600 .type
= __type_integer(int, 1, 1, 0, __LITTLE_ENDIAN
, 10, none
),
602 [ilog2(LTTNG_EPOLL_NRFLAGS
)] = {
604 .type
= __type_integer(int, EPOLL_FLAGS_PADDING_SIZE
, 1, 0,
605 __LITTLE_ENDIAN
, 10, none
),
610 static struct lttng_event_field lttng_epoll_data_fields
[] = {
613 .type
= __type_integer(uint64_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
617 .type
= __type_integer(int, 0, 0, 0, __BYTE_ORDER
, 10, none
),
621 static struct lttng_event_field epoll_ctl_fields
[] = {
623 .name
= "data_union",
625 .atype
= atype_struct
,
626 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_data_fields
),
627 .u
._struct
.fields
= lttng_epoll_data_fields
,
631 .name
= "raw_events",
632 .type
= __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
637 .atype
= atype_struct
,
638 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_ctl_events_fields
),
639 .u
._struct
.fields
= lttng_epoll_ctl_events_fields
,
643 #endif /* ONCE_LTTNG_TRACE_EPOLL_CTL_H */
645 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
646 #define OVERRIDE_32_epoll_ctl
647 #define OVERRIDE_64_epoll_ctl
648 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_ctl
,
649 TP_PROTO(sc_exit(long ret
,) int epfd
, int op
, int fd
,
650 struct epoll_event __user
* uevent
),
651 TP_ARGS(sc_exit(ret
,) epfd
, op
, fd
, uevent
),
653 struct epoll_event event
;
657 tp_locvar
->err
= lib_ring_buffer_copy_from_user_check_nofault(
658 &tp_locvar
->event
, uevent
, sizeof(struct epoll_event
));
661 sc_exit(ctf_integer(long, ret
, ret
))
662 sc_in(ctf_integer(int, epfd
, epfd
))
663 sc_in(ctf_enum(lttng_epoll_op
, int, op_enum
, op
))
664 sc_in(ctf_integer(int, fd
, fd
))
668 .atype
= atype_struct
,
669 .u
._struct
.nr_fields
= ARRAY_SIZE(epoll_ctl_fields
),
670 .u
._struct
.fields
= epoll_ctl_fields
,
675 if (!tp_locvar
->err
) {
676 ctf_integer_type(uint64_t, tp_locvar
->event
.data
)
677 ctf_integer_type(int, tp_locvar
->event
.data
)
678 ctf_integer_bitfield_type(uint32_t,
679 tp_locvar
->event
.events
)
680 ctf_integer_bitfield_type(uint8_t,
681 (uint8_t) tp_locvar
->event
.events
)
683 ctf_integer_type(uint64_t, 0)
684 ctf_integer_type(int, 0)
685 ctf_integer_bitfield_type(uint32_t, 0)
686 ctf_integer_bitfield_type(uint8_t, 0)
694 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
696 #ifndef ONCE_LTTNG_TRACE_EPOLL_H
697 #define ONCE_LTTNG_TRACE_EPOLL_H
699 static struct lttng_event_field lttng_epoll_wait_fields
[] = {
701 .name
= "data_union",
703 .atype
= atype_struct
,
704 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_data_fields
),
705 .u
._struct
.fields
= lttng_epoll_data_fields
,
709 .name
= "raw_events",
710 .type
= __type_integer(uint32_t, 0, 0, 0, __BYTE_ORDER
, 16, none
),
715 .atype
= atype_struct
,
716 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_ctl_events_fields
),
717 .u
._struct
.fields
= lttng_epoll_ctl_events_fields
,
722 static struct lttng_type lttng_epoll_wait_elem
= {
723 .atype
= atype_struct
,
724 .u
._struct
.nr_fields
= ARRAY_SIZE(lttng_epoll_wait_fields
),
725 .u
._struct
.fields
= lttng_epoll_wait_fields
,
728 #endif /* ONCE_LTTNG_TRACE_EPOLL_H */
730 #define LTTNG_SYSCALL_EPOLL_WAIT_locvar \
732 unsigned int fds_length; \
734 struct epoll_event *events; \
737 #define LTTNG_SYSCALL_EPOLL_WAIT_code_pre \
738 BUILD_BUG_ON(((ARRAY_SIZE(lttng_epoll_ctl_events_fields) - 1) + \
739 EPOLL_FLAGS_PADDING_SIZE) != \
740 sizeof(uint8_t) * BITS_PER_BYTE); \
743 unsigned long maxalloc; \
745 tp_locvar->fds_length = 0; \
746 tp_locvar->events = NULL; \
747 tp_locvar->overflow = 0; \
749 if (maxevents <= 0 || ret <= 0 || ret > maxevents) \
752 if (maxevents > PAGE_SIZE / sizeof(struct epoll_event)) { \
753 maxalloc = PAGE_SIZE / sizeof(struct epoll_event); \
755 maxalloc = maxevents; \
758 if (ret > maxalloc) { \
759 tp_locvar->fds_length = maxalloc; \
760 tp_locvar->overflow = 1; \
762 tp_locvar->fds_length = ret; \
765 tp_locvar->events = kmalloc( \
766 maxalloc * sizeof(struct epoll_event), \
767 GFP_ATOMIC | GFP_NOWAIT); \
768 if (!tp_locvar->events) { \
769 tp_locvar->fds_length = 0; \
773 err = lib_ring_buffer_copy_from_user_check_nofault( \
774 tp_locvar->events, uevents, \
775 maxevents * sizeof(struct epoll_event)); \
777 tp_locvar->fds_length = 0; \
782 #define LTTNG_SYSCALL_EPOLL_WAIT_fds_field \
785 .atype = atype_sequence_compound, \
786 .u.sequence_compound.length_name = \
788 .u.sequence_compound.elem_type = \
789 <tng_epoll_wait_elem, \
795 ctf_align(uint64_t) \
796 for (i = 0; i < tp_locvar->fds_length; i++) { \
797 ctf_integer_type(uint64_t, tp_locvar->events[i].data) \
798 ctf_integer_type(int, tp_locvar->events[i].data) \
799 ctf_integer_bitfield_type(uint32_t, \
800 tp_locvar->events[i].events) \
801 ctf_integer_bitfield_type(uint8_t, \
802 (uint8_t) tp_locvar->events[i].events) \
807 #define LTTNG_SYSCALL_EPOLL_WAIT_code_post \
809 kfree(tp_locvar->events); \
813 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
814 #define OVERRIDE_32_epoll_wait
815 #define OVERRIDE_64_epoll_wait
816 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_wait
,
817 TP_PROTO(sc_exit(long ret
,) int epfd
, struct epoll_event __user
* uevents
,
818 int maxevents
, int timeout
),
819 TP_ARGS(sc_exit(ret
,) epfd
, uevents
, maxevents
, timeout
),
821 LTTNG_SYSCALL_EPOLL_WAIT_locvar
824 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
827 sc_exit(ctf_integer(long, ret
, ret
))
828 sc_in(ctf_integer(int, epfd
, epfd
))
829 sc_in(ctf_integer(int, maxevents
, maxevents
))
830 sc_in(ctf_integer(int, timeout
, timeout
))
831 sc_out(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
832 sc_out(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
834 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
838 LTTNG_SYSCALL_EPOLL_WAIT_code_post
841 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) */
843 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM)
844 #define OVERRIDE_32_epoll_pwait
845 #define OVERRIDE_64_epoll_pwait
846 SC_LTTNG_TRACEPOINT_EVENT_CODE(epoll_pwait
,
847 TP_PROTO(sc_exit(long ret
,) int epfd
, struct epoll_event __user
* uevents
,
848 int maxevents
, int timeout
, const sigset_t __user
* sigmask
, size_t sigsetsize
),
849 TP_ARGS(sc_exit(ret
,) epfd
, uevents
, maxevents
, timeout
, sigmask
, sigsetsize
),
851 LTTNG_SYSCALL_EPOLL_WAIT_locvar
854 LTTNG_SYSCALL_EPOLL_WAIT_code_pre
857 sc_exit(ctf_integer(long, ret
, ret
))
858 sc_in(ctf_integer(int, epfd
, epfd
))
859 sc_in(ctf_integer(int, maxevents
, maxevents
))
860 sc_in(ctf_integer(int, timeout
, timeout
))
861 sc_in(ctf_integer_hex(const sigset_t
*, sigmask
, sigmask
))
862 sc_in(ctf_integer(size_t, sigsetsize
, sigsetsize
))
863 sc_out(ctf_integer(unsigned int, fds_length
, tp_locvar
->fds_length
))
864 sc_out(ctf_integer(uint8_t, overflow
, tp_locvar
->overflow
))
866 LTTNG_SYSCALL_EPOLL_WAIT_fds_field
870 LTTNG_SYSCALL_EPOLL_WAIT_code_post
873 #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */
875 #endif /* CREATE_SYSCALL_TABLE */