Browse Source

Implement decoding of io_uring_* syscalls

... introduced by Linux kernel commits v5.1-rc1~99^2~14,
v5.1-rc1~99^2~7, and v5.1-rc7~24^2.

* configure.ac (AC_CHECK_HEADERS): Add linux/io_uring.h.
* io_uring.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* pathtrace.c (pathtrace_match_set): Add SEN_io_uring_enter,
SEN_io_uring_register, and SEN_io_uring_setup.
* xlat/uring_enter_flags.in: New file.
* xlat/uring_register_opcodes.in: Likewise.
* linux/32/syscallent.h [425, 426, 427]: Wire up io_uring_setup,
io_uring_enter, and io_uring_register.
* linux/64/syscallent.h: Likewise.
* linux/arm/syscallent.h: Likewise.
* linux/hppa/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/powerpc64/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/s390x/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/syscallent.h: Likewise.
* linux/xtensa/syscallent.h: Likewise.
* linux/alpha/syscallent.h [535, 536, 537]: Likewise.
* linux/ia64/syscallent.h [1024 + 425, 1024 + 426, 1024 + 427]: Likewise.
* linux/mips/syscallent-n32.h [6425, 6426, 6427]: Likewise.
* linux/mips/syscallent-n64.h [5425, 5426, 5427]: Likewise.
* linux/mips/syscallent-o32.h [4425, 4426, 4427]: Likewise.
* NEWS: Mention this change.
* tests/io_uring_enter.c: New file.
* tests/io_uring_register.c: Likewise.
* tests/io_uring_setup.c: Likewise.
* tests/gen_tests.in (io_uring_enter, io_uring_register,
io_uring_setup): New entries.
* tests/pure_executables.list: Add io_uring_enter, io_uring_register,
and io_uring_setup.
* tests/.gitignore: Likewise.
Dmitry V. Levin 6 months ago
parent
commit
d7e00d657a

+ 1
- 0
Makefile.am View File

@@ -145,6 +145,7 @@ strace_SOURCES =	\
145 145
 	inotify.c	\
146 146
 	inotify_ioctl.c	\
147 147
 	io.c		\
148
+	io_uring.c	\
148 149
 	ioctl.c		\
149 150
 	ioperm.c	\
150 151
 	iopl.c		\

+ 2
- 1
NEWS View File

@@ -13,7 +13,8 @@ Noteworthy changes in release ?.? (????-??-??)
13 13
     pselect6_time64, ppoll_time64, io_pgetevents_time64, recvmmsg_time64,
14 14
     mq_timedsend_time64, mq_timedreceive_time64, semtimedop_time64,
15 15
     rt_sigtimedwait_time64, futex_time64, sched_rr_get_interval_time64,
16
-    and pidfd_send_signal syscalls.
16
+    pidfd_send_signal, io_uring_setup, io_uring_enter, and io_uring_register
17
+    syscalls.
17 18
   * Wired up getegid, geteuid, getppid, io_pgetevents, statfs64, and fstatfs64
18 19
     syscalls on alpha.
19 20
   * Wired up kexec_file_load and migrate_pages syscalls on arm.

+ 1
- 0
configure.ac View File

@@ -387,6 +387,7 @@ AC_CHECK_HEADERS(m4_normalize([
387 387
 	linux/hiddev.h
388 388
 	linux/if_addr.h
389 389
 	linux/if_link.h
390
+	linux/io_uring.h
390 391
 	linux/ip_vs.h
391 392
 	linux/ipc.h
392 393
 	linux/kcmp.h

+ 135
- 0
io_uring.c View File

@@ -0,0 +1,135 @@
1
+/*
2
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
3
+ * All rights reserved.
4
+ *
5
+ * SPDX-License-Identifier: LGPL-2.1-or-later
6
+ */
7
+
8
+#include "defs.h"
9
+
10
+#ifdef HAVE_LINUX_IO_URING_H
11
+# include "print_fields.h"
12
+# include <linux/io_uring.h>
13
+#endif
14
+
15
+#include "xlat/uring_setup_flags.h"
16
+#include "xlat/uring_enter_flags.h"
17
+#include "xlat/uring_register_opcodes.h"
18
+
19
+SYS_FUNC(io_uring_setup)
20
+{
21
+	const uint32_t nentries = tcp->u_arg[0];
22
+	const kernel_ulong_t params_addr = tcp->u_arg[1];
23
+
24
+#ifdef HAVE_LINUX_IO_URING_H
25
+	struct io_uring_params params;
26
+
27
+	if (entering(tcp)) {
28
+		tprintf("%u, ", nentries);
29
+
30
+		if (umove_or_printaddr(tcp, params_addr, &params))
31
+			return RVAL_DECODED | RVAL_FD;
32
+
33
+		PRINT_FIELD_FLAGS("{", params, flags, uring_setup_flags,
34
+				  "IORING_SETUP_???");
35
+		PRINT_FIELD_X(", ", params, sq_thread_cpu);
36
+		PRINT_FIELD_U(", ", params, sq_thread_idle);
37
+		for (unsigned int i = 0; i < ARRAY_SIZE(params.resv); ++i) {
38
+			if (params.resv[i]) {
39
+				for (i = 0; i < ARRAY_SIZE(params.resv); ++i)
40
+					tprintf("%s%#x",
41
+						(i ? ", " : ", resv={"),
42
+						params.resv[i]);
43
+				tprints("}");
44
+				break;
45
+			}
46
+		}
47
+		return 0;
48
+	} else {
49
+		if (syserror(tcp)) {
50
+			/* The remaining part of params is irrelevant.  */
51
+		} else if (umove(tcp, params_addr, &params)) {
52
+			tprints(", ???");
53
+		} else {
54
+			PRINT_FIELD_U(", ", params, sq_entries);
55
+			PRINT_FIELD_U(", ", params, cq_entries);
56
+			PRINT_FIELD_U(", sq_off={", params.sq_off, head);
57
+			PRINT_FIELD_U(", ", params.sq_off, tail);
58
+			PRINT_FIELD_U(", ", params.sq_off, ring_mask);
59
+			PRINT_FIELD_U(", ", params.sq_off, ring_entries);
60
+			PRINT_FIELD_U(", ", params.sq_off, flags);
61
+			PRINT_FIELD_U(", ", params.sq_off, dropped);
62
+			PRINT_FIELD_U(", ", params.sq_off, array);
63
+			PRINT_FIELD_U("}, cq_off={", params.cq_off, head);
64
+			PRINT_FIELD_U(", ", params.cq_off, tail);
65
+			PRINT_FIELD_U(", ", params.cq_off, ring_mask);
66
+			PRINT_FIELD_U(", ", params.cq_off, ring_entries);
67
+			PRINT_FIELD_U(", ", params.cq_off, overflow);
68
+			PRINT_FIELD_U(", ", params.cq_off, cqes);
69
+			tprints("}");
70
+		}
71
+		tprints("}");
72
+	}
73
+#else /* !HAVE_LINUX_IO_URING_H */
74
+	tprintf("%u, ", nentries);
75
+	printaddr(params_addr);
76
+#endif
77
+
78
+	return RVAL_DECODED | RVAL_FD;
79
+}
80
+
81
+SYS_FUNC(io_uring_enter)
82
+{
83
+	const int fd = tcp->u_arg[0];
84
+	const uint32_t to_submit = tcp->u_arg[1];
85
+	const uint32_t min_complete = tcp->u_arg[2];
86
+	const uint32_t flags = tcp->u_arg[3];
87
+	const kernel_ulong_t sigset_addr = tcp->u_arg[4];
88
+	const kernel_ulong_t sigset_size = tcp->u_arg[5];
89
+
90
+	printfd(tcp, fd);
91
+	tprintf(", %u, %u, ", to_submit, min_complete);
92
+	printflags(uring_enter_flags, flags, "IORING_ENTER_???");
93
+	tprints(", ");
94
+	print_sigset_addr_len(tcp, sigset_addr, sigset_size);
95
+	tprintf(", %" PRI_klu, sigset_size);
96
+
97
+	return RVAL_DECODED;
98
+}
99
+
100
+static bool
101
+print_fd_array_member(struct tcb *tcp, void *elem_buf, size_t elem_size,
102
+		      void *data)
103
+{
104
+	printfd(tcp, *(int *) elem_buf);
105
+	return true;
106
+}
107
+
108
+SYS_FUNC(io_uring_register)
109
+{
110
+	const int fd = tcp->u_arg[0];
111
+	const unsigned int opcode = tcp->u_arg[1];
112
+	const kernel_ulong_t arg = tcp->u_arg[2];
113
+	const unsigned int nargs = tcp->u_arg[3];
114
+	int buf;
115
+
116
+	printfd(tcp, fd);
117
+	tprints(", ");
118
+	printxval(uring_register_opcodes, opcode, "IORING_REGISTER_???");
119
+	tprints(", ");
120
+	switch (opcode) {
121
+		case IORING_REGISTER_BUFFERS:
122
+			tprint_iov(tcp, nargs, arg, IOV_DECODE_ADDR);
123
+			break;
124
+		case IORING_REGISTER_FILES:
125
+			print_array(tcp, arg, nargs, &buf, sizeof(buf),
126
+				    tfetch_mem, print_fd_array_member, NULL);
127
+			break;
128
+		default:
129
+			printaddr(arg);
130
+			break;
131
+	}
132
+	tprintf(", %u", nargs);
133
+
134
+	return RVAL_DECODED;
135
+}

+ 3
- 0
linux/32/syscallent.h View File

@@ -313,6 +313,9 @@
313 313
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
314 314
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
315 315
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
316
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
317
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
318
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
316 319
 
317 320
 #undef sys_ARCH_mmap
318 321
 #undef ARCH_WANT_SYNC_FILE_RANGE2

+ 3
- 0
linux/64/syscallent.h View File

@@ -287,3 +287,6 @@
287 287
 [294] = { 5,	TD,		SEN(kexec_file_load),		"kexec_file_load"	},
288 288
 /* [295 ... 423] - reserved to sync up with other architectures */
289 289
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
290
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
291
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
292
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
linux/alpha/syscallent.h View File

@@ -478,3 +478,6 @@
478 478
 [532] = { 0,	PU|NF,		SEN(getppid),			"getppid"		},
479 479
 /* all other architectures have common numbers for new syscalls, alpha is the exception */
480 480
 [534] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
481
+[535] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
482
+[536] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
483
+[537] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
linux/arm/syscallent.h View File

@@ -431,6 +431,9 @@
431 431
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
432 432
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
433 433
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
434
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
435
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
436
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
434 437
 
435 438
 #ifdef __ARM_EABI__
436 439
 # define ARM_FIRST_SHUFFLED_SYSCALL 500

+ 3
- 0
linux/hppa/syscallent.h View File

@@ -380,3 +380,6 @@
380 380
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
381 381
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
382 382
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
383
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
384
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
385
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
linux/i386/syscallent.h View File

@@ -425,6 +425,9 @@
425 425
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
426 426
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
427 427
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
428
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
429
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
430
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
428 431
 
429 432
 #define SYS_socket_subcall	500
430 433
 #include "subcall32.h"

+ 3
- 0
linux/ia64/syscallent.h View File

@@ -343,3 +343,6 @@
343 343
 [1024 + 333] = { 4,	0,		SEN(rseq),			"rseq"			},
344 344
 /* [1024 + 334 ... 1024 + 423] - reserved to sync up with other architectures */
345 345
 [1024 + 424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
346
+[1024 + 425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
347
+[1024 + 426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
348
+[1024 + 427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
linux/m68k/syscallent.h View File

@@ -423,6 +423,9 @@
423 423
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
424 424
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
425 425
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
426
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
427
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
428
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
426 429
 
427 430
 #define SYS_socket_subcall	500
428 431
 #include "subcall32.h"

+ 3
- 0
linux/microblaze/syscallent.h View File

@@ -429,3 +429,6 @@
429 429
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
430 430
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
431 431
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
432
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
433
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
434
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
linux/mips/syscallent-n32.h View File

@@ -362,6 +362,9 @@
362 362
 [6422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
363 363
 [6423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
364 364
 [6424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
365
+[6425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
366
+[6426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
367
+[6427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
365 368
 
366 369
 # define SYS_socket_subcall      6500
367 370
 # include "subcall32.h"

+ 3
- 0
linux/mips/syscallent-n64.h View File

@@ -338,6 +338,9 @@
338 338
 [5328] = { 6,	0,		SEN(io_pgetevents_time64),	"io_pgetevents"		},
339 339
 /* [5329 ... 5423] - reserved to sync up with other architectures */
340 340
 [5424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
341
+[5425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
342
+[5426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
343
+[5427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
341 344
 
342 345
 # define SYS_socket_subcall      5500
343 346
 # include "subcall64.h"

+ 3
- 0
linux/mips/syscallent-o32.h View File

@@ -409,6 +409,9 @@
409 409
 [4422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
410 410
 [4423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
411 411
 [4424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
412
+[4425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
413
+[4426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
414
+[4427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
412 415
 
413 416
 # define SYS_socket_subcall      4500
414 417
 # include "subcall32.h"

+ 3
- 0
linux/powerpc/syscallent.h View File

@@ -417,6 +417,9 @@
417 417
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
418 418
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
419 419
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
420
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
421
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
422
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
420 423
 
421 424
 #define SYS_socket_subcall	500
422 425
 #include "subcall32.h"

+ 3
- 0
linux/powerpc64/syscallent.h View File

@@ -394,6 +394,9 @@
394 394
 [402] = { 3,	TI,		SEN(msgctl),			"msgctl"		},
395 395
 /* [403 ... 423] - reserved to sync up with other architectures */
396 396
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
397
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
398
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
399
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
397 400
 
398 401
 #define SYS_socket_subcall	500
399 402
 #include "subcall64.h"

+ 3
- 0
linux/s390/syscallent.h View File

@@ -428,6 +428,9 @@
428 428
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
429 429
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
430 430
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
431
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
432
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
433
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
431 434
 
432 435
 #define SYS_socket_subcall	500
433 436
 #include "subcall32.h"

+ 3
- 0
linux/s390x/syscallent.h View File

@@ -394,6 +394,9 @@
394 394
 [402] = { 3,	TI,		SEN(msgctl),			"msgctl"		},
395 395
 /* [403 ... 423] - reserved to sync up with other architectures */
396 396
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
397
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
398
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
399
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
397 400
 
398 401
 #define SYS_socket_subcall	500
399 402
 #include "subcall64.h"

+ 3
- 0
linux/sh/syscallent.h View File

@@ -426,6 +426,9 @@
426 426
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
427 427
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
428 428
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
429
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
430
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
431
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
429 432
 
430 433
 #define SYS_socket_subcall	500
431 434
 #include "subcall32.h"

+ 3
- 0
linux/sh64/syscallent.h View File

@@ -400,6 +400,9 @@
400 400
 [393] = { 6,	TD,		SEN(pwritev2),			"pwritev2"		},
401 401
 /* [403 ... 423] - reserved to sync up with other architectures */
402 402
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
403
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
404
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
405
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
403 406
 
404 407
 #define SYS_socket_subcall	500
405 408
 #include "subcall64.h"

+ 3
- 0
linux/sparc/syscallent.h View File

@@ -403,6 +403,9 @@
403 403
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
404 404
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
405 405
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
406
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
407
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
408
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
406 409
 
407 410
 #define SYS_socket_subcall	500
408 411
 #include "subcall32.h"

+ 3
- 0
linux/sparc64/syscallent.h View File

@@ -383,6 +383,9 @@
383 383
 [402] = { 3,	TI,		SEN(msgctl),			"msgctl"		},
384 384
 /* [403 ... 423] - reserved to sync up with other architectures */
385 385
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
386
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
387
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
388
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},
386 389
 
387 390
 #define SYS_socket_subcall	500
388 391
 #include "subcall64.h"

+ 3
- 0
linux/x32/syscallent.h View File

@@ -382,3 +382,6 @@
382 382
 [545] = { 5,	CST|TD|TF|TP|SE|SI,	SEN(execveat),		"execveat"		},
383 383
 [546] = { 5,	TD,		SEN(preadv2),			"preadv2"		},
384 384
 [547] = { 5,	TD,		SEN(pwritev2),			"pwritev2"		},
385
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
386
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
387
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
linux/x86_64/syscallent.h View File

@@ -342,3 +342,6 @@
342 342
 [334] = { 4,	0,		SEN(rseq),			"rseq"			},
343 343
 /* [335 ... 423] - reserved to sync up with other architectures */
344 344
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
345
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
346
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
347
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
linux/xtensa/syscallent.h View File

@@ -370,3 +370,6 @@
370 370
 [422] = { 6,	0,		SEN(futex_time64),		"futex_time64"		},
371 371
 [423] = { 2,	0,		SEN(sched_rr_get_interval_time64),	"sched_rr_get_interval_time64"	},
372 372
 [424] = { 4,	TD|TS,		SEN(pidfd_send_signal),		"pidfd_send_signal"	},
373
+[425] = { 2,	TD,		SEN(io_uring_setup),		"io_uring_setup"	},
374
+[426] = { 6,	TD|TS,		SEN(io_uring_enter),		"io_uring_enter"	},
375
+[427] = { 4,	TD|TM,		SEN(io_uring_register),		"io_uring_register"	},

+ 3
- 0
pathtrace.c View File

@@ -326,6 +326,9 @@ pathtrace_match_set(struct tcb *tcp, struct path_set *set)
326 326
 	case SEN_fanotify_init:
327 327
 	case SEN_inotify_init:
328 328
 	case SEN_inotify_init1:
329
+	case SEN_io_uring_enter:
330
+	case SEN_io_uring_register:
331
+	case SEN_io_uring_setup:
329 332
 	case SEN_memfd_create:
330 333
 	case SEN_mq_getsetattr:
331 334
 	case SEN_mq_notify:

+ 3
- 0
tests/.gitignore View File

@@ -143,6 +143,9 @@ inject-nf
143 143
 inotify
144 144
 inotify_init1
145 145
 int_0x80
146
+io_uring_enter
147
+io_uring_register
148
+io_uring_setup
146 149
 ioctl
147 150
 ioctl_block
148 151
 ioctl_dm

+ 3
- 0
tests/gen_tests.in View File

@@ -118,6 +118,9 @@ inet-cmsg	-e trace=recvmsg
118 118
 init_module	-a27
119 119
 inotify	-a23 -e trace=inotify_add_watch,inotify_rm_watch
120 120
 inotify_init1	-a27
121
+io_uring_enter	-y
122
+io_uring_register	-y
123
+io_uring_setup	-a26 -y
121 124
 ioctl_block	+ioctl.test
122 125
 ioctl_dm	+ioctl.test -s9
123 126
 ioctl_dm-v	+ioctl.test -v -s9

+ 83
- 0
tests/io_uring_enter.c View File

@@ -0,0 +1,83 @@
1
+/*
2
+ * Check decoding of io_uring_enter syscall.
3
+ *
4
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
5
+ * All rights reserved.
6
+ *
7
+ * SPDX-License-Identifier: GPL-2.0-or-later
8
+ */
9
+
10
+#include "tests.h"
11
+#include <unistd.h>
12
+#include <asm/unistd.h>
13
+#include "scno.h"
14
+
15
+#ifdef __NR_io_uring_enter
16
+
17
+# include <fcntl.h>
18
+# include <signal.h>
19
+# include <stdio.h>
20
+# include <string.h>
21
+
22
+static const char *errstr;
23
+
24
+static long
25
+sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
26
+		   unsigned int min_complete, unsigned int flags,
27
+		   const void *sigset_addr, kernel_ulong_t sigset_size)
28
+
29
+{
30
+	kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
31
+	kernel_ulong_t arg1 = fill | fd;
32
+	kernel_ulong_t arg2 = fill | to_submit;
33
+	kernel_ulong_t arg3 = fill | min_complete;
34
+	kernel_ulong_t arg4 = fill | flags;
35
+	kernel_ulong_t arg5 = (unsigned long) sigset_addr;
36
+	kernel_ulong_t arg6 = sigset_size;
37
+
38
+	long rc = syscall(__NR_io_uring_enter,
39
+			  arg1, arg2, arg3, arg4, arg5, arg6);
40
+	errstr = sprintrc(rc);
41
+	return rc;
42
+}
43
+
44
+int
45
+main(void)
46
+{
47
+	static const char path[] = "/dev/null";
48
+
49
+	skip_if_unavailable("/proc/self/fd/");
50
+
51
+	int fd = open(path, O_RDONLY);
52
+	if (fd < 0)
53
+		perror_msg_and_fail("open: %s", path);
54
+
55
+	const unsigned int size = get_sigset_size();
56
+	void *const sigmask = tail_alloc(size);
57
+	sigset_t mask;
58
+
59
+	memset(&mask, -1, sizeof(mask));
60
+	sigdelset(&mask, SIGHUP);
61
+	sigdelset(&mask, SIGKILL);
62
+	sigdelset(&mask, SIGSTOP);
63
+	memcpy(sigmask, &mask, size);
64
+
65
+	const unsigned int to_submit = 0xdeadbeef;
66
+	const unsigned int min_complete = 0xcafef00d;
67
+
68
+	sys_io_uring_enter(fd, to_submit, min_complete, -1U, sigmask, size);
69
+	printf("io_uring_enter(%u<%s>, %u, %u"
70
+	       ", IORING_ENTER_GETEVENTS|IORING_ENTER_SQ_WAKEUP|%#x"
71
+	       ", %s, %u) = %s\n",
72
+	       fd, path, to_submit, min_complete, -1U - 3,
73
+	       "~[HUP KILL STOP]", size, errstr);
74
+
75
+	puts("+++ exited with 0 +++");
76
+	return 0;
77
+}
78
+
79
+#else
80
+
81
+SKIP_MAIN_UNDEFINED("__NR_io_uring_enter")
82
+
83
+#endif

+ 100
- 0
tests/io_uring_register.c View File

@@ -0,0 +1,100 @@
1
+/*
2
+ * Check decoding of io_uring_register syscall.
3
+ *
4
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
5
+ * All rights reserved.
6
+ *
7
+ * SPDX-License-Identifier: GPL-2.0-or-later
8
+ */
9
+
10
+#include "tests.h"
11
+#include <unistd.h>
12
+#include <asm/unistd.h>
13
+#include "scno.h"
14
+
15
+#ifdef __NR_io_uring_register
16
+
17
+# include <fcntl.h>
18
+# include <stdio.h>
19
+# include <string.h>
20
+# include <sys/uio.h>
21
+
22
+static const char *errstr;
23
+
24
+static long
25
+sys_io_uring_register(unsigned int fd, unsigned int opcode,
26
+		      const void *arg, unsigned int nargs)
27
+
28
+{
29
+	kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
30
+	kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
31
+	kernel_ulong_t arg1 = fill | fd;
32
+	kernel_ulong_t arg2 = fill | opcode;
33
+	kernel_ulong_t arg3 = (unsigned long) arg;
34
+	kernel_ulong_t arg4 = fill | nargs;
35
+
36
+	long rc = syscall(__NR_io_uring_register,
37
+			  arg1, arg2, arg3, arg4, bad, bad);
38
+	errstr = sprintrc(rc);
39
+	return rc;
40
+}
41
+
42
+int
43
+main(void)
44
+{
45
+	static const char path_null[] = "/dev/null";
46
+	static const char path_full[] = "/dev/full";
47
+	const struct iovec iov[] = {
48
+		{
49
+			.iov_base = (void *) (unsigned long) 0xfacefeedcafef00d,
50
+			.iov_len = (unsigned long) 0xdeadfacebeefcafe
51
+		},
52
+		{
53
+			.iov_base = (void *) path_null,
54
+			.iov_len = sizeof(path_null)
55
+		}
56
+	};
57
+	const struct iovec *arg_iov = tail_memdup(iov, sizeof(iov));
58
+
59
+	skip_if_unavailable("/proc/self/fd/");
60
+
61
+	int fd_null = open(path_null, O_RDONLY);
62
+	if (fd_null < 0)
63
+		perror_msg_and_fail("open: %s", path_null);
64
+
65
+	int fd_full = open(path_full, O_RDONLY);
66
+	if (fd_full < 0)
67
+		perror_msg_and_fail("open: %s", path_null);
68
+
69
+	int fds[] = { fd_full, fd_null };
70
+	const int *arg_fds = tail_memdup(fds, sizeof(fds));
71
+
72
+	sys_io_uring_register(fd_null, 0xbadc0ded, path_null, 0xdeadbeef);
73
+	printf("io_uring_register(%u<%s>, %#x /* IORING_REGISTER_??? */"
74
+	       ", %p, %u) = %s\n",
75
+	       fd_null, path_null, 0xbadc0ded, path_null, 0xdeadbeef, errstr);
76
+
77
+	sys_io_uring_register(fd_null, 0, arg_iov, ARRAY_SIZE(iov));
78
+	printf("io_uring_register(%u<%s>, IORING_REGISTER_BUFFERS"
79
+	       ", [{iov_base=%p, iov_len=%lu}, {iov_base=%p, iov_len=%lu}]"
80
+	       ", %u) = %s\n",
81
+	       fd_null, path_null, iov[0].iov_base,
82
+	       (unsigned long) iov[0].iov_len,
83
+	       iov[1].iov_base, (unsigned long) iov[1].iov_len,
84
+	       (unsigned int) ARRAY_SIZE(iov), errstr);
85
+
86
+	sys_io_uring_register(fd_null, 2, arg_fds, ARRAY_SIZE(fds));
87
+	printf("io_uring_register(%u<%s>, IORING_REGISTER_FILES"
88
+	       ", [%u<%s>, %u<%s>], %u) = %s\n",
89
+	       fd_null, path_null, fd_full, path_full, fd_null, path_null,
90
+	       (unsigned int) ARRAY_SIZE(fds), errstr);
91
+
92
+	puts("+++ exited with 0 +++");
93
+	return 0;
94
+}
95
+
96
+#else
97
+
98
+SKIP_MAIN_UNDEFINED("__NR_io_uring_register")
99
+
100
+#endif

+ 103
- 0
tests/io_uring_setup.c View File

@@ -0,0 +1,103 @@
1
+/*
2
+ * Check decoding of io_uring_setup syscall.
3
+ *
4
+ * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
5
+ * All rights reserved.
6
+ *
7
+ * SPDX-License-Identifier: GPL-2.0-or-later
8
+ */
9
+
10
+#include "tests.h"
11
+#include <unistd.h>
12
+#include <asm/unistd.h>
13
+#include "scno.h"
14
+
15
+#if defined HAVE_LINUX_IO_URING_H && defined __NR_io_uring_setup
16
+
17
+# include <stdio.h>
18
+# include <stdint.h>
19
+# include <string.h>
20
+# include <linux/io_uring.h>
21
+
22
+# include "print_fields.h"
23
+
24
+static const char *errstr;
25
+
26
+static long
27
+sys_io_uring_setup(uint32_t nentries, const void *params)
28
+{
29
+	kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
30
+	kernel_ulong_t bad = (kernel_ulong_t) 0xbadc0dedbadc0dedULL;
31
+	kernel_ulong_t arg1 = fill | nentries;
32
+	kernel_ulong_t arg2 = (unsigned long) params;
33
+
34
+	long rc = syscall(__NR_io_uring_setup, arg1, arg2, bad, bad, bad, bad);
35
+	errstr = sprintrc(rc);
36
+	return rc;
37
+}
38
+
39
+int
40
+main(void)
41
+{
42
+	long rc;
43
+	TAIL_ALLOC_OBJECT_CONST_PTR(struct io_uring_params, params);
44
+	const void *efault = (const void *) params + 1;
45
+
46
+	skip_if_unavailable("/proc/self/fd/");
47
+
48
+	sys_io_uring_setup(-1U, NULL);
49
+	printf("io_uring_setup(%u, NULL) = %s\n", -1U, errstr);
50
+
51
+	sys_io_uring_setup(0, efault);
52
+	printf("io_uring_setup(%u, %p) = %s\n", 0, efault, errstr);
53
+
54
+	fill_memory(params, sizeof(*params));
55
+	params->flags = -1;
56
+	sys_io_uring_setup(1, params);
57
+	printf("io_uring_setup(%u, {flags=IORING_SETUP_IOPOLL"
58
+	       "|IORING_SETUP_SQPOLL|IORING_SETUP_SQ_AFF|%#x"
59
+	       ", sq_thread_cpu=%#x, sq_thread_idle=%u, resv={",
60
+	       1, -1U - 7, params->sq_thread_cpu, params->sq_thread_idle);
61
+	for (unsigned int i = 0; i < ARRAY_SIZE(params->resv); ++i)
62
+		printf("%s%#x", i ? ", " : "", params->resv[i]);
63
+	printf("}}) = %s\n", errstr);
64
+
65
+	memset(params, 0, sizeof(*params));
66
+	rc = sys_io_uring_setup(2, params);
67
+	printf("io_uring_setup(%u, {flags=0, sq_thread_cpu=0"
68
+	       ", sq_thread_idle=0", 2);
69
+	if (rc < 0)
70
+		printf("}) = %s\n", errstr);
71
+	else
72
+		printf(", sq_entries=%u, cq_entries=%u"
73
+		       ", sq_off={head=%u, tail=%u, ring_mask=%u"
74
+		       ", ring_entries=%u, flags=%u, dropped=%u, array=%u}"
75
+		       ", cq_off={head=%u, tail=%u, ring_mask=%u"
76
+		       ", ring_entries=%u, overflow=%u, cqes=%u}"
77
+		       "}) = %ld<anon_inode:[io_uring]>\n",
78
+		       params->sq_entries,
79
+		       params->cq_entries,
80
+		       params->sq_off.head,
81
+		       params->sq_off.tail,
82
+		       params->sq_off.ring_mask,
83
+		       params->sq_off.ring_entries,
84
+		       params->sq_off.flags,
85
+		       params->sq_off.dropped,
86
+		       params->sq_off.array,
87
+		       params->cq_off.head,
88
+		       params->cq_off.tail,
89
+		       params->cq_off.ring_mask,
90
+		       params->cq_off.ring_entries,
91
+		       params->cq_off.overflow,
92
+		       params->cq_off.cqes,
93
+		       rc);
94
+
95
+	puts("+++ exited with 0 +++");
96
+	return 0;
97
+}
98
+
99
+#else
100
+
101
+SKIP_MAIN_UNDEFINED("HAVE_LINUX_IO_URING_H && __NR_io_uring_setup")
102
+
103
+#endif

+ 3
- 0
tests/pure_executables.list View File

@@ -120,6 +120,9 @@ inet-cmsg
120 120
 init_module
121 121
 inotify
122 122
 inotify_init1
123
+io_uring_enter
124
+io_uring_register
125
+io_uring_setup
123 126
 ioctl
124 127
 ioctl_block
125 128
 ioctl_dm

+ 2
- 0
xlat/uring_enter_flags.in View File

@@ -0,0 +1,2 @@
1
+IORING_ENTER_GETEVENTS	1U
2
+IORING_ENTER_SQ_WAKEUP	2U

+ 4
- 0
xlat/uring_register_opcodes.in View File

@@ -0,0 +1,4 @@
1
+IORING_REGISTER_BUFFERS		0U
2
+IORING_UNREGISTER_BUFFERS	1U
3
+IORING_REGISTER_FILES		2U
4
+IORING_UNREGISTER_FILES		3U

+ 3
- 0
xlat/uring_setup_flags.in View File

@@ -0,0 +1,3 @@
1
+IORING_SETUP_IOPOLL	1U
2
+IORING_SETUP_SQPOLL	2U
3
+IORING_SETUP_SQ_AFF	4U

Loading…
Cancel
Save