* [PATCH v2 0/2] tools: Fix tools/virtio test build
@ 2026-06-29 2:21 Yichong Chen
2026-06-29 2:21 ` [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test Yichong Chen
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Yichong Chen @ 2026-06-29 2:21 UTC (permalink / raw)
To: mst, jasowang, xuanzhuo, eperezma
Cc: akpm, rppt, ljs, pabeni, chenyichong, linux-kernel,
virtualization
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
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test
2026-06-29 2:21 [PATCH v2 0/2] tools: Fix tools/virtio test build Yichong Chen
@ 2026-06-29 2:21 ` Yichong Chen
2026-07-01 13:36 ` SJ Park
2026-06-29 2:21 ` [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h Yichong Chen
2026-06-29 9:09 ` [PATCH v2 0/2] tools: Fix tools/virtio test build Eugenio Perez Martin
2 siblings, 1 reply; 7+ messages in thread
From: Yichong Chen @ 2026-06-29 2:21 UTC (permalink / raw)
To: mst, jasowang, xuanzhuo, eperezma
Cc: akpm, rppt, ljs, pabeni, chenyichong, linux-kernel,
virtualization
vhost_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.
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
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
diff --git a/tools/virtio/asm/percpu_types.h b/tools/virtio/asm/percpu_types.h
new file mode 100644
index 000000000000..4eb53d93c099
--- /dev/null
+++ b/tools/virtio/asm/percpu_types.h
@@ -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 */
diff --git a/tools/virtio/linux/completion.h b/tools/virtio/linux/completion.h
new file mode 100644
index 000000000000..5e54b679721b
--- /dev/null
+++ b/tools/virtio/linux/completion.h
@@ -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 */
diff --git a/tools/virtio/linux/device.h b/tools/virtio/linux/device.h
index 075c2140d975..abf100cb0023 100644
--- a/tools/virtio/linux/device.h
+++ b/tools/virtio/linux/device.h
@@ -1,4 +1,5 @@
#ifndef LINUX_DEVICE_H
+#define LINUX_DEVICE_H
struct device {
void *parent;
diff --git a/tools/virtio/linux/dma-mapping.h b/tools/virtio/linux/dma-mapping.h
index 8d1a16cb20db..b9fc5e8338e3 100644
--- a/tools/virtio/linux/dma-mapping.h
+++ b/tools/virtio/linux/dma-mapping.h
@@ -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
diff --git a/tools/virtio/linux/mod_devicetable.h b/tools/virtio/linux/mod_devicetable.h
new file mode 100644
index 000000000000..3ba594b8229d
--- /dev/null
+++ b/tools/virtio/linux/mod_devicetable.h
@@ -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 */
diff --git a/tools/virtio/linux/virtio_features.h b/tools/virtio/linux/virtio_features.h
new file mode 100644
index 000000000000..04cbb9622ec7
--- /dev/null
+++ b/tools/virtio/linux/virtio_features.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_VIRTIO_FEATURES_H
+#define _LINUX_VIRTIO_FEATURES_H
+
+#include <linux/bug.h>
+#include <linux/string.h>
+#include <linux/types.h>
+
+#define VIRTIO_FEATURES_U64S 2
+#define VIRTIO_FEATURES_BITS (VIRTIO_FEATURES_U64S * 64)
+
+#define VIRTIO_BIT(b) (1ULL << ((b) & 0x3f))
+#define VIRTIO_U64(b) ((b) >> 6)
+
+#define VIRTIO_DECLARE_FEATURES(name) \
+ union { \
+ u64 name; \
+ u64 name##_array[VIRTIO_FEATURES_U64S];\
+ }
+
+static inline bool virtio_features_chk_bit(unsigned int bit)
+{
+ return bit < VIRTIO_FEATURES_BITS;
+}
+
+static inline bool virtio_features_test_bit(const u64 *features,
+ unsigned int bit)
+{
+ return virtio_features_chk_bit(bit) &&
+ !!(features[VIRTIO_U64(bit)] & VIRTIO_BIT(bit));
+}
+
+static inline void virtio_features_set_bit(u64 *features, unsigned int bit)
+{
+ if (virtio_features_chk_bit(bit))
+ features[VIRTIO_U64(bit)] |= VIRTIO_BIT(bit);
+}
+
+static inline void virtio_features_clear_bit(u64 *features, unsigned int bit)
+{
+ if (virtio_features_chk_bit(bit))
+ features[VIRTIO_U64(bit)] &= ~VIRTIO_BIT(bit);
+}
+
+static inline void virtio_features_zero(u64 *features)
+{
+ memset(features, 0, sizeof(features[0]) * VIRTIO_FEATURES_U64S);
+}
+
+static inline void virtio_features_from_u64(u64 *features, u64 from)
+{
+ virtio_features_zero(features);
+ features[0] = from;
+}
+
+static inline bool virtio_features_equal(const u64 *f1, const u64 *f2)
+{
+ int i;
+
+ for (i = 0; i < VIRTIO_FEATURES_U64S; ++i)
+ if (f1[i] != f2[i])
+ return false;
+ return true;
+}
+
+static inline void virtio_features_copy(u64 *to, const u64 *from)
+{
+ memcpy(to, from, sizeof(to[0]) * VIRTIO_FEATURES_U64S);
+}
+
+static inline void virtio_features_andnot(u64 *to, const u64 *f1, const u64 *f2)
+{
+ int i;
+
+ for (i = 0; i < VIRTIO_FEATURES_U64S; i++)
+ to[i] = f1[i] & ~f2[i];
+}
+
+#endif /* _LINUX_VIRTIO_FEATURES_H */
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h
2026-06-29 2:21 [PATCH v2 0/2] tools: Fix tools/virtio test build Yichong Chen
2026-06-29 2:21 ` [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test Yichong Chen
@ 2026-06-29 2:21 ` Yichong Chen
2026-07-01 13:35 ` SJ Park
2026-06-29 9:09 ` [PATCH v2 0/2] tools: Fix tools/virtio test build Eugenio Perez Martin
2 siblings, 1 reply; 7+ messages in thread
From: Yichong Chen @ 2026-06-29 2:21 UTC (permalink / raw)
To: mst, jasowang, xuanzhuo, eperezma
Cc: akpm, rppt, ljs, pabeni, chenyichong, linux-kernel,
virtualization
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.
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
tools/include/linux/overflow.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/include/linux/overflow.h b/tools/include/linux/overflow.h
index 3427d7880326..98963688143f 100644
--- a/tools/include/linux/overflow.h
+++ b/tools/include/linux/overflow.h
@@ -1,4 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+#include <stdint.h>
#ifndef __LINUX_OVERFLOW_H
#define __LINUX_OVERFLOW_H
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] tools: Fix tools/virtio test build
2026-06-29 2:21 [PATCH v2 0/2] tools: Fix tools/virtio test build Yichong Chen
2026-06-29 2:21 ` [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test Yichong Chen
2026-06-29 2:21 ` [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h Yichong Chen
@ 2026-06-29 9:09 ` Eugenio Perez Martin
2 siblings, 0 replies; 7+ messages in thread
From: Eugenio Perez Martin @ 2026-06-29 9:09 UTC (permalink / raw)
To: Yichong Chen
Cc: mst, jasowang, xuanzhuo, akpm, rppt, ljs, pabeni, linux-kernel,
virtualization
On Mon, Jun 29, 2026 at 4:22 AM Yichong Chen <chenyichong@uniontech.com> wrote:
>
> 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
>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Thanks!
> 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
>
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h
2026-06-29 2:21 ` [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h Yichong Chen
@ 2026-07-01 13:35 ` SJ Park
2026-07-02 2:20 ` Yichong Chen
0 siblings, 1 reply; 7+ messages in thread
From: SJ Park @ 2026-07-01 13:35 UTC (permalink / raw)
To: Yichong Chen
Cc: SJ Park, mst, jasowang, xuanzhuo, eperezma, akpm, rppt, ljs,
pabeni, linux-kernel, virtualization
On Mon, 29 Jun 2026 10:21:24 +0800 Yichong Chen <chenyichong@uniontech.com> wrote:
> 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.
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?
>
> Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
> ---
> tools/include/linux/overflow.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/include/linux/overflow.h b/tools/include/linux/overflow.h
> index 3427d7880326..98963688143f 100644
> --- a/tools/include/linux/overflow.h
> +++ b/tools/include/linux/overflow.h
> @@ -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
[...]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test
2026-06-29 2:21 ` [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test Yichong Chen
@ 2026-07-01 13:36 ` SJ Park
0 siblings, 0 replies; 7+ messages in thread
From: SJ Park @ 2026-07-01 13:36 UTC (permalink / raw)
To: Yichong Chen
Cc: SJ Park, mst, jasowang, xuanzhuo, eperezma, akpm, rppt, ljs,
pabeni, linux-kernel, virtualization
On Mon, 29 Jun 2026 10:21:23 +0800 Yichong Chen <chenyichong@uniontech.com> wrote:
> vhost_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.
I confirmed this patch fixes the build on my setup.
>
> Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Tested-by: SJ Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h
2026-07-01 13:35 ` SJ Park
@ 2026-07-02 2:20 ` Yichong Chen
0 siblings, 0 replies; 7+ messages in thread
From: Yichong Chen @ 2026-07-02 2:20 UTC (permalink / raw)
To: sj
Cc: akpm, chenyichong, eperezma, jasowang, linux-kernel, ljs, mst,
pabeni, rppt, virtualization, xuanzhuo
Hi 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-07-02 2:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 2:21 [PATCH v2 0/2] tools: Fix tools/virtio test build Yichong Chen
2026-06-29 2:21 ` [PATCH v2 1/2] tools/virtio: Add missing compat definitions for vhost_net_test Yichong Chen
2026-07-01 13:36 ` SJ Park
2026-06-29 2:21 ` [PATCH v2 2/2] tools/include: Include stdint.h for SIZE_MAX in overflow.h Yichong Chen
2026-07-01 13:35 ` SJ Park
2026-07-02 2:20 ` Yichong Chen
2026-06-29 9:09 ` [PATCH v2 0/2] tools: Fix tools/virtio test build Eugenio Perez Martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox