* [PATCH 0/2] tools/virtio: fix the build and the posix_memalign() checks
@ 2026-10-20 3:29 Liam R. Howlett (Google)
2026-10-20 3:29 ` [PATCH 1/2] tools/virtio: add a shim for linux/device-id/virtio.h Liam R. Howlett (Google)
2026-10-20 3:29 ` [PATCH 2/2] tools/virtio: check posix_memalign() for failure Liam R. Howlett (Google)
0 siblings, 2 replies; 5+ messages in thread
From: Liam R. Howlett (Google) @ 2026-10-20 3:29 UTC (permalink / raw)
To: Michael S . Tsirkin, Jason Wang, Eugenio Pérez
Cc: Xuan Zhuo, Uwe Kleine-König, virtualization, linux-kernel,
Liam R. Howlett (Google)
Working on other tools, I came across the fact that posix_memalign()'s
return is not the standard negative error. Scanning the git repo, I
came across the virtio issue with the return. Testing turned out the be
broke as well, so there's a patch to fix testing prior to fixing the
caller.
Liam R. Howlett (Google) (2):
tools/virtio: add a shim for linux/device-id/virtio.h
tools/virtio: check posix_memalign() for failure
tools/virtio/linux/device-id/virtio.h | 2 ++
tools/virtio/linux/kernel.h | 3 ++-
tools/virtio/vhost_net_test.c | 2 +-
tools/virtio/virtio_test.c | 2 +-
4 files changed, 6 insertions(+), 3 deletions(-)
create mode 100644 tools/virtio/linux/device-id/virtio.h
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] tools/virtio: add a shim for linux/device-id/virtio.h
2026-10-20 3:29 [PATCH 0/2] tools/virtio: fix the build and the posix_memalign() checks Liam R. Howlett (Google)
@ 2026-10-20 3:29 ` Liam R. Howlett (Google)
2026-10-20 8:16 ` sashiko-bot
2026-10-20 3:29 ` [PATCH 2/2] tools/virtio: check posix_memalign() for failure Liam R. Howlett (Google)
1 sibling, 1 reply; 5+ messages in thread
From: Liam R. Howlett (Google) @ 2026-10-20 3:29 UTC (permalink / raw)
To: Michael S . Tsirkin, Jason Wang, Eugenio Pérez
Cc: Xuan Zhuo, Uwe Kleine-König, virtualization, linux-kernel,
Liam R. Howlett (Google)
include/linux/virtio.h takes struct virtio_device_id from
<linux/device-id/virtio.h>, which the tools build cannot find.
Add a shim for it beside the others, pointing at the real header.
Fixes: ecca1d63c1ea ("Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (headers)")
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
---
tools/virtio/linux/device-id/virtio.h | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 tools/virtio/linux/device-id/virtio.h
diff --git a/tools/virtio/linux/device-id/virtio.h b/tools/virtio/linux/device-id/virtio.h
new file mode 100644
index 0000000000000..3c3e8c514c8d4
--- /dev/null
+++ b/tools/virtio/linux/device-id/virtio.h
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <../../include/linux/device-id/virtio.h>
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] tools/virtio: check posix_memalign() for failure
2026-10-20 3:29 [PATCH 0/2] tools/virtio: fix the build and the posix_memalign() checks Liam R. Howlett (Google)
2026-10-20 3:29 ` [PATCH 1/2] tools/virtio: add a shim for linux/device-id/virtio.h Liam R. Howlett (Google)
@ 2026-10-20 3:29 ` Liam R. Howlett (Google)
2026-10-20 8:18 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Liam R. Howlett (Google) @ 2026-10-20 3:29 UTC (permalink / raw)
To: Michael S . Tsirkin, Jason Wang, Eugenio Pérez
Cc: Xuan Zhuo, Uwe Kleine-König, virtualization, linux-kernel,
Liam R. Howlett (Google)
posix_memalign() returns zero or a positive error number and does not set
errno. virtio_test and vhost_net_test assert that the return is not
negative, which will always be true, and the userspace __get_free_page()
ignores it, so a failed allocation continues without setting the pointer
Assert a zero return in the tests, and return 0 from __get_free_page() on
failure, as the kernel's does.
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
---
tools/virtio/linux/kernel.h | 3 ++-
tools/virtio/vhost_net_test.c | 2 +-
tools/virtio/virtio_test.c | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index 104abf9d1aee5..3497660c690a9 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -106,7 +106,8 @@ static inline unsigned long __get_free_page(gfp_t gfp)
{
void *p;
- posix_memalign(&p, PAGE_SIZE, PAGE_SIZE);
+ if (posix_memalign(&p, PAGE_SIZE, PAGE_SIZE))
+ return 0;
return (unsigned long)p;
}
diff --git a/tools/virtio/vhost_net_test.c b/tools/virtio/vhost_net_test.c
index 566e15420bb65..3122ea0970568 100644
--- a/tools/virtio/vhost_net_test.c
+++ b/tools/virtio/vhost_net_test.c
@@ -197,7 +197,7 @@ static void vq_info_add(struct vdev_info *dev, int idx, int num, int fd)
info->idx = idx;
info->kick = eventfd(0, EFD_NONBLOCK);
r = posix_memalign(&info->ring, 4096, vring_size(num, 4096));
- assert(r >= 0);
+ assert(!r);
vq_reset(info, num, &dev->vdev);
vhost_vq_setup(dev, info);
diff --git a/tools/virtio/virtio_test.c b/tools/virtio/virtio_test.c
index 028f54e6854a8..9d61463f6e09b 100644
--- a/tools/virtio/virtio_test.c
+++ b/tools/virtio/virtio_test.c
@@ -116,7 +116,7 @@ static void vq_info_add(struct vdev_info *dev, int num)
info->kick = eventfd(0, EFD_NONBLOCK);
info->call = eventfd(0, EFD_NONBLOCK);
r = posix_memalign(&info->ring, 4096, vring_size(num, 4096));
- assert(r >= 0);
+ assert(!r);
vq_reset(info, num, &dev->vdev);
vhost_vq_setup(dev, info);
dev->fds[info->idx].fd = info->call;
--
2.47.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] tools/virtio: add a shim for linux/device-id/virtio.h
2026-10-20 3:29 ` [PATCH 1/2] tools/virtio: add a shim for linux/device-id/virtio.h Liam R. Howlett (Google)
@ 2026-10-20 8:16 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-10-20 8:16 UTC (permalink / raw)
To: Liam R. Howlett (Google)
Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
> include/linux/virtio.h takes struct virtio_device_id from
> <linux/device-id/virtio.h>, which the tools build cannot find.
>
> Add a shim for it beside the others, pointing at the real header.
>
> Fixes: ecca1d63c1ea ("Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (headers)")
> Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261020032958.1930203-1-liam@infradead.org?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] tools/virtio: check posix_memalign() for failure
2026-10-20 3:29 ` [PATCH 2/2] tools/virtio: check posix_memalign() for failure Liam R. Howlett (Google)
@ 2026-10-20 8:18 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-10-20 8:18 UTC (permalink / raw)
To: Liam R. Howlett (Google)
Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
> posix_memalign() returns zero or a positive error number and does not set
> errno. virtio_test and vhost_net_test assert that the return is not
> negative, which will always be true, and the userspace __get_free_page()
> ignores it, so a failed allocation continues without setting the pointer
>
> Assert a zero return in the tests, and return 0 from __get_free_page() on
> failure, as the kernel's does.
>
> Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261020032958.1930203-1-liam@infradead.org?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-20 8:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 3:29 [PATCH 0/2] tools/virtio: fix the build and the posix_memalign() checks Liam R. Howlett (Google)
2026-10-20 3:29 ` [PATCH 1/2] tools/virtio: add a shim for linux/device-id/virtio.h Liam R. Howlett (Google)
2026-10-20 8:16 ` sashiko-bot
2026-10-20 3:29 ` [PATCH 2/2] tools/virtio: check posix_memalign() for failure Liam R. Howlett (Google)
2026-10-20 8:18 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.