1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_POWERPC_BOOK3S_64_HASH_4K_H 3 #define _ASM_POWERPC_BOOK3S_64_HASH_4K_H 4 /* 5 * Entries per page directory level. The PTE level must use a 64b record 6 * for each page table entry. The PMD and PGD level use a 32b record for 7 * each entry by assuming that each entry is page aligned. 8 */ 9 #define H_PTE_INDEX_SIZE 9 10 #define H_PMD_INDEX_SIZE 7 11 #define H_PUD_INDEX_SIZE 9 12 #define H_PGD_INDEX_SIZE 9 13 14 #ifndef __ASSEMBLY__ 15 #define H_PTE_TABLE_SIZE (sizeof(pte_t) << H_PTE_INDEX_SIZE) 16 #define H_PMD_TABLE_SIZE (sizeof(pmd_t) << H_PMD_INDEX_SIZE) 17 #define H_PUD_TABLE_SIZE (sizeof(pud_t) << H_PUD_INDEX_SIZE) 18 #define H_PGD_TABLE_SIZE (sizeof(pgd_t) << H_PGD_INDEX_SIZE) 19 20 #define H_PAGE_F_GIX_SHIFT 53 21 #define H_PAGE_F_SECOND _RPAGE_RPN44 /* HPTE is in 2ndary HPTEG */ 22 #define H_PAGE_F_GIX (_RPAGE_RPN43 | _RPAGE_RPN42 | _RPAGE_RPN41) 23 #define H_PAGE_BUSY _RPAGE_RSV1 /* software: PTE & hash are busy */ 24 #define H_PAGE_HASHPTE _RPAGE_RSV2 /* software: PTE & hash are busy */ 25 26 /* PTE flags to conserve for HPTE identification */ 27 #define _PAGE_HPTEFLAGS (H_PAGE_BUSY | H_PAGE_HASHPTE | \ 28 H_PAGE_F_SECOND | H_PAGE_F_GIX) 29 /* 30 * Not supported by 4k linux page size 31 */ 32 #define H_PAGE_4K_PFN 0x0 33 #define H_PAGE_THP_HUGE 0x0 34 #define H_PAGE_COMBO 0x0 35 #define H_PTE_FRAG_NR 0 36 #define H_PTE_FRAG_SIZE_SHIFT 0 37 /* 38 * On all 4K setups, remap_4k_pfn() equates to remap_pfn_range() 39 */ 40 #define remap_4k_pfn(vma, addr, pfn, prot) \ 41 remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, (prot)) 42 43 #ifdef CONFIG_HUGETLB_PAGE 44 static inline int hash__hugepd_ok(hugepd_t hpd) 45 { 46 unsigned long hpdval = hpd_val(hpd); 47 /* 48 * if it is not a pte and have hugepd shift mask 49 * set, then it is a hugepd directory pointer 50 */ 51 if (!(hpdval & _PAGE_PTE) && 52 ((hpdval & HUGEPD_SHIFT_MASK) != 0)) 53 return true; 54 return false; 55 } 56 #endif 57 58 /* 59 * 4K PTE format is different from 64K PTE format. Saving the hash_slot is just 60 * a matter of returning the PTE bits that need to be modified. On 64K PTE, 61 * things are a little more involved and hence needs many more parameters to 62 * accomplish the same. However we want to abstract this out from the caller by 63 * keeping the prototype consistent across the two formats. 64 */ 65 static inline unsigned long pte_set_hidx(pte_t *ptep, real_pte_t rpte, 66 unsigned int subpg_index, unsigned long hidx) 67 { 68 return (hidx << H_PAGE_F_GIX_SHIFT) & 69 (H_PAGE_F_SECOND | H_PAGE_F_GIX); 70 } 71 72 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 73 74 static inline char *get_hpte_slot_array(pmd_t *pmdp) 75 { 76 BUG(); 77 return NULL; 78 } 79 80 static inline unsigned int hpte_valid(unsigned char *hpte_slot_array, int index) 81 { 82 BUG(); 83 return 0; 84 } 85 86 static inline unsigned int hpte_hash_index(unsigned char *hpte_slot_array, 87 int index) 88 { 89 BUG(); 90 return 0; 91 } 92 93 static inline void mark_hpte_slot_valid(unsigned char *hpte_slot_array, 94 unsigned int index, unsigned int hidx) 95 { 96 BUG(); 97 } 98 99 static inline int hash__pmd_trans_huge(pmd_t pmd) 100 { 101 return 0; 102 } 103 104 static inline int hash__pmd_same(pmd_t pmd_a, pmd_t pmd_b) 105 { 106 BUG(); 107 return 0; 108 } 109 110 static inline pmd_t hash__pmd_mkhuge(pmd_t pmd) 111 { 112 BUG(); 113 return pmd; 114 } 115 116 extern unsigned long hash__pmd_hugepage_update(struct mm_struct *mm, 117 unsigned long addr, pmd_t *pmdp, 118 unsigned long clr, unsigned long set); 119 extern pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, 120 unsigned long address, pmd_t *pmdp); 121 extern void hash__pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, 122 pgtable_t pgtable); 123 extern pgtable_t hash__pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp); 124 extern pmd_t hash__pmdp_huge_get_and_clear(struct mm_struct *mm, 125 unsigned long addr, pmd_t *pmdp); 126 extern int hash__has_transparent_hugepage(void); 127 #endif 128 129 #endif /* !__ASSEMBLY__ */ 130 131 #endif /* _ASM_POWERPC_BOOK3S_64_HASH_4K_H */ 132