linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Thayne Harbaugh <thayne@c2.net>
To: Andi Kleen <andi@firstfloor.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, discuss@x86-64.org
Subject: Re: [PATCH] Inconsistent mmap()/mremap() flags
Date: Mon, 01 Oct 2007 20:57:10 -0600	[thread overview]
Message-ID: <1191293830.5200.22.camel@phantasm.home.enterpriseandprosperity.com> (raw)
In-Reply-To: <200710011313.30171.andi@firstfloor.org>

On Mon, 2007-10-01 at 13:13 +0200, Andi Kleen wrote:
> > @@ -388,6 +392,9 @@
> >  			if (vma->vm_flags & VM_MAYSHARE)
> >  				map_flags |= MAP_SHARED;
> >  
> > +			if (flags & MAP_32BIT)
> > +				map_flags |= MAP_32BIT;
> > +
> >  			new_addr = get_unmapped_area(vma->vm_file, 0, new_len,
> >  						vma->vm_pgoff, map_flags);
> >  			ret = new_addr;
> 
> That's not enough -- you would also need to fail the mremap when the result
> is > 2GB (MAP_32BIT is actually a MAP_31BIT) 

Yeah, after I sent the email I realized that it was a bit more involved.
As far as the 32/31 bit, it just depends on the perspective.  I can see
that 32 bits are needed to represent all possible return values from
mmap() - possible address and error value of -1.  From that perspective
I think that MAP_32BIT is appropriate.

> But that would be ugly to implement without a new architecture wrapper
> or better changing arch_get_unmapped_area()
> 
> It might be better to just not bother. MAP_32BIT is a kind of hack anyways
> that at least for mmap can be easily emulated in user space anyways.

Care to give me some hints as to how that would be easily emulated in
user space?  That might be a better solution for the case I want to
solve.

> Given for mremap() it is not that easy because there is no "hint" argument
> without MREMAP_FIXED; but unless someone really needs it i would prefer
> to not propagate the hack. If it's really needed it's probably better
> to implement a start search hint for mremap()

It came up for user-mode Qemu for the case of emulating 32bit archs on
x86_64 using mmap.  At the moment it calls mmap with MAP_32BIT and then
uses the returned address directly in the emulator.  Without MAP_32BIT
there's the possibility of having an address that would be too large to
pass to what a 32bit arch would expect.  Since the MAP_32BIT flag solves
the problem for mmap() I was expecting something similar for mremap() -
unfortunately the MAP_32BIT feature is consistent throughout.

Thoughts?


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-10-02  2:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-28  5:46 [PATCH] Inconsistent mmap()/mremap() flags Thayne Harbaugh
2007-10-01 11:13 ` Andi Kleen
2007-10-02  2:57   ` Thayne Harbaugh [this message]
2007-10-02  5:15     ` Andi Kleen
2007-10-02  7:06       ` Thayne Harbaugh
2007-10-02 12:19         ` Hugh Dickins
2007-10-02 13:45           ` [discuss] " Andi Kleen
2007-10-02 14:16             ` Hugh Dickins
2007-10-02 15:21               ` Thayne Harbaugh

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=1191293830.5200.22.camel@phantasm.home.enterpriseandprosperity.com \
    --to=thayne@c2.net \
    --cc=andi@firstfloor.org \
    --cc=discuss@x86-64.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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 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).