tools: Fix tools/virtio test build
v3 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 v3:
- Move the stdint.h include inside the overflow.h include guard, as SJ suggested.
- Add Tested-by from SJ Park to patch 1.
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 | 2 + 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, 113 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 v3 1/2 tools/virtio: Add missing compat definitions for vhost_net_test
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.
--- 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
PATCH v3 2/2 tools/include: Include stdint.h for SIZE_MAX in overflow.h
In reply to Yichong Chentools/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 | 2 ++ 1 file changed, 2 insertions(+)
tools/include/linux/overflow.h +2 -0
@@ -2,6 +2,8 @@#ifndef __LINUX_OVERFLOW_H#define __LINUX_OVERFLOW_H +#include <stdint.h> +#include <linux/compiler.h> /*
Signature · 1 line
2.51.0