2 * arch/arm/include/asm/hugetlb-2level.h
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 #ifndef _ASM_ARM_HUGETLB_2LEVEL_H
23 #define _ASM_ARM_HUGETLB_2LEVEL_H
26 static inline pte_t huge_ptep_get(pte_t *ptep)
28 pmd_t pmd = *((pmd_t *)ptep);
34 retval = __pte((pteval_t) (pmd_val(pmd) & HPAGE_MASK)
35 | arm_hugepteprotval);
38 retval = pte_mkexec(retval);
40 retval = pte_mknexec(retval);
43 retval = pte_mkyoung(retval);
45 retval = pte_mkold(retval);
48 retval = pte_mkdirty(retval);
50 retval = pte_mkclean(retval);
53 retval = pte_mkwrite(retval);
55 retval = pte_wrprotect(retval);
60 static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
61 pte_t *ptep, pte_t pte)
63 pmdval_t pmdval = (pmdval_t) pte_val(pte);
64 pmd_t *pmdp = (pmd_t *) ptep;
66 /* take the target address bits from the pte only */
70 * now use pmd_modify to translate the permission bits from the pte
71 * and set the memory type information.
73 pmdval = pmd_val(pmd_modify(__pmd(pmdval), __pgprot(pte_val(pte))));
75 __sync_icache_dcache(pte);
77 set_pmd_at(mm, addr, pmdp, __pmd(pmdval));
80 static inline pte_t pte_mkhuge(pte_t pte) { return pte; }
82 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
83 unsigned long addr, pte_t *ptep)
85 pmd_t *pmdp = (pmd_t *)ptep;
87 flush_tlb_range(vma, addr, addr + HPAGE_SIZE);
90 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
91 unsigned long addr, pte_t *ptep)
93 pmd_t *pmdp = (pmd_t *) ptep;
94 set_pmd_at(mm, addr, pmdp, pmd_wrprotect(*pmdp));
98 static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
99 unsigned long addr, pte_t *ptep)
101 pmd_t *pmdp = (pmd_t *)ptep;
102 pte_t pte = huge_ptep_get(ptep);
108 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
109 unsigned long addr, pte_t *ptep,
110 pte_t pte, int dirty)
112 int changed = !pte_same(huge_ptep_get(ptep), pte);
114 set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
115 flush_tlb_range(vma, addr, addr + HPAGE_SIZE);
121 #endif /* _ASM_ARM_HUGETLB_2LEVEL_H */