blob: 932dadfdca544e4f08c130ee921c0954f1694643 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0
2#include <linux/hugetlb.h>
3#include <linux/err.h>
4
5int pud_huge(pud_t pud)
6{
Olivier Deprez157378f2022-04-04 15:47:50 +02007 return pud_leaf(pud);
David Brazdil0f672f62019-12-10 10:32:29 +00008}
9
10int pmd_huge(pmd_t pmd)
11{
Olivier Deprez157378f2022-04-04 15:47:50 +020012 return pmd_leaf(pmd);
David Brazdil0f672f62019-12-10 10:32:29 +000013}
14
Olivier Deprez157378f2022-04-04 15:47:50 +020015bool __init arch_hugetlb_valid_size(unsigned long size)
David Brazdil0f672f62019-12-10 10:32:29 +000016{
Olivier Deprez157378f2022-04-04 15:47:50 +020017 if (size == HPAGE_SIZE)
18 return true;
19 else if (IS_ENABLED(CONFIG_64BIT) && size == PUD_SIZE)
20 return true;
21 else
22 return false;
David Brazdil0f672f62019-12-10 10:32:29 +000023}
David Brazdil0f672f62019-12-10 10:32:29 +000024
25#ifdef CONFIG_CONTIG_ALLOC
26static __init int gigantic_pages_init(void)
27{
28 /* With CONTIG_ALLOC, we can allocate gigantic pages at runtime */
Olivier Deprez157378f2022-04-04 15:47:50 +020029 if (IS_ENABLED(CONFIG_64BIT))
David Brazdil0f672f62019-12-10 10:32:29 +000030 hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
31 return 0;
32}
33arch_initcall(gigantic_pages_init);
34#endif