diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2007-05-06 17:50:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:12:57 -0400 |
commit | 06abdfb47ee745a4d79721de24260815ec6bca2b (patch) | |
tree | afbf3f7a0f020529317ec115d2b5f62f67c84404 /mm | |
parent | 036e08568cbee4b16e14551e9f004c3d490d6271 (diff) |
get_unmapped_area handles MAP_FIXED in generic code
generic arch_get_unmapped_area() now handles MAP_FIXED. Now that all
implementations have been fixed, change the toplevel get_unmapped_area() to
call into arch or drivers for the MAP_FIXED case.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
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: William Irwin <bill.irwin@oracle.com>
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>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mmap.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -1200,6 +1200,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, | |||
1200 | if (len > TASK_SIZE) | 1200 | if (len > TASK_SIZE) |
1201 | return -ENOMEM; | 1201 | return -ENOMEM; |
1202 | 1202 | ||
1203 | if (flags & MAP_FIXED) | ||
1204 | return addr; | ||
1205 | |||
1203 | if (addr) { | 1206 | if (addr) { |
1204 | addr = PAGE_ALIGN(addr); | 1207 | addr = PAGE_ALIGN(addr); |
1205 | vma = find_vma(mm, addr); | 1208 | vma = find_vma(mm, addr); |
@@ -1273,6 +1276,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, | |||
1273 | if (len > TASK_SIZE) | 1276 | if (len > TASK_SIZE) |
1274 | return -ENOMEM; | 1277 | return -ENOMEM; |
1275 | 1278 | ||
1279 | if (flags & MAP_FIXED) | ||
1280 | return addr; | ||
1281 | |||
1276 | /* requesting a specific address */ | 1282 | /* requesting a specific address */ |
1277 | if (addr) { | 1283 | if (addr) { |
1278 | addr = PAGE_ALIGN(addr); | 1284 | addr = PAGE_ALIGN(addr); |
@@ -1361,22 +1367,21 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, | |||
1361 | unsigned long pgoff, unsigned long flags) | 1367 | unsigned long pgoff, unsigned long flags) |
1362 | { | 1368 | { |
1363 | unsigned long ret; | 1369 | unsigned long ret; |
1364 | 1370 | unsigned long (*get_area)(struct file *, unsigned long, | |
1365 | if (!(flags & MAP_FIXED)) { | 1371 | unsigned long, unsigned long, unsigned long); |
1366 | unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); | 1372 | |
1367 | 1373 | get_area = current->mm->get_unmapped_area; | |
1368 | get_area = current->mm->get_unmapped_area; | 1374 | if (file && file->f_op && file->f_op->get_unmapped_area) |
1369 | if (file && file->f_op && file->f_op->get_unmapped_area) | 1375 | get_area = file->f_op->get_unmapped_area; |
1370 | get_area = file->f_op->get_unmapped_area; | 1376 | addr = get_area(file, addr, len, pgoff, flags); |
1371 | addr = get_area(file, addr, len, pgoff, flags); | 1377 | if (IS_ERR_VALUE(addr)) |
1372 | if (IS_ERR_VALUE(addr)) | 1378 | return addr; |
1373 | return addr; | ||
1374 | } | ||
1375 | 1379 | ||
1376 | if (addr > TASK_SIZE - len) | 1380 | if (addr > TASK_SIZE - len) |
1377 | return -ENOMEM; | 1381 | return -ENOMEM; |
1378 | if (addr & ~PAGE_MASK) | 1382 | if (addr & ~PAGE_MASK) |
1379 | return -EINVAL; | 1383 | return -EINVAL; |
1384 | |||
1380 | if (file && is_file_hugepages(file)) { | 1385 | if (file && is_file_hugepages(file)) { |
1381 | /* | 1386 | /* |
1382 | * Check if the given range is hugepage aligned, and | 1387 | * Check if the given range is hugepage aligned, and |