Skip to contentSkip to conversation

vfio: fix cdev build with old Linux headers

PATCH In review Thomas Monjalon 3 participants 4 messages Nov 2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: fix cdev build with old Linux headers

System headers may indirectly include linux/stddef.h before the imported UAPI headers.
Both versions share the _LINUX_STDDEF_H include guard, so the imported header is then skipped.

If the system header lacks __counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure in vfio.h:

In file included from lib/eal/linux/eal_vfio_cdev.c:14:
kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'

Include the imported UAPI headers before the system headers so their compatibility definitions are available.

Fixes d129414711aa ("vfio: introduce cdev mode")
---
 lib/eal/linux/eal_vfio_cdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/eal/linux/eal_vfio_cdev.c +3 -3
index 4a955248ae..e7cd547c1c 100644
@@ -2,6 +2,9 @@
  * Copyright(c) 2010-2025 Intel Corporation
  */
 
+#include <uapi/linux/iommufd.h>
+#include <uapi/linux/vfio.h>
+
 #include <dirent.h>
 #include <fcntl.h>
 #include <limits.h>
@@ -10,9 +13,6 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 
-#include <uapi/linux/iommufd.h>
-#include <uapi/linux/vfio.h>
-
 #include <rte_log.h>
 #include <rte_errno.h>
 #include <rte_memory.h>
Signature · 1 line
2.55.0
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Thomas Monjalon

System headers may indirectly include linux/stddef.h before the imported UAPI headers.
Both versions share the _LINUX_STDDEF_H include guard, so the imported header is then skipped.

If the system header lacks __counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure in vfio.h:

In file included from lib/eal/linux/eal_vfio_cdev.c:14:
kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'

Quoted 6 lines

Include the imported UAPI headers before the system headers so their compatibility definitions are available.

Fixes d129414711aa ("vfio: introduce cdev mode")

Strange we did not hit it earlier, but the fix lgtm.
I though I had fixed such issues.. but I probably missed (messed?) the new cdev file.

Signature · 1 line
David Marchand
Acked-by on v1 1/1
#2 lore raw
In reply to Thomas Monjalon
Quoted 13 lines · Thomas Monjalon

System headers may indirectly include linux/stddef.h before the imported UAPI headers.
Both versions share the _LINUX_STDDEF_H include guard, so the imported header is then skipped.

If the system header lacks __counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure in vfio.h:

In file included from lib/eal/linux/eal_vfio_cdev.c:14:
kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'

Quoted 7 lines

Include the imported UAPI headers before the system headers so their compatibility definitions are available.

Fixes d129414711aa ("vfio: introduce cdev mode")

---

LGTM

Quoted 30 lines
 lib/eal/linux/eal_vfio_cdev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/eal/linux/eal_vfio_cdev.c +3 -3
index 4a955248ae..e7cd547c1c 100644
@@ -2,6 +2,9 @@
  * Copyright(c) 2010-2025 Intel Corporation
  */
 
+#include <uapi/linux/iommufd.h>
+#include <uapi/linux/vfio.h>
+
 #include <dirent.h>
 #include <fcntl.h>
 #include <limits.h>
@@ -10,9 +13,6 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 
-#include <uapi/linux/iommufd.h>
-#include <uapi/linux/vfio.h>
-
 #include <rte_log.h>
 #include <rte_errno.h>
 #include <rte_memory.h>
Signature · 1 line
2.55.0
author Acked-by David Marchand Applied
#3 lore raw

02/11/2026 16:34, Bruce Richardson:

Quoted 14 lines · Thomas Monjalon
Quoted 13 lines

System headers may indirectly include linux/stddef.h before the imported UAPI headers.
Both versions share the _LINUX_STDDEF_H include guard, so the imported header is then skipped.

If the system header lacks __counted_by,
its fallback definition in the imported header is not processed, causing a compilation failure in vfio.h:

In file included from lib/eal/linux/eal_vfio_cdev.c:14:
kernel/linux/uapi/linux/vfio.h:1524:51: error:
expected ':', ',', ';', '}' or '__attribute__' before '__counted_by'

Quoted 8 lines
Quoted 7 lines

Include the imported UAPI headers before the system headers so their compatibility definitions are available.

Fixes d129414711aa ("vfio: introduce cdev mode")

---

Applied