Skip to content

Commit

Permalink
get_unmapped_area handles MAP_FIXED in generic code
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Ivan Kokshaysky <[email protected]>
Cc: Russell King <[email protected]>
Cc: David Howells <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: "Luck, Tony" <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: Grant Grundler <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: William Irwin <[email protected]>
Cc: Adam Litke <[email protected]>
Cc: David Gibson <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
ozbenh authored and Linus Torvalds committed May 7, 2007
1 parent 036e085 commit 06abdfb
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
if (len > TASK_SIZE)
return -ENOMEM;

if (flags & MAP_FIXED)
return addr;

if (addr) {
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
Expand Down Expand Up @@ -1273,6 +1276,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
if (len > TASK_SIZE)
return -ENOMEM;

if (flags & MAP_FIXED)
return addr;

/* requesting a specific address */
if (addr) {
addr = PAGE_ALIGN(addr);
Expand Down Expand Up @@ -1361,22 +1367,21 @@ get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
unsigned long pgoff, unsigned long flags)
{
unsigned long ret;

if (!(flags & MAP_FIXED)) {
unsigned long (*get_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);

get_area = current->mm->get_unmapped_area;
if (file && file->f_op && file->f_op->get_unmapped_area)
get_area = file->f_op->get_unmapped_area;
addr = get_area(file, addr, len, pgoff, flags);
if (IS_ERR_VALUE(addr))
return addr;
}
unsigned long (*get_area)(struct file *, unsigned long,
unsigned long, unsigned long, unsigned long);

get_area = current->mm->get_unmapped_area;
if (file && file->f_op && file->f_op->get_unmapped_area)
get_area = file->f_op->get_unmapped_area;
addr = get_area(file, addr, len, pgoff, flags);
if (IS_ERR_VALUE(addr))
return addr;

if (addr > TASK_SIZE - len)
return -ENOMEM;
if (addr & ~PAGE_MASK)
return -EINVAL;

if (file && is_file_hugepages(file)) {
/*
* Check if the given range is hugepage aligned, and
Expand Down

0 comments on commit 06abdfb

Please sign in to comment.