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.
16 #include <linux/hugetlb.h>
17 #include <linux/pagemap.h>
18 #include <linux/err.h>
19 #include <linux/sysctl.h>
22 #include <asm/tlbflush.h>
24 pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
25 unsigned long addr, unsigned long sz)
32 pgd = pgd_offset(mm, addr);
33 p4d = p4d_alloc(mm, pgd, addr);
34 pud = pud_alloc(mm, p4d, addr);
36 pte = (pte_t *)pmd_alloc(mm, pud, addr);
41 pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr,
49 pgd = pgd_offset(mm, addr);
50 if (pgd_present(*pgd)) {
51 p4d = p4d_offset(pgd, addr);
52 if (p4d_present(*p4d)) {
53 pud = pud_offset(p4d, addr);
54 if (pud_present(*pud))
55 pmd = pmd_offset(pud, addr);
61 int pmd_huge(pmd_t pmd)
63 return (pmd_val(pmd) & _PAGE_HUGE) != 0;
66 int pud_huge(pud_t pud)
68 return (pud_val(pud) & _PAGE_HUGE) != 0;