All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Janda <felix.janda@posteo.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Riku Voipio <riku.voipio@iki.fi>
Subject: Re: [Qemu-devel] [PATCH] linux-user: fix mremap for 64bit targets on 32bit hosts
Date: Wed, 28 Sep 2016 22:46:33 -0400	[thread overview]
Message-ID: <20160929024633.GA1285@nyan> (raw)
In-Reply-To: <CAFEAcA9q5uZ7Dyrr+rychGkBiGz-Q-XQdLZKix=ZuY9L+g8JXQ@mail.gmail.com>

Peter Maydell wrote:
> On 17 September 2016 at 18:20, Felix Janda <felix.janda@posteo.de> wrote:
> > Signed-off-by: Felix Janda <felix.janda@posteo.de>
> > ---
> >  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

      reply	other threads:[~2016-09-29  2:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18  1:20 [Qemu-devel] [PATCH] linux-user: fix mremap for 64bit targets on 32bit hosts Felix Janda
2016-09-22  6:22 ` Riku Voipio
2016-09-23  0:36   ` Felix Janda
2016-09-28 23:30 ` Peter Maydell
2016-09-29  2:46   ` Felix Janda [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=20160929024633.GA1285@nyan \
    --to=felix.janda@posteo.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.