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 4 5 #define PAGE_SHIFT_8M 23 6 7 static inline pte_t *hugepd_page(hugepd_t hpd) 8 { 9 BUG_ON(!hugepd_ok(hpd)); 10 11 return (pte_t *)__va(hpd_val(hpd) & ~HUGEPD_SHIFT_MASK); 12 } 13 14 static inline unsigned int hugepd_shift(hugepd_t hpd) 15 { 16 return PAGE_SHIFT_8M; 17 } 18 19 static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr, 20 unsigned int pdshift) 21 { 22 unsigned long idx = (addr & (SZ_4M - 1)) >> PAGE_SHIFT; 23 24 return hugepd_page(hpd) + idx; 25 } 26 27 static inline void flush_hugetlb_page(struct vm_area_struct *vma, 28 unsigned long vmaddr) 29 { 30 flush_tlb_page(vma, vmaddr); 31 } 32 33 static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift) 34 { 35 *hpdp = __hugepd(__pa(new) | _PMD_USER | _PMD_PRESENT | _PMD_PAGE_8M); 36 } 37 38 static inline void hugepd_populate_kernel(hugepd_t *hpdp, pte_t *new, unsigned int pshift) 39 { 40 *hpdp = __hugepd(__pa(new) | _PMD_PRESENT | _PMD_PAGE_8M); 41 } 42 43 static inline int check_and_get_huge_psize(int shift) 44 { 45 return shift_to_mmu_psize(shift); 46 } 47 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, 50 pte_t pte, unsigned long sz); 51 52 #define __HAVE_ARCH_HUGE_PTE_CLEAR 53 static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, 54 pte_t *ptep, unsigned long sz) 55 { 56 pte_update(mm, addr, ptep, ~0UL, 0, 1); 57 } 58 59 #define __HAVE_ARCH_HUGE_PTEP_SET_WRPROTECT 60 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 61 unsigned long addr, pte_t *ptep) 62 { 63 unsigned long clr = ~pte_val(pte_wrprotect(__pte(~0))); 64 unsigned long set = pte_val(pte_wrprotect(__pte(0))); 65 66 pte_update(mm, addr, ptep, clr, set, 1); 67 } 68 69 #ifdef CONFIG_PPC_4K_PAGES 70 static inline pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags) 71 { 72 size_t size = 1UL << shift; 73 74 if (size == SZ_16K) 75 return __pte(pte_val(entry) | _PAGE_SPS); 76 else 77 return __pte(pte_val(entry) | _PAGE_SPS | _PAGE_HUGE); 78 } 79 #define arch_make_huge_pte arch_make_huge_pte 80 #endif 81 82 #endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */ 83