boot.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_BOOT_H
  3. #define _ASM_X86_BOOT_H
  4. #include <asm/pgtable_types.h>
  5. #include <uapi/asm/boot.h>
  6. /* Physical address where kernel should be loaded. */
  7. #define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
  8. + (CONFIG_PHYSICAL_ALIGN - 1)) \
  9. & ~(CONFIG_PHYSICAL_ALIGN - 1))
  10. /* Minimum kernel alignment, as a power of two */
  11. #ifdef CONFIG_X86_64
  12. # define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
  13. #else
  14. # define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT + THREAD_SIZE_ORDER)
  15. #endif
  16. #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"
  20. #endif
  21. #if defined(CONFIG_KERNEL_BZIP2)
  22. # define BOOT_HEAP_SIZE 0x400000
  23. #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 a
  27. * round number and to allow some slack.
  28. */
  29. # define BOOT_HEAP_SIZE 0x30000
  30. #else
  31. # define BOOT_HEAP_SIZE 0x10000
  32. #endif
  33. #ifdef CONFIG_X86_64
  34. # define BOOT_STACK_SIZE 0x4000
  35. /*
  36. * Used by decompressor's startup_32() to allocate page tables for identity
  37. * mapping of the 4G of RAM in 4-level paging mode:
  38. * - 1 level4 table;
  39. * - 1 level3 table;
  40. * - 4 level2 table that maps everything with 2M pages;
  41. *
  42. * The additional level5 table needed for 5-level paging is allocated from
  43. * trampoline_32bit memory.
  44. */
  45. # define BOOT_INIT_PGT_SIZE (6*4096)
  46. /*
  47. * Total number of page tables kernel_add_identity_map() can allocate,
  48. * including page tables consumed by startup_32().
  49. *
  50. * Worst-case scenario:
  51. * - 5-level paging needs 1 level5 table;
  52. * - KASLR needs to map kernel, boot_params, cmdline and randomized kernel,
  53. * assuming all of them cross 256T boundary:
  54. * + 4*2 level4 table;
  55. * + 4*2 level3 table;
  56. * + 4*2 level2 table;
  57. * - X86_VERBOSE_BOOTUP needs to map the first 2M (video RAM):
  58. * + 1 level4 table;
  59. * + 1 level3 table;
  60. * + 1 level2 table;
  61. * Total: 28 tables
  62. *
  63. * Add 4 spare table in case decompressor touches anything beyond what is
  64. * accounted above. Warn if it happens.
  65. */
  66. # define BOOT_PGT_SIZE_WARN (28*4096)
  67. # define BOOT_PGT_SIZE (32*4096)
  68. #else /* !CONFIG_X86_64 */
  69. # define BOOT_STACK_SIZE 0x1000
  70. #endif
  71. #endif /* _ASM_X86_BOOT_H */