android_kernel_motorola_sm6225/arch/powerpc/mm
Benjamin Herrenschmidt d506a77251 get_unmapped_area handles MAP_FIXED on powerpc
The current get_unmapped_area code calls the f_ops->get_unmapped_area or the
arch one (via the mm) only when MAP_FIXED is not passed.  That makes it
impossible for archs to impose proper constraints on regions of the virtual
address space.  To work around that, get_unmapped_area() then calls some
hugetlbfs specific hacks.

This cause several problems, among others:

- It makes it impossible for a driver or filesystem to do the same thing
  that hugetlbfs does (for example, to allow a driver to use larger page sizes
  to map external hardware) if that requires applying a constraint on the
  addresses (constraining that mapping in certain regions and other mappings
  out of those regions).

- Some archs like arm, mips, sparc, sparc64, sh and sh64 already want
  MAP_FIXED to be passed down in order to deal with aliasing issues.  The code
  is there to handle it...  but is never called.

This series of patches moves the logic to handle MAP_FIXED down to the various
arch/driver get_unmapped_area() implementations, and then changes the generic
code to always call them.  The hugetlbfs hacks then disappear from the generic
code.

Since I need to do some special 64K pages mappings for SPEs on cell, I need to
work around the first problem at least.  I have further patches thus
implementing a "slices" layer that handles multiple page sizes through slices
of the address space for use by hugetlbfs, the SPE code, and possibly others,
but it requires that serie of patches first/

There is still a potential (but not practical) issue due to the fact that
filesystems/drivers implemeting g_u_a will effectively bypass all arch checks.
 This is not an issue in practice as the only filesystems/drivers using that
hook are doing so for arch specific purposes in the first place.

There is also a problem with mremap that will completely bypass all arch
checks.  I'll try to address that separately, I'm not 100% certain yet how,
possibly by making it not work when the vma has a file whose f_ops has a
get_unmapped_area callback, and by making it use is_hugepage_only_range()
before expanding into a new area.

Also, I want to turn is_hugepage_only_range() into a more generic
is_normal_page_range() as that's really what it will end up meaning when used
in stack grow, brk grow and mremap.

None of the above "issues" however are introduced by this patch, they are
already there, so I think the patch can go ini for 2.6.22.

This patch:

Handle MAP_FIXED in powerpc's arch_get_unmapped_area() in all 3
implementations of it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: William Irwin <bill.irwin@oracle.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: David Howells <dhowells@redhat.com>
Cc: Andi Kleen <ak@suse.de>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Matthew Wilcox <willy@debian.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Adam Litke <agl@us.ibm.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-07 12:12:55 -07:00
..
4xx_mmu.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
44x_mmu.c [POWERPC] Fix powerpc 44x_mmu build 2006-08-25 13:41:41 +10:00
fault.c [PATCH] Do a single one-line printk in bad_page_fault() 2006-11-13 14:48:56 +11:00
fsl_booke_mmu.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
hash_low_32.S [POWERPC] Fix 32-bit mm operations when not using BATs 2007-04-13 04:09:39 +10:00
hash_low_64.S [POWERPC] Allow drivers to map individual 4k pages to userspace 2007-04-13 03:55:18 +10:00
hash_native_64.c [POWERPC] Rename get_property to of_get_property: arch/powerpc 2007-04-13 03:55:19 +10:00
hash_utils_64.c [POWERPC] DEBUG_PAGEALLOC for 64-bit 2007-04-13 04:09:39 +10:00
hugetlbpage.c get_unmapped_area handles MAP_FIXED on powerpc 2007-05-07 12:12:55 -07:00
imalloc.c [PATCH] getting rid of all casts of k[cmz]alloc() calls 2006-12-13 09:05:58 -08:00
init_32.c [POWERPC] DEBUG_PAGEALLOC for 32-bit 2007-04-13 04:09:39 +10:00
init_64.c slab allocators: remove multiple alignment specifications 2007-05-07 12:12:55 -07:00
lmb.c [POWERPC] Allow duplicate lmb_reserve() calls 2007-03-08 15:43:28 +11:00
Makefile [POWERPC] ps3: multiplatform build fixes 2006-12-04 20:41:16 +11:00
mem.c [POWERPC] Fix 32-bit mm operations when not using BATs 2007-04-13 04:09:39 +10:00
mmap.c [PATCH] powerpc: trivial: modify comments to refer to new location of files 2006-02-10 16:53:51 +11:00
mmu_context_32.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
mmu_context_64.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
mmu_decl.h [POWERPC] Cleanup and fix breakage in tlbflush.h 2007-04-24 22:08:56 +10:00
numa.c [POWERPC] Rename get_property to of_get_property: arch/powerpc 2007-04-13 03:55:19 +10:00
pgtable_32.c [POWERPC] Abolish PHYS_FMT macro from arch/powerpc 2007-04-24 22:11:16 +10:00
pgtable_64.c [POWERPC] Fix bug with early ioremap and 64k pages 2007-02-16 14:00:20 +11:00
ppc_mmu_32.c [POWERPC] DEBUG_PAGEALLOC for 32-bit 2007-04-13 04:09:39 +10:00
slb.c [POWERPC] iSeries: fix slb.c for combined build 2006-12-04 20:39:19 +11:00
slb_low.S [POWERPC] implement BEGIN/END_FW_FTR_SECTION 2006-10-03 16:50:21 +10:00
stab.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
tlb_32.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
tlb_64.c [POWERPC] Make tlb flush batch use lazy MMU mode 2007-04-13 04:09:38 +10:00