From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11598 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general 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 Message-ID: <20170624221848.GW1627@brightrain.aerifal.cx> References: <20170615141927.GN1627@brightrain.aerifal.cx> <95368764-4c3d-8f6e-4030-87872d8913ea@nonterra.com> <20170621004107.GZ1627@brightrain.aerifal.cx> <29a099b1-8c83-28d2-c996-80d84dda8e7f@nonterra.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1498342744 3470 195.159.176.226 (24 Jun 2017 22:19:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 24 Jun 2017 22:19:04 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11611-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jun 25 00:19:01 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dOtON-0000bN-4t for gllmg-musl@m.gmane.org; Sun, 25 Jun 2017 00:18:59 +0200 Original-Received: (qmail 21943 invoked by uid 550); 24 Jun 2017 22:19:01 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 21925 invoked from network); 24 Jun 2017 22:19:00 -0000 Content-Disposition: inline In-Reply-To: <29a099b1-8c83-28d2-c996-80d84dda8e7f@nonterra.com> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11598 Archived-At: 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