]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/x86/include/asm/pgtable_64_types.h
x86/pgtable: Move two more functions from pgtable_64.h to pgtable.h
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / include / asm / pgtable_64_types.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
fb355149
JF
2#ifndef _ASM_X86_PGTABLE_64_DEFS_H
3#define _ASM_X86_PGTABLE_64_DEFS_H
4
8170e6be
PA
5#include <asm/sparsemem.h>
6
54321d94
JF
7#ifndef __ASSEMBLY__
8#include <linux/types.h>
a95ae27c 9#include <asm/kaslr.h>
54321d94
JF
10
11/*
12 * These are used to make use of C type-checking..
13 */
14typedef unsigned long pteval_t;
15typedef unsigned long pmdval_t;
16typedef unsigned long pudval_t;
fe1e8c3e 17typedef unsigned long p4dval_t;
54321d94
JF
18typedef unsigned long pgdval_t;
19typedef unsigned long pgprotval_t;
20
21typedef struct { pteval_t pte; } pte_t;
22
23#endif /* !__ASSEMBLY__ */
24
fb355149
JF
25#define SHARED_KERNEL_PMD 0
26
b8504058
KS
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
fb355149
JF
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
b8504058
KS
51#endif /* CONFIG_X86_5LEVEL */
52
fb355149
JF
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
1dddd251
TG
78/*
79 * See Documentation/x86/x86_64/mm.txt for a description of the memory map.
80 *
81 * Be very careful vs. KASLR when changing anything here. The KASLR address
82 * range must not overlap with anything except the KASAN shadow area, which
83 * is correct as KASAN disables KASLR.
84 */
92a0f81d
TG
85#define MAXMEM _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
86
4c7c4483 87#ifdef CONFIG_X86_5LEVEL
9f449772
AL
88# define VMALLOC_SIZE_TB _AC(12800, UL)
89# define __VMALLOC_BASE _AC(0xffa0000000000000, UL)
92a0f81d 90# define __VMEMMAP_BASE _AC(0xffd4000000000000, UL)
f55f0501
AL
91# define LDT_PGD_ENTRY _AC(-112, UL)
92# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)
4c7c4483 93#else
92a0f81d
TG
94# define VMALLOC_SIZE_TB _AC(32, UL)
95# define __VMALLOC_BASE _AC(0xffffc90000000000, UL)
96# define __VMEMMAP_BASE _AC(0xffffea0000000000, UL)
f2078904 97# define LDT_PGD_ENTRY _AC(-3, UL)
f55f0501 98# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)
4c7c4483 99#endif
92a0f81d 100
a95ae27c 101#ifdef CONFIG_RANDOMIZE_MEMORY
92a0f81d
TG
102# define VMALLOC_START vmalloc_base
103# define VMEMMAP_START vmemmap_base
a95ae27c 104#else
92a0f81d
TG
105# define VMALLOC_START __VMALLOC_BASE
106# define VMEMMAP_START __VMEMMAP_BASE
a95ae27c 107#endif /* CONFIG_RANDOMIZE_MEMORY */
92a0f81d
TG
108
109#define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
110
111#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
f06bdd40 112/* The module sections ends with the start of the fixmap */
f5a40711 113#define MODULES_END _AC(0xffffffffff000000, UL)
92a0f81d
TG
114#define MODULES_LEN (MODULES_END - MODULES_VADDR)
115
116#define ESPFIX_PGD_ENTRY _AC(-2, UL)
117#define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << P4D_SHIFT)
118
f2078904 119#define CPU_ENTRY_AREA_PGD _AC(-4, UL)
92a0f81d
TG
120#define CPU_ENTRY_AREA_BASE (CPU_ENTRY_AREA_PGD << P4D_SHIFT)
121
122#define EFI_VA_START ( -4 * (_AC(1, UL) << 30))
123#define EFI_VA_END (-68 * (_AC(1, UL) << 30))
fb355149 124
8170e6be
PA
125#define EARLY_DYNAMIC_PAGE_TABLES 64
126
1ed0d08a
JR
127#define PGD_KERNEL_START ((PAGE_SIZE / 2) / sizeof(pgd_t))
128
fb355149 129#endif /* _ASM_X86_PGTABLE_64_DEFS_H */