From 75e2cb144191ecdbba87cfea3608cdc0664c8142 Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Mon, 21 Jul 2025 14:52:20 +0800 Subject: [PATCH] hostmem/shm: Allow shm memory backend serve as shared memory for coco-VMs shm can surely serve as the shared memory for coco-VMs. But currently it doesn't check the backend->guest_memfd to pass down the RAM_GUEST_MEMFD flag. It leads to failure when creating coco-VMs (e.g., TDX guest) which require private mmeory. Set and pass down RAM_GUEST_MEMFD when backend->guest_memfd is true, to allow shm memory backend serve as shared memory for coco-VMs. Cc: Stefano Garzarella Cc: qemu-stable Signed-off-by: Xiaoyao Li Acked-by: David Hildenbrand Acked-by: Stefano Garzarella Link: https://lore.kernel.org/r/20250721065220.895606-1-xiaoyao.li@intel.com Signed-off-by: Peter Xu --- backends/hostmem-shm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/backends/hostmem-shm.c b/backends/hostmem-shm.c index f66211a2ec..806e2670e0 100644 --- a/backends/hostmem-shm.c +++ b/backends/hostmem-shm.c @@ -54,6 +54,7 @@ have_fd: /* Let's do the same as memory-backend-ram,share=on would do. */ ram_flags = RAM_SHARED; ram_flags |= backend->reserve ? 0 : RAM_NORESERVE; + ram_flags |= backend->guest_memfd ? RAM_GUEST_MEMFD : 0; return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), backend_name, backend->size, -- 2.47.3