diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-06-08 10:31:48 +0200 |
---|---|---|
committer | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-08-11 14:34:17 +0200 |
commit | a30e5defe41b5b806c223865e92b20d8c9b08f4b (patch) | |
tree | 951497fc46da844592018ed259a45da9adf9d8fb | |
parent | 3361fdf80d3e9f56d7cf50ba90c9193f53ea65aa (diff) | |
download | strace-a30e5defe41b5b806c223865e92b20d8c9b08f4b.tar.gz |
io_uring: decode struct io_uring_rsrc_register.flags field
Introduced by Linux commit v5.19-rc1~251^2~20.
* configure.ac: Remove struct io_uring_rsrc_register.resv check.
* src/xlat/uring_register_rsrc_flags.in: New file.
* src/io_uring.c: Include "xlat/uring_register_rsrc_flags.h".
(print_io_uring_register_rsrc): Remove CHECK_TYPE_SIZE for arg.resv,
decode flags field using PRINT_FIELD_FLAGS instead of optional decoding
of no longer existing resv field.
* tests/io_uring_register.c: Update expected output.
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/io_uring.c | 19 | ||||
-rw-r--r-- | src/xlat/uring_register_rsrc_flags.in | 2 | ||||
-rw-r--r-- | tests/io_uring_register.c | 20 |
4 files changed, 16 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac index 2c68e5de2..4797b42dd 100644 --- a/configure.ac +++ b/configure.ac @@ -581,12 +581,6 @@ AC_CHECK_MEMBERS(m4_normalize([ struct iocb.aio_rw_flags ]),,, [#include <linux/aio_abi.h>]) -AC_CHECK_TYPES([struct io_uring_rsrc_register], [ - AC_CHECK_MEMBERS(m4_normalize([ - struct io_uring_rsrc_register.resv - ]),,, [#include <linux/io_uring.h>]) -],, [#include <linux/io_uring.h>]) - CPPFLAGS="$saved_CPPFLAGS" st_CHECK_ENUMS diff --git a/src/io_uring.c b/src/io_uring.c index a8602d27a..e59ccbe3c 100644 --- a/src/io_uring.c +++ b/src/io_uring.c @@ -19,6 +19,7 @@ #include "xlat/uring_setup_flags.h" #include "xlat/uring_sqe_flags.h" #include "xlat/uring_register_opcodes.h" +#include "xlat/uring_register_rsrc_flags.h" #include "xlat/uring_restriction_opcodes.h" static void @@ -385,20 +386,12 @@ print_io_uring_rsrc_tags(struct tcb *tcp, const uint64_t tags, tfetch_mem, print_xint_array_member, NULL); } -/* Work around field name change in Linux commit v5.19-rc1~251^2~20. */ -#ifdef HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV -# define RESV resv -#else -# define RESV flags -#endif - static void print_io_uring_register_rsrc(struct tcb *tcp, const kernel_ulong_t addr, const unsigned int size, const unsigned int opcode) { struct io_uring_rsrc_register arg; CHECK_TYPE_SIZE(arg, 32); - CHECK_TYPE_SIZE(arg.RESV, sizeof(uint32_t)); CHECK_TYPE_SIZE(arg.resv2, sizeof(uint64_t)); if (size < 32) { @@ -412,11 +405,9 @@ print_io_uring_register_rsrc(struct tcb *tcp, const kernel_ulong_t addr, tprint_struct_begin(); PRINT_FIELD_U(arg, nr); - if (arg.RESV) { - tprint_struct_next(); - tprints_field_name("resv"); - PRINT_VAL_X(arg.RESV); - } + tprint_struct_next(); + PRINT_FIELD_FLAGS(arg, flags, uring_register_rsrc_flags, + "IORING_RSRC_REGISTER_???"); if (arg.resv2) { tprint_struct_next(); @@ -435,8 +426,6 @@ print_io_uring_register_rsrc(struct tcb *tcp, const kernel_ulong_t addr, tprint_struct_end(); } -#undef RESV - static void print_io_uring_update_rsrc(struct tcb *tcp, const kernel_ulong_t addr, const unsigned int size, const unsigned int opcode) diff --git a/src/xlat/uring_register_rsrc_flags.in b/src/xlat/uring_register_rsrc_flags.in new file mode 100644 index 000000000..881ea8318 --- /dev/null +++ b/src/xlat/uring_register_rsrc_flags.in @@ -0,0 +1,2 @@ +#unconditional +IORING_RSRC_REGISTER_SPARSE diff --git a/tests/io_uring_register.c b/tests/io_uring_register.c index 482b60f1b..b87b3c9bd 100644 --- a/tests/io_uring_register.c +++ b/tests/io_uring_register.c @@ -44,13 +44,6 @@ #define ARR_ITEM(arr_, idx_) ((arr_)[(idx_) % ARRAY_SIZE(arr_)]) -/* Work around field name change in Linux commit v5.19-rc1~251^2~20. */ -#ifdef HAVE_STRUCT_IO_URING_RSRC_REGISTER_RESV -# define RESV resv -#else -# define RESV flags -#endif - static const char path_null[] = "/dev/null"; static const char path_full[] = "/dev/full"; @@ -652,6 +645,13 @@ main(void) { 13, "IORING_REGISTER_FILES2" }, { 15, "IORING_REGISTER_BUFFERS2" }, }; + static const struct strval32 rsrc_flags[] = { + { ARG_STR(0) }, + { ARG_XLAT_KNOWN(0x1, "IORING_RSRC_REGISTER_SPARSE") }, + { ARG_XLAT_UNKNOWN(0x2, "IORING_RSRC_REGISTER_???") }, + { ARG_XLAT_KNOWN(0xbadc0ded, + "IORING_RSRC_REGISTER_SPARSE|0xbadc0dec") }, + }; static const uint64_t tags[] = { 0x1337, 1, 0xdead, 0xfacefeed, 0xbadc0deddadfacedULL, 0 }; const uint64_t *arg_tags = tail_memdup(tags, sizeof(tags)); @@ -709,7 +709,7 @@ main(void) rsrc_reg->nr += !!(j & 16); rsrc_reg->nr &= ~-!(j & 32); - rsrc_reg->RESV = j & 64 ? 0xbadc0ded : 0; + rsrc_reg->flags = ARR_ITEM(rsrc_flags, j >> 6).val; rsrc_reg->resv2 = j & 128 ? 0xfacecafebeeffeedULL : 0; memcpy(big_rsrc_reg, rsrc_reg, sizeof(*rsrc_reg)); @@ -722,14 +722,14 @@ main(void) sizeof(*rsrc_reg) + (k / 2) * 8); printf("io_uring_register(%u<%s>, " XLAT_FMT - ", {nr=%zu%s%s", + ", {nr=%zu, flags=%s%s", fd_null, path_null, XLAT_SEL(rsrc_reg_ops[i].op, rsrc_reg_ops[i].str), j & 32 ? (i ? ARRAY_SIZE(iov) : ARRAY_SIZE(fds)) + !!(j & 16) : 0, - j & 64 ? ", resv=0xbadc0ded" : "", + ARR_ITEM(rsrc_flags, j >> 6).str, j & 128 ? ", resv2=0xfacecafebeeffeed" : ""); print_rsrc_data(arg_iov, iov, arg_fds, fds, |