Skip to contentSkip to conversation

vfio: selftests: Clean up <uapi/linux/types.h> includes

PATCH Applied David Matlack 2 participants 4 messages Dec 19, 2025 – Dec 23, 2025

Subsystems (4)
lore
Share & tools
lore

David Matlack

author maintainer
#0 lore raw

cover vfio: selftests: Clean up <uapi/linux/types.h> includes

Small clean up series to eliminate the extra includes of <uapi/linux/types.h> from various VFIO selftests files. This include is not causing any problems now, but it is causing benign typedef redifinitions. Those redifinitions will become a problem when the VFIO selftests library is built into KVM selftests, since KVM selftests build with -std=gnu99.

Cc Yosry Ahmed <[email protected]>
Cc Josh Hilke <[email protected]>

David Matlack (2):
tools include: Add definitions for __aligned_{l,b}e64
vfio: selftests: Drop <uapi/linux/types.h> includes

 tools/include/linux/types.h                               | 8 ++++++++
 .../selftests/vfio/lib/include/libvfio/iova_allocator.h   | 1 -
 tools/testing/selftests/vfio/lib/iommu.c                  | 1 -
 tools/testing/selftests/vfio/lib/iova_allocator.c         | 1 -
 tools/testing/selftests/vfio/lib/vfio_pci_device.c        | 1 -
 tools/testing/selftests/vfio/vfio_dma_mapping_test.c      | 1 -
 tools/testing/selftests/vfio/vfio_iommufd_setup_test.c    | 1 -
 7 files changed, 8 insertions(+), 6 deletions(-)

base-commit: d721f52e31553a848e0e9947ca15a49c5674aef3

Signature · 1 line
2.52.0.322.g1dd061c0dc-goog
author maintainer
#1 lore raw

PATCH 1/2 tools include: Add definitions for __aligned_{l,b}e64

Add definitions for the missing __aligned_le64 and __aligned_be64 to tools/include/linux/types.h. The former is needed by <linux/iommufd.h> for builds where tools/include/ is on the include path ahead of usr/include/.

---
 tools/include/linux/types.h | 8 ++++++++
 1 file changed, 8 insertions(+)
tools/include/linux/types.h +8 -0
index 4928e33d44ac..d41f8a261bce 100644
@@ -88,6 +88,14 @@ typedef struct {
 # define __aligned_u64 __u64 __attribute__((aligned(8)))
 #endif
 
+#ifndef __aligned_be64
+# define __aligned_be64 __be64 __attribute__((aligned(8)))
+#endif
+
+#ifndef __aligned_le64
+# define __aligned_le64 __le64 __attribute__((aligned(8)))
+#endif
+
 struct list_head {
 	struct list_head *next, *prev;
 };
Signature · 1 line
2.52.0.322.g1dd061c0dc-goog
author maintainer
#2 lore raw

PATCH 2/2 vfio: selftests: Drop <uapi/linux/types.h> includes

In reply to David Matlack

Drop the <uapi/linux/types.h> includes now that <linux/types.h> (tools/include/linux/types.h) has a definition for __aligned_le64, which is needed by <linux/iommufd.h>.

Including <uapi/linux/types.h> is harmless but causes benign typedef redifitions. This is not a problem for VFIO selftests but be an issue when the VFIO selftests library is built into KVM selftests, since they are built with -std=gnu99 which does not allow typedef redifitions.

No functional change intended.

---
 .../testing/selftests/vfio/lib/include/libvfio/iova_allocator.h  | 1 -
 tools/testing/selftests/vfio/lib/iommu.c                         | 1 -
 tools/testing/selftests/vfio/lib/iova_allocator.c                | 1 -
 tools/testing/selftests/vfio/lib/vfio_pci_device.c               | 1 -
 tools/testing/selftests/vfio/vfio_dma_mapping_test.c             | 1 -
 tools/testing/selftests/vfio/vfio_iommufd_setup_test.c           | 1 -
 6 files changed, 6 deletions(-)
tools/testing/selftests/vfio/lib/include/libvfio/iova_allocator.h +0 -1
index 8f1d994e9ea2..c7c0796a757f 100644
@@ -2,7 +2,6 @@
 #ifndef SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_IOVA_ALLOCATOR_H
 #define SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_IOVA_ALLOCATOR_H
 
-#include <uapi/linux/types.h>
 #include <linux/list.h>
 #include <linux/types.h>
 #include <linux/iommufd.h>
tools/testing/selftests/vfio/lib/iommu.c +0 -1
index 8079d43523f3..58b7fb7430d4 100644
@@ -11,7 +11,6 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 
-#include <uapi/linux/types.h>
 #include <linux/limits.h>
 #include <linux/mman.h>
 #include <linux/types.h>
tools/testing/selftests/vfio/lib/iova_allocator.c +0 -1
index a12b0a51e9e6..8c1cc86b70cd 100644
@@ -11,7 +11,6 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 
-#include <uapi/linux/types.h>
 #include <linux/iommufd.h>
 #include <linux/limits.h>
 #include <linux/mman.h>
tools/testing/selftests/vfio/lib/vfio_pci_device.c +0 -1
index 13fdb4b0b10f..0b335e4e0435 100644
@@ -11,7 +11,6 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 
-#include <uapi/linux/types.h>
 #include <linux/iommufd.h>
 #include <linux/limits.h>
 #include <linux/mman.h>
tools/testing/selftests/vfio/vfio_dma_mapping_test.c +0 -1
index 5397822c3dd4..41b8cae7a6ae 100644
@@ -3,7 +3,6 @@
 #include <sys/mman.h>
 #include <unistd.h>
 
-#include <uapi/linux/types.h>
 #include <linux/iommufd.h>
 #include <linux/limits.h>
 #include <linux/mman.h>
tools/testing/selftests/vfio/vfio_iommufd_setup_test.c +0 -1
index caf1c6291f3d..5d980b148d83 100644
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <uapi/linux/types.h>
 #include <linux/limits.h>
 #include <linux/sizes.h>
 #include <linux/vfio.h>
Signature · 1 line
2.52.0.322.g1dd061c0dc-goog
maintainer Applied
#3 lore raw
In reply to David Matlack
Quoted 24 lines · On Fri, 19 Dec 2025 23:38:16 +0000 David Matlack <[email protected]> wrote:

Small clean up series to eliminate the extra includes of <uapi/linux/types.h> from various VFIO selftests files. This include is not causing any problems now, but it is causing benign typedef redifinitions. Those redifinitions will become a problem when the VFIO selftests library is built into KVM selftests, since KVM selftests build with -std=gnu99.

Cc Yosry Ahmed <[email protected]>
Cc Josh Hilke <[email protected]>

David Matlack (2):
tools include: Add definitions for __aligned_{l,b}e64
vfio: selftests: Drop <uapi/linux/types.h> includes

 tools/include/linux/types.h                               | 8 ++++++++
 .../selftests/vfio/lib/include/libvfio/iova_allocator.h   | 1 -
 tools/testing/selftests/vfio/lib/iommu.c                  | 1 -
 tools/testing/selftests/vfio/lib/iova_allocator.c         | 1 -
 tools/testing/selftests/vfio/lib/vfio_pci_device.c        | 1 -
 tools/testing/selftests/vfio/vfio_dma_mapping_test.c      | 1 -
 tools/testing/selftests/vfio/vfio_iommufd_setup_test.c    | 1 -
 7 files changed, 8 insertions(+), 6 deletions(-)
Quoted 1 line

base-commit: d721f52e31553a848e0e9947ca15a49c5674aef3

Applied to vfio for-linus branch for v6.19. Thanks,

Alex