License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / arch / x86 / include / asm / pgtable_64_types.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_PGTABLE_64_DEFS_H
3 #define _ASM_X86_PGTABLE_64_DEFS_H
4
5 #include <asm/sparsemem.h>
6
7 #ifndef __ASSEMBLY__
8 #include <linux/types.h>
9 #include <asm/kaslr.h>
10
11 /*
12  * These are used to make use of C type-checking..
13  */
14 typedef unsigned long   pteval_t;
15 typedef unsigned long   pmdval_t;
16 typedef unsigned long   pudval_t;
17 typedef unsigned long   p4dval_t;
18 typedef unsigned long   pgdval_t;
19 typedef unsigned long   pgprotval_t;
20
21 typedef struct { pteval_t pte; } pte_t;
22
23 #endif  /* !__ASSEMBLY__ */
24
25 #define SHARED_KERNEL_PMD       0
26
27 #ifdef CONFIG_X86_5LEVEL
28
29 /*
30  * PGDIR_SHIFT determines what a top-level page table entry can map
31  */
32 #define PGDIR_SHIFT     48
33 #define PTRS_PER_PGD    512
34
35 /*
36  * 4th level page in 5-level paging case
37  */
38 #define P4D_SHIFT       39
39 #define PTRS_PER_P4D    512
40 #define P4D_SIZE        (_AC(1, UL) << P4D_SHIFT)
41 #define P4D_MASK        (~(P4D_SIZE - 1))
42
43 #else /* CONFIG_X86_5LEVEL */
44
45 /*
46  * PGDIR_SHIFT determines what a top-level page table entry can map
47  */
48 #define PGDIR_SHIFT     39
49 #define PTRS_PER_PGD    512
50
51 #endif /* CONFIG_X86_5LEVEL */
52
53 /*
54  * 3rd level page
55  */
56 #define PUD_SHIFT       30
57 #define PTRS_PER_PUD    512
58
59 /*
60  * PMD_SHIFT determines the size of the area a middle-level
61  * page table can map
62  */
63 #define PMD_SHIFT       21
64 #define PTRS_PER_PMD    512
65
66 /*
67  * entries per page directory level
68  */
69 #define PTRS_PER_PTE    512
70
71 #define PMD_SIZE        (_AC(1, UL) << PMD_SHIFT)
72 #define PMD_MASK        (~(PMD_SIZE - 1))
73 #define PUD_SIZE        (_AC(1, UL) << PUD_SHIFT)
74 #define PUD_MASK        (~(PUD_SIZE - 1))
75 #define PGDIR_SIZE      (_AC(1, UL) << PGDIR_SHIFT)
76 #define PGDIR_MASK      (~(PGDIR_SIZE - 1))
77
78 /* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */
79 #define MAXMEM          _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
80 #ifdef CONFIG_X86_5LEVEL
81 #define VMALLOC_SIZE_TB _AC(16384, UL)
82 #define __VMALLOC_BASE  _AC(0xff92000000000000, UL)
83 #define __VMEMMAP_BASE  _AC(0xffd4000000000000, UL)
84 #else
85 #define VMALLOC_SIZE_TB _AC(32, UL)
86 #define __VMALLOC_BASE  _AC(0xffffc90000000000, UL)
87 #define __VMEMMAP_BASE  _AC(0xffffea0000000000, UL)
88 #endif
89 #ifdef CONFIG_RANDOMIZE_MEMORY
90 #define VMALLOC_START   vmalloc_base
91 #define VMEMMAP_START   vmemmap_base
92 #else
93 #define VMALLOC_START   __VMALLOC_BASE
94 #define VMEMMAP_START   __VMEMMAP_BASE
95 #endif /* CONFIG_RANDOMIZE_MEMORY */
96 #define VMALLOC_END     (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
97 #define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
98 /* The module sections ends with the start of the fixmap */
99 #define MODULES_END   __fix_to_virt(__end_of_fixed_addresses + 1)
100 #define MODULES_LEN   (MODULES_END - MODULES_VADDR)
101 #define ESPFIX_PGD_ENTRY _AC(-2, UL)
102 #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << P4D_SHIFT)
103 #define EFI_VA_START     ( -4 * (_AC(1, UL) << 30))
104 #define EFI_VA_END       (-68 * (_AC(1, UL) << 30))
105
106 #define EARLY_DYNAMIC_PAGE_TABLES       64
107
108 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */