qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Subject: Re: [Qemu-devel] QEMU issues on SPARC hosts due to more-than-page-alignment requirement for MAP_SHARED|MAP_FIXED...
Date: Thu, 15 Jun 2017 21:13:48 +0200	[thread overview]
Message-ID: <c1efba1b-0af9-50a5-e200-a3f74a88d1c1@redhat.com> (raw)
In-Reply-To: <CAFEAcA9+HauZoeSxrdXE+cENswUPsjoSOVFJ-wMfboYH5wC2=Q@mail.gmail.com>

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

  reply	other threads:[~2017-06-15 19:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 18:17 [Qemu-devel] QEMU issues on SPARC hosts due to more-than-page-alignment requirement for MAP_SHARED|MAP_FIXED Peter Maydell
2017-06-15 19:13 ` Laszlo Ersek [this message]
2017-06-16  9:18   ` Peter Maydell
2017-06-19 22:49     ` Richard Henderson
2017-06-20  8:03       ` Peter Maydell
2017-06-16  9:16 ` John Paul Adrian Glaubitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1efba1b-0af9-50a5-e200-a3f74a88d1c1@redhat.com \
    --to=lersek@redhat.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).