2 * arch/arm/mm/hugetlbpage.c
4 * Copyright (C) 2012 ARM Ltd.
6 * Based on arch/x86/include/asm/hugetlb.h and Bill Carson's patches
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/init.h>
25 #include <linux/hugetlb.h>
26 #include <linux/pagemap.h>
27 #include <linux/err.h>
28 #include <linux/sysctl.h>
31 #include <asm/tlbflush.h>
32 #include <asm/pgalloc.h>
35 * On ARM, huge pages are backed by pmd's rather than pte's, so we do a lot
36 * of type casting from pmd_t * to pte_t *.
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);
55 struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
58 return ERR_PTR(-EINVAL);
61 int pmd_huge(pmd_t pmd)
63 return (pmd_val(pmd) & PMD_TYPE_MASK) == PMD_TYPE_SECT;
66 int pud_huge(pud_t pud)
71 int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
76 pte_t *huge_pte_alloc(struct mm_struct *mm,
77 unsigned long addr, unsigned long sz)
83 pgd = pgd_offset(mm, addr);
84 pud = pud_alloc(mm, pgd, addr);
86 pte = (pte_t *)pmd_alloc(mm, pud, addr);
91 struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
92 pmd_t *pmd, int write)
97 pfn = ((pmd_val(*pmd) & HPAGE_MASK) >> PAGE_SHIFT);
98 page = pfn_to_page(pfn);