mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: pthread_getattr_np doing loads of mremaps on ARM, MIPS under QEMU user-mode
Date: Sat, 24 Jun 2017 18:18:48 -0400	[thread overview]
Message-ID: <20170624221848.GW1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <29a099b1-8c83-28d2-c996-80d84dda8e7f@nonterra.com>

On Sun, Jun 25, 2017 at 01:05:52AM +0300, Tobias Koch wrote:
> Hi,
> 
> thank you! And yes, you are absolutely right. QEMU always fails in
> mmap.c after looking at page flags in the extended memory range:
> 
>         int prot = 0;
>         if (reserved_va && old_size < new_size) {
>             abi_ulong addr;
>             for (addr = old_addr + old_size;
>                  addr < old_addr + new_size;
>                  addr++) {
>                 prot |= page_get_flags(addr);
>             }
>         }
>         if (prot == 0) {
>             host_addr = mremap(g2h(old_addr), old_size, new_size, flags);
>             if (host_addr != MAP_FAILED && reserved_va && old_size > new_size) {
>                 mmap_reserve(old_addr + old_size, new_size - old_size);
>             }
>         } else {
> 	    /* musl's pthread_getattr_np always fails here doing mremaps: */
>  	    errno = ENOMEM;
>             host_addr = MAP_FAILED;
>         }
> 
> I wonder why it cannot just try the remap directly and use the
> result of that, but that's clearly a question for the QEMU people.

They can't try to mremap arbitrary addresses in the emulated address
space without first translating them to the host address space. When
page_get_flags fails they probably need to be generating EFAULT
themselves or something.

Rich


      reply	other threads:[~2017-06-24 22:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 13:08 Tobias Koch
2017-06-15 14:19 ` Rich Felker
2017-06-15 20:01   ` Tobias Koch
2017-06-21  0:41     ` Rich Felker
2017-06-24 22:05       ` Tobias Koch
2017-06-24 22:18         ` Rich Felker [this message]

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=20170624221848.GW1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).