tools: Fix tools/virtio test build
PATCH v2 1/2 tools/virtio: Add missing compat definitions for vhost_net_test
In reply to Yichong Chenvhost_net_test builds virtio_ring.c in userspace.
Recent virtio headers pull in helper headers that are not provided by the tools/virtio compatibility layer, including asm/percpu_types.h, linux/completion.h, linux/mod_devicetable.h and linux/virtio_features.h.
Add the missing compat definitions and the DMA attribute used by the current virtio ring code.
--- tools/virtio/asm/percpu_types.h | 7 +++ tools/virtio/linux/completion.h | 9 ++++ tools/virtio/linux/device.h | 1 + tools/virtio/linux/dma-mapping.h | 1 + tools/virtio/linux/mod_devicetable.h | 14 +++++ tools/virtio/linux/virtio_features.h | 79 ++++++++++++++++++++++++++++ 6 files changed, 111 insertions(+) create mode 100644 tools/virtio/asm/percpu_types.h create mode 100644 tools/virtio/linux/completion.h create mode 100644 tools/virtio/linux/mod_devicetable.h create mode 100644 tools/virtio/linux/virtio_features.h
tools/virtio/asm/percpu_types.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_PERCPU_TYPES_H +#define _ASM_PERCPU_TYPES_H + +#define __percpu_qual + +#endif /* _ASM_PERCPU_TYPES_H */
tools/virtio/linux/completion.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_COMPLETION_H +#define _LINUX_COMPLETION_H + +struct completion { +unsigned int done; +}; + +#endif /* _LINUX_COMPLETION_H */
tools/virtio/linux/device.h +1 -0
@@ -1,4 +1,5 @@ #ifndef LINUX_DEVICE_H +#define LINUX_DEVICE_H struct device { void *parent;
tools/virtio/linux/dma-mapping.h +1 -0
@@ -61,5 +61,6 @@ enum dma_data_direction {#define DMA_MAPPING_ERROR (~(dma_addr_t)0)#define DMA_ATTR_CPU_CACHE_CLEAN (1UL << 11) +#define DMA_ATTR_DEBUGGING_IGNORE_CACHELINES 0#endif
tools/virtio/linux/mod_devicetable.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MOD_DEVICETABLE_H +#define _LINUX_MOD_DEVICETABLE_H + +#include <linux/types.h> + +struct virtio_device_id { +__u32 device; +__u32 vendor; +}; + +#define VIRTIO_DEV_ANY_ID 0xffffffff + +#endif /* _LINUX_MOD_DEVICETABLE_H */
tools/virtio/linux/virtio_features.h new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.51.0
v2 cover tools: Fix tools/virtio test build
Hi,
This series fixes build failures hit by:
make -C tools/virtio test
It is based on linux-next commit:
commit 3d5670d672ae ("Add linux-next specific files for 20260626")
Patch 1 adds tools/virtio compatibility definitions needed by current virtio headers when building the tools/virtio tests. Patch 2 makes tools/include/linux/overflow.h include stdint.h for SIZE_MAX, which is used by its size helper functions.
With the series applied, make -C tools/virtio test builds virtio_test, vringh_test and vhost_net_test successfully.
Tested on x86_64 and arm64 with:
make -C tools/virtio clean
make -C tools/virtio test
Changes in v2:
- Rebase and retest on linux-next.
- Add the missing asm/percpu_types.h compat header reported by Eugenio.
- Keep the tools/virtio compat definitions aligned with current virtio_features.h helpers.
- Drop the slab.h kmalloc_obj/kmalloc_objs change because linux-next already defines them in tools/virtio/linux/kernel.h.
Yichong Chen (2):
tools/virtio: Add missing compat definitions for vhost_net_test tools/include: Include stdint.h for SIZE_MAX in overflow.h
tools/include/linux/overflow.h | 1 + tools/virtio/asm/percpu_types.h | 7 +++ tools/virtio/linux/completion.h | 9 ++++ tools/virtio/linux/device.h | 1 + tools/virtio/linux/dma-mapping.h | 1 + tools/virtio/linux/mod_devicetable.h | 14 +++++ tools/virtio/linux/virtio_features.h | 79 ++++++++++++++++++++++++++++ 7 files changed, 112 insertions(+) create mode 100644 tools/virtio/asm/percpu_types.h create mode 100644 tools/virtio/linux/completion.h create mode 100644 tools/virtio/linux/mod_devicetable.h create mode 100644 tools/virtio/linux/virtio_features.h
Signature · 1 line
2.51.0
PATCH v2 2/2 tools/include: Include stdint.h for SIZE_MAX in overflow.h
tools/include/linux/overflow.h uses SIZE_MAX in its size helper functions.
Include stdint.h so tools users that include overflow.h without another SIZE_MAX provider can build.
--- tools/include/linux/overflow.h | 1 + 1 file changed, 1 insertion(+)
tools/include/linux/overflow.h +1 -0
@@ -1,4 +1,5 @@/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +#include <stdint.h> #ifndef __LINUX_OVERFLOW_H#define __LINUX_OVERFLOW_H
Signature · 1 line
2.51.0
Quoted 16 lines · Yichong Chen
Hi,
This series fixes build failures hit by:
make -C
tools/virtiotestIt is based on linux-next commit:
commit
3d5670d672ae("Add linux-next specific files for 20260626")Patch 1 adds
tools/virtiocompatibility definitions needed by current virtio headers when building thetools/virtiotests. Patch 2 makestools/include/linux/overflow.hincludestdint.hforSIZE_MAX, which is used by its size helper functions.
Quoted 8 lines
With the series applied, make -C
tools/virtiotest buildsvirtio_test,vringh_testandvhost_net_testsuccessfully.Tested on
x86_64and arm64 with:make -C
tools/virtioclean
make -Ctools/virtiotest
Thanks!
Quoted 28 lines
Changes in v2:
- Rebase and retest on linux-next.
- Add the missingasm/percpu_types.hcompat header reported by Eugenio.
- Keep thetools/virtiocompat definitions aligned with currentvirtio_features.hhelpers.
- Drop theslab.hkmalloc_obj/kmalloc_objs change because linux-next already defines them intools/virtio/linux/kernel.h.Yichong Chen (2):
tools/virtio: Add missing compat definitions forvhost_net_testtools/include: Includestdint.hforSIZE_MAXinoverflow.htools/include/linux/overflow.h | 1 + tools/virtio/asm/percpu_types.h | 7 +++ tools/virtio/linux/completion.h | 9 ++++ tools/virtio/linux/device.h | 1 + tools/virtio/linux/dma-mapping.h | 1 + tools/virtio/linux/mod_devicetable.h | 14 +++++ tools/virtio/linux/virtio_features.h | 79 ++++++++++++++++++++++++++++ 7 files changed, 112 insertions(+) create mode 100644 tools/virtio/asm/percpu_types.h create mode 100644 tools/virtio/linux/completion.h create mode 100644 tools/virtio/linux/mod_devicetable.h create mode 100644 tools/virtio/linux/virtio_features.h--
2.51.0
Re: [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h
In reply to Yichong ChenQuoted 5 lines · On Mon, 29 Jun 2026 10:21:24 +0800 Yichong Chen <[email protected]>…
tools/include/linux/overflow.husesSIZE_MAXin its size helper functions.Include
stdint.hso tools users that includeoverflow.hwithout anotherSIZE_MAXprovider can build.
On the latest mm-new reverting this patch (for test), I was able to build tools/virtio.
git checkout akpm.korg.mm/mm-new
[...]
HEAD is now at f5ea2fbe68e0c mm/swap, PM: hibernate: atomically replace hibernation pin $ git revert 9d462d8b9b705548451325ee4376dfd549e14aa2 -s --no-edit
[detached HEAD f2202247e38d9] Revert "tools/include: include stdint.h for SIZE_MAX in overflow.h"
Date: Wed Jul 1 06:33:03 2026 -0700
1 file changed, 1 deletion(-)
$ make -C tools/virtio/ clean
make: Entering directory '/home/lkhack/worktree.linux/tools/virtio'
rm -f *.o vringh_test virtio_test vhost_net_test vhost_test/*.o \
vhost_test/.*.cmd vhost_test/Module.symvers \
vhost_test/modules.order *.d
make: Leaving directory '/home/lkhack/worktree.linux/tools/virtio'
$ make -C tools/virtio/ test
make: Entering directory '/home/lkhack/worktree.linux/tools/virtio'
cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h -mfunction-return=thunk -fcf-protection=none -mindirect-branch-register -pthread -c -o virtio_test.o virtio_test.c
cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h -mfunction-return=thunk -fcf-protection=none -mindirect-branch-register -pthread -c -o virtio_ring.o ../../drivers/virtio/virtio_ring.c
cc -pthread virtio_test.o virtio_ring.o -o virtio_test
cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h -mfunction-return=thunk -fcf-protection=none -mindirect-branch-register -pthread -c -o vringh_test.o vringh_test.c
cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h -mfunction-return=thunk -fcf-protection=none -mindirect-branch-register -pthread -c -o vringh.o ../../drivers/vhost/vringh.c
cc -pthread vringh_test.o vringh.o virtio_ring.o -o vringh_test
cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow -fno-strict-aliasing -fno-common -MMD -U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h -mfunction-return=thunk -fcf-protection=none -mindirect-branch-register -pthread -c -o vhost_net_test.o vhost_net_test.c
cc -pthread vhost_net_test.o virtio_ring.o -o vhost_net_test
make: Leaving directory '/home/lkhack/worktree.linux/tools/virtio'
Am I missing something?
Quoted 11 lines
Signed-off-by Yichong Chen <[email protected]>--- tools/include/linux/overflow.h | 1 + 1 file changed, 1 insertion(+)tools/include/linux/overflow.h +0
-0
tools/include/linux/overflow.h line 4
Quoted 4 lines
tools/include/linux/overflow.h +1
-0@@ -1,4 +1,5 @@/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +#include <stdint.h> #ifndef __LINUX_OVERFLOW_H#define __LINUX_OVERFLOW_H
Shouldn't the include placed after #define __LINUX_OVERFLOW_H ?
Thanks,
SJ
[...]
Re: [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test
In reply to Yichong ChenQuoted 9 lines · On Mon, 29 Jun 2026 10:21:23 +0800 Yichong Chen <[email protected]>…
vhost_net_testbuildsvirtio_ring.cin userspace.Recent virtio headers pull in helper headers that are not provided by the
tools/virtiocompatibility layer, includingasm/percpu_types.h,linux/completion.h,linux/mod_devicetable.handlinux/virtio_features.h.Add the missing compat definitions and the DMA attribute used by the current virtio ring code.
I confirmed this patch fixes the build on my setup.
Quoted 2 lines
Signed-off-by Yichong Chen <[email protected]>
Thanks,
SJ
[...]
Re: [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h
In reply to SJ ParkHi SJ,
You are right. The include should be inside the header guard, after #define __LINUX_OVERFLOW_H.
I will fix it in the next version.
Thanks,
Yichong