Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] strace: fix build against v5.8 uapi headers
@ 2020-08-06 19:59 Bruce Ashfield
  2020-08-06 20:02 ` ✗ patchtest: failure for " Patchwork
  2020-08-06 20:02 ` [PATCH] " Bruce Ashfield
  0 siblings, 2 replies; 3+ messages in thread
From: Bruce Ashfield @ 2020-08-06 19:59 UTC (permalink / raw)
  To: richard.purdie; +Cc: openembedded-core

From: Bruce Ashfield <bruce.ashfield@gmail.com>

The 5.8 kernel introduced changes to io uring that require adjustments
in strace for it to build against the new headers. See kernel commits
v5.8-rc1~190^2~22 and v5.8-rc1~190^2~21 for details.

There are two patches in the upstream strace that deal with the new
flags, so we port them to the v5.7 release until a new one is
available upstream.

We also have a third patch that is oe specific, which is the addition
of a newly generated flags file and removal of some static checks.
We need this change to build, since released versions of strace don't
run the bootstrap step and hence won't generate the flags or fixup
any static checks.

Tested against the v5.4 and v5.8 kernels.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---

Note: also tested against both the 5.8 and 5.4 libc-headers.

Bruce

 ...-io_uring-Add-io_cqring_offset-flags.patch | 154 ++++++++++++++++++
 ...struct-io_cqring_offsets-compile-tim.patch |  46 ++++++
 ...g-fix-build-against-5.8-libc-headers.patch |  98 +++++++++++
 meta/recipes-devtools/strace/strace_5.7.bb    |   3 +
 4 files changed, 301 insertions(+)
 create mode 100644 meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch
 create mode 100644 meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
 create mode 100644 meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch

diff --git a/meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch b/meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch
new file mode 100644
index 0000000000..dceeff7c7e
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch
@@ -0,0 +1,154 @@
+From 592b915033de37322e19f3e6413de33317d272fe Mon Sep 17 00:00:00 2001
+From: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Date: Mon, 15 Jun 2020 22:01:26 +1200
+Subject: [PATCH] io_uring: Add io_cqring_offset flags
+
+Add support for displaying struct io_cqring_offsets.flags introduced
+by Linux kernel commits v5.8-rc1~190^2~22 and v5.8-rc1~190^2~21.
+
+* types/io_uring.h (struct_io_cqring_offsets): Replace resv array
+with flags, resv1, and resv2 fields.
+* xlat/uring_cqring_flags.in: New file.
+* configure.ac (AC_CHECK_MEMBERS): Check struct io_cqring_offsets.flags.
+* io_uring.c: Include "xlat/uring_cqring_flags.h".
+(SYS_FUNC(io_uring_setup)): Replace printing of the resv array
+of struct io_cqring_offsets with flags, resv1, and resv2 fields.
+* tests/io_uring_setup.c: Check it.
+
+Upstream-status: backport of commit 592b915033de37322e19f3e6413de33317d272fe
+
+Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
+Resolves: https://github.com/strace/strace/issues/138
+---
+ configure.ac               |  1 +
+ io_uring.c                 | 11 +++++++----
+ tests/io_uring_setup.c     | 31 ++++++++++++++++++++++++++-----
+ types/io_uring.h           |  4 +++-
+ xlat/uring_cqring_flags.in |  1 +
+ 5 files changed, 38 insertions(+), 10 deletions(-)
+ create mode 100644 xlat/uring_cqring_flags.in
+
+diff --git a/configure.ac b/configure.ac
+index d0fd51ff..91c2249e 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -481,6 +481,7 @@ AC_CHECK_HEADERS([linux/bpf.h], [
+ 
+ AC_CHECK_HEADERS([linux/io_uring.h], [
+ 	AC_CHECK_MEMBERS(m4_normalize([
++		struct io_cqring_offsets.flags,
+ 		struct io_uring_params.features,
+ 		struct io_uring_params.wq_fd,
+ 		struct io_uring_params.resv
+diff --git a/io_uring.c b/io_uring.c
+index cfeea82b..2ffe163e 100644
+--- a/io_uring.c
++++ b/io_uring.c
+@@ -17,6 +17,7 @@
+ #include "xlat/uring_setup_flags.h"
+ #include "xlat/uring_enter_flags.h"
+ #include "xlat/uring_register_opcodes.h"
++#include "xlat/uring_cqring_flags.h"
+ 
+ #ifdef HAVE_STRUCT_IO_URING_PARAMS
+ # ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV
+@@ -88,10 +89,12 @@ SYS_FUNC(io_uring_setup)
+ 		PRINT_FIELD_U(", ", params.cq_off, ring_entries);
+ 		PRINT_FIELD_U(", ", params.cq_off, overflow);
+ 		PRINT_FIELD_U(", ", params.cq_off, cqes);
+-		if (!IS_ARRAY_ZERO(params.cq_off.resv)) {
+-			PRINT_FIELD_ARRAY(", ", params.cq_off, resv, tcp,
+-					  print_xint64_array_member);
+-		}
++		PRINT_FIELD_FLAGS(", ", params.cq_off, flags,
++				  uring_cqring_flags, "IORING_CQ_???");
++		if (params.cq_off.resv1)
++			PRINT_FIELD_X(", ", params.cq_off, resv1);
++		if (params.cq_off.resv2)
++			PRINT_FIELD_X(", ", params.cq_off, resv2);
+ 		tprints("}");
+ 	}
+ 	tprints("}");
+diff --git a/tests/io_uring_setup.c b/tests/io_uring_setup.c
+index 317b0d7a..a59e4a1a 100644
+--- a/tests/io_uring_setup.c
++++ b/tests/io_uring_setup.c
+@@ -27,6 +27,7 @@
+ # include "xlat.h"
+ 
+ # include "xlat/uring_setup_features.h"
++# include "xlat/uring_cqring_flags.h"
+ 
+ # ifdef HAVE_STRUCT_IO_URING_PARAMS_FEATURES
+ #  ifdef HAVE_STRUCT_IO_URING_PARAMS_WQ_FD
+@@ -144,20 +145,40 @@ main(void)
+ 						params->sq_off.resv2);
+ 
+ 			printf("}, cq_off={head=%u, tail=%u, ring_mask=%u"
+-			       ", ring_entries=%u, overflow=%u, cqes=%u",
++			       ", ring_entries=%u, overflow=%u, cqes=%u, flags=",
+ 			       params->cq_off.head,
+ 			       params->cq_off.tail,
+ 			       params->cq_off.ring_mask,
+ 			       params->cq_off.ring_entries,
+ 			       params->cq_off.overflow,
+ 			       params->cq_off.cqes);
+-			if (params->cq_off.resv[0] || params->cq_off.resv[1]) {
+-				printf(", resv=[%#llx, %#llx]",
++#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS
++			printflags(uring_cqring_flags,
++			       params->cq_off.flags,
++			       "IORING_CQ_???");
++			if (params->cq_off.resv1)
++				printf(", resv1=%#x", params->cq_off.resv1);
++			if (params->cq_off.resv2)
++				printf(", resv2=%#llx",
+ 				       (unsigned long long)
+-						params->cq_off.resv[0],
++						params->cq_off.resv2);
++#else
++			union {
++				struct {
++					uint32_t flags;
++					uint32_t resv1;
++				} s;
++				uint64_t v;
++			} u = { .v = params->cq_off.resv[0] };
++			printflags(uring_cqring_flags, u.s.flags,
++				   "IORING_CQ_???");
++			if (u.s.resv1)
++				printf(", resv1=%#x", u.s.resv1);
++			if (params->cq_off.resv[1])
++				printf(", resv2=%#llx",
+ 				       (unsigned long long)
+ 						params->cq_off.resv[1]);
+-			}
++#endif
+ 
+ 			printf("}}) = %ld<anon_inode:[io_uring]>\n", rc);
+ 		}
+diff --git a/types/io_uring.h b/types/io_uring.h
+index 76f432c3..2fe1c13a 100644
+--- a/types/io_uring.h
++++ b/types/io_uring.h
+@@ -31,7 +31,9 @@ typedef struct {
+ 	uint32_t ring_entries;
+ 	uint32_t overflow;
+ 	uint32_t cqes;
+-	uint64_t resv[2];
++	/** Added by v5.8-rc1~190^2~22 */	uint32_t flags;
++	/** Added by v5.8-rc1~190^2~22 */	uint32_t resv1;
++	/** Added by v5.8-rc1~190^2~22 */	uint64_t resv2;
+ } struct_io_cqring_offsets;
+ 
+ typedef struct {
+diff --git a/xlat/uring_cqring_flags.in b/xlat/uring_cqring_flags.in
+new file mode 100644
+index 00000000..c81fbc20
+--- /dev/null
++++ b/xlat/uring_cqring_flags.in
+@@ -0,0 +1 @@
++IORING_CQ_EVENTFD_DISABLED	1U
+-- 
+2.19.1
+
diff --git a/meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch b/meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
new file mode 100644
index 0000000000..774b520a06
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
@@ -0,0 +1,46 @@
+From fded17c15bca4150165f899cc47f67bab963d9a7 Mon Sep 17 00:00:00 2001
+From: Chris Packham <chris.packham@alliedtelesis.co.nz>
+Date: Mon, 15 Jun 2020 22:01:25 +1200
+Subject: [PATCH] io_uring: Remove struct io_cqring_offsets compile time
+ asserts
+
+The generated types/check-io_uring.c already checks the kernel's struct
+io_cqring_offsets for compatibility with the strace definition so
+there's no need for manual checks.
+
+Upstream-status: backport of commit fded17c15bca4150165f899cc47f67bab963d9a7
+
+* io_uring.c [HAVE_STRUCT_IO_CQRING_OFFSETS]: Remove static_asserts.
+---
+ io_uring.c | 15 ---------------
+ 1 file changed, 15 deletions(-)
+
+diff --git a/io_uring.c b/io_uring.c
+index cd183457..cfeea82b 100644
+--- a/io_uring.c
++++ b/io_uring.c
+@@ -18,21 +18,6 @@
+ #include "xlat/uring_enter_flags.h"
+ #include "xlat/uring_register_opcodes.h"
+ 
+-#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS
+-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
+-static_assert(offsetof(struct_io_cqring_offsets, resv)
+-             >= offsetof(struct io_cqring_offsets, resv),
+-             "struct io_cqring_offsets.resv offset mismatch"
+-             ", please update the decoder");
+-static_assert(sizeof_field(struct_io_cqring_offsets, resv)
+-             <= sizeof_field(struct io_cqring_offsets, resv),
+-             "struct io_cqring_offsets.resv size mismatch"
+-             ", please update the decoder");
+-# else /* !HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */
+-static_assert(0, "struct io_cqring_offsets.resv is missing"
+-		 ", please update the decoder");
+-# endif
+-#endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */
+ #ifdef HAVE_STRUCT_IO_URING_PARAMS
+ # ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV
+ static_assert(offsetof(struct_io_uring_params, resv)
+-- 
+2.19.1
+
diff --git a/meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch b/meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch
new file mode 100644
index 0000000000..cfce3eca51
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch
@@ -0,0 +1,98 @@
+From 8dda6b8ddbe18b6bb83cf1fa6bc71ebdc82e1b72 Mon Sep 17 00:00:00 2001
+From: Bruce Ashfield <bruce.ashfield@gmail.com>
+Date: Mon, 3 Aug 2020 23:00:39 -0400
+Subject: [PATCH] uring: fix build against 5.8 libc-headers
+
+To get strace building against v5.8 headers before the next
+version of strace is released, we need to copy in a bootstrapped
+file from the latest git (xlat/uring_cqring_flags.h) and remove
+remove unnecessary asserts for v5.8+ (in a similar manner to the
+main strace repository).
+
+Upstream-status: inappropriate. oe specific (upstream builds bootstrap)
+
+Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
+---
+ types/check-io_uring.c    | 10 --------
+ xlat/uring_cqring_flags.h | 48 +++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 48 insertions(+), 10 deletions(-)
+ create mode 100644 xlat/uring_cqring_flags.h
+
+diff --git a/types/check-io_uring.c b/types/check-io_uring.c
+index dc21569..d5bd4b1 100644
+--- a/types/check-io_uring.c
++++ b/types/check-io_uring.c
+@@ -13,16 +13,6 @@ static_assert(sizeof(struct io_sqring_offsets) <= offsetof(struct_io_sqring_offs
+ # endif /* HAVE_STRUCT_IO_SQRING_OFFSETS_RESV2 */
+ #endif /* HAVE_STRUCT_IO_SQRING_OFFSETS */
+ 
+-#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS
+-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
+-static_assert(sizeof(struct io_cqring_offsets) == sizeof(struct_io_cqring_offsets),
+-      "struct io_cqring_offsets size mismatch, please update the decoder or fix the kernel");
+-# else
+-static_assert(sizeof(struct io_cqring_offsets) <= offsetof(struct_io_cqring_offsets, resv),
+-"struct io_cqring_offsets size mismatch, please update the decoder or fix the kernel");
+-# endif /* HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */
+-#endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */
+-
+ #ifdef HAVE_STRUCT_IO_URING_PARAMS
+ # ifdef HAVE_STRUCT_IO_URING_PARAMS_CQ_OFF
+ static_assert(sizeof(struct io_uring_params) == sizeof(struct_io_uring_params),
+diff --git a/xlat/uring_cqring_flags.h b/xlat/uring_cqring_flags.h
+new file mode 100644
+index 0000000..0352749
+--- /dev/null
++++ b/xlat/uring_cqring_flags.h
+@@ -0,0 +1,48 @@
++/* Generated by ./xlat/gen.sh from ./xlat/uring_cqring_flags.in; do not edit. */
++
++#include "gcc_compat.h"
++#include "static_assert.h"
++
++#if defined(IORING_CQ_EVENTFD_DISABLED) || (defined(HAVE_DECL_IORING_CQ_EVENTFD_DISABLED) && HAVE_DECL_IORING_CQ_EVENTFD_DISABLED)
++DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
++static_assert((IORING_CQ_EVENTFD_DISABLED) == (1U), "IORING_CQ_EVENTFD_DISABLED != 1U");
++DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
++#else
++# define IORING_CQ_EVENTFD_DISABLED 1U
++#endif
++
++#ifndef XLAT_MACROS_ONLY
++
++# ifdef IN_MPERS
++
++#  error static const struct xlat uring_cqring_flags in mpers mode
++
++# else
++
++static const struct xlat_data uring_cqring_flags_xdata[] = {
++ XLAT(IORING_CQ_EVENTFD_DISABLED),
++ #define XLAT_VAL_0 ((unsigned) (IORING_CQ_EVENTFD_DISABLED))
++ #define XLAT_STR_0 STRINGIFY(IORING_CQ_EVENTFD_DISABLED)
++};
++static
++const struct xlat uring_cqring_flags[1] = { {
++ .data = uring_cqring_flags_xdata,
++ .size = ARRAY_SIZE(uring_cqring_flags_xdata),
++ .type = XT_NORMAL,
++ .flags_mask = 0
++#  ifdef XLAT_VAL_0
++  | XLAT_VAL_0
++#  endif
++  ,
++ .flags_strsz = 0
++#  ifdef XLAT_STR_0
++  + sizeof(XLAT_STR_0)
++#  endif
++  ,
++} };
++
++#  undef XLAT_STR_0
++#  undef XLAT_VAL_0
++# endif /* !IN_MPERS */
++
++#endif /* !XLAT_MACROS_ONLY */
+-- 
+2.19.1
+
diff --git a/meta/recipes-devtools/strace/strace_5.7.bb b/meta/recipes-devtools/strace/strace_5.7.bb
index c184d035aa..bc6aea54d3 100644
--- a/meta/recipes-devtools/strace/strace_5.7.bb
+++ b/meta/recipes-devtools/strace/strace_5.7.bb
@@ -14,6 +14,9 @@ SRC_URI = "https://strace.io/files/${PV}/strace-${PV}.tar.xz \
            file://ptest-spacesave.patch \
            file://uintptr_t.patch \
            file://0001-strace-fix-reproducibilty-issues.patch \
+           file://0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch \
+           file://0001-io_uring-Add-io_cqring_offset-flags.patch \
+           file://0001-uring-fix-build-against-5.8-libc-headers.patch \
            "
 SRC_URI[sha256sum] = "b284b59f9bcd95b9728cea5bd5c0edc5ebe360af73dc76fbf6334f11c777ccd8"
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* ✗ patchtest: failure for strace: fix build against v5.8 uapi headers
  2020-08-06 19:59 [PATCH] strace: fix build against v5.8 uapi headers Bruce Ashfield
@ 2020-08-06 20:02 ` Patchwork
  2020-08-06 20:02 ` [PATCH] " Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2020-08-06 20:02 UTC (permalink / raw)
  To: Bruce Ashfield; +Cc: openembedded-core

== Series Details ==

Series: strace: fix build against v5.8 uapi headers
Revision: 1
URL   : https://patchwork.openembedded.org/series/25507/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Issue             A patch file has been added, but does not have a Signed-off-by tag [test_signed_off_by_presence] 
  Suggested fix    Sign off the added patch file (meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch)

* Issue             Upstream-Status is in incorrect format [test_upstream_status_presence_format] 
  Suggested fix    Fix Upstream-Status format in 0001-io_uring-Add-io_cqring_offset-flags.patch
  Current          Upstream-status: backport of commit 592b915033de37322e19f3e6413de33317d272fe
  Standard format  Upstream-Status: <Valid status>
  Valid status     Pending, Accepted, Backport, Denied, Inappropriate [reason], Submitted [where]



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] strace: fix build against v5.8 uapi headers
  2020-08-06 19:59 [PATCH] strace: fix build against v5.8 uapi headers Bruce Ashfield
  2020-08-06 20:02 ` ✗ patchtest: failure for " Patchwork
@ 2020-08-06 20:02 ` Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: Bruce Ashfield @ 2020-08-06 20:02 UTC (permalink / raw)
  To: Richard Purdie; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 16687 bytes --]

Actually, disregard this patch for now.

Less than 24 hours ago, strace 5.8 released. I'll test it against the 5.8
headers and update to that instead if it works.

Bruce

On Thu, Aug 6, 2020 at 3:59 PM <bruce.ashfield@gmail.com> wrote:

> From: Bruce Ashfield <bruce.ashfield@gmail.com>
>
> The 5.8 kernel introduced changes to io uring that require adjustments
> in strace for it to build against the new headers. See kernel commits
> v5.8-rc1~190^2~22 and v5.8-rc1~190^2~21 for details.
>
> There are two patches in the upstream strace that deal with the new
> flags, so we port them to the v5.7 release until a new one is
> available upstream.
>
> We also have a third patch that is oe specific, which is the addition
> of a newly generated flags file and removal of some static checks.
> We need this change to build, since released versions of strace don't
> run the bootstrap step and hence won't generate the flags or fixup
> any static checks.
>
> Tested against the v5.4 and v5.8 kernels.
>
> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
> ---
>
> Note: also tested against both the 5.8 and 5.4 libc-headers.
>
> Bruce
>
>  ...-io_uring-Add-io_cqring_offset-flags.patch | 154 ++++++++++++++++++
>  ...struct-io_cqring_offsets-compile-tim.patch |  46 ++++++
>  ...g-fix-build-against-5.8-libc-headers.patch |  98 +++++++++++
>  meta/recipes-devtools/strace/strace_5.7.bb    |   3 +
>  4 files changed, 301 insertions(+)
>  create mode 100644
> meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch
>  create mode 100644
> meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
>  create mode 100644
> meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch
>
> diff --git
> a/meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch
> b/meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch
> new file mode 100644
> index 0000000000..dceeff7c7e
> --- /dev/null
> +++
> b/meta/recipes-devtools/strace/strace/0001-io_uring-Add-io_cqring_offset-flags.patch
> @@ -0,0 +1,154 @@
> +From 592b915033de37322e19f3e6413de33317d272fe Mon Sep 17 00:00:00 2001
> +From: Chris Packham <chris.packham@alliedtelesis.co.nz>
> +Date: Mon, 15 Jun 2020 22:01:26 +1200
> +Subject: [PATCH] io_uring: Add io_cqring_offset flags
> +
> +Add support for displaying struct io_cqring_offsets.flags introduced
> +by Linux kernel commits v5.8-rc1~190^2~22 and v5.8-rc1~190^2~21.
> +
> +* types/io_uring.h (struct_io_cqring_offsets): Replace resv array
> +with flags, resv1, and resv2 fields.
> +* xlat/uring_cqring_flags.in: New file.
> +* configure.ac (AC_CHECK_MEMBERS): Check struct io_cqring_offsets.flags.
> +* io_uring.c: Include "xlat/uring_cqring_flags.h".
> +(SYS_FUNC(io_uring_setup)): Replace printing of the resv array
> +of struct io_cqring_offsets with flags, resv1, and resv2 fields.
> +* tests/io_uring_setup.c: Check it.
> +
> +Upstream-status: backport of commit
> 592b915033de37322e19f3e6413de33317d272fe
> +
> +Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
> +Resolves: https://github.com/strace/strace/issues/138
> +---
> + configure.ac               |  1 +
> + io_uring.c                 | 11 +++++++----
> + tests/io_uring_setup.c     | 31 ++++++++++++++++++++++++++-----
> + types/io_uring.h           |  4 +++-
> + xlat/uring_cqring_flags.in |  1 +
> + 5 files changed, 38 insertions(+), 10 deletions(-)
> + create mode 100644 xlat/uring_cqring_flags.in
> +
> +diff --git a/configure.ac b/configure.ac
> +index d0fd51ff..91c2249e 100644
> +--- a/configure.ac
> ++++ b/configure.ac
> +@@ -481,6 +481,7 @@ AC_CHECK_HEADERS([linux/bpf.h], [
> +
> + AC_CHECK_HEADERS([linux/io_uring.h], [
> +       AC_CHECK_MEMBERS(m4_normalize([
> ++              struct io_cqring_offsets.flags,
> +               struct io_uring_params.features,
> +               struct io_uring_params.wq_fd,
> +               struct io_uring_params.resv
> +diff --git a/io_uring.c b/io_uring.c
> +index cfeea82b..2ffe163e 100644
> +--- a/io_uring.c
> ++++ b/io_uring.c
> +@@ -17,6 +17,7 @@
> + #include "xlat/uring_setup_flags.h"
> + #include "xlat/uring_enter_flags.h"
> + #include "xlat/uring_register_opcodes.h"
> ++#include "xlat/uring_cqring_flags.h"
> +
> + #ifdef HAVE_STRUCT_IO_URING_PARAMS
> + # ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV
> +@@ -88,10 +89,12 @@ SYS_FUNC(io_uring_setup)
> +               PRINT_FIELD_U(", ", params.cq_off, ring_entries);
> +               PRINT_FIELD_U(", ", params.cq_off, overflow);
> +               PRINT_FIELD_U(", ", params.cq_off, cqes);
> +-              if (!IS_ARRAY_ZERO(params.cq_off.resv)) {
> +-                      PRINT_FIELD_ARRAY(", ", params.cq_off, resv, tcp,
> +-                                        print_xint64_array_member);
> +-              }
> ++              PRINT_FIELD_FLAGS(", ", params.cq_off, flags,
> ++                                uring_cqring_flags, "IORING_CQ_???");
> ++              if (params.cq_off.resv1)
> ++                      PRINT_FIELD_X(", ", params.cq_off, resv1);
> ++              if (params.cq_off.resv2)
> ++                      PRINT_FIELD_X(", ", params.cq_off, resv2);
> +               tprints("}");
> +       }
> +       tprints("}");
> +diff --git a/tests/io_uring_setup.c b/tests/io_uring_setup.c
> +index 317b0d7a..a59e4a1a 100644
> +--- a/tests/io_uring_setup.c
> ++++ b/tests/io_uring_setup.c
> +@@ -27,6 +27,7 @@
> + # include "xlat.h"
> +
> + # include "xlat/uring_setup_features.h"
> ++# include "xlat/uring_cqring_flags.h"
> +
> + # ifdef HAVE_STRUCT_IO_URING_PARAMS_FEATURES
> + #  ifdef HAVE_STRUCT_IO_URING_PARAMS_WQ_FD
> +@@ -144,20 +145,40 @@ main(void)
> +                                               params->sq_off.resv2);
> +
> +                       printf("}, cq_off={head=%u, tail=%u, ring_mask=%u"
> +-                             ", ring_entries=%u, overflow=%u, cqes=%u",
> ++                             ", ring_entries=%u, overflow=%u, cqes=%u,
> flags=",
> +                              params->cq_off.head,
> +                              params->cq_off.tail,
> +                              params->cq_off.ring_mask,
> +                              params->cq_off.ring_entries,
> +                              params->cq_off.overflow,
> +                              params->cq_off.cqes);
> +-                      if (params->cq_off.resv[0] ||
> params->cq_off.resv[1]) {
> +-                              printf(", resv=[%#llx, %#llx]",
> ++#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_FLAGS
> ++                      printflags(uring_cqring_flags,
> ++                             params->cq_off.flags,
> ++                             "IORING_CQ_???");
> ++                      if (params->cq_off.resv1)
> ++                              printf(", resv1=%#x",
> params->cq_off.resv1);
> ++                      if (params->cq_off.resv2)
> ++                              printf(", resv2=%#llx",
> +                                      (unsigned long long)
> +-                                              params->cq_off.resv[0],
> ++                                              params->cq_off.resv2);
> ++#else
> ++                      union {
> ++                              struct {
> ++                                      uint32_t flags;
> ++                                      uint32_t resv1;
> ++                              } s;
> ++                              uint64_t v;
> ++                      } u = { .v = params->cq_off.resv[0] };
> ++                      printflags(uring_cqring_flags, u.s.flags,
> ++                                 "IORING_CQ_???");
> ++                      if (u.s.resv1)
> ++                              printf(", resv1=%#x", u.s.resv1);
> ++                      if (params->cq_off.resv[1])
> ++                              printf(", resv2=%#llx",
> +                                      (unsigned long long)
> +                                               params->cq_off.resv[1]);
> +-                      }
> ++#endif
> +
> +                       printf("}}) = %ld<anon_inode:[io_uring]>\n", rc);
> +               }
> +diff --git a/types/io_uring.h b/types/io_uring.h
> +index 76f432c3..2fe1c13a 100644
> +--- a/types/io_uring.h
> ++++ b/types/io_uring.h
> +@@ -31,7 +31,9 @@ typedef struct {
> +       uint32_t ring_entries;
> +       uint32_t overflow;
> +       uint32_t cqes;
> +-      uint64_t resv[2];
> ++      /** Added by v5.8-rc1~190^2~22 */       uint32_t flags;
> ++      /** Added by v5.8-rc1~190^2~22 */       uint32_t resv1;
> ++      /** Added by v5.8-rc1~190^2~22 */       uint64_t resv2;
> + } struct_io_cqring_offsets;
> +
> + typedef struct {
> +diff --git a/xlat/uring_cqring_flags.in b/xlat/uring_cqring_flags.in
> +new file mode 100644
> +index 00000000..c81fbc20
> +--- /dev/null
> ++++ b/xlat/uring_cqring_flags.in
> +@@ -0,0 +1 @@
> ++IORING_CQ_EVENTFD_DISABLED    1U
> +--
> +2.19.1
> +
> diff --git
> a/meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
> b/meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
> new file mode 100644
> index 0000000000..774b520a06
> --- /dev/null
> +++
> b/meta/recipes-devtools/strace/strace/0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch
> @@ -0,0 +1,46 @@
> +From fded17c15bca4150165f899cc47f67bab963d9a7 Mon Sep 17 00:00:00 2001
> +From: Chris Packham <chris.packham@alliedtelesis.co.nz>
> +Date: Mon, 15 Jun 2020 22:01:25 +1200
> +Subject: [PATCH] io_uring: Remove struct io_cqring_offsets compile time
> + asserts
> +
> +The generated types/check-io_uring.c already checks the kernel's struct
> +io_cqring_offsets for compatibility with the strace definition so
> +there's no need for manual checks.
> +
> +Upstream-status: backport of commit
> fded17c15bca4150165f899cc47f67bab963d9a7
> +
> +* io_uring.c [HAVE_STRUCT_IO_CQRING_OFFSETS]: Remove static_asserts.
> +---
> + io_uring.c | 15 ---------------
> + 1 file changed, 15 deletions(-)
> +
> +diff --git a/io_uring.c b/io_uring.c
> +index cd183457..cfeea82b 100644
> +--- a/io_uring.c
> ++++ b/io_uring.c
> +@@ -18,21 +18,6 @@
> + #include "xlat/uring_enter_flags.h"
> + #include "xlat/uring_register_opcodes.h"
> +
> +-#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS
> +-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
> +-static_assert(offsetof(struct_io_cqring_offsets, resv)
> +-             >= offsetof(struct io_cqring_offsets, resv),
> +-             "struct io_cqring_offsets.resv offset mismatch"
> +-             ", please update the decoder");
> +-static_assert(sizeof_field(struct_io_cqring_offsets, resv)
> +-             <= sizeof_field(struct io_cqring_offsets, resv),
> +-             "struct io_cqring_offsets.resv size mismatch"
> +-             ", please update the decoder");
> +-# else /* !HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */
> +-static_assert(0, "struct io_cqring_offsets.resv is missing"
> +-               ", please update the decoder");
> +-# endif
> +-#endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */
> + #ifdef HAVE_STRUCT_IO_URING_PARAMS
> + # ifdef HAVE_STRUCT_IO_URING_PARAMS_RESV
> + static_assert(offsetof(struct_io_uring_params, resv)
> +--
> +2.19.1
> +
> diff --git
> a/meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch
> b/meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch
> new file mode 100644
> index 0000000000..cfce3eca51
> --- /dev/null
> +++
> b/meta/recipes-devtools/strace/strace/0001-uring-fix-build-against-5.8-libc-headers.patch
> @@ -0,0 +1,98 @@
> +From 8dda6b8ddbe18b6bb83cf1fa6bc71ebdc82e1b72 Mon Sep 17 00:00:00 2001
> +From: Bruce Ashfield <bruce.ashfield@gmail.com>
> +Date: Mon, 3 Aug 2020 23:00:39 -0400
> +Subject: [PATCH] uring: fix build against 5.8 libc-headers
> +
> +To get strace building against v5.8 headers before the next
> +version of strace is released, we need to copy in a bootstrapped
> +file from the latest git (xlat/uring_cqring_flags.h) and remove
> +remove unnecessary asserts for v5.8+ (in a similar manner to the
> +main strace repository).
> +
> +Upstream-status: inappropriate. oe specific (upstream builds bootstrap)
> +
> +Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
> +---
> + types/check-io_uring.c    | 10 --------
> + xlat/uring_cqring_flags.h | 48 +++++++++++++++++++++++++++++++++++++++
> + 2 files changed, 48 insertions(+), 10 deletions(-)
> + create mode 100644 xlat/uring_cqring_flags.h
> +
> +diff --git a/types/check-io_uring.c b/types/check-io_uring.c
> +index dc21569..d5bd4b1 100644
> +--- a/types/check-io_uring.c
> ++++ b/types/check-io_uring.c
> +@@ -13,16 +13,6 @@ static_assert(sizeof(struct io_sqring_offsets) <=
> offsetof(struct_io_sqring_offs
> + # endif /* HAVE_STRUCT_IO_SQRING_OFFSETS_RESV2 */
> + #endif /* HAVE_STRUCT_IO_SQRING_OFFSETS */
> +
> +-#ifdef HAVE_STRUCT_IO_CQRING_OFFSETS
> +-# ifdef HAVE_STRUCT_IO_CQRING_OFFSETS_RESV
> +-static_assert(sizeof(struct io_cqring_offsets) ==
> sizeof(struct_io_cqring_offsets),
> +-      "struct io_cqring_offsets size mismatch, please update the decoder
> or fix the kernel");
> +-# else
> +-static_assert(sizeof(struct io_cqring_offsets) <=
> offsetof(struct_io_cqring_offsets, resv),
> +-"struct io_cqring_offsets size mismatch, please update the decoder or
> fix the kernel");
> +-# endif /* HAVE_STRUCT_IO_CQRING_OFFSETS_RESV */
> +-#endif /* HAVE_STRUCT_IO_CQRING_OFFSETS */
> +-
> + #ifdef HAVE_STRUCT_IO_URING_PARAMS
> + # ifdef HAVE_STRUCT_IO_URING_PARAMS_CQ_OFF
> + static_assert(sizeof(struct io_uring_params) ==
> sizeof(struct_io_uring_params),
> +diff --git a/xlat/uring_cqring_flags.h b/xlat/uring_cqring_flags.h
> +new file mode 100644
> +index 0000000..0352749
> +--- /dev/null
> ++++ b/xlat/uring_cqring_flags.h
> +@@ -0,0 +1,48 @@
> ++/* Generated by ./xlat/gen.sh from ./xlat/uring_cqring_flags.in; do not
> edit. */
> ++
> ++#include "gcc_compat.h"
> ++#include "static_assert.h"
> ++
> ++#if defined(IORING_CQ_EVENTFD_DISABLED) ||
> (defined(HAVE_DECL_IORING_CQ_EVENTFD_DISABLED) &&
> HAVE_DECL_IORING_CQ_EVENTFD_DISABLED)
> ++DIAG_PUSH_IGNORE_TAUTOLOGICAL_COMPARE
> ++static_assert((IORING_CQ_EVENTFD_DISABLED) == (1U),
> "IORING_CQ_EVENTFD_DISABLED != 1U");
> ++DIAG_POP_IGNORE_TAUTOLOGICAL_COMPARE
> ++#else
> ++# define IORING_CQ_EVENTFD_DISABLED 1U
> ++#endif
> ++
> ++#ifndef XLAT_MACROS_ONLY
> ++
> ++# ifdef IN_MPERS
> ++
> ++#  error static const struct xlat uring_cqring_flags in mpers mode
> ++
> ++# else
> ++
> ++static const struct xlat_data uring_cqring_flags_xdata[] = {
> ++ XLAT(IORING_CQ_EVENTFD_DISABLED),
> ++ #define XLAT_VAL_0 ((unsigned) (IORING_CQ_EVENTFD_DISABLED))
> ++ #define XLAT_STR_0 STRINGIFY(IORING_CQ_EVENTFD_DISABLED)
> ++};
> ++static
> ++const struct xlat uring_cqring_flags[1] = { {
> ++ .data = uring_cqring_flags_xdata,
> ++ .size = ARRAY_SIZE(uring_cqring_flags_xdata),
> ++ .type = XT_NORMAL,
> ++ .flags_mask = 0
> ++#  ifdef XLAT_VAL_0
> ++  | XLAT_VAL_0
> ++#  endif
> ++  ,
> ++ .flags_strsz = 0
> ++#  ifdef XLAT_STR_0
> ++  + sizeof(XLAT_STR_0)
> ++#  endif
> ++  ,
> ++} };
> ++
> ++#  undef XLAT_STR_0
> ++#  undef XLAT_VAL_0
> ++# endif /* !IN_MPERS */
> ++
> ++#endif /* !XLAT_MACROS_ONLY */
> +--
> +2.19.1
> +
> diff --git a/meta/recipes-devtools/strace/strace_5.7.bb
> b/meta/recipes-devtools/strace/strace_5.7.bb
> index c184d035aa..bc6aea54d3 100644
> --- a/meta/recipes-devtools/strace/strace_5.7.bb
> +++ b/meta/recipes-devtools/strace/strace_5.7.bb
> @@ -14,6 +14,9 @@ SRC_URI = "
> https://strace.io/files/${PV}/strace-${PV}.tar.xz \
>             file://ptest-spacesave.patch \
>             file://uintptr_t.patch \
>             file://0001-strace-fix-reproducibilty-issues.patch \
> +
>  file://0001-io_uring-Remove-struct-io_cqring_offsets-compile-tim.patch \
> +           file://0001-io_uring-Add-io_cqring_offset-flags.patch \
> +           file://0001-uring-fix-build-against-5.8-libc-headers.patch \
>             "
>  SRC_URI[sha256sum] =
> "b284b59f9bcd95b9728cea5bd5c0edc5ebe360af73dc76fbf6334f11c777ccd8"
>
> --
> 2.19.1
>
>

-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II

[-- Attachment #2: Type: text/html, Size: 21480 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-06 20:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-06 19:59 [PATCH] strace: fix build against v5.8 uapi headers Bruce Ashfield
2020-08-06 20:02 ` ✗ patchtest: failure for " Patchwork
2020-08-06 20:02 ` [PATCH] " Bruce Ashfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox