/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_X86_BOOT_H2#define _ASM_X86_BOOT_H345#include <asm/pgtable_types.h>6#include <uapi/asm/boot.h>78/* Minimum kernel alignment, as a power of two */9#ifdef CONFIG_X86_6410# define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT11#else12# define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_SIZE_ORDER)13#endif14#define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)1516#if (CONFIG_PHYSICAL_ALIGN & (CONFIG_PHYSICAL_ALIGN-1)) || \17(CONFIG_PHYSICAL_ALIGN < MIN_KERNEL_ALIGN)18# error "Invalid value for CONFIG_PHYSICAL_ALIGN"19#endif2021#if defined(CONFIG_KERNEL_BZIP2)22# define BOOT_HEAP_SIZE 0x40000023#elif defined(CONFIG_KERNEL_ZSTD)24/*25* Zstd needs to allocate the ZSTD_DCtx in order to decompress the kernel.26* The ZSTD_DCtx is ~160KB, so set the heap size to 192KB because it is a27* round number and to allow some slack.28*/29# define BOOT_HEAP_SIZE 0x3000030#else31# define BOOT_HEAP_SIZE 0x1000032#endif3334#ifdef CONFIG_X86_6435# define BOOT_STACK_SIZE 0x40003637/*38* Used by decompressor's startup_32() to allocate page tables for identity39* mapping of the 4G of RAM in 4-level paging mode:40* - 1 level4 table;41* - 1 level3 table;42* - 4 level2 table that maps everything with 2M pages;43*44* The additional level5 table needed for 5-level paging is allocated from45* trampoline_32bit memory.46*/47# define BOOT_INIT_PGT_SIZE (6*4096)4849/*50* Total number of page tables kernel_add_identity_map() can allocate,51* including page tables consumed by startup_32().52*53* Worst-case scenario:54* - 5-level paging needs 1 level5 table;55* - KASLR needs to map kernel, boot_params, cmdline and randomized kernel,56* assuming all of them cross 256T boundary:57* + 4*2 level4 table;58* + 4*2 level3 table;59* + 4*2 level2 table;60* - X86_VERBOSE_BOOTUP needs to map the first 2M (video RAM):61* + 1 level4 table;62* + 1 level3 table;63* + 1 level2 table;64* Total: 28 tables65*66* Add 4 spare table in case decompressor touches anything beyond what is67* accounted above. Warn if it happens.68*/69# define BOOT_PGT_SIZE_WARN (28*4096)70# define BOOT_PGT_SIZE (32*4096)7172#else /* !CONFIG_X86_64 */73# define BOOT_STACK_SIZE 0x100074#endif7576#define TRAMPOLINE_32BIT_SIZE (2 * PAGE_SIZE)7778#define TRAMPOLINE_32BIT_CODE_OFFSET PAGE_SIZE79#define TRAMPOLINE_32BIT_CODE_SIZE 0xA08081#ifndef __ASSEMBLER__82extern unsigned int output_len;83extern const unsigned long kernel_text_size;84extern const unsigned long kernel_total_size;8586unsigned long decompress_kernel(unsigned char *outbuf, unsigned long virt_addr,87void (*error)(char *x));8889extern struct boot_params *boot_params_ptr;90extern unsigned long *trampoline_32bit;91extern const u16 trampoline_ljmp_imm_offset;9293void trampoline_32bit_src(void *trampoline, bool enable_5lvl);9495#endif9697#endif /* _ASM_X86_BOOT_H */9899100