[PATCH] include: set vm hva aligned with huge pagesize on loongarch

Mao Bibo posted 1 patch 3 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220628030400.1291793-1-maobibo@loongson.cn
include/qemu/osdep.h | 3 +++
1 file changed, 3 insertions(+)
[PATCH] include: set vm hva aligned with huge pagesize on loongarch
Posted by Mao Bibo 3 years, 7 months ago
On loongarch system, page size is 16K rather than 4K like general platforms,
and huge pagesize is 32M. This patch sets hva for vm aligned with huge pagesize
on loongarch host system.

Signed-off-by: Mao Bibo <maobibo@loongson.cn>
---
 include/qemu/osdep.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index b1c161c035..4f9aa53e35 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -451,6 +451,9 @@ extern int madvise(char *, size_t, int);
 #  define QEMU_VMALLOC_ALIGN (256 * 4096)
 #elif defined(__linux__) && defined(__sparc__)
 #  define QEMU_VMALLOC_ALIGN MAX(qemu_real_host_page_size(), SHMLBA)
+#elif defined(__linux__) && defined(__loongarch__)
+#  define QEMU_VMALLOC_ALIGN (qemu_real_host_page_size() * \
+                              qemu_real_host_page_size() / sizeof(long))
 #else
 #  define QEMU_VMALLOC_ALIGN qemu_real_host_page_size()
 #endif
-- 
2.27.0