18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <linux/hugetlb.h> 38c2ecf20Sopenharmony_ci#include <linux/err.h> 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciint pud_huge(pud_t pud) 68c2ecf20Sopenharmony_ci{ 78c2ecf20Sopenharmony_ci return pud_leaf(pud); 88c2ecf20Sopenharmony_ci} 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciint pmd_huge(pmd_t pmd) 118c2ecf20Sopenharmony_ci{ 128c2ecf20Sopenharmony_ci return pmd_leaf(pmd); 138c2ecf20Sopenharmony_ci} 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cibool __init arch_hugetlb_valid_size(unsigned long size) 168c2ecf20Sopenharmony_ci{ 178c2ecf20Sopenharmony_ci if (size == HPAGE_SIZE) 188c2ecf20Sopenharmony_ci return true; 198c2ecf20Sopenharmony_ci else if (IS_ENABLED(CONFIG_64BIT) && size == PUD_SIZE) 208c2ecf20Sopenharmony_ci return true; 218c2ecf20Sopenharmony_ci else 228c2ecf20Sopenharmony_ci return false; 238c2ecf20Sopenharmony_ci} 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#ifdef CONFIG_CONTIG_ALLOC 268c2ecf20Sopenharmony_cistatic __init int gigantic_pages_init(void) 278c2ecf20Sopenharmony_ci{ 288c2ecf20Sopenharmony_ci /* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */ 298c2ecf20Sopenharmony_ci if (IS_ENABLED(CONFIG_64BIT)) 308c2ecf20Sopenharmony_ci hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); 318c2ecf20Sopenharmony_ci return 0; 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ciarch_initcall(gigantic_pages_init); 348c2ecf20Sopenharmony_ci#endif 35