* [PATCH 01/14] tools/virtio: fix up compiler.h stub
[not found] <cover.1764873799.git.mst@redhat.com>
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 02/14] virtio: make it self-contained Michael S. Tsirkin
` (13 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Add #undef __user before and after including compiler_types.h to avoid
redefinition warnings when compiling with system headers that also
define __user. This allows tools/virtio to build without warnings.
Additionally, stub out __must_check
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/compiler.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/virtio/linux/compiler.h b/tools/virtio/linux/compiler.h
index 204ef0e9f542..7f9e308f3880 100644
--- a/tools/virtio/linux/compiler.h
+++ b/tools/virtio/linux/compiler.h
@@ -2,7 +2,11 @@
#ifndef LINUX_COMPILER_H
#define LINUX_COMPILER_H
+/* Avoid redefinition warnings */
+#undef __user
#include "../../../include/linux/compiler_types.h"
+#undef __user
+#define __user
#define WRITE_ONCE(var, val) \
(*((volatile typeof(val) *)(&(var))) = (val))
@@ -35,4 +39,6 @@
__v; \
})
+#define __must_check
+
#endif
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 02/14] virtio: make it self-contained
[not found] <cover.1764873799.git.mst@redhat.com>
2025-12-04 18:46 ` [PATCH 01/14] tools/virtio: fix up compiler.h stub Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 03/14] tools/virtio: use kernel's virtio.h Michael S. Tsirkin
` (12 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
virtio.h uses struct module, add a forward declaration to
make the header self-contained.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/linux/virtio.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 132a474e5914..3626eb694728 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -13,6 +13,8 @@
#include <linux/completion.h>
#include <linux/virtio_features.h>
+struct module;
+
/**
* struct virtqueue - a queue to register buffers for sending or receiving.
* @list: the chain of virtqueues for this device
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 03/14] tools/virtio: use kernel's virtio.h
[not found] <cover.1764873799.git.mst@redhat.com>
2025-12-04 18:46 ` [PATCH 01/14] tools/virtio: fix up compiler.h stub Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 02/14] virtio: make it self-contained Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 04/14] tools/virtio: add struct module forward declaration Michael S. Tsirkin
` (11 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Replace virtio stubs with an include of the kernel header.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/virtio.h | 73 +------------------------------------
1 file changed, 1 insertion(+), 72 deletions(-)
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h
index 5d3440f474dd..d3029c944589 100644
--- a/tools/virtio/linux/virtio.h
+++ b/tools/virtio/linux/virtio.h
@@ -1,72 +1 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef LINUX_VIRTIO_H
-#define LINUX_VIRTIO_H
-#include <linux/scatterlist.h>
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-
-struct device {
- void *parent;
-};
-
-struct virtio_device {
- struct device dev;
- u64 features;
- struct list_head vqs;
- spinlock_t vqs_list_lock;
- const struct virtio_config_ops *config;
-};
-
-struct virtqueue {
- struct list_head list;
- void (*callback)(struct virtqueue *vq);
- const char *name;
- struct virtio_device *vdev;
- unsigned int index;
- unsigned int num_free;
- unsigned int num_max;
- void *priv;
- bool reset;
-};
-
-/* Interfaces exported by virtio_ring. */
-int virtqueue_add_sgs(struct virtqueue *vq,
- struct scatterlist *sgs[],
- unsigned int out_sgs,
- unsigned int in_sgs,
- void *data,
- gfp_t gfp);
-
-int virtqueue_add_outbuf(struct virtqueue *vq,
- struct scatterlist sg[], unsigned int num,
- void *data,
- gfp_t gfp);
-
-int virtqueue_add_inbuf(struct virtqueue *vq,
- struct scatterlist sg[], unsigned int num,
- void *data,
- gfp_t gfp);
-
-bool virtqueue_kick(struct virtqueue *vq);
-
-void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len);
-
-void virtqueue_disable_cb(struct virtqueue *vq);
-
-bool virtqueue_enable_cb(struct virtqueue *vq);
-bool virtqueue_enable_cb_delayed(struct virtqueue *vq);
-
-void *virtqueue_detach_unused_buf(struct virtqueue *vq);
-struct virtqueue *vring_new_virtqueue(unsigned int index,
- unsigned int num,
- unsigned int vring_align,
- struct virtio_device *vdev,
- bool weak_barriers,
- bool ctx,
- void *pages,
- bool (*notify)(struct virtqueue *vq),
- void (*callback)(struct virtqueue *vq),
- const char *name);
-void vring_del_virtqueue(struct virtqueue *vq);
-
-#endif
+#include <../../include/linux/virtio.h>
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/14] tools/virtio: add struct module forward declaration
[not found] <cover.1764873799.git.mst@redhat.com>
` (2 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 03/14] tools/virtio: use kernel's virtio.h Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 05/14] tools/virtio: stub DMA mapping functions Michael S. Tsirkin
` (10 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Declarate struct module in our linux/module.h stub.
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/module.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/virtio/linux/module.h b/tools/virtio/linux/module.h
index b91681fc1571..b842ae9d870c 100644
--- a/tools/virtio/linux/module.h
+++ b/tools/virtio/linux/module.h
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/export.h>
+struct module;
+
#define MODULE_LICENSE(__MODULE_LICENSE_value) \
static __attribute__((unused)) const char *__MODULE_LICENSE_name = \
__MODULE_LICENSE_value
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 05/14] tools/virtio: stub DMA mapping functions
[not found] <cover.1764873799.git.mst@redhat.com>
` (3 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 04/14] tools/virtio: add struct module forward declaration Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 06/14] tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs Michael S. Tsirkin
` (9 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Add dma_map_page_attrs and dma_unmap_page_attrs stubs.
Follow the same pattern as existing DMA mapping stubs.
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/dma-mapping.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/virtio/linux/dma-mapping.h b/tools/virtio/linux/dma-mapping.h
index 095958461788..fddfa2fbb276 100644
--- a/tools/virtio/linux/dma-mapping.h
+++ b/tools/virtio/linux/dma-mapping.h
@@ -22,6 +22,7 @@ enum dma_data_direction {
#define dma_free_coherent(d, s, p, h) kfree(p)
#define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o))
+#define dma_map_page_attrs(d, p, o, s, dir, a) (page_to_phys(p) + (o))
#define dma_map_single(d, p, s, dir) (virt_to_phys(p))
#define dma_map_single_attrs(d, p, s, dir, a) (virt_to_phys(p))
@@ -29,6 +30,9 @@ enum dma_data_direction {
#define dma_unmap_single(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
#define dma_unmap_page(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
+#define dma_unmap_page_attrs(d, a, s, r, t) do { \
+ (void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \
+} while (0)
#define sg_dma_address(sg) (0)
#define sg_dma_len(sg) (0)
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 06/14] tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs
[not found] <cover.1764873799.git.mst@redhat.com>
` (4 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 05/14] tools/virtio: stub DMA mapping functions Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 07/14] tools/virtio: add ucopysize.h stub Michael S. Tsirkin
` (8 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Add dev_WARN_ONCE and is_vmalloc_addr stubs needed by virtio_ring.c.
is_vmalloc_addr stub always returns false - that's fine since it's
merely a sanity check.
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/kernel.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index 6702008f7f5c..d7fc70b68a2b 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -14,6 +14,7 @@
#include <linux/log2.h>
#include <linux/types.h>
#include <linux/overflow.h>
+#include <linux/limits.h>
#include <linux/list.h>
#include <linux/printk.h>
#include <linux/bug.h>
@@ -135,6 +136,14 @@ static inline void *krealloc_array(void *p, size_t new_n, size_t new_size, gfp_t
#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
#define dev_warn_once(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
+#define dev_WARN_ONCE(dev, condition, format...) \
+ WARN_ONCE(condition, format)
+
+static inline bool is_vmalloc_addr(const void *x)
+{
+ return false;
+}
+
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 07/14] tools/virtio: add ucopysize.h stub
[not found] <cover.1764873799.git.mst@redhat.com>
` (5 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 06/14] tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 08/14] tools/virtio: pass KCFLAGS to module build Michael S. Tsirkin
` (7 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Add ucopysize.h with stub implementations of check_object_size,
copy_overflow, and check_copy_size.
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/ucopysize.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 tools/virtio/linux/ucopysize.h
diff --git a/tools/virtio/linux/ucopysize.h b/tools/virtio/linux/ucopysize.h
new file mode 100644
index 000000000000..8beb7755d060
--- /dev/null
+++ b/tools/virtio/linux/ucopysize.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_UCOPYSIZE_H__
+#define __LINUX_UCOPYSIZE_H__
+
+#include <linux/bug.h>
+
+static inline void check_object_size(const void *ptr, unsigned long n,
+ bool to_user)
+{ }
+
+static inline void copy_overflow(int size, unsigned long count)
+{
+}
+
+static __always_inline __must_check bool
+check_copy_size(const void *addr, size_t bytes, bool is_source)
+{
+ return true;
+}
+
+#endif /* __LINUX_UCOPYSIZE_H__ */
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 08/14] tools/virtio: pass KCFLAGS to module build
[not found] <cover.1764873799.git.mst@redhat.com>
` (6 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 07/14] tools/virtio: add ucopysize.h stub Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 09/14] tools/virtio: add struct cpumask to cpumask.h Michael S. Tsirkin
` (6 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Update the mod target to pass KCFLAGS with the in-tree vhost driver
include path. This way vhost_test can find vhost headers.
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
index e25e99c1c3b7..a60316211df6 100644
--- a/tools/virtio/Makefile
+++ b/tools/virtio/Makefile
@@ -20,8 +20,9 @@ CFLAGS += -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/ -I ../
CFLAGS += -pthread
LDFLAGS += -pthread
vpath %.c ../../drivers/virtio ../../drivers/vhost
+BUILD=KCFLAGS="-I "`pwd`/../../drivers/vhost ${MAKE} -C `pwd`/../.. V=${V}
mod:
- ${MAKE} -C `pwd`/../.. M=`pwd`/vhost_test V=${V}
+ ${BUILD} M=`pwd`/vhost_test
#oot: build vhost as an out of tree module for a distro kernel
#no effort is taken to make it actually build or work, but tends to mostly work
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 09/14] tools/virtio: add struct cpumask to cpumask.h
[not found] <cover.1764873799.git.mst@redhat.com>
` (7 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 08/14] tools/virtio: pass KCFLAGS to module build Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 10/14] tools/virtio: stub might_sleep and synchronize_rcu Michael S. Tsirkin
` (5 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Add struct cpumask stub used by virtio_config.h.
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/cpumask.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/virtio/linux/cpumask.h b/tools/virtio/linux/cpumask.h
index 307da69d6b26..38ffc00e149d 100644
--- a/tools/virtio/linux/cpumask.h
+++ b/tools/virtio/linux/cpumask.h
@@ -4,4 +4,8 @@
#include <linux/kernel.h>
+struct cpumask {
+ unsigned long bits[1];
+};
+
#endif /* _LINUX_CPUMASK_H */
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 10/14] tools/virtio: stub might_sleep and synchronize_rcu
[not found] <cover.1764873799.git.mst@redhat.com>
` (8 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 09/14] tools/virtio: add struct cpumask to cpumask.h Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 11/14] tools/virtio: switch to kernel's virtio_config.h Michael S. Tsirkin
` (4 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Add might_sleep() and synchronize_rcu() stubs needed by virtio_config.h.
might_sleep() is a no-op, synchronize_rcu doesn't work but we don't
need it to.
Created using Cursor CLI.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/kernel.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index d7fc70b68a2b..416d02703f61 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -144,6 +144,13 @@ static inline bool is_vmalloc_addr(const void *x)
return false;
}
+#define might_sleep() do { } while (0)
+
+static inline void synchronize_rcu(void)
+{
+ assert(0);
+}
+
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 11/14] tools/virtio: switch to kernel's virtio_config.h
[not found] <cover.1764873799.git.mst@redhat.com>
` (9 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 10/14] tools/virtio: stub might_sleep and synchronize_rcu Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 12/14] virtio_features: make it self-contained Michael S. Tsirkin
` (3 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Drops stubs in virtio_config.h, use the kernel's version instead - we
are now activly developing it, so the stub became too hard to maintain.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/virtio_config.h | 102 +----------------------------
1 file changed, 1 insertion(+), 101 deletions(-)
diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h
index 42a564f22f2d..a0cd3f9a3111 100644
--- a/tools/virtio/linux/virtio_config.h
+++ b/tools/virtio/linux/virtio_config.h
@@ -1,101 +1 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef LINUX_VIRTIO_CONFIG_H
-#define LINUX_VIRTIO_CONFIG_H
-#include <linux/virtio_byteorder.h>
-#include <linux/virtio.h>
-#include <uapi/linux/virtio_config.h>
-
-struct virtio_config_ops {
- int (*disable_vq_and_reset)(struct virtqueue *vq);
- int (*enable_vq_after_reset)(struct virtqueue *vq);
-};
-
-/*
- * __virtio_test_bit - helper to test feature bits. For use by transports.
- * Devices should normally use virtio_has_feature,
- * which includes more checks.
- * @vdev: the device
- * @fbit: the feature bit
- */
-static inline bool __virtio_test_bit(const struct virtio_device *vdev,
- unsigned int fbit)
-{
- return vdev->features & (1ULL << fbit);
-}
-
-/**
- * __virtio_set_bit - helper to set feature bits. For use by transports.
- * @vdev: the device
- * @fbit: the feature bit
- */
-static inline void __virtio_set_bit(struct virtio_device *vdev,
- unsigned int fbit)
-{
- vdev->features |= (1ULL << fbit);
-}
-
-/**
- * __virtio_clear_bit - helper to clear feature bits. For use by transports.
- * @vdev: the device
- * @fbit: the feature bit
- */
-static inline void __virtio_clear_bit(struct virtio_device *vdev,
- unsigned int fbit)
-{
- vdev->features &= ~(1ULL << fbit);
-}
-
-#define virtio_has_feature(dev, feature) \
- (__virtio_test_bit((dev), feature))
-
-/**
- * virtio_has_dma_quirk - determine whether this device has the DMA quirk
- * @vdev: the device
- */
-static inline bool virtio_has_dma_quirk(const struct virtio_device *vdev)
-{
- /*
- * Note the reverse polarity of the quirk feature (compared to most
- * other features), this is for compatibility with legacy systems.
- */
- return !virtio_has_feature(vdev, VIRTIO_F_ACCESS_PLATFORM);
-}
-
-static inline bool virtio_is_little_endian(struct virtio_device *vdev)
-{
- return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||
- virtio_legacy_is_little_endian();
-}
-
-/* Memory accessors */
-static inline u16 virtio16_to_cpu(struct virtio_device *vdev, __virtio16 val)
-{
- return __virtio16_to_cpu(virtio_is_little_endian(vdev), val);
-}
-
-static inline __virtio16 cpu_to_virtio16(struct virtio_device *vdev, u16 val)
-{
- return __cpu_to_virtio16(virtio_is_little_endian(vdev), val);
-}
-
-static inline u32 virtio32_to_cpu(struct virtio_device *vdev, __virtio32 val)
-{
- return __virtio32_to_cpu(virtio_is_little_endian(vdev), val);
-}
-
-static inline __virtio32 cpu_to_virtio32(struct virtio_device *vdev, u32 val)
-{
- return __cpu_to_virtio32(virtio_is_little_endian(vdev), val);
-}
-
-static inline u64 virtio64_to_cpu(struct virtio_device *vdev, __virtio64 val)
-{
- return __virtio64_to_cpu(virtio_is_little_endian(vdev), val);
-}
-
-static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val)
-{
- return __cpu_to_virtio64(virtio_is_little_endian(vdev), val);
-}
-
-#endif
+#include "../../include/linux/virtio_config.h"
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 12/14] virtio_features: make it self-contained
[not found] <cover.1764873799.git.mst@redhat.com>
` (10 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 11/14] tools/virtio: switch to kernel's virtio_config.h Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 13/14] tools/virtio: fix up oot build Michael S. Tsirkin
` (2 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
virtio_features.h uses WARN_ON_ONCE and memset so it must
include linux/bug.h and linux/string.h
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/linux/virtio_features.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/virtio_features.h b/include/linux/virtio_features.h
index ea2ad8717882..ce59ea91f474 100644
--- a/include/linux/virtio_features.h
+++ b/include/linux/virtio_features.h
@@ -3,6 +3,8 @@
#define _LINUX_VIRTIO_FEATURES_H
#include <linux/bits.h>
+#include <linux/bug.h>
+#include <linux/string.h>
#define VIRTIO_FEATURES_U64S 2
#define VIRTIO_FEATURES_BITS (VIRTIO_FEATURES_U64S * 64)
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 13/14] tools/virtio: fix up oot build
[not found] <cover.1764873799.git.mst@redhat.com>
` (11 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 12/14] virtio_features: make it self-contained Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 14/14] tools/virtio: add device, device_driver stubs Michael S. Tsirkin
2025-12-09 13:09 ` [PATCH 00/14] tools/virtio: cleanups, fixes Michael S. Tsirkin
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
oot build tends to help uncover bugs so it's worth keeping around,
as long as it's low effort.
add stubs for a couple of macros virtio gained recently,
and disable vdpa in the test build.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/Makefile | 5 +++--
tools/virtio/oot-stubs.h | 10 ++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
create mode 100644 tools/virtio/oot-stubs.h
diff --git a/tools/virtio/Makefile b/tools/virtio/Makefile
index a60316211df6..2cac5fd4b979 100644
--- a/tools/virtio/Makefile
+++ b/tools/virtio/Makefile
@@ -38,8 +38,9 @@ OOT_CONFIGS=\
CONFIG_VHOST_NET=n \
CONFIG_VHOST_SCSI=n \
CONFIG_VHOST_VSOCK=n \
- CONFIG_VHOST_RING=n
-OOT_BUILD=KCFLAGS="-I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
+ CONFIG_VHOST_RING=n \
+ CONFIG_VHOST_VDPA=n
+OOT_BUILD=KCFLAGS="-include "`pwd`"/oot-stubs.h -I "${OOT_VHOST} ${MAKE} -C ${OOT_KSRC} V=${V}
oot-build:
echo "UNSUPPORTED! Don't use the resulting modules in production!"
${OOT_BUILD} M=`pwd`/vhost_test
diff --git a/tools/virtio/oot-stubs.h b/tools/virtio/oot-stubs.h
new file mode 100644
index 000000000000..69e059cd14d6
--- /dev/null
+++ b/tools/virtio/oot-stubs.h
@@ -0,0 +1,10 @@
+#include <linux/bug.h>
+#include <linux/string.h>
+#include <linux/virtio_features.h>
+
+#ifndef VIRTIO_FEATURES_BITS
+#define VIRTIO_FEATURES_BITS 128
+#endif
+#ifndef VIRTIO_U64
+#define VIRTIO_U64(b) ((b) >> 6)
+#endif
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 14/14] tools/virtio: add device, device_driver stubs
[not found] <cover.1764873799.git.mst@redhat.com>
` (12 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 13/14] tools/virtio: fix up oot build Michael S. Tsirkin
@ 2025-12-04 18:46 ` Michael S. Tsirkin
2025-12-09 13:09 ` [PATCH 00/14] tools/virtio: cleanups, fixes Michael S. Tsirkin
14 siblings, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-04 18:46 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, Xuan Zhuo, Eugenio Pérez, virtualization
Add stubs needed by virtio.h
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
tools/virtio/linux/device.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/virtio/linux/device.h b/tools/virtio/linux/device.h
index 4ad7e1df0db5..075c2140d975 100644
--- a/tools/virtio/linux/device.h
+++ b/tools/virtio/linux/device.h
@@ -1,2 +1,10 @@
#ifndef LINUX_DEVICE_H
+
+struct device {
+ void *parent;
+};
+
+struct device_driver {
+ const char *name;
+};
#endif
--
MST
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH 00/14] tools/virtio: cleanups, fixes
[not found] <cover.1764873799.git.mst@redhat.com>
` (13 preceding siblings ...)
2025-12-04 18:46 ` [PATCH 14/14] tools/virtio: add device, device_driver stubs Michael S. Tsirkin
@ 2025-12-09 13:09 ` Michael S. Tsirkin
2025-12-10 6:24 ` Jason Wang
14 siblings, 1 reply; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-09 13:09 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason Wang, virtualization
On Thu, Dec 04, 2025 at 01:46:01PM -0500, Michael S. Tsirkin wrote:
> Recent virtio changes brought about build errors for tools/virtio,
> as usual. I did some refactoring to hopefully reduce maintainance
> load going forward.
>
> Adding stubs is tedious and seemed a perfect fit for cursor -
> so I used it for that, then rewrote some commits and accepted
> others. commit logs I've rewritten.
>
> Found and fixed a couple of minor bugs while doing this - that
> part's all mine.
Jason, any feedback?
> Michael S. Tsirkin (14):
> tools/virtio: fix up compiler.h stub
> virtio: make it self-contained
> tools/virtio: use kernel's virtio.h
> tools/virtio: add struct module forward declaration
> tools/virtio: stub DMA mapping functions
> tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs
> tools/virtio: add ucopysize.h stub
> tools/virtio: pass KCFLAGS to module build
> tools/virtio: add struct cpumask to cpumask.h
> tools/virtio: stub might_sleep and synchronize_rcu
> tools/virtio: switch to kernel's virtio_config.h
> virtio_features: make it self-contained
> tools/virtio: fix up oot build
> tools/virtio: add device, device_driver stubs
>
> include/linux/virtio.h | 2 +
> include/linux/virtio_features.h | 2 +
> tools/virtio/Makefile | 8 ++-
> tools/virtio/linux/compiler.h | 6 ++
> tools/virtio/linux/cpumask.h | 4 ++
> tools/virtio/linux/device.h | 8 +++
> tools/virtio/linux/dma-mapping.h | 4 ++
> tools/virtio/linux/kernel.h | 16 +++++
> tools/virtio/linux/module.h | 2 +
> tools/virtio/linux/ucopysize.h | 21 ++++++
> tools/virtio/linux/virtio.h | 73 +--------------------
> tools/virtio/linux/virtio_config.h | 102 +----------------------------
> tools/virtio/oot-stubs.h | 10 +++
> 13 files changed, 82 insertions(+), 176 deletions(-)
> create mode 100644 tools/virtio/linux/ucopysize.h
> create mode 100644 tools/virtio/oot-stubs.h
>
> --
> MST
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/14] tools/virtio: cleanups, fixes
2025-12-09 13:09 ` [PATCH 00/14] tools/virtio: cleanups, fixes Michael S. Tsirkin
@ 2025-12-10 6:24 ` Jason Wang
2025-12-10 7:01 ` Michael S. Tsirkin
2025-12-11 7:12 ` Michael S. Tsirkin
0 siblings, 2 replies; 19+ messages in thread
From: Jason Wang @ 2025-12-10 6:24 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: linux-kernel, virtualization
On Tue, Dec 9, 2025 at 9:09 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Thu, Dec 04, 2025 at 01:46:01PM -0500, Michael S. Tsirkin wrote:
> > Recent virtio changes brought about build errors for tools/virtio,
> > as usual. I did some refactoring to hopefully reduce maintainance
> > load going forward.
> >
> > Adding stubs is tedious and seemed a perfect fit for cursor -
> > so I used it for that, then rewrote some commits and accepted
> > others. commit logs I've rewritten.
> >
> > Found and fixed a couple of minor bugs while doing this - that
> > part's all mine.
>
>
> Jason, any feedback?
Looks good to me. But I wonder, it looks like synchronization will
become more and more a burden in the future, I wonder if it's time to
switch to using uAPI instead of trying to reuse kernel virtio core to
test vhost?
Thanks
>
> > Michael S. Tsirkin (14):
> > tools/virtio: fix up compiler.h stub
> > virtio: make it self-contained
> > tools/virtio: use kernel's virtio.h
> > tools/virtio: add struct module forward declaration
> > tools/virtio: stub DMA mapping functions
> > tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs
> > tools/virtio: add ucopysize.h stub
> > tools/virtio: pass KCFLAGS to module build
> > tools/virtio: add struct cpumask to cpumask.h
> > tools/virtio: stub might_sleep and synchronize_rcu
> > tools/virtio: switch to kernel's virtio_config.h
> > virtio_features: make it self-contained
> > tools/virtio: fix up oot build
> > tools/virtio: add device, device_driver stubs
> >
> > include/linux/virtio.h | 2 +
> > include/linux/virtio_features.h | 2 +
> > tools/virtio/Makefile | 8 ++-
> > tools/virtio/linux/compiler.h | 6 ++
> > tools/virtio/linux/cpumask.h | 4 ++
> > tools/virtio/linux/device.h | 8 +++
> > tools/virtio/linux/dma-mapping.h | 4 ++
> > tools/virtio/linux/kernel.h | 16 +++++
> > tools/virtio/linux/module.h | 2 +
> > tools/virtio/linux/ucopysize.h | 21 ++++++
> > tools/virtio/linux/virtio.h | 73 +--------------------
> > tools/virtio/linux/virtio_config.h | 102 +----------------------------
> > tools/virtio/oot-stubs.h | 10 +++
> > 13 files changed, 82 insertions(+), 176 deletions(-)
> > create mode 100644 tools/virtio/linux/ucopysize.h
> > create mode 100644 tools/virtio/oot-stubs.h
> >
> > --
> > MST
> >
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/14] tools/virtio: cleanups, fixes
2025-12-10 6:24 ` Jason Wang
@ 2025-12-10 7:01 ` Michael S. Tsirkin
2025-12-11 7:12 ` Michael S. Tsirkin
1 sibling, 0 replies; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-10 7:01 UTC (permalink / raw)
To: Jason Wang; +Cc: linux-kernel, virtualization
On Wed, Dec 10, 2025 at 02:24:02PM +0800, Jason Wang wrote:
> On Tue, Dec 9, 2025 at 9:09 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Thu, Dec 04, 2025 at 01:46:01PM -0500, Michael S. Tsirkin wrote:
> > > Recent virtio changes brought about build errors for tools/virtio,
> > > as usual. I did some refactoring to hopefully reduce maintainance
> > > load going forward.
> > >
> > > Adding stubs is tedious and seemed a perfect fit for cursor -
> > > so I used it for that, then rewrote some commits and accepted
> > > others. commit logs I've rewritten.
> > >
> > > Found and fixed a couple of minor bugs while doing this - that
> > > part's all mine.
> >
> >
> > Jason, any feedback?
>
> Looks good to me. But I wonder, it looks like synchronization will
> become more and more a burden in the future, I wonder if it's time to
> switch to using uAPI instead of trying to reuse kernel virtio core to
> test vhost?
>
> Thanks
Nothing prevents you from adding more tests, for sure.
UAPI - will likely not get us there. But if you have the energy to
add selftests, maybe.
> >
> > > Michael S. Tsirkin (14):
> > > tools/virtio: fix up compiler.h stub
> > > virtio: make it self-contained
> > > tools/virtio: use kernel's virtio.h
> > > tools/virtio: add struct module forward declaration
> > > tools/virtio: stub DMA mapping functions
> > > tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs
> > > tools/virtio: add ucopysize.h stub
> > > tools/virtio: pass KCFLAGS to module build
> > > tools/virtio: add struct cpumask to cpumask.h
> > > tools/virtio: stub might_sleep and synchronize_rcu
> > > tools/virtio: switch to kernel's virtio_config.h
> > > virtio_features: make it self-contained
> > > tools/virtio: fix up oot build
> > > tools/virtio: add device, device_driver stubs
> > >
> > > include/linux/virtio.h | 2 +
> > > include/linux/virtio_features.h | 2 +
> > > tools/virtio/Makefile | 8 ++-
> > > tools/virtio/linux/compiler.h | 6 ++
> > > tools/virtio/linux/cpumask.h | 4 ++
> > > tools/virtio/linux/device.h | 8 +++
> > > tools/virtio/linux/dma-mapping.h | 4 ++
> > > tools/virtio/linux/kernel.h | 16 +++++
> > > tools/virtio/linux/module.h | 2 +
> > > tools/virtio/linux/ucopysize.h | 21 ++++++
> > > tools/virtio/linux/virtio.h | 73 +--------------------
> > > tools/virtio/linux/virtio_config.h | 102 +----------------------------
> > > tools/virtio/oot-stubs.h | 10 +++
> > > 13 files changed, 82 insertions(+), 176 deletions(-)
> > > create mode 100644 tools/virtio/linux/ucopysize.h
> > > create mode 100644 tools/virtio/oot-stubs.h
> > >
> > > --
> > > MST
> > >
> >
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/14] tools/virtio: cleanups, fixes
2025-12-10 6:24 ` Jason Wang
2025-12-10 7:01 ` Michael S. Tsirkin
@ 2025-12-11 7:12 ` Michael S. Tsirkin
2025-12-11 7:22 ` Jason Wang
1 sibling, 1 reply; 19+ messages in thread
From: Michael S. Tsirkin @ 2025-12-11 7:12 UTC (permalink / raw)
To: Jason Wang; +Cc: linux-kernel, virtualization
On Wed, Dec 10, 2025 at 02:24:02PM +0800, Jason Wang wrote:
> On Tue, Dec 9, 2025 at 9:09 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Thu, Dec 04, 2025 at 01:46:01PM -0500, Michael S. Tsirkin wrote:
> > > Recent virtio changes brought about build errors for tools/virtio,
> > > as usual. I did some refactoring to hopefully reduce maintainance
> > > load going forward.
> > >
> > > Adding stubs is tedious and seemed a perfect fit for cursor -
> > > so I used it for that, then rewrote some commits and accepted
> > > others. commit logs I've rewritten.
> > >
> > > Found and fixed a couple of minor bugs while doing this - that
> > > part's all mine.
> >
> >
> > Jason, any feedback?
>
> Looks good to me.
Can I get an Ack then?
> But I wonder, it looks like synchronization will
> become more and more a burden in the future, I wonder if it's time to
> switch to using uAPI instead of trying to reuse kernel virtio core to
> test vhost?
>
> Thanks
>
> >
> > > Michael S. Tsirkin (14):
> > > tools/virtio: fix up compiler.h stub
> > > virtio: make it self-contained
> > > tools/virtio: use kernel's virtio.h
> > > tools/virtio: add struct module forward declaration
> > > tools/virtio: stub DMA mapping functions
> > > tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs
> > > tools/virtio: add ucopysize.h stub
> > > tools/virtio: pass KCFLAGS to module build
> > > tools/virtio: add struct cpumask to cpumask.h
> > > tools/virtio: stub might_sleep and synchronize_rcu
> > > tools/virtio: switch to kernel's virtio_config.h
> > > virtio_features: make it self-contained
> > > tools/virtio: fix up oot build
> > > tools/virtio: add device, device_driver stubs
> > >
> > > include/linux/virtio.h | 2 +
> > > include/linux/virtio_features.h | 2 +
> > > tools/virtio/Makefile | 8 ++-
> > > tools/virtio/linux/compiler.h | 6 ++
> > > tools/virtio/linux/cpumask.h | 4 ++
> > > tools/virtio/linux/device.h | 8 +++
> > > tools/virtio/linux/dma-mapping.h | 4 ++
> > > tools/virtio/linux/kernel.h | 16 +++++
> > > tools/virtio/linux/module.h | 2 +
> > > tools/virtio/linux/ucopysize.h | 21 ++++++
> > > tools/virtio/linux/virtio.h | 73 +--------------------
> > > tools/virtio/linux/virtio_config.h | 102 +----------------------------
> > > tools/virtio/oot-stubs.h | 10 +++
> > > 13 files changed, 82 insertions(+), 176 deletions(-)
> > > create mode 100644 tools/virtio/linux/ucopysize.h
> > > create mode 100644 tools/virtio/oot-stubs.h
> > >
> > > --
> > > MST
> > >
> >
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 00/14] tools/virtio: cleanups, fixes
2025-12-11 7:12 ` Michael S. Tsirkin
@ 2025-12-11 7:22 ` Jason Wang
0 siblings, 0 replies; 19+ messages in thread
From: Jason Wang @ 2025-12-11 7:22 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: linux-kernel, virtualization
On Thu, Dec 11, 2025 at 3:13 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Wed, Dec 10, 2025 at 02:24:02PM +0800, Jason Wang wrote:
> > On Tue, Dec 9, 2025 at 9:09 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > >
> > > On Thu, Dec 04, 2025 at 01:46:01PM -0500, Michael S. Tsirkin wrote:
> > > > Recent virtio changes brought about build errors for tools/virtio,
> > > > as usual. I did some refactoring to hopefully reduce maintainance
> > > > load going forward.
> > > >
> > > > Adding stubs is tedious and seemed a perfect fit for cursor -
> > > > so I used it for that, then rewrote some commits and accepted
> > > > others. commit logs I've rewritten.
> > > >
> > > > Found and fixed a couple of minor bugs while doing this - that
> > > > part's all mine.
> > >
> > >
> > > Jason, any feedback?
> >
> > Looks good to me.
>
> Can I get an Ack then?
>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-12-11 7:23 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1764873799.git.mst@redhat.com>
2025-12-04 18:46 ` [PATCH 01/14] tools/virtio: fix up compiler.h stub Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 02/14] virtio: make it self-contained Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 03/14] tools/virtio: use kernel's virtio.h Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 04/14] tools/virtio: add struct module forward declaration Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 05/14] tools/virtio: stub DMA mapping functions Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 06/14] tools/virtio: add dev_WARN_ONCE and is_vmalloc_addr stubs Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 07/14] tools/virtio: add ucopysize.h stub Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 08/14] tools/virtio: pass KCFLAGS to module build Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 09/14] tools/virtio: add struct cpumask to cpumask.h Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 10/14] tools/virtio: stub might_sleep and synchronize_rcu Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 11/14] tools/virtio: switch to kernel's virtio_config.h Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 12/14] virtio_features: make it self-contained Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 13/14] tools/virtio: fix up oot build Michael S. Tsirkin
2025-12-04 18:46 ` [PATCH 14/14] tools/virtio: add device, device_driver stubs Michael S. Tsirkin
2025-12-09 13:09 ` [PATCH 00/14] tools/virtio: cleanups, fixes Michael S. Tsirkin
2025-12-10 6:24 ` Jason Wang
2025-12-10 7:01 ` Michael S. Tsirkin
2025-12-11 7:12 ` Michael S. Tsirkin
2025-12-11 7:22 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).