mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Tobias Koch <tobias.koch@nonterra.com>
To: musl@lists.openwall.com
Subject: Re: pthread_getattr_np doing loads of mremaps on ARM, MIPS under QEMU user-mode
Date: Sun, 25 Jun 2017 01:05:52 +0300	[thread overview]
Message-ID: <29a099b1-8c83-28d2-c996-80d84dda8e7f@nonterra.com> (raw)
In-Reply-To: <20170621004107.GZ1627@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1599 bytes --]

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.

Tobias


On 21/06/2017 03:41, Rich Felker wrote:
> [...]
> OK, qemu-user is just emulating mremap very poorly. The man page
> documents that it fails with EFAULT when the address passed is not
> valid, but qemu seems to be giving ENOMEM, which has a different
> meaning. I remember we looked hard when this was first implemented to
> find an acceptable/safe way to probe for valid pages, so I doubt we'll
> find a better or equally good way that both works around the bug in
> qemu-user and does the right thing on all real kernels. I think the
> qemu bug should just be reported and fixed.
>
> Rich


[-- Attachment #2: Type: text/html, Size: 2388 bytes --]

  reply	other threads:[~2017-06-24 22:05 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 [this message]
2017-06-24 22:18         ` Rich Felker

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=29a099b1-8c83-28d2-c996-80d84dda8e7f@nonterra.com \
    --to=tobias.koch@nonterra.com \
    --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).