| 1 | // SPDX-License-Identifier: GPL-2.0 | 
|---|---|
| 2 | /* | 
| 3 | * IA-32 Huge TLB Page Support for Kernel. | 
| 4 | * | 
| 5 | * Copyright (C) 2002, Rohit Seth <rohit.seth@intel.com> | 
| 6 | */ | 
| 7 | |
| 8 | #include <linux/init.h> | 
| 9 | #include <linux/fs.h> | 
| 10 | #include <linux/mm.h> | 
| 11 | #include <linux/sched/mm.h> | 
| 12 | #include <linux/hugetlb.h> | 
| 13 | #include <linux/pagemap.h> | 
| 14 | #include <linux/err.h> | 
| 15 | #include <linux/sysctl.h> | 
| 16 | #include <linux/compat.h> | 
| 17 | #include <asm/mman.h> | 
| 18 | #include <asm/tlb.h> | 
| 19 | #include <asm/tlbflush.h> | 
| 20 | #include <asm/elf.h> | 
| 21 | |
| 22 | |
| 23 | #ifdef CONFIG_X86_64 | 
| 24 | bool __init arch_hugetlb_valid_size(unsigned long size) | 
| 25 | { | 
| 26 | if (size == PMD_SIZE) | 
| 27 | return true; | 
| 28 | else if (size == PUD_SIZE && boot_cpu_has(X86_FEATURE_GBPAGES)) | 
| 29 | return true; | 
| 30 | else | 
| 31 | return false; | 
| 32 | } | 
| 33 | |
| 34 | #ifdef CONFIG_CONTIG_ALLOC | 
| 35 | static __init int gigantic_pages_init(void) | 
| 36 | { | 
| 37 | /* With compaction or CMA we can allocate gigantic pages at runtime */ | 
| 38 | if (boot_cpu_has(X86_FEATURE_GBPAGES)) | 
| 39 | hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT); | 
| 40 | return 0; | 
| 41 | } | 
| 42 | arch_initcall(gigantic_pages_init); | 
| 43 | #endif | 
| 44 | #endif | 
| 45 | 
