GNU Linux-libre 4.14.295-gnu1
[releases.git] / arch / x86 / include / asm / page_64_types.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_PAGE_64_DEFS_H
3 #define _ASM_X86_PAGE_64_DEFS_H
4
5 #ifndef __ASSEMBLY__
6 #include <asm/kaslr.h>
7 #endif
8
9 #ifdef CONFIG_KASAN
10 #ifdef CONFIG_KASAN_EXTRA
11 #define KASAN_STACK_ORDER 2
12 #else
13 #define KASAN_STACK_ORDER 1
14 #endif
15 #else
16 #define KASAN_STACK_ORDER 0
17 #endif
18
19 #define THREAD_SIZE_ORDER       (2 + KASAN_STACK_ORDER)
20 #define THREAD_SIZE  (PAGE_SIZE << THREAD_SIZE_ORDER)
21 #define CURRENT_MASK (~(THREAD_SIZE - 1))
22
23 #define EXCEPTION_STACK_ORDER (1 + KASAN_STACK_ORDER)
24 #define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
25
26 #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
27 #define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
28
29 #define IRQ_STACK_ORDER (2 + KASAN_STACK_ORDER)
30 #define IRQ_STACK_SIZE (PAGE_SIZE << IRQ_STACK_ORDER)
31
32 #define DOUBLEFAULT_STACK 1
33 #define NMI_STACK 2
34 #define DEBUG_STACK 3
35 #define MCE_STACK 4
36 #define N_EXCEPTION_STACKS 4  /* hw limit: 7 */
37
38 /*
39  * Set __PAGE_OFFSET to the most negative possible address +
40  * PGDIR_SIZE*17 (pgd slot 273).
41  *
42  * The gap is to allow a space for LDT remap for PTI (1 pgd slot) and space for
43  * a hypervisor (16 slots). Choosing 16 slots for a hypervisor is arbitrary,
44  * but it's what Xen requires.
45  */
46 #ifdef CONFIG_X86_5LEVEL
47 #define __PAGE_OFFSET_BASE      _AC(0xff11000000000000, UL)
48 #else
49 #define __PAGE_OFFSET_BASE      _AC(0xffff888000000000, UL)
50 #endif
51
52 #ifdef CONFIG_RANDOMIZE_MEMORY
53 #define __PAGE_OFFSET           page_offset_base
54 #else
55 #define __PAGE_OFFSET           __PAGE_OFFSET_BASE
56 #endif /* CONFIG_RANDOMIZE_MEMORY */
57
58 #define __START_KERNEL_map      _AC(0xffffffff80000000, UL)
59
60 /* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */
61 #ifdef CONFIG_X86_5LEVEL
62 #define __PHYSICAL_MASK_SHIFT   52
63 #define __VIRTUAL_MASK_SHIFT    56
64 #else
65 #define __PHYSICAL_MASK_SHIFT   46
66 #define __VIRTUAL_MASK_SHIFT    47
67 #endif
68
69 /*
70  * Kernel image size is limited to 1GiB due to the fixmap living in the
71  * next 1GiB (see level2_kernel_pgt in arch/x86/kernel/head_64.S). Use
72  * 512MiB by default, leaving 1.5GiB for modules once the page tables
73  * are fully set up. If kernel ASLR is configured, it can extend the
74  * kernel page table mapping, reducing the size of the modules area.
75  */
76 #if defined(CONFIG_RANDOMIZE_BASE)
77 #define KERNEL_IMAGE_SIZE       (1024 * 1024 * 1024)
78 #else
79 #define KERNEL_IMAGE_SIZE       (512 * 1024 * 1024)
80 #endif
81
82 #endif /* _ASM_X86_PAGE_64_DEFS_H */