linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area
@ 2007-04-04  4:01 Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

This is a "first step" as there are still cleanups to be done in various
areas touched by that code but I think it's probably good to go as is and
at least enables me to implement what I need for 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 serie 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 in after review of the individual
bits by respective maintainers I suppose.

Cheers,
Ben.

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 2/14] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/powerpc/mm/hugetlbpage.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Index: linux-cell/arch/powerpc/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/powerpc/mm/hugetlbpage.c	2007-03-22 14:52:07.000000000 +1100
+++ linux-cell/arch/powerpc/mm/hugetlbpage.c	2007-03-22 14:57:40.000000000 +1100
@@ -572,6 +572,13 @@ unsigned long arch_get_unmapped_area(str
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
+	/* handle fixed mapping: prevent overlap with huge pages */
+	if (flags & MAP_FIXED) {
+		if (is_hugepage_only_range(mm, addr, len))
+			return -EINVAL;
+		return addr;
+	}
+
 	if (addr) {
 		addr = PAGE_ALIGN(addr);
 		vma = find_vma(mm, addr);
@@ -647,6 +654,13 @@ arch_get_unmapped_area_topdown(struct fi
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
+	/* handle fixed mapping: prevent overlap with huge pages */
+	if (flags & MAP_FIXED) {
+		if (is_hugepage_only_range(mm, addr, len))
+			return -EINVAL;
+		return addr;
+	}
+
 	/* dont allow allocations above current base */
 	if (mm->free_area_cache > base)
 		mm->free_area_cache = base;
@@ -829,6 +843,13 @@ unsigned long hugetlb_get_unmapped_area(
 	/* Paranoia, caller should have dealt with this */
 	BUG_ON((addr + len)  < addr);
 
+	/* Handle MAP_FIXED */
+	if (flags & MAP_FIXED) {
+		if (prepare_hugepage_range(addr, len, pgoff))
+			return -EINVAL;
+		return addr;
+	}
+
 	if (test_thread_flag(TIF_32BIT)) {
 		curareas = current->mm->context.low_htlb_areas;
 

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/14] get_unmapped_area handles MAP_FIXED on alpha
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 3/14] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/alpha/kernel/osf_sys.c |    3 +++
 1 file changed, 3 insertions(+)

Index: linux-cell/arch/alpha/kernel/osf_sys.c
===================================================================
--- linux-cell.orig/arch/alpha/kernel/osf_sys.c	2007-03-22 14:58:33.000000000 +1100
+++ linux-cell/arch/alpha/kernel/osf_sys.c	2007-03-22 14:58:44.000000000 +1100
@@ -1267,6 +1267,9 @@ arch_get_unmapped_area(struct file *filp
 	if (len > limit)
 		return -ENOMEM;
 
+	if (flags & MAP_FIXED)
+		return addr;
+
 	/* First, see if the given suggestion fits.
 
 	   The OSF/1 loader (/sbin/loader) relies on us returning an

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/14] get_unmapped_area handles MAP_FIXED on arm
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 2/14] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 4/14] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/arm/mm/mmap.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux-cell/arch/arm/mm/mmap.c
===================================================================
--- linux-cell.orig/arch/arm/mm/mmap.c	2007-03-22 14:59:51.000000000 +1100
+++ linux-cell/arch/arm/mm/mmap.c	2007-03-22 15:00:01.000000000 +1100
@@ -49,8 +49,7 @@ arch_get_unmapped_area(struct file *filp
 #endif
 
 	/*
-	 * We should enforce the MAP_FIXED case.  However, currently
-	 * the generic kernel code doesn't allow us to handle this.
+	 * We enforce the MAP_FIXED case.
 	 */
 	if (flags & MAP_FIXED) {
 		if (aliasing && flags & MAP_SHARED && addr & (SHMLBA - 1))

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 5/14] get_unmapped_area handles MAP_FIXED on i386
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (3 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 4/14] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/i386/mm/hugetlbpage.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-cell/arch/i386/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/i386/mm/hugetlbpage.c	2007-03-22 16:08:12.000000000 +1100
+++ linux-cell/arch/i386/mm/hugetlbpage.c	2007-03-22 16:14:19.000000000 +1100
@@ -367,6 +367,12 @@ hugetlb_get_unmapped_area(struct file *f
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
+	if (flags & MAP_FIXED) {
+		if (prepare_hugepage_range(addr, len, pgoff))
+			return -EINVAL;
+		return addr;
+	}
+
 	if (addr) {
 		addr = ALIGN(addr, HPAGE_SIZE);
 		vma = find_vma(mm, addr);

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/14] get_unmapped_area handles MAP_FIXED on frv
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (2 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 3/14] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 5/14] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/frv/mm/elf-fdpic.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: linux-cell/arch/frv/mm/elf-fdpic.c
===================================================================
--- linux-cell.orig/arch/frv/mm/elf-fdpic.c	2007-03-22 15:00:50.000000000 +1100
+++ linux-cell/arch/frv/mm/elf-fdpic.c	2007-03-22 15:01:06.000000000 +1100
@@ -64,6 +64,10 @@ unsigned long arch_get_unmapped_area(str
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
+	/* handle MAP_FIXED */
+	if (flags & MAP_FIXED)
+		return addr;
+
 	/* only honour a hint if we're not going to clobber something doing so */
 	if (addr) {
 		addr = PAGE_ALIGN(addr);

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/14] get_unmapped_area handles MAP_FIXED on ia64
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (5 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 9/14] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/ia64/kernel/sys_ia64.c |    7 +++++++
 arch/ia64/mm/hugetlbpage.c  |    8 ++++++++
 2 files changed, 15 insertions(+)

Index: linux-cell/arch/ia64/kernel/sys_ia64.c
===================================================================
--- linux-cell.orig/arch/ia64/kernel/sys_ia64.c	2007-03-22 15:10:45.000000000 +1100
+++ linux-cell/arch/ia64/kernel/sys_ia64.c	2007-03-22 15:10:47.000000000 +1100
@@ -33,6 +33,13 @@ arch_get_unmapped_area (struct file *fil
 	if (len > RGN_MAP_LIMIT)
 		return -ENOMEM;
 
+	/* handle fixed mapping: prevent overlap with huge pages */
+	if (flags & MAP_FIXED) {
+		if (is_hugepage_only_range(mm, addr, len))
+			return -EINVAL;
+		return addr;
+	}
+
 #ifdef CONFIG_HUGETLB_PAGE
 	if (REGION_NUMBER(addr) == RGN_HPAGE)
 		addr = 0;
Index: linux-cell/arch/ia64/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/ia64/mm/hugetlbpage.c	2007-03-22 15:12:32.000000000 +1100
+++ linux-cell/arch/ia64/mm/hugetlbpage.c	2007-03-22 15:12:39.000000000 +1100
@@ -148,6 +148,14 @@ unsigned long hugetlb_get_unmapped_area(
 		return -ENOMEM;
 	if (len & ~HPAGE_MASK)
 		return -EINVAL;
+
+	/* Handle MAP_FIXED */
+	if (flags & MAP_FIXED) {
+		if (prepare_hugepage_range(addr, len, pgoff))
+			return -EINVAL;
+		return addr;
+	}
+
 	/* This code assumes that RGN_HPAGE != 0. */
 	if ((REGION_NUMBER(addr) != RGN_HPAGE) || (addr & (HPAGE_SIZE - 1)))
 		addr = HPAGE_REGION_BASE;
 

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (4 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 5/14] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 6/14] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/parisc/kernel/sys_parisc.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: linux-cell/arch/parisc/kernel/sys_parisc.c
===================================================================
--- linux-cell.orig/arch/parisc/kernel/sys_parisc.c	2007-03-22 15:28:05.000000000 +1100
+++ linux-cell/arch/parisc/kernel/sys_parisc.c	2007-03-22 15:29:08.000000000 +1100
@@ -106,6 +106,11 @@ unsigned long arch_get_unmapped_area(str
 {
 	if (len > TASK_SIZE)
 		return -ENOMEM;
+	/* Might want to check for cache aliasing issues for MAP_FIXED case
+	 * like ARM or MIPS ??? --BenH.
+	 */
+	if (flags & MAP_FIXED)
+		return addr;
 	if (!addr)
 		addr = TASK_UNMAPPED_BASE;
 

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 8/14] get_unmapped_area handles MAP_FIXED on sparc64
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (7 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 9/14] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 10/14] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/sparc64/mm/hugetlbpage.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-cell/arch/sparc64/mm/hugetlbpage.c
===================================================================
--- linux-cell.orig/arch/sparc64/mm/hugetlbpage.c	2007-03-22 16:12:57.000000000 +1100
+++ linux-cell/arch/sparc64/mm/hugetlbpage.c	2007-03-22 16:15:33.000000000 +1100
@@ -175,6 +175,12 @@ hugetlb_get_unmapped_area(struct file *f
 	if (len > task_size)
 		return -ENOMEM;
 
+	if (flags & MAP_FIXED) {
+		if (prepare_hugepage_range(addr, len, pgoff))
+			return -EINVAL;
+		return addr;
+	}
+
 	if (addr) {
 		addr = ALIGN(addr, HPAGE_SIZE);
 		vma = find_vma(mm, addr);

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 9/14] get_unmapped_area handles MAP_FIXED on x86_64
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (6 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 6/14] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 8/14] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/x86_64/kernel/sys_x86_64.c |    3 +++
 1 file changed, 3 insertions(+)

Index: linux-cell/arch/x86_64/kernel/sys_x86_64.c
===================================================================
--- linux-cell.orig/arch/x86_64/kernel/sys_x86_64.c	2007-03-22 16:10:10.000000000 +1100
+++ linux-cell/arch/x86_64/kernel/sys_x86_64.c	2007-03-22 16:11:06.000000000 +1100
@@ -93,6 +93,9 @@ arch_get_unmapped_area(struct file *filp
 	unsigned long start_addr;
 	unsigned long begin, end;
 	
+	if (flags & MAP_FIXED)
+		return addr;
+
 	find_start_end(flags, &begin, &end); 
 
 	if (len > end)

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 10/14] get_unmapped_area handles MAP_FIXED in hugetlbfs
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (8 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 8/14] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu) Benjamin Herrenschmidt
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 fs/hugetlbfs/inode.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-cell/fs/hugetlbfs/inode.c
===================================================================
--- linux-cell.orig/fs/hugetlbfs/inode.c	2007-03-22 16:12:56.000000000 +1100
+++ linux-cell/fs/hugetlbfs/inode.c	2007-03-22 16:16:02.000000000 +1100
@@ -115,6 +115,12 @@ hugetlb_get_unmapped_area(struct file *f
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
+	if (flags & MAP_FIXED) {
+		if (prepare_hugepage_range(addr, len, pgoff))
+			return -EINVAL;
+		return addr;
+	}
+
 	if (addr) {
 		addr = ALIGN(addr, HPAGE_SIZE);
 		vma = find_vma(mm, addr);

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu)
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (10 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu) Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:03 ` [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 fs/ramfs/file-nommu.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux-cell/fs/ramfs/file-nommu.c
===================================================================
--- linux-cell.orig/fs/ramfs/file-nommu.c	2007-03-22 16:18:27.000000000 +1100
+++ linux-cell/fs/ramfs/file-nommu.c	2007-03-22 16:20:14.000000000 +1100
@@ -238,7 +238,10 @@ unsigned long ramfs_nommu_get_unmapped_a
 	struct page **pages = NULL, **ptr, *page;
 	loff_t isize;
 
-	if (!(flags & MAP_SHARED))
+	/* Deal with MAP_FIXED differently ? Forbid it ? Need help from some nommu
+	 * folks there... --BenH.
+	 */
+	if ((flags & MAP_FIXED) || !(flags & MAP_SHARED))
 		return addr;
 
 	/* the mapping mustn't extend beyond the EOF */

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu)
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (9 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 10/14] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
@ 2007-04-04  4:01 ` Benjamin Herrenschmidt
  2007-04-04  4:01 ` [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu) Benjamin Herrenschmidt
  2007-04-04  4:03 ` [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

This also fixes a bug, I think, it used to return a pgoff (pfn)
instead of an address. (To split ?)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

 drivers/char/mem.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux-cell/drivers/char/mem.c
===================================================================
--- linux-cell.orig/drivers/char/mem.c	2007-03-22 16:24:04.000000000 +1100
+++ linux-cell/drivers/char/mem.c	2007-03-22 16:26:30.000000000 +1100
@@ -246,9 +246,12 @@ static unsigned long get_unmapped_area_m
 					   unsigned long pgoff,
 					   unsigned long flags)
 {
+	if (flags & MAP_FIXED)
+		if ((addr >> PAGE_SHIFT) != pgoff)
+			return (unsigned long) -EINVAL;
 	if (!valid_mmap_phys_addr_range(pgoff, len))
 		return (unsigned long) -EINVAL;
-	return pgoff;
+	return pgoff << PAGE_SHIFT;
 }
 
 /* can't do an in-place private mapping if there's no MMU */

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area
  2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
                   ` (11 preceding siblings ...)
  2007-04-04  4:01 ` [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu) Benjamin Herrenschmidt
@ 2007-04-04  4:03 ` Benjamin Herrenschmidt
  12 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:03 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

On Wed, 2007-04-04 at 14:01 +1000, Benjamin Herrenschmidt wrote:
> This is a "first step" as there are still cleanups to be done in various
> areas touched by that code but I think it's probably good to go as is and
> at least enables me to implement what I need for PowerPC.


 .../...

And sorry for the double-send of some of the patches, a script hickup on
my side.

Cheers,
Ben.


--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc
  2007-04-04  4:02 Benjamin Herrenschmidt
@ 2007-04-04  4:02 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04  4:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-arch, Linux Memory Management, linux-kernel

---

 arch/parisc/kernel/sys_parisc.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: linux-cell/arch/parisc/kernel/sys_parisc.c
===================================================================
--- linux-cell.orig/arch/parisc/kernel/sys_parisc.c	2007-03-22 15:28:05.000000000 +1100
+++ linux-cell/arch/parisc/kernel/sys_parisc.c	2007-03-22 15:29:08.000000000 +1100
@@ -106,6 +106,11 @@ unsigned long arch_get_unmapped_area(str
 {
 	if (len > TASK_SIZE)
 		return -ENOMEM;
+	/* Might want to check for cache aliasing issues for MAP_FIXED case
+	 * like ARM or MIPS ??? --BenH.
+	 */
+	if (flags & MAP_FIXED)
+		return addr;
 	if (!addr)
 		addr = TASK_UNMAPPED_BASE;
 

--
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>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-04-04  4:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-04  4:01 [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 1/14] get_unmapped_area handles MAP_FIXED on powerpc Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 2/14] get_unmapped_area handles MAP_FIXED on alpha Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 3/14] get_unmapped_area handles MAP_FIXED on arm Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 4/14] get_unmapped_area handles MAP_FIXED on frv Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 5/14] get_unmapped_area handles MAP_FIXED on i386 Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 6/14] get_unmapped_area handles MAP_FIXED on ia64 Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 9/14] get_unmapped_area handles MAP_FIXED on x86_64 Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 8/14] get_unmapped_area handles MAP_FIXED on sparc64 Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 10/14] get_unmapped_area handles MAP_FIXED in hugetlbfs Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 12/14] get_unmapped_area handles MAP_FIXED in /dev/mem (nommu) Benjamin Herrenschmidt
2007-04-04  4:01 ` [PATCH 11/14] get_unmapped_area handles MAP_FIXED on ramfs (nommu) Benjamin Herrenschmidt
2007-04-04  4:03 ` [PATCH 0/14] Pass MAP_FIXED down to get_unmapped_area Benjamin Herrenschmidt
2007-04-04  4:02 Benjamin Herrenschmidt
2007-04-04  4:02 ` [PATCH 7/14] get_unmapped_area handles MAP_FIXED on parisc Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox