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
8 * Copyright (C) 2002, Rohit Seth <rohit.seth@intel.com>
9 * Copyright 2005, Embedded Alley Solutions, Inc.
10 * Matt Porter <mporter@embeddedalley.com>
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
, unsigned long addr
,
31 pgd
= pgd_offset(mm
, addr
);
32 pud
= pud_alloc(mm
, pgd
, addr
);
34 pte
= (pte_t
*)pmd_alloc(mm
, pud
, addr
);
39 pte_t
*huge_pte_offset(struct mm_struct
*mm
, unsigned long addr
)
45 pgd
= pgd_offset(mm
, addr
);
46 if (pgd_present(*pgd
)) {
47 pud
= pud_offset(pgd
, addr
);
48 if (pud_present(*pud
))
49 pmd
= pmd_offset(pud
, addr
);
54 int huge_pmd_unshare(struct mm_struct
*mm
, unsigned long *addr
, pte_t
*ptep
)
60 * This function checks for proper alignment of input addr and len parameters.
62 int is_aligned_hugepage_range(unsigned long addr
, unsigned long len
)
64 if (len
& ~HPAGE_MASK
)
66 if (addr
& ~HPAGE_MASK
)
71 int pmd_huge(pmd_t pmd
)
73 return (pmd_val(pmd
) & _PAGE_HUGE
) != 0;
76 int pud_huge(pud_t pud
)
78 return (pud_val(pud
) & _PAGE_HUGE
) != 0;