On 06/15/17 20:17, Peter Maydell wrote: > It turns out that SPARC hosts impose a requirement that > if you mmap MAP_SHARED|MAP_FIXED then the address must be > aligned to SHMLBA alignment, which for SPARC is 16K and > larger than the 8K page size: > http://lxr.linux.no/#linux+v4.10.1/arch/sparc/kernel/sys_sparc_64.c#L158 > > QEMU doesn't really cope with this. In particular, ivmshm > doesn't work: > > $ ppc64-softmmu/qemu-system-ppc64 -display none -device > ivshmem,shm=/qtest-20273-1334572184,size=0x1 > qemu-system-ppc64: System page size 0x2000 is not enabled in > page_size_mask (0x11000). Performance may be slow > qemu-system-ppc64: -device > ivshmem,shm=/qtest-20273-1334572184,size=0x1: ivshmem is deprecated, > please use ivshmem-plain or ivshmem-doorbell instead > Unexpected error in file_ram_alloc() at /home/pm215/qemu/exec.c:1599: > qemu-system-ppc64: -device > ivshmem,shm=/qtest-20273-1334572184,size=0x1: unable to map backing > store for guest RAM: Invalid argument > Aborted > > (noticed because this is a make check failure). > > exec.c calls qemu_fd_getpagesize() to figure out the alignment > here (on a file in /dev/shm/) and ends up in its default codepath > that returns getpagesize(), which is too small. > > What's the best way to fix this? As far as I can tell > the restriction applies to any mapping, not just /dev/shm files. > QEMU's assumptions that pagesize is the alignment requirement > seem fairly widespread :-(
In POSIX, SHMLBA is specified for shmat(), and not specified for mmap(). http://pubs.opengroup.org/onlinepubs/9699919799/functions/shmat.html http://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html Apparently, /dev/shm (tmpfs) stands for the same sysv memory sharing that shmat() stands for. Perhaps we can collect the /dev/shm mappings and apply the shmat() restriction(s) to them explicitly -- but only to them. If that's not the case, i.e. Linux on SPARC enforces SHMLBA for all kinds of mmap() -- which I would call a POSIX conformance bug --, then we can perhaps generally round up to SHMLBA within qemu_fd_getpagesize() and qemu_mempath_getpagesize(), on SPARC hosts. Laszlo