Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_POWERPC_BOOK3S_64_PGTABLE_4K_H
0003 #define _ASM_POWERPC_BOOK3S_64_PGTABLE_4K_H
0004 /*
0005  * hash 4k can't share hugetlb and also doesn't support THP
0006  */
0007 #ifndef __ASSEMBLY__
0008 #ifdef CONFIG_HUGETLB_PAGE
0009 static inline int pmd_huge(pmd_t pmd)
0010 {
0011     /*
0012      * leaf pte for huge page
0013      */
0014     if (radix_enabled())
0015         return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE));
0016     return 0;
0017 }
0018 
0019 static inline int pud_huge(pud_t pud)
0020 {
0021     /*
0022      * leaf pte for huge page
0023      */
0024     if (radix_enabled())
0025         return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE));
0026     return 0;
0027 }
0028 
0029 static inline int pgd_huge(pgd_t pgd)
0030 {
0031     /*
0032      * leaf pte for huge page
0033      */
0034     if (radix_enabled())
0035         return !!(pgd_raw(pgd) & cpu_to_be64(_PAGE_PTE));
0036     return 0;
0037 }
0038 #define pgd_huge pgd_huge
0039 /*
0040  * With radix , we have hugepage ptes in the pud and pmd entries. We don't
0041  * need to setup hugepage directory for them. Our pte and page directory format
0042  * enable us to have this enabled.
0043  */
0044 static inline int hugepd_ok(hugepd_t hpd)
0045 {
0046     if (radix_enabled())
0047         return 0;
0048     return hash__hugepd_ok(hpd);
0049 }
0050 #define is_hugepd(hpd)      (hugepd_ok(hpd))
0051 
0052 /*
0053  * 16M and 16G huge page directory tables are allocated from slab cache
0054  *
0055  */
0056 #define H_16M_CACHE_INDEX (PAGE_SHIFT + H_PTE_INDEX_SIZE + H_PMD_INDEX_SIZE - 24)
0057 #define H_16G_CACHE_INDEX                                                      \
0058     (PAGE_SHIFT + H_PTE_INDEX_SIZE + H_PMD_INDEX_SIZE + H_PUD_INDEX_SIZE - 34)
0059 
0060 static inline int get_hugepd_cache_index(int index)
0061 {
0062     switch (index) {
0063     case H_16M_CACHE_INDEX:
0064         return HTLB_16M_INDEX;
0065     case H_16G_CACHE_INDEX:
0066         return HTLB_16G_INDEX;
0067     default:
0068         BUG();
0069     }
0070     /* should not reach */
0071 }
0072 
0073 #endif /* CONFIG_HUGETLB_PAGE */
0074 
0075 #endif /* __ASSEMBLY__ */
0076 
0077 #endif /*_ASM_POWERPC_BOOK3S_64_PGTABLE_4K_H */