Pull asus into release branch
[pandora-kernel.git] / arch / powerpc / mm / hugetlbpage.c
index 506d897..f6ffaaa 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/machdep.h>
 #include <asm/cputable.h>
 #include <asm/tlb.h>
+#include <asm/spu.h>
 
 #include <linux/sysctl.h>
 
@@ -146,6 +147,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
        return hugepte_offset(hpdp, addr);
 }
 
+int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
+{
+       return 0;
+}
+
 static void free_hugepte_range(struct mmu_gather *tlb, hugepd_t *hpdp)
 {
        pte_t *hugepte = hugepd_page(*hpdp);
@@ -508,6 +514,9 @@ int prepare_hugepage_range(unsigned long addr, unsigned long len, pgoff_t pgoff)
        if ((addr + len) > 0x100000000UL)
                err = open_high_hpage_areas(current->mm,
                                            HTLB_AREA_MASK(addr, len));
+#ifdef CONFIG_SPE_BASE
+       spu_flush_all_slbs(current->mm);
+#endif
        if (err) {
                printk(KERN_DEBUG "prepare_hugepage_range(%lx, %lx)"
                       " failed (lowmask: 0x%04hx, highmask: 0x%04hx)\n",
@@ -739,7 +748,8 @@ static int htlb_check_hinted_area(unsigned long addr, unsigned long len)
        struct vm_area_struct *vma;
 
        vma = find_vma(current->mm, addr);
-       if (!vma || ((addr + len) <= vma->vm_start))
+       if (TASK_SIZE - len >= addr &&
+           (!vma || ((addr + len) <= vma->vm_start)))
                return 0;
 
        return -ENOMEM;
@@ -810,6 +820,8 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
                return -EINVAL;
        if (len & ~HPAGE_MASK)
                return -EINVAL;
+       if (len > TASK_SIZE)
+               return -ENOMEM;
 
        if (!cpu_has_feature(CPU_FTR_16M_PAGE))
                return -EINVAL;
@@ -818,9 +830,6 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
        BUG_ON((addr + len)  < addr);
 
        if (test_thread_flag(TIF_32BIT)) {
-               /* Paranoia, caller should have dealt with this */
-               BUG_ON((addr + len) > 0x100000000UL);
-
                curareas = current->mm->context.low_htlb_areas;
 
                /* First see if we can use the hint address */
@@ -1009,7 +1018,6 @@ repeat:
 
                /* Primary is full, try the secondary */
                if (unlikely(slot == -1)) {
-                       new_pte |= _PAGE_F_SECOND;
                        hpte_group = ((~hash & htab_hash_mask) *
                                      HPTES_PER_GROUP) & ~0x7UL; 
                        slot = ppc_md.hpte_insert(hpte_group, va, pa, rflags,
@@ -1028,7 +1036,7 @@ repeat:
                if (unlikely(slot == -2))
                        panic("hash_huge_page: pte_insert failed\n");
 
-               new_pte |= (slot << 12) & _PAGE_F_GIX;
+               new_pte |= (slot << 12) & (_PAGE_F_SECOND | _PAGE_F_GIX);
        }
 
        /*
@@ -1042,7 +1050,7 @@ repeat:
        return err;
 }
 
-static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags)
+static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
 {
        memset(addr, 0, kmem_cache_size(cache));
 }