qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ram-block-attributes: Avoid the overkill of shared memory with hugetlbfs backend
@ 2025-10-17  8:14 Chenyi Qiang
  2025-10-17 13:57 ` Peter Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chenyi Qiang @ 2025-10-17  8:14 UTC (permalink / raw)
  To: Peter Xu, David Hildenbrand, Alexey Kardashevskiy, Paolo Bonzini,
	Philippe Mathieu-Daudé
  Cc: Chenyi Qiang, qemu-devel, Gao Chao, Li Xiaoyao

Currently, private memory and shared memory have different backend in
CoCo VMs. It is possible for users to specify the shared memory with
hugetlbfs backend while private memory with guest_memfd backend only
supports 4K page size. In this case, ram_block->page_size is different
from the host page size which will trigger the assertion when getting
block size. Relax the restriction to allow shared memory to use
hugetlbfs backend.

Fixes: 5d6483edaa92 ("ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd")
Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
---
 system/ram-block-attributes.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c
index 68e8a027032..0f39ccf9090 100644
--- a/system/ram-block-attributes.c
+++ b/system/ram-block-attributes.c
@@ -28,10 +28,11 @@ ram_block_attributes_get_block_size(const RamBlockAttributes *attr)
      * Because page conversion could be manipulated in the size of at least 4K
      * or 4K aligned, Use the host page size as the granularity to track the
      * memory attribute.
+     * When hugetlbfs is used as backend of shared memory, ram_block->page_size
+     * is different from host page size. So it is not appropriate to use
+     * ram_block->page_size here.
      */
-    g_assert(attr && attr->ram_block);
-    g_assert(attr->ram_block->page_size == qemu_real_host_page_size());
-    return attr->ram_block->page_size;
+    return qemu_real_host_page_size();
 }
 
 
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-20 11:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17  8:14 [PATCH] ram-block-attributes: Avoid the overkill of shared memory with hugetlbfs backend Chenyi Qiang
2025-10-17 13:57 ` Peter Xu
2025-10-17 15:13 ` David Hildenbrand
2025-10-20 10:32   ` Chenyi Qiang
2025-10-20 11:31     ` David Hildenbrand
2025-10-20 11:48       ` Chenyi Qiang
2025-10-20 11:34 ` David Hildenbrand

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).