1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H
3 #define _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H
5 #define PAGE_SHIFT_8M 23
7 static inline pte_t *hugepd_page(hugepd_t hpd)
9 BUG_ON(!hugepd_ok(hpd));
11 return (pte_t *)__va(hpd_val(hpd) & ~HUGEPD_SHIFT_MASK);
14 static inline unsigned int hugepd_shift(hugepd_t hpd)
19 static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr,
22 unsigned long idx = (addr & (SZ_4M - 1)) >> PAGE_SHIFT;
24 return hugepd_page(hpd) + idx;
27 static inline void flush_hugetlb_page(struct vm_area_struct *vma,
30 flush_tlb_page(vma, vmaddr);
33 static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift)
35 *hpdp = __hugepd(__pa(new) | _PMD_USER | _PMD_PRESENT | _PMD_PAGE_8M);
38 static inline void hugepd_populate_kernel(hugepd_t *hpdp, pte_t *new, unsigned int pshift)
40 *hpdp = __hugepd(__pa(new) | _PMD_PRESENT | _PMD_PAGE_8M);
43 static inline int check_and_get_huge_psize(int shift)
45 return shift_to_mmu_psize(shift);
48 #define __HAVE_ARCH_HUGE_SET_HUGE_PTE_AT
49 void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte);
51 #define __HAVE_ARCH_HUGE_PTE_CLEAR
52 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr,
53 pte_t *ptep, unsigned long sz)
55 pte_update(mm, addr, ptep, ~0UL, 0, 1);
58 #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT
59 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
60 unsigned long addr, pte_t *ptep)
62 unsigned long clr = ~pte_val(pte_wrprotect(__pte(~0)));
63 unsigned long set = pte_val(pte_wrprotect(__pte(0)));
65 pte_update(mm, addr, ptep, clr, set, 1);
68 #ifdef CONFIG_PPC_4K_PAGES
69 static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags)
71 size_t size = 1UL << shift;
74 return __pte(pte_val(entry) | _PAGE_SPS);
76 return __pte(pte_val(entry) | _PAGE_SPS | _PAGE_HUGE);
78 #define arch_make_huge_pte arch_make_huge_pte
81 #endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */