2 * MIPS Huge TLB Page Support for Kernel.
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
9 * Copyright 2005, Embedded Alley Solutions, Inc.
11 * Copyright (C) 2008, 2009 Cavium Networks, Inc.
14 #include <linux/init.h>
17 #include <linux/hugetlb.h>
18 #include <linux/pagemap.h>
19 #include <linux/err.h>
20 #include <linux/sysctl.h>
23 #include <asm/tlbflush.h>
25 pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr,
32 pgd = pgd_offset(mm, addr);
33 pud = pud_alloc(mm, pgd, addr);
35 pte = (pte_t *)pmd_alloc(mm, pud, addr);
40 pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
46 pgd = pgd_offset(mm, addr);
47 if (pgd_present(*pgd)) {
48 pud = pud_offset(pgd, addr);
49 if (pud_present(*pud))
50 pmd = pmd_offset(pud, addr);
55 int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
61 * This function checks for proper alignment of input addr and len parameters.
63 int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
65 if (len & ~HPAGE_MASK)
67 if (addr & ~HPAGE_MASK)
73 follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
75 return ERR_PTR(-EINVAL);
78 int pmd_huge(pmd_t pmd)
80 return (pmd_val(pmd) & _PAGE_HUGE) != 0;
83 int pud_huge(pud_t pud)
85 return (pud_val(pud) & _PAGE_HUGE) != 0;
89 follow_huge_pmd(struct mm_struct *mm, unsigned long address,
90 pmd_t *pmd, int write)
94 page = pte_page(*(pte_t *)pmd);
96 page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT);