2019-05-26 20:50:38 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/hugetlb.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
|
|
|
int pud_huge(pud_t pud)
|
|
|
|
{
|
2020-02-20 14:10:23 +08:00
|
|
|
return pud_leaf(pud);
|
2019-05-26 20:50:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int pmd_huge(pmd_t pmd)
|
|
|
|
{
|
2020-02-20 14:10:23 +08:00
|
|
|
return pmd_leaf(pmd);
|
2019-05-26 20:50:38 +08:00
|
|
|
}
|
|
|
|
|
2020-06-04 07:00:34 +08:00
|
|
|
bool __init arch_hugetlb_valid_size(unsigned long size)
|
|
|
|
{
|
|
|
|
if (size == HPAGE_SIZE)
|
|
|
|
return true;
|
|
|
|
else if (IS_ENABLED(CONFIG_64BIT) && size == PUD_SIZE)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:50:38 +08:00
|
|
|
#ifdef CONFIG_CONTIG_ALLOC
|
|
|
|
static __init int gigantic_pages_init(void)
|
|
|
|
{
|
|
|
|
/* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */
|
2020-06-04 07:00:42 +08:00
|
|
|
if (IS_ENABLED(CONFIG_64BIT))
|
2019-05-26 20:50:38 +08:00
|
|
|
hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
arch_initcall(gigantic_pages_init);
|
|
|
|
#endif
|