1 #ifndef _ASM_POWERPC_HUGETLB_H
2 #define _ASM_POWERPC_HUGETLB_H
4 #ifdef CONFIG_HUGETLB_PAGE
7 extern struct kmem_cache
*hugepte_cache
;
9 static inline pte_t
*hugepd_page(hugepd_t hpd
)
11 BUG_ON(!hugepd_ok(hpd
));
12 return (pte_t
*)((hpd
.pd
& ~HUGEPD_SHIFT_MASK
) | PD_HUGE
);
15 static inline unsigned int hugepd_shift(hugepd_t hpd
)
17 return hpd
.pd
& HUGEPD_SHIFT_MASK
;
20 static inline pte_t
*hugepte_offset(hugepd_t
*hpdp
, unsigned long addr
,
24 * On FSL BookE, we have multiple higher-level table entries that
25 * point to the same hugepte. Just use the first one since they're all
26 * identical. So for that case, idx=0.
28 unsigned long idx
= 0;
30 pte_t
*dir
= hugepd_page(*hpdp
);
31 #ifndef CONFIG_PPC_FSL_BOOK3E
32 idx
= (addr
& ((1UL << pdshift
) - 1)) >> hugepd_shift(*hpdp
);
38 pte_t
*huge_pte_offset_and_shift(struct mm_struct
*mm
,
39 unsigned long addr
, unsigned *shift
);
41 void flush_dcache_icache_hugepage(struct page
*page
);
43 #if defined(CONFIG_PPC_MM_SLICES) || defined(CONFIG_PPC_SUBPAGE_PROT)
44 int is_hugepage_only_range(struct mm_struct
*mm
, unsigned long addr
,
47 static inline int is_hugepage_only_range(struct mm_struct
*mm
,
55 void book3e_hugetlb_preload(struct vm_area_struct
*vma
, unsigned long ea
,
57 void flush_hugetlb_page(struct vm_area_struct
*vma
, unsigned long vmaddr
);
59 void hugetlb_free_pgd_range(struct mmu_gather
*tlb
, unsigned long addr
,
60 unsigned long end
, unsigned long floor
,
61 unsigned long ceiling
);
64 * The version of vma_mmu_pagesize() in arch/powerpc/mm/hugetlbpage.c needs
65 * to override the version in mm/hugetlb.c
67 #define vma_mmu_pagesize vma_mmu_pagesize
70 * If the arch doesn't supply something else, assume that hugepage
71 * size aligned regions are ok without further preparation.
73 static inline int prepare_hugepage_range(struct file
*file
,
74 unsigned long addr
, unsigned long len
)
76 struct hstate
*h
= hstate_file(file
);
77 if (len
& ~huge_page_mask(h
))
79 if (addr
& ~huge_page_mask(h
))
84 static inline void hugetlb_prefault_arch_hook(struct mm_struct
*mm
)
89 static inline void set_huge_pte_at(struct mm_struct
*mm
, unsigned long addr
,
90 pte_t
*ptep
, pte_t pte
)
92 set_pte_at(mm
, addr
, ptep
, pte
);
95 static inline pte_t
huge_ptep_get_and_clear(struct mm_struct
*mm
,
96 unsigned long addr
, pte_t
*ptep
)
99 return __pte(pte_update(mm
, addr
, ptep
, ~0UL, 1));
101 return __pte(pte_update(ptep
, ~0UL, 0));
105 static inline void huge_ptep_clear_flush(struct vm_area_struct
*vma
,
106 unsigned long addr
, pte_t
*ptep
)
109 pte
= huge_ptep_get_and_clear(vma
->vm_mm
, addr
, ptep
);
110 flush_tlb_page(vma
, addr
);
113 static inline int huge_pte_none(pte_t pte
)
115 return pte_none(pte
);
118 static inline pte_t
huge_pte_wrprotect(pte_t pte
)
120 return pte_wrprotect(pte
);
123 static inline int huge_ptep_set_access_flags(struct vm_area_struct
*vma
,
124 unsigned long addr
, pte_t
*ptep
,
125 pte_t pte
, int dirty
)
127 #ifdef HUGETLB_NEED_PRELOAD
129 * The "return 1" forces a call of update_mmu_cache, which will write a
130 * TLB entry. Without this, platforms that don't do a write of the TLB
131 * entry in the TLB miss handler asm will fault ad infinitum.
133 ptep_set_access_flags(vma
, addr
, ptep
, pte
, dirty
);
136 return ptep_set_access_flags(vma
, addr
, ptep
, pte
, dirty
);
140 static inline pte_t
huge_ptep_get(pte_t
*ptep
)
145 static inline int arch_prepare_hugepage(struct page
*page
)
150 static inline void arch_release_hugepage(struct page
*page
)
154 #else /* ! CONFIG_HUGETLB_PAGE */
155 static inline void flush_hugetlb_page(struct vm_area_struct
*vma
,
156 unsigned long vmaddr
)
159 #endif /* CONFIG_HUGETLB_PAGE */
163 * FSL Book3E platforms require special gpage handling - the gpages
164 * are reserved early in the boot process by memblock instead of via
165 * the .dts as on IBM platforms.
167 #if defined(CONFIG_HUGETLB_PAGE) && defined(CONFIG_PPC_FSL_BOOK3E)
168 extern void __init
reserve_hugetlb_gpages(void);
170 static inline void reserve_hugetlb_gpages(void)
175 #endif /* _ASM_POWERPC_HUGETLB_H */