Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170624221848.GW1627@brightrain.aerifal.cx>
Date: Sat, 24 Jun 2017 18:18:48 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: pthread_getattr_np doing loads of mremaps on ARM, MIPS
 under QEMU user-mode

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.