97168e
From 60da56e3685969493ae483c3cc2c66af13d00baf Mon Sep 17 00:00:00 2001
97168e
From: Thomas Huth <thuth@redhat.com>
97168e
Date: Wed, 10 Aug 2022 14:57:18 +0200
97168e
Subject: [PATCH 1/3] backends/hostmem: Fix support of memory-backend-memfd in
97168e
 qemu_maxrampagesize()
97168e
MIME-Version: 1.0
97168e
Content-Type: text/plain; charset=UTF-8
97168e
Content-Transfer-Encoding: 8bit
97168e
97168e
RH-Author: Cédric Le Goater <None>
97168e
RH-MergeRequest: 221: backends/hostmem: Fix support of memory-backend-memfd in qemu_maxrampagesize()
97168e
RH-Bugzilla: 2117149
97168e
RH-Acked-by: Thomas Huth <thuth@redhat.com>
97168e
RH-Acked-by: David Hildenbrand <david@redhat.com>
97168e
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
97168e
RH-Commit: [1/1] b5a1047750af32c0a261b8385ea0e819eb16681a
97168e
97168e
It is currently not possible yet to use "memory-backend-memfd" on s390x
97168e
with hugepages enabled. This problem is caused by qemu_maxrampagesize()
97168e
not taking memory-backend-memfd objects into account yet, so the code
97168e
in s390_memory_init() fails to enable the huge page support there via
97168e
s390_set_max_pagesize(). Fix it by generalizing the code, so that it
97168e
looks at qemu_ram_pagesize(memdev->mr.ram_block) instead of re-trying
97168e
to get the information from the filesystem.
97168e
97168e
Suggested-by: David Hildenbrand <david@redhat.com>
97168e
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2116496
97168e
Message-Id: <20220810125720.3849835-2-thuth@redhat.com>
97168e
Reviewed-by: David Hildenbrand <david@redhat.com>
97168e
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
97168e
Signed-off-by: Thomas Huth <thuth@redhat.com>
97168e
(cherry picked from commit 8be934b70e923104da883b990dee18f02552d40e)
97168e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2117149
97168e
[clg: Resolved conflict on qemu_real_host_page_size() ]
97168e
Signed-off-by: Cédric Le Goater <clg@redhat.com>
97168e
---
97168e
 backends/hostmem.c | 14 ++------------
97168e
 1 file changed, 2 insertions(+), 12 deletions(-)
97168e
97168e
diff --git a/backends/hostmem.c b/backends/hostmem.c
97168e
index 4c05862ed5..0c4654ea85 100644
97168e
--- a/backends/hostmem.c
97168e
+++ b/backends/hostmem.c
97168e
@@ -305,22 +305,12 @@ bool host_memory_backend_is_mapped(HostMemoryBackend *backend)
97168e
     return backend->is_mapped;
97168e
 }
97168e
 
97168e
-#ifdef __linux__
97168e
 size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
97168e
 {
97168e
-    Object *obj = OBJECT(memdev);
97168e
-    char *path = object_property_get_str(obj, "mem-path", NULL);
97168e
-    size_t pagesize = qemu_mempath_getpagesize(path);
97168e
-
97168e
-    g_free(path);
97168e
+    size_t pagesize = qemu_ram_pagesize(memdev->mr.ram_block);
97168e
+    g_assert(pagesize >= qemu_real_host_page_size);
97168e
     return pagesize;
97168e
 }
97168e
-#else
97168e
-size_t host_memory_backend_pagesize(HostMemoryBackend *memdev)
97168e
-{
97168e
-    return qemu_real_host_page_size;
97168e
-}
97168e
-#endif
97168e
 
97168e
 static void
97168e
 host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
97168e
-- 
97168e
2.35.3
97168e