From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpROa-0000ab-Oo for qemu-devel@nongnu.org; Wed, 28 Sep 2016 22:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpROW-0003y4-6I for qemu-devel@nongnu.org; Wed, 28 Sep 2016 22:48:24 -0400 Received: from mout02.posteo.de ([185.67.36.66]:58410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpROW-0003wZ-03 for qemu-devel@nongnu.org; Wed, 28 Sep 2016 22:48:20 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id C6D7C20C73 for ; Thu, 29 Sep 2016 04:48:12 +0200 (CEST) Date: Wed, 28 Sep 2016 22:46:33 -0400 From: Felix Janda Message-ID: <20160929024633.GA1285@nyan> References: <20160918012014.GA11017@nyan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] linux-user: fix mremap for 64bit targets on 32bit hosts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers , Riku Voipio Peter Maydell wrote: > On 17 September 2016 at 18:20, Felix Janda wrote: > > Signed-off-by: Felix Janda > > --- > > linux-user/mmap.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/linux-user/mmap.c b/linux-user/mmap.c > > index c4371d9..4882816 100644 > > --- a/linux-user/mmap.c > > +++ b/linux-user/mmap.c > > @@ -682,7 +682,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, > > > > if (flags & MREMAP_FIXED) { > > host_addr = (void *) syscall(__NR_mremap, g2h(old_addr), > > - old_size, new_size, > > + (size_t) old_size, (size_t) new_size, > > flags, > > g2h(new_addr)); > > > > @@ -701,7 +701,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, > > host_addr = MAP_FAILED; > > } else { > > host_addr = (void *) syscall(__NR_mremap, g2h(old_addr), > > - old_size, new_size, > > + (size_t) old_size, (size_t) new_size, > > flags | MREMAP_FIXED, > > g2h(mmap_start)); > > if (reserved_va) { > > -- > > 2.7.3 > > Rather than this, I think it would be better to switch to > using the mremap() library call rather than direct syscall > here, which then matches the other mremap()s later in the > function. (That will work right because mremap()'s prototype > says it takes size_t arguments, whereas syscall() is a > generic thing which doesn't, and so the C default promotions > do the wrong thing with the abi_ulongs.) > > The use of syscall(__NR_mremap, ...) originally dates back to 2008: > https://lists.gnu.org/archive/html/qemu-devel/2008-12/msg01087.html > https://lists.gnu.org/archive/html/qemu-devel/2008-12/msg00480.html > > and was to permit compilation with glibc 2.4 which didn't > support the 5-argument mremap() or define MREMAP_FIXED. > > Since glibc 2.4 dates back to a decade ago now, we no longer > need to carry this ugly (and buggy) workaround for it. This sounds like a good idea. Thanks also for digging up the history. I will prepare a new patch. Thanks, Felix