include/uapi/cxl/features.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
The uuid_t type is kernel internal, and Paul reports the following build
error when it is used in a uapi header:
usr/include/cxl/features.h:59:9: error: unknown type name ‘uuid_t’
Create a uuid type (__uapi_uuid_t) compatible with the longstanding
definition uuid/uuid.h for userspace builds, and use uuid_t directly for
kernel builds.
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Reported-by: "Paul E. McKenney" <paulmck@kernel.org>
Closes: http://lore.kernel.org/f6489337-67c7-48c8-b48a-58603ec15328@paulmck-laptop
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504050434.Eb4vugh5-lkp@intel.com/
Fixes: 9b8e73cdb141 ("cxl: Move cxl feature command structs to user header")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Changes since v1 [1]:
* Fix a build robot report for older gcc that has different alignment
rules for struct wrapped data types (0day kbuild robot)
[1]: http://lore.kernel.org/67eac8df3e217_201f02948d@dwillia2-xfh.jf.intel.com.notmuch
include/uapi/cxl/features.h | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/include/uapi/cxl/features.h b/include/uapi/cxl/features.h
index d6db8984889f..d0d2d022957d 100644
--- a/include/uapi/cxl/features.h
+++ b/include/uapi/cxl/features.h
@@ -8,10 +8,20 @@
#define _UAPI_CXL_FEATURES_H_
#include <linux/types.h>
-#ifndef __KERNEL__
-#include <uuid/uuid.h>
-#else
+
+typedef unsigned char __uapi_uuid_t[16];
+
+#ifdef __KERNEL__
#include <linux/uuid.h>
+/*
+ * Note that gcc-8.5.0 has different alignment rules when the type is
+ * contained in a struct, so wrap the type passed to __align_of__ to
+ * avoid false positive assertions
+ */
+static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t) &&
+ __alignof__(struct { __uapi_uuid_t uuid; }) ==
+ __alignof__(struct { uuid_t uuid; }));
+#define __uapi_uuid_t uuid_t
#endif
/*
@@ -60,7 +70,7 @@ struct cxl_mbox_get_sup_feats_in {
* Get Supported Features Supported Feature Entry
*/
struct cxl_feat_entry {
- uuid_t uuid;
+ __uapi_uuid_t uuid;
__le16 id;
__le16 get_feat_size;
__le16 set_feat_size;
@@ -110,7 +120,7 @@ struct cxl_mbox_get_sup_feats_out {
* CXL spec r3.2 section 8.2.9.6.2 Table 8-99
*/
struct cxl_mbox_get_feat_in {
- uuid_t uuid;
+ __uapi_uuid_t uuid;
__le16 offset;
__le16 count;
__u8 selection;
@@ -143,7 +153,7 @@ enum cxl_get_feat_selection {
*/
struct cxl_mbox_set_feat_in {
__struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */,
- uuid_t uuid;
+ __uapi_uuid_t uuid;
__le32 flags;
__le16 offset;
__u8 version;
The uuid_t type is kernel internal, and Paul reports the following build
error when it is used in a uapi header:
usr/include/cxl/features.h:59:9: error: unknown type name ‘uuid_t’
Create a uuid type (__uapi_uuid_t) compatible with the longstanding
definition uuid/uuid.h for userspace builds, and use uuid_t directly for
kernel builds.
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Reported-by: "Paul E. McKenney" <paulmck@kernel.org>
Closes: http://lore.kernel.org/f6489337-67c7-48c8-b48a-58603ec15328@paulmck-laptop
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504050434.Eb4vugh5-lkp@intel.com/
Fixes: 9b8e73cdb141 ("cxl: Move cxl feature command structs to user header")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Changes since v2:
* Drop the tinkering with __align_of__ and just document the safety
rules (Jason)
include/uapi/cxl/features.h | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/include/uapi/cxl/features.h b/include/uapi/cxl/features.h
index d6db8984889f..490606d7694b 100644
--- a/include/uapi/cxl/features.h
+++ b/include/uapi/cxl/features.h
@@ -8,10 +8,19 @@
#define _UAPI_CXL_FEATURES_H_
#include <linux/types.h>
-#ifndef __KERNEL__
-#include <uuid/uuid.h>
-#else
+
+typedef unsigned char __uapi_uuid_t[16];
+
+#ifdef __KERNEL__
#include <linux/uuid.h>
+/*
+ * Note, __uapi_uuid_t is 1-byte aligned on modern compilers and 4-byte
+ * aligned on others. Ensure that __uapi_uuid_t in a struct is placed at
+ * a 4-byte aligned offset, or the structure is packed, to ensure
+ * consistent padding.
+ */
+static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t));
+#define __uapi_uuid_t uuid_t
#endif
/*
@@ -60,7 +69,7 @@ struct cxl_mbox_get_sup_feats_in {
* Get Supported Features Supported Feature Entry
*/
struct cxl_feat_entry {
- uuid_t uuid;
+ __uapi_uuid_t uuid;
__le16 id;
__le16 get_feat_size;
__le16 set_feat_size;
@@ -110,7 +119,7 @@ struct cxl_mbox_get_sup_feats_out {
* CXL spec r3.2 section 8.2.9.6.2 Table 8-99
*/
struct cxl_mbox_get_feat_in {
- uuid_t uuid;
+ __uapi_uuid_t uuid;
__le16 offset;
__le16 count;
__u8 selection;
@@ -143,7 +152,7 @@ enum cxl_get_feat_selection {
*/
struct cxl_mbox_set_feat_in {
__struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */,
- uuid_t uuid;
+ __uapi_uuid_t uuid;
__le32 flags;
__le16 offset;
__u8 version;
On Thu, Apr 10, 2025 at 11:27:40AM -0700, Dan Williams wrote:
> The uuid_t type is kernel internal, and Paul reports the following build
> error when it is used in a uapi header:
>
> usr/include/cxl/features.h:59:9: error: unknown type name ‘uuid_t’
>
> Create a uuid type (__uapi_uuid_t) compatible with the longstanding
> definition uuid/uuid.h for userspace builds, and use uuid_t directly for
> kernel builds.
>
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
> Reported-by: "Paul E. McKenney" <paulmck@kernel.org>
> Closes: http://lore.kernel.org/f6489337-67c7-48c8-b48a-58603ec15328@paulmck-laptop
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202504050434.Eb4vugh5-lkp@intel.com/
> Fixes: 9b8e73cdb141 ("cxl: Move cxl feature command structs to user header")
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> Changes since v2:
> * Drop the tinkering with __align_of__ and just document the safety
> rules (Jason)
>
> include/uapi/cxl/features.h | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
Applied thanks
Jason
On Thu, Apr 10, 2025 at 11:27:40AM -0700, Dan Williams wrote:
> The uuid_t type is kernel internal, and Paul reports the following build
> error when it is used in a uapi header:
>
> usr/include/cxl/features.h:59:9: error: unknown type name ‘uuid_t’
>
> Create a uuid type (__uapi_uuid_t) compatible with the longstanding
> definition uuid/uuid.h for userspace builds, and use uuid_t directly for
> kernel builds.
>
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
> Reported-by: "Paul E. McKenney" <paulmck@kernel.org>
> Closes: http://lore.kernel.org/f6489337-67c7-48c8-b48a-58603ec15328@paulmck-laptop
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202504050434.Eb4vugh5-lkp@intel.com/
> Fixes: 9b8e73cdb141 ("cxl: Move cxl feature command structs to user header")
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Nice, thank you!!!
Tested-by: Paul E. McKenney <paulmck@kernel.org>
> ---
> Changes since v2:
> * Drop the tinkering with __align_of__ and just document the safety
> rules (Jason)
>
> include/uapi/cxl/features.h | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/include/uapi/cxl/features.h b/include/uapi/cxl/features.h
> index d6db8984889f..490606d7694b 100644
> --- a/include/uapi/cxl/features.h
> +++ b/include/uapi/cxl/features.h
> @@ -8,10 +8,19 @@
> #define _UAPI_CXL_FEATURES_H_
>
> #include <linux/types.h>
> -#ifndef __KERNEL__
> -#include <uuid/uuid.h>
> -#else
> +
> +typedef unsigned char __uapi_uuid_t[16];
> +
> +#ifdef __KERNEL__
> #include <linux/uuid.h>
> +/*
> + * Note, __uapi_uuid_t is 1-byte aligned on modern compilers and 4-byte
> + * aligned on others. Ensure that __uapi_uuid_t in a struct is placed at
> + * a 4-byte aligned offset, or the structure is packed, to ensure
> + * consistent padding.
> + */
> +static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t));
> +#define __uapi_uuid_t uuid_t
> #endif
>
> /*
> @@ -60,7 +69,7 @@ struct cxl_mbox_get_sup_feats_in {
> * Get Supported Features Supported Feature Entry
> */
> struct cxl_feat_entry {
> - uuid_t uuid;
> + __uapi_uuid_t uuid;
> __le16 id;
> __le16 get_feat_size;
> __le16 set_feat_size;
> @@ -110,7 +119,7 @@ struct cxl_mbox_get_sup_feats_out {
> * CXL spec r3.2 section 8.2.9.6.2 Table 8-99
> */
> struct cxl_mbox_get_feat_in {
> - uuid_t uuid;
> + __uapi_uuid_t uuid;
> __le16 offset;
> __le16 count;
> __u8 selection;
> @@ -143,7 +152,7 @@ enum cxl_get_feat_selection {
> */
> struct cxl_mbox_set_feat_in {
> __struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */,
> - uuid_t uuid;
> + __uapi_uuid_t uuid;
> __le32 flags;
> __le16 offset;
> __u8 version;
>
On 4/10/25 11:27 AM, Dan Williams wrote:
> The uuid_t type is kernel internal, and Paul reports the following build
> error when it is used in a uapi header:
>
> usr/include/cxl/features.h:59:9: error: unknown type name ‘uuid_t’
>
> Create a uuid type (__uapi_uuid_t) compatible with the longstanding
> definition uuid/uuid.h for userspace builds, and use uuid_t directly for
> kernel builds.
>
> Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
> Reported-by: "Paul E. McKenney" <paulmck@kernel.org>
> Closes: http://lore.kernel.org/f6489337-67c7-48c8-b48a-58603ec15328@paulmck-laptop
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202504050434.Eb4vugh5-lkp@intel.com/
> Fixes: 9b8e73cdb141 ("cxl: Move cxl feature command structs to user header")
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> Changes since v2:
> * Drop the tinkering with __align_of__ and just document the safety
> rules (Jason)
>
> include/uapi/cxl/features.h | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/include/uapi/cxl/features.h b/include/uapi/cxl/features.h
> index d6db8984889f..490606d7694b 100644
> --- a/include/uapi/cxl/features.h
> +++ b/include/uapi/cxl/features.h
> @@ -8,10 +8,19 @@
> #define _UAPI_CXL_FEATURES_H_
>
> #include <linux/types.h>
> -#ifndef __KERNEL__
> -#include <uuid/uuid.h>
> -#else
> +
> +typedef unsigned char __uapi_uuid_t[16];
> +
> +#ifdef __KERNEL__
> #include <linux/uuid.h>
> +/*
> + * Note, __uapi_uuid_t is 1-byte aligned on modern compilers and 4-byte
> + * aligned on others. Ensure that __uapi_uuid_t in a struct is placed at
> + * a 4-byte aligned offset, or the structure is packed, to ensure
> + * consistent padding.
> + */
> +static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t));
> +#define __uapi_uuid_t uuid_t
> #endif
>
> /*
> @@ -60,7 +69,7 @@ struct cxl_mbox_get_sup_feats_in {
> * Get Supported Features Supported Feature Entry
> */
> struct cxl_feat_entry {
> - uuid_t uuid;
> + __uapi_uuid_t uuid;
> __le16 id;
> __le16 get_feat_size;
> __le16 set_feat_size;
> @@ -110,7 +119,7 @@ struct cxl_mbox_get_sup_feats_out {
> * CXL spec r3.2 section 8.2.9.6.2 Table 8-99
> */
> struct cxl_mbox_get_feat_in {
> - uuid_t uuid;
> + __uapi_uuid_t uuid;
> __le16 offset;
> __le16 count;
> __u8 selection;
> @@ -143,7 +152,7 @@ enum cxl_get_feat_selection {
> */
> struct cxl_mbox_set_feat_in {
> __struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */,
> - uuid_t uuid;
> + __uapi_uuid_t uuid;
> __le32 flags;
> __le16 offset;
> __u8 version;
>
© 2016 - 2025 Red Hat, Inc.