From b54cfecf1e95ae8146e988a1b2d4dc6034d171cc Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Mon, 5 Mar 2018 14:09:52 -0500 Subject: [PATCH] sparc: Make sure we mmap at SHMLBA alignment SPARC Linux has an oddity that it insists that mmap() of MAP_FIXED memory must be at an alignment defined by SHMLBA, which is more aligned than the page size (typically, SHMLBA alignment is to 16K, and pages are 8K). This is a relic of ancient hardware that had cache aliasing constraints, but even on modern hardware the kernel still insists on the alignment. To ensure that we get mmap() alignment sufficient to make the kernel happy, change QEMU_VMALLOC_ALIGN, qemu_fd_getpagesize() and qemu_mempath_getpagesize() to use the maximum of getpagesize() and SHMLBA. In particular, this allows 'make check' to pass on Sparc: we were previously failing the ivshmem tests. Backports commit 57d1f6d7ce23e79a8ebe4a57bd2363b269b4664b from qemu --- qemu/util/oslib-posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu/util/oslib-posix.c b/qemu/util/oslib-posix.c index 8457fab9..c86c7ff4 100644 --- a/qemu/util/oslib-posix.c +++ b/qemu/util/oslib-posix.c @@ -35,6 +35,9 @@ #elif defined(__linux__) && defined(__s390x__) /* Use 1 MiB (segment size) alignment so gmap can be used by KVM. */ # define QEMU_VMALLOC_ALIGN (256 * 4096) +#elif defined(__linux__) && defined(__sparc__) +#include +# define QEMU_VMALLOC_ALIGN MAX(getpagesize(), SHMLBA) #else # define QEMU_VMALLOC_ALIGN getpagesize() #endif