18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_BOOT_H 38c2ecf20Sopenharmony_ci#define _ASM_X86_BOOT_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include <asm/pgtable_types.h> 78c2ecf20Sopenharmony_ci#include <uapi/asm/boot.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* Physical address where kernel should be loaded. */ 108c2ecf20Sopenharmony_ci#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \ 118c2ecf20Sopenharmony_ci + (CONFIG_PHYSICAL_ALIGN - 1)) \ 128c2ecf20Sopenharmony_ci & ~(CONFIG_PHYSICAL_ALIGN - 1)) 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* Minimum kernel alignment, as a power of two */ 158c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64 168c2ecf20Sopenharmony_ci# define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT 178c2ecf20Sopenharmony_ci#else 188c2ecf20Sopenharmony_ci# define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_SIZE_ORDER) 198c2ecf20Sopenharmony_ci#endif 208c2ecf20Sopenharmony_ci#define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#if (CONFIG_PHYSICAL_ALIGN & (CONFIG_PHYSICAL_ALIGN-1)) || \ 238c2ecf20Sopenharmony_ci (CONFIG_PHYSICAL_ALIGN < MIN_KERNEL_ALIGN) 248c2ecf20Sopenharmony_ci# error "Invalid value for CONFIG_PHYSICAL_ALIGN" 258c2ecf20Sopenharmony_ci#endif 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#if defined(CONFIG_KERNEL_BZIP2) 288c2ecf20Sopenharmony_ci# define BOOT_HEAP_SIZE 0x400000 298c2ecf20Sopenharmony_ci#elif defined(CONFIG_KERNEL_ZSTD) 308c2ecf20Sopenharmony_ci/* 318c2ecf20Sopenharmony_ci * Zstd needs to allocate the ZSTD_DCtx in order to decompress the kernel. 328c2ecf20Sopenharmony_ci * The ZSTD_DCtx is ~160KB, so set the heap size to 192KB because it is a 338c2ecf20Sopenharmony_ci * round number and to allow some slack. 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci# define BOOT_HEAP_SIZE 0x30000 368c2ecf20Sopenharmony_ci#else 378c2ecf20Sopenharmony_ci# define BOOT_HEAP_SIZE 0x10000 388c2ecf20Sopenharmony_ci#endif 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64 418c2ecf20Sopenharmony_ci# define BOOT_STACK_SIZE 0x4000 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* 448c2ecf20Sopenharmony_ci * Used by decompressor's startup_32() to allocate page tables for identity 458c2ecf20Sopenharmony_ci * mapping of the 4G of RAM in 4-level paging mode: 468c2ecf20Sopenharmony_ci * - 1 level4 table; 478c2ecf20Sopenharmony_ci * - 1 level3 table; 488c2ecf20Sopenharmony_ci * - 4 level2 table that maps everything with 2M pages; 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * The additional level5 table needed for 5-level paging is allocated from 518c2ecf20Sopenharmony_ci * trampoline_32bit memory. 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ci# define BOOT_INIT_PGT_SIZE (6*4096) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* 568c2ecf20Sopenharmony_ci * Total number of page tables kernel_add_identity_map() can allocate, 578c2ecf20Sopenharmony_ci * including page tables consumed by startup_32(). 588c2ecf20Sopenharmony_ci * 598c2ecf20Sopenharmony_ci * Worst-case scenario: 608c2ecf20Sopenharmony_ci * - 5-level paging needs 1 level5 table; 618c2ecf20Sopenharmony_ci * - KASLR needs to map kernel, boot_params, cmdline and randomized kernel, 628c2ecf20Sopenharmony_ci * assuming all of them cross 256T boundary: 638c2ecf20Sopenharmony_ci * + 4*2 level4 table; 648c2ecf20Sopenharmony_ci * + 4*2 level3 table; 658c2ecf20Sopenharmony_ci * + 4*2 level2 table; 668c2ecf20Sopenharmony_ci * - X86_VERBOSE_BOOTUP needs to map the first 2M (video RAM): 678c2ecf20Sopenharmony_ci * + 1 level4 table; 688c2ecf20Sopenharmony_ci * + 1 level3 table; 698c2ecf20Sopenharmony_ci * + 1 level2 table; 708c2ecf20Sopenharmony_ci * Total: 28 tables 718c2ecf20Sopenharmony_ci * 728c2ecf20Sopenharmony_ci * Add 4 spare table in case decompressor touches anything beyond what is 738c2ecf20Sopenharmony_ci * accounted above. Warn if it happens. 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_ci# define BOOT_PGT_SIZE_WARN (28*4096) 768c2ecf20Sopenharmony_ci# define BOOT_PGT_SIZE (32*4096) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#else /* !CONFIG_X86_64 */ 798c2ecf20Sopenharmony_ci# define BOOT_STACK_SIZE 0x1000 808c2ecf20Sopenharmony_ci#endif 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#endif /* _ASM_X86_BOOT_H */ 83