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