Skip to contentSkip to conversation

hostmem/shm: Allow shm memory backend serve as shared memory for coco-VMs

PATCH In review Xiaoyao Li 4 participants 7 messages Jul 21, 2025 – Oct 24, 2025 Arm STM32

lore
Share & tools
lore

Xiaoyao Li

author
#0 lore raw

PATCH 1/1 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 <[email protected]>
---
 backends/hostmem-shm.c | 1 +
 1 file changed, 1 insertion(+)
backends/hostmem-shm.c +1 -0
index f66211a2ec92..806e2670e039 100644
@@ -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,
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Xiaoyao Li

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.

Quoted 8 lines

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 <[email protected]>

---
backends/hostmem-shm.c | 1 +

1 file changed, 1 insertion(+)

LGTM!

Thanks,
Stefano

Quoted 16 lines
backends/hostmem-shm.c +1 -0
index f66211a2ec92..806e2670e039 100644
@@ -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,
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#2 lore raw
In reply to Xiaoyao Li
Quoted 10 lines · Xiaoyao Li

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 <[email protected]>
Signature · 3 lines
Cheers,

David / dhildenb
author
#3 lore raw
In reply to Xiaoyao Li
Quoted 7 lines · Xiaoyao Li

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.

ping...

Paolo, will you merge it for QEMU 10.1? I think it's worth it.

Quoted 18 lines
cc Stefano Garzarella <[email protected]>
---
  backends/hostmem-shm.c | 1 +
  1 file changed, 1 insertion(+)
backends/hostmem-shm.c +1 -0
index f66211a2ec92..806e2670e039 100644
@@ -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,
author
#4 lore raw
Quoted 6 lines · Xiaoyao Li
Quoted 5 lines · Xiaoyao Li

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.

Quoted 6 lines
Quoted 2 lines

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.

ping...

Paolo, will you merge it for QEMU 10.1? I think it's worth it.

ping again.

Quoted 20 lines
Quoted 18 lines
cc Stefano Garzarella <[email protected]>

---
  backends/hostmem-shm.c | 1 +

  1 file changed, 1 insertion(+)
backends/hostmem-shm.c +1 -0
index f66211a2ec92..806e2670e039 100644
@@ -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-

Quoted 1 line

size,

author
#5 lore raw
Quoted 7 lines · Xiaoyao Li
Quoted 6 lines · Xiaoyao Li
Quoted 5 lines · Xiaoyao Li

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.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

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.

ping...

Paolo, will you merge it for QEMU 10.1? I think it's worth it.

ping again.

ping++,

+ Peter,

Maybe you can queue it in case it gets missed from Paolo again?

Quoted 21 lines
Quoted 19 lines
Quoted 17 lines
cc Stefano Garzarella <[email protected]>

---
  backends/hostmem-shm.c | 1 +

  1 file changed, 1 insertion(+)
backends/hostmem-shm.c +1 -0
index f66211a2ec92..806e2670e039 100644
@@ -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,
#6 lore raw
Quoted 15 lines · Xiaoyao Li
Quoted 14 lines · Xiaoyao Li
Quoted 12 lines · Xiaoyao Li
Quoted 7 lines · Xiaoyao Li

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.

ping...

Paolo, will you merge it for QEMU 10.1? I think it's worth it.

Quoted 7 lines
Quoted 1 line

ping again.

ping++,

+ Peter,

Maybe you can queue it in case it gets missed from Paolo again?

Yep, queued now and I copied stable, let me know otherwise. Thanks.

Signature · 1 line
Peter Xu