Linux-libre 4.19.123-gnu
[librecmc/linux-libre.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 (0 + 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 #define __PAGE_OFFSET_BASE_L5   _AC(0xff11000000000000, UL)
47 #define __PAGE_OFFSET_BASE_L4   _AC(0xffff888000000000, UL)
48
49 #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT
50 #define __PAGE_OFFSET           page_offset_base
51 #else
52 #define __PAGE_OFFSET           __PAGE_OFFSET_BASE_L4
53 #endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */
54
55 #define __START_KERNEL_map      _AC(0xffffffff80000000, UL)
56
57 /* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */
58
59 #define __PHYSICAL_MASK_SHIFT   52
60
61 #ifdef CONFIG_X86_5LEVEL
62 #define __VIRTUAL_MASK_SHIFT    (pgtable_l5_enabled() ? 56 : 47)
63 #else
64 #define __VIRTUAL_MASK_SHIFT    47
65 #endif
66
67 /*
68  * Kernel image size is limited to 1GiB due to the fixmap living in the
69  * next 1GiB (see level2_kernel_pgt in arch/x86/kernel/head_64.S). Use
70  * 512MiB by default, leaving 1.5GiB for modules once the page tables
71  * are fully set up. If kernel ASLR is configured, it can extend the
72  * kernel page table mapping, reducing the size of the modules area.
73  */
74 #if defined(CONFIG_RANDOMIZE_BASE)
75 #define KERNEL_IMAGE_SIZE       (1024 * 1024 * 1024)
76 #else
77 #define KERNEL_IMAGE_SIZE       (512 * 1024 * 1024)
78 #endif
79
80 #endif /* _ASM_X86_PAGE_64_DEFS_H */