.. | .. |
---|
24 | 24 | # error "Invalid value for CONFIG_PHYSICAL_ALIGN" |
---|
25 | 25 | #endif |
---|
26 | 26 | |
---|
27 | | -#ifdef CONFIG_KERNEL_BZIP2 |
---|
| 27 | +#if defined(CONFIG_KERNEL_BZIP2) |
---|
28 | 28 | # define BOOT_HEAP_SIZE 0x400000 |
---|
29 | | -#else /* !CONFIG_KERNEL_BZIP2 */ |
---|
| 29 | +#elif defined(CONFIG_KERNEL_ZSTD) |
---|
| 30 | +/* |
---|
| 31 | + * Zstd needs to allocate the ZSTD_DCtx in order to decompress the kernel. |
---|
| 32 | + * The ZSTD_DCtx is ~160KB, so set the heap size to 192KB because it is a |
---|
| 33 | + * round number and to allow some slack. |
---|
| 34 | + */ |
---|
| 35 | +# define BOOT_HEAP_SIZE 0x30000 |
---|
| 36 | +#else |
---|
30 | 37 | # define BOOT_HEAP_SIZE 0x10000 |
---|
31 | 38 | #endif |
---|
32 | 39 | |
---|
33 | 40 | #ifdef CONFIG_X86_64 |
---|
34 | 41 | # define BOOT_STACK_SIZE 0x4000 |
---|
35 | 42 | |
---|
36 | | -# define BOOT_INIT_PGT_SIZE (6*4096) |
---|
37 | | -# ifdef CONFIG_RANDOMIZE_BASE |
---|
38 | 43 | /* |
---|
39 | | - * Assuming all cross the 512GB boundary: |
---|
40 | | - * 1 page for level4 |
---|
41 | | - * (2+2)*4 pages for kernel, param, cmd_line, and randomized kernel |
---|
42 | | - * 2 pages for first 2M (video RAM: CONFIG_X86_VERBOSE_BOOTUP). |
---|
43 | | - * Total is 19 pages. |
---|
| 44 | + * Used by decompressor's startup_32() to allocate page tables for identity |
---|
| 45 | + * mapping of the 4G of RAM in 4-level paging mode: |
---|
| 46 | + * - 1 level4 table; |
---|
| 47 | + * - 1 level3 table; |
---|
| 48 | + * - 4 level2 table that maps everything with 2M pages; |
---|
| 49 | + * |
---|
| 50 | + * The additional level5 table needed for 5-level paging is allocated from |
---|
| 51 | + * trampoline_32bit memory. |
---|
44 | 52 | */ |
---|
45 | | -# ifdef CONFIG_X86_VERBOSE_BOOTUP |
---|
46 | | -# define BOOT_PGT_SIZE (19*4096) |
---|
47 | | -# else /* !CONFIG_X86_VERBOSE_BOOTUP */ |
---|
48 | | -# define BOOT_PGT_SIZE (17*4096) |
---|
49 | | -# endif |
---|
50 | | -# else /* !CONFIG_RANDOMIZE_BASE */ |
---|
51 | | -# define BOOT_PGT_SIZE BOOT_INIT_PGT_SIZE |
---|
52 | | -# endif |
---|
| 53 | +# define BOOT_INIT_PGT_SIZE (6*4096) |
---|
| 54 | + |
---|
| 55 | +/* |
---|
| 56 | + * Total number of page tables kernel_add_identity_map() can allocate, |
---|
| 57 | + * including page tables consumed by startup_32(). |
---|
| 58 | + * |
---|
| 59 | + * Worst-case scenario: |
---|
| 60 | + * - 5-level paging needs 1 level5 table; |
---|
| 61 | + * - KASLR needs to map kernel, boot_params, cmdline and randomized kernel, |
---|
| 62 | + * assuming all of them cross 256T boundary: |
---|
| 63 | + * + 4*2 level4 table; |
---|
| 64 | + * + 4*2 level3 table; |
---|
| 65 | + * + 4*2 level2 table; |
---|
| 66 | + * - X86_VERBOSE_BOOTUP needs to map the first 2M (video RAM): |
---|
| 67 | + * + 1 level4 table; |
---|
| 68 | + * + 1 level3 table; |
---|
| 69 | + * + 1 level2 table; |
---|
| 70 | + * Total: 28 tables |
---|
| 71 | + * |
---|
| 72 | + * Add 4 spare table in case decompressor touches anything beyond what is |
---|
| 73 | + * accounted above. Warn if it happens. |
---|
| 74 | + */ |
---|
| 75 | +# define BOOT_PGT_SIZE_WARN (28*4096) |
---|
| 76 | +# define BOOT_PGT_SIZE (32*4096) |
---|
53 | 77 | |
---|
54 | 78 | #else /* !CONFIG_X86_64 */ |
---|
55 | 79 | # define BOOT_STACK_SIZE 0x1000 |
---|