aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDominik Dingel <dingel@linux.vnet.ibm.com>2016-04-25 13:55:38 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-05-23 16:53:42 +0200
commitd2f39add725e2be849f5fb014a72368f711056fc (patch)
treef6eb2641919e12ab6a9b3ed8f74616aa6de2b8a8 /include
parente081c24d30c1e7b29eb4450aa16d6a0da5782797 (diff)
exec.c: Ensure right alignment also for file backed ram
While in the anonymous ram case we already take care of the right alignment such an alignment gurantee does not exist for file backed ram allocation. Instead, pagesize is used for alignment. On s390 this is not enough for gmap, as we need to satisfy an alignment up to segments. Reported-by: Halil Pasic <pasic@linux.vnet.ibm.com> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com> Message-Id: <1461585338-45863-1-git-send-email-dingel@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/osdep.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 268ec66958..994bfa023a 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -263,6 +263,19 @@ void qemu_anon_ram_free(void *ptr, size_t size);
#endif
+#if defined(__linux__) && \
+ (defined(__x86_64__) || defined(__arm__) || defined(__aarch64__))
+ /* Use 2 MiB alignment so transparent hugepages can be used by KVM.
+ Valgrind does not support alignments larger than 1 MiB,
+ therefore we need special code which handles running on Valgrind. */
+# define QEMU_VMALLOC_ALIGN (512 * 4096)
+#elif defined(__linux__) && defined(__s390x__)
+ /* Use 1 MiB (segment size) alignment so gmap can be used by KVM. */
+# define QEMU_VMALLOC_ALIGN (256 * 4096)
+#else
+# define QEMU_VMALLOC_ALIGN getpagesize()
+#endif
+
int qemu_madvise(void *addr, size_t len, int advice);
int qemu_open(const char *name, int flags, ...);