aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2024-01-15 15:32:44 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2024-01-18 10:43:51 +0100
commit5fd1674d21d3e3489f077c67dcd841b72ed351b8 (patch)
tree2bb7a3096473bb690e8db1d207eee8fc9f2bf185
parent592d0bc0302ff5b5209ecd7f8733f285bc008cff (diff)
downloadqemu-5fd1674d21d3e3489f077c67dcd841b72ed351b8.zip
qemu-5fd1674d21d3e3489f077c67dcd841b72ed351b8.tar.gz
qemu-5fd1674d21d3e3489f077c67dcd841b72ed351b8.tar.bz2
qemu/osdep: Add huge page aligned support on LoongArch platform
On LoongArch kvm mode if transparent huge page wants to be enabled, base address and size of memslot from both HVA and GPA view. And LoongArch supports both 4K and 16K page size with Linux kernel, so transparent huge page size is calculated from real page size rather than hardcoded size. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Message-ID: <20240115073244.174155-1-maobibo@loongson.cn> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--include/qemu/osdep.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 9a405be..c9692cc 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -547,6 +547,14 @@ 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__)
+ /*
+ * For transparent hugepage optimization, it has better be huge page
+ * aligned. LoongArch host system supports two kinds of pagesize: 4K
+ * and 16K, here calculate huge page size from host page size
+ */
+# 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