[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3] xen/public: fix flexible array definitions
- To: Juergen Gross <jgross@xxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Fri, 1 Dec 2023 12:25:31 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=59muZDofqtl0R5R++rxFjMykMnix45sGuK4dDL0bNRg=; b=ctNQTSxHvpctERJvZLkopOoRz8560rIDIhz2Dign/J8xd5nj4VAj1H/mugahX/02VpdanN5o1Rrq2t5ztoBYJUP7Bcsk23v9gVKOlHYWz+XVmxYRmWduqMY3ST4GunzvdoRsMlnIhbI5VKnj4vszynpXkGlKEGAoAbrEKKlnhVTIYQk96814jMSKf5Hxp0rKrezQe/yI2gCCW4J240OWtDSE8bpil3LvkKYqRg42/3ze+z/NuCjpzIdAwfNn8cjoOOXnFQNuWo8u8foQXXaewPrZf8x0AgZAO2fc0ldxjYdjHVizR+NwLhMNXxWKmHkXq7Mr0lCH3LF+/4LLF1K7uQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eaea+QuC6Oq9zeDqLJn5NP87PfnwQpUAFStTCfKYvFtIeq/CxDeBhIuYjy8fMOHX9fGvIz/oG+R5hHNxhIxMHiZ3bpWy3Judhi7JyfJ8fhpvBkXjVFiHE8g9mYdoKgp43Yd1NfhtHafwlLqYYI6WExLxmUrZ/9azY9bRTaTnykp+1itNZfYafCgP3LfT5umkS0E4SdmZSZvZD4udiWAqiAuxQ0XT5901bjcETheb+kdW7HpLjtbPW3cY+5UZP5CU5bqwQLJxJVCmXDzPOaXfPy4U1DDtERFsBRs19wx1CMtQyTcuVJeKf5k9cHuhDldfBZexdsvRncXT4W5v4Cq1Hw==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
- Cc: Henry Wang <Henry.Wang@xxxxxxx>, Community Manager <community.manager@xxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Fri, 01 Dec 2023 11:25:39 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 01.12.2023 12:20, Juergen Gross wrote:
> Flexible arrays in public headers can be problematic with some
> compilers.
>
> With XEN_FLEX_ARRAY_DIM there is a mechanism available to deal with
> this issue, but care must be taken to not change the affected structs
> in an incompatible way.
>
> So bump __XEN_LATEST_INTERFACE_VERSION__ and introduce a new macro
> XENPV_FLEX_ARRAY_DIM which will be XENPV_FLEX_ARRAY_DIM with the
> interface version being new enough and "1" (the value used today in
> the affected headers) when the interface version is an old one.
>
> Replace the arr[1] instances (this includes the ones seen to be
> problematic in recent Linux kernels [1]) with arr[XENPV_FLEX_ARRAY_DIM]
> in order to avoid compilation errors.
>
> [1]: https://bugzilla.kernel.org/show_bug.cgi?id=217693
>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> --- a/xen/include/public/io/ring.h
> +++ b/xen/include/public/io/ring.h
> @@ -25,8 +25,16 @@
> * and grant_table.h from the Xen public headers.
> */
>
> +#include "../xen.h"
> #include "../xen-compat.h"
Just to mention it: While perhaps good practice, I'm not convinced this
extra #include is actually needed here.
> +/* Some PV I/O interfaces need a compatibility variant. */
> +#if __XEN_INTERFACE_VERSION__ < 0x00041300
> +#define XENPV_FLEX_ARRAY_DIM 1 /* variable size */
> +#else
> +#define XENPV_FLEX_ARRAY_DIM XEN_FLEX_ARRAY_DIM
> +#endif
> +
> #if __XEN_INTERFACE_VERSION__ < 0x00030208
> #define xen_mb() mb()
> #define xen_rmb() rmb()
> @@ -110,7 +118,7 @@ struct __name##_sring {
> \
> uint8_t pvt_pad[4]; \
> } pvt; \
> uint8_t __pad[44]; \
> - union __name##_sring_entry ring[1]; /* variable-length */ \
> + union __name##_sring_entry ring[XENPV_FLEX_ARRAY_DIM]; \
> }; \
> \
> /* "Front" end's private variables */ \
> @@ -479,7 +487,7 @@ struct name##_data_intf {
> \
> uint8_t pad2[56];
> \
>
> \
> RING_IDX ring_order;
> \
> - grant_ref_t ref[];
> \
> + grant_ref_t ref[XEN_FLEX_ARRAY_DIM];
> \
> };
> \
> DEFINE_XEN_FLEX_RING(name)
>
|