Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[cascardo/linux.git] / arch / ia64 / mm / hugetlbpage.c
index 9dbc7da..c7c90f4 100644 (file)
@@ -8,7 +8,6 @@
  * Feb, 2004: dynamic hugetlb page size via boot parameter
  */
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/mm.h>
@@ -65,14 +64,21 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr)
        return pte;
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 #define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; }
 
 /*
  * Don't actually need to do any preparation, but need to make sure
  * the address is in the right region.
  */
-int prepare_hugepage_range(unsigned long addr, unsigned long len)
+int prepare_hugepage_range(unsigned long addr, unsigned long len, pgoff_t pgoff)
 {
+       if (pgoff & (~HPAGE_MASK >> PAGE_SHIFT))
+               return -EINVAL;
        if (len & ~HPAGE_MASK)
                return -EINVAL;
        if (addr & ~HPAGE_MASK)
@@ -113,8 +119,7 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb,
                        unsigned long floor, unsigned long ceiling)
 {
        /*
-        * This is called only when is_hugepage_only_range(addr,),
-        * and it follows that is_hugepage_only_range(end,) also.
+        * This is called to free hugetlb page tables.
         *
         * The offset of these addresses from the base of the hugetlb
         * region must be scaled down by HPAGE_SIZE/PAGE_SIZE so that
@@ -126,9 +131,9 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb,
 
        addr = htlbpage_to_page(addr);
        end  = htlbpage_to_page(end);
-       if (is_hugepage_only_range(tlb->mm, floor, HPAGE_SIZE))
+       if (REGION_NUMBER(floor) == RGN_HPAGE)
                floor = htlbpage_to_page(floor);
-       if (is_hugepage_only_range(tlb->mm, ceiling, HPAGE_SIZE))
+       if (REGION_NUMBER(ceiling) == RGN_HPAGE)
                ceiling = htlbpage_to_page(ceiling);
 
        free_pgd_range(tlb, addr, end, floor, ceiling);
@@ -143,6 +148,14 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
                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;