1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_BOOT_H
3 #define _ASM_X86_BOOT_H
6 #include <asm/pgtable_types.h>
7 #include <uapi/asm/boot.h>
9 /* Minimum kernel alignment, as a power of two */
11 # define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13 # define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_SIZE_ORDER)
15 #define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)
17 #if (CONFIG_PHYSICAL_ALIGN & (CONFIG_PHYSICAL_ALIGN-1)) || \
18 (CONFIG_PHYSICAL_ALIGN < MIN_KERNEL_ALIGN)
19 # error "Invalid value for CONFIG_PHYSICAL_ALIGN"
22 #if defined(CONFIG_KERNEL_BZIP2)
23 # define BOOT_HEAP_SIZE 0x400000
24 #elif defined(CONFIG_KERNEL_ZSTD)
26 * Zstd needs to allocate the ZSTD_DCtx in order to decompress the kernel.
27 * The ZSTD_DCtx is ~160KB, so set the heap size to 192KB because it is a
28 * round number and to allow some slack.
30 # define BOOT_HEAP_SIZE 0x30000
32 # define BOOT_HEAP_SIZE 0x10000
36 # define BOOT_STACK_SIZE 0x4000
39 * Used by decompressor's startup_32() to allocate page tables for identity
40 * mapping of the 4G of RAM in 4-level paging mode:
43 * - 4 level2 table that maps everything with 2M pages;
45 * The additional level5 table needed for 5-level paging is allocated from
46 * trampoline_32bit memory.
48 # define BOOT_INIT_PGT_SIZE (6*4096)
51 * Total number of page tables kernel_add_identity_map() can allocate,
52 * including page tables consumed by startup_32().
54 * Worst-case scenario:
55 * - 5-level paging needs 1 level5 table;
56 * - KASLR needs to map kernel, boot_params, cmdline and randomized kernel,
57 * assuming all of them cross 256T boundary:
61 * - X86_VERBOSE_BOOTUP needs to map the first 2M (video RAM):
67 * Add 4 spare table in case decompressor touches anything beyond what is
68 * accounted above. Warn if it happens.
70 # define BOOT_PGT_SIZE_WARN (28*4096)
71 # define BOOT_PGT_SIZE (32*4096)
73 #else /* !CONFIG_X86_64 */
74 # define BOOT_STACK_SIZE 0x1000
78 extern unsigned int output_len;
79 extern const unsigned long kernel_text_size;
80 extern const unsigned long kernel_total_size;
82 unsigned long decompress_kernel(unsigned char *outbuf, unsigned long virt_addr,
83 void (*error)(char *x));
85 extern struct boot_params *boot_params_ptr;
88 #endif /* _ASM_X86_BOOT_H */