1 /* SPDX-License-Identifier: MIT */
2 /*
3 * Description: test that using SETUP_NO_MMAP with an invalid SQ ring
4 * address fails.
5 *
6 */
7 #include <stdlib.h>
8 #include <sys/types.h>
9 #include <stdio.h>
10 #include <unistd.h>
11
12 #include "liburing.h"
13 #include "helpers.h"
14
main(int argc,char * argv[])15 int main(int argc, char *argv[])
16 {
17 struct io_uring_params p = {
18 .sq_entries = 2,
19 .cq_entries = 4,
20 .flags = IORING_SETUP_NO_MMAP,
21 };
22 struct io_uring ring;
23 void *addr;
24 int ret;
25
26 if (argc > 1)
27 return T_EXIT_SKIP;
28
29 t_posix_memalign(&addr, sysconf(_SC_PAGESIZE), 8192);
30 p.cq_off.user_addr = (unsigned long long) (uintptr_t) addr;
31
32 ret = io_uring_queue_init_params(2, &ring, &p);
33 if (ret == -EINVAL) {
34 /* kernel doesn't support SETUP_NO_MMAP */
35 free(addr);
36 return T_EXIT_SKIP;
37 } else if (ret && (ret != -EFAULT && ret != -ENOMEM)) {
38 fprintf(stderr, "Got %d, wanted -EFAULT\n", ret);
39 return T_EXIT_FAIL;
40 }
41
42 free(addr);
43 return T_EXIT_PASS;
44 }
45