[PATCH 1/2] [GSoC] add IORING_REGISTER_SYNC_CANCEL command parser

michaelkongboming at gmail.com michaelkongboming at gmail.com
Tue Mar 28 08:52:19 UTC 2023


From: Boming Kong <michaelkongboming at gmail.com>

---
IORING_REGISTER_SYNC_CANCEL command was introduced in 6.0 kernel, and here is a parser for this command
 src/io_uring.c                     | 32 ++++++++++++++++++++++++++++++
 src/xlat/uring_register_opcodes.in |  1 +
 2 files changed, 33 insertions(+)

diff --git a/src/io_uring.c b/src/io_uring.c
index b7c5428ff..6600b9f17 100644
--- a/src/io_uring.c
+++ b/src/io_uring.c
@@ -595,6 +595,35 @@ print_io_uring_buf_reg(struct tcb *tcp, const kernel_ulong_t addr)
 	tprint_struct_end();
 }

+static void
+print_io_uring_sync_cancel(struct tcb *tcp, const kernel_ulong_t addr){
+
+	struct io_uring_sync_cancel_reg arg;
+	CHECK_TYPE_SIZE(arg, 64);
+	CHECK_TYPE_SIZE(arg.pad, sizeof(uint64_t) * 4);
+
+	if(umove_or_printaddr(tcp, addr, &arg))
+		return;
+
+	tprint_struct_begin();
+	PRINT_FIELD_ADDR64(arg, addr);
+
+	tprint_struct_next();
+	PRINT_FIELD_U(arg, fd);
+
+	tprint_struct_next();
+	PRINT_FIELD_U(arg, flags);
+
+	if (!IS_ARRAY_ZERO(arg.pad)) {
+		tprint_struct_next();
+		PRINT_FIELD_ARRAY(arg, pad, tcp, print_xint_array_member);
+	}
+
+	tprint_struct_end();
+
+	return;
+}
+
 SYS_FUNC(io_uring_register)
 {
 	const int fd = tcp->u_arg[0];
@@ -661,6 +690,9 @@ SYS_FUNC(io_uring_register)
 	case IORING_UNREGISTER_PBUF_RING:
 		print_io_uring_buf_reg(tcp, arg);
 		break;
+	case IORING_REGISTER_SYNC_CANCEL:
+		print_io_uring_sync_cancel(tcp, arg);
+		break;
 	case IORING_UNREGISTER_BUFFERS:
 	case IORING_UNREGISTER_FILES:
 	case IORING_UNREGISTER_EVENTFD:
diff --git a/src/xlat/uring_register_opcodes.in b/src/xlat/uring_register_opcodes.in
index 4d74ace39..6b7f15090 100644
--- a/src/xlat/uring_register_opcodes.in
+++ b/src/xlat/uring_register_opcodes.in
@@ -24,3 +24,4 @@ IORING_REGISTER_RING_FDS
 IORING_UNREGISTER_RING_FDS
 IORING_REGISTER_PBUF_RING
 IORING_UNREGISTER_PBUF_RING
+IORING_REGISTER_SYNC_CANCEL
\ No newline at end of file
--
2.40.0


>From 3dc34789d0f0841d08dab27aa30e6b0b349e6ef5 Mon Sep 17 00:00:00 2001
From: Boming Kong <michaelkongboming at gmail.com>
Date: Tue, 28 Mar 2023 01:21:59 -0700
Subject: [PATCH 2/2] [GSoC] modify IORING_REGISTER_SYNC_CANCEL parser

---
Print the timeout info of struct io_uring_sync_cancel_reg in nanosecond, also change "Invalid op" test op number to 25 so it does not block by IORING_REGISTER_SYNC_CANCEL
 src/io_uring.c            | 3 +++
 tests/io_uring_register.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/io_uring.c b/src/io_uring.c
index 6600b9f17..1fa23a40b 100644
--- a/src/io_uring.c
+++ b/src/io_uring.c
@@ -614,6 +614,9 @@ print_io_uring_sync_cancel(struct tcb *tcp, const kernel_ulong_t addr){
 	tprint_struct_next();
 	PRINT_FIELD_U(arg, flags);

+	tprint_struct_next();
+	PRINT_FIELD_U(arg, timeout.tv_nsec);
+
 	if (!IS_ARRAY_ZERO(arg.pad)) {
 		tprint_struct_next();
 		PRINT_FIELD_ARRAY(arg, pad, tcp, print_xint_array_member);
diff --git a/tests/io_uring_register.c b/tests/io_uring_register.c
index b191be752..983718402 100644
--- a/tests/io_uring_register.c
+++ b/tests/io_uring_register.c
@@ -172,7 +172,7 @@ main(void)


 	/* Invalid op */
-	static const unsigned int invalid_ops[] = { 0xbadc0dedU, 24 };
+	static const unsigned int invalid_ops[] = { 0xbadc0dedU, 25 };

 	for (size_t i = 0; i < ARRAY_SIZE(invalid_ops); i++) {
 		sys_io_uring_register(fd_null, invalid_ops[i], path_null,
--
2.40.0



More information about the Strace-devel mailing list