From 3afcb3630944d7565d6ab6106b61461b292aa93f Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 3 Jun 2026 16:33:28 -0400 Subject: tools/virtio: fix build for kmalloc_obj API and missing stubs Add stubs for kmalloc_obj() and kmalloc_objs() to the tools/virtio test harness, matching the new kernel allocator API. Also add the DMA_ATTR_CPU_CACHE_CLEAN definition and include kernel.h from err.h for the unlikely() macro. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Michael S. Tsirkin Message-ID: --- tools/virtio/linux/kernel.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/virtio/linux/kernel.h') diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h index 416d02703f61..104abf9d1aee 100644 --- a/tools/virtio/linux/kernel.h +++ b/tools/virtio/linux/kernel.h @@ -65,6 +65,12 @@ static inline void *kmalloc_array(unsigned n, size_t s, gfp_t gfp) return kmalloc(n * s, gfp); } +#define kmalloc_obj(VAR_OR_TYPE, ...) \ + ((typeof(VAR_OR_TYPE) *)kmalloc(sizeof(typeof(VAR_OR_TYPE)), 0)) + +#define kmalloc_objs(VAR_OR_TYPE, COUNT, ...) \ + ((typeof(VAR_OR_TYPE) *)kmalloc(sizeof(typeof(VAR_OR_TYPE)) * (COUNT), 0)) + static inline void *kzalloc(size_t s, gfp_t gfp) { void *p = kmalloc(s, gfp); -- cgit v1.2.3