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, pte_t pte); 50 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) 54 { 55 pte_update(mm, addr, ptep, ~0UL, 0, 1); 56 } 57 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) 61 { 62 unsigned long clr = ~pte_val(pte_wrprotect(__pte(~0))); 63 unsigned long set = pte_val(pte_wrprotect(__pte(0))); 64 65 pte_update(mm, addr, ptep, clr, set, 1); 66 } 67 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) 70 { 71 size_t size = 1UL << shift; 72 73 if (size == SZ_16K) 74 return __pte(pte_val(entry) & ~_PAGE_HUGE); 75 else 76 return entry; 77 } 78 #define arch_make_huge_pte arch_make_huge_pte 79 #endif 80 81 #endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */ 82