1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H
3 #define _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H
4
hugepd_page(hugepd_t hpd)5 static inline pte_t *hugepd_page(hugepd_t hpd)
6 {
7 if (WARN_ON(!hugepd_ok(hpd)))
8 return NULL;
9
10 return (pte_t *)((hpd_val(hpd) & ~HUGEPD_SHIFT_MASK) | PD_HUGE);
11 }
12
hugepd_shift(hugepd_t hpd)13 static inline unsigned int hugepd_shift(hugepd_t hpd)
14 {
15 return hpd_val(hpd) & HUGEPD_SHIFT_MASK;
16 }
17
hugepte_offset(hugepd_t hpd,unsigned long addr,unsigned int pdshift)18 static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
19 unsigned int pdshift)
20 {
21 /*
22 * On FSL BookE, we have multiple higher-level table entries that
23 * point to the same hugepte. Just use the first one since they're all
24 * identical. So for that case, idx=0.
25 */
26 return hugepd_page(hpd);
27 }
28
29 void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
30
hugepd_populate(hugepd_t * hpdp,pte_t * new,unsigned int pshift)31 static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift)
32 {
33 /* We use the old format for PPC_FSL_BOOK3E */
34 *hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift);
35 }
36
check_and_get_huge_psize(int shift)37 static inline int check_and_get_huge_psize(int shift)
38 {
39 if (shift & 1) /* Not a power of 4 */
40 return -EINVAL;
41
42 return shift_to_mmu_psize(shift);
43 }
44
45 #endif /* _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H */
46