2 * Check decoding of io_uring_enter syscall.
4 * Copyright (c) 2019 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
14 #ifdef __NR_io_uring_enter
21 static const char *errstr;
24 sys_io_uring_enter(unsigned int fd, unsigned int to_submit,
25 unsigned int min_complete, unsigned int flags,
26 const void *sigset_addr, kernel_ulong_t sigset_size)
29 kernel_ulong_t fill = (kernel_ulong_t) 0xdefaced00000000ULL;
30 kernel_ulong_t arg1 = fill | fd;
31 kernel_ulong_t arg2 = fill | to_submit;
32 kernel_ulong_t arg3 = fill | min_complete;
33 kernel_ulong_t arg4 = fill | flags;
34 kernel_ulong_t arg5 = (unsigned long) sigset_addr;
35 kernel_ulong_t arg6 = sigset_size;
37 long rc = syscall(__NR_io_uring_enter,
38 arg1, arg2, arg3, arg4, arg5, arg6);
39 errstr = sprintrc(rc);
46 static const char path[] = "/dev/null";
48 skip_if_unavailable("/proc/self/fd/");
50 int fd = open(path, O_RDONLY);
52 perror_msg_and_fail("open: %s", path);
54 const unsigned int size = get_sigset_size();
55 void *const sigmask = tail_alloc(size);
58 memset(&mask, -1, sizeof(mask));
59 sigdelset(&mask, SIGHUP);
60 sigdelset(&mask, SIGKILL);
61 sigdelset(&mask, SIGSTOP);
62 memcpy(sigmask, &mask, size);
64 const unsigned int to_submit = 0xdeadbeef;
65 const unsigned int min_complete = 0xcafef00d;
67 sys_io_uring_enter(fd, to_submit, min_complete, -1U, sigmask, size);
68 printf("io_uring_enter(%u<%s>, %u, %u"
69 ", IORING_ENTER_GETEVENTS|IORING_ENTER_SQ_WAKEUP|%#x"
71 fd, path, to_submit, min_complete, -1U - 3,
72 "~[HUP KILL STOP]", size, errstr);
74 puts("+++ exited with 0 +++");
80 SKIP_MAIN_UNDEFINED("__NR_io_uring_enter")