efi-stub.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. =================
  2. The EFI Boot Stub
  3. =================
  4. On the x86 and ARM platforms, a kernel zImage/bzImage can masquerade
  5. as a PE/COFF image, thereby convincing EFI firmware loaders to load
  6. it as an EFI executable. The code that modifies the bzImage header,
  7. along with the EFI-specific entry point that the firmware loader
  8. jumps to are collectively known as the "EFI boot stub", and live in
  9. arch/x86/boot/header.S and arch/x86/boot/compressed/eboot.c,
  10. respectively. For ARM the EFI stub is implemented in
  11. arch/arm/boot/compressed/efi-header.S and
  12. arch/arm/boot/compressed/efi-stub.c. EFI stub code that is shared
  13. between architectures is in drivers/firmware/efi/libstub.
  14. For arm64, there is no compressed kernel support, so the Image itself
  15. masquerades as a PE/COFF image and the EFI stub is linked into the
  16. kernel. The arm64 EFI stub lives in arch/arm64/kernel/efi-entry.S
  17. and drivers/firmware/efi/libstub/arm64-stub.c.
  18. By using the EFI boot stub it's possible to boot a Linux kernel
  19. without the use of a conventional EFI boot loader, such as grub or
  20. elilo. Since the EFI boot stub performs the jobs of a boot loader, in
  21. a certain sense it *IS* the boot loader.
  22. The EFI boot stub is enabled with the CONFIG_EFI_STUB kernel option.
  23. How to install bzImage.efi
  24. --------------------------
  25. The bzImage located in arch/x86/boot/bzImage must be copied to the EFI
  26. System Partition (ESP) and renamed with the extension ".efi". Without
  27. the extension the EFI firmware loader will refuse to execute it. It's
  28. not possible to execute bzImage.efi from the usual Linux file systems
  29. because EFI firmware doesn't have support for them. For ARM the
  30. arch/arm/boot/zImage should be copied to the system partition, and it
  31. may not need to be renamed. Similarly for arm64, arch/arm64/boot/Image
  32. should be copied but not necessarily renamed.
  33. Passing kernel parameters from the EFI shell
  34. --------------------------------------------
  35. Arguments to the kernel can be passed after bzImage.efi, e.g.::
  36. fs0:> bzImage.efi console=ttyS0 root=/dev/sda4
  37. The "initrd=" option
  38. --------------------
  39. Like most boot loaders, the EFI stub allows the user to specify
  40. multiple initrd files using the "initrd=" option. This is the only EFI
  41. stub-specific command line parameter, everything else is passed to the
  42. kernel when it boots.
  43. The path to the initrd file must be an absolute path from the
  44. beginning of the ESP, relative path names do not work. Also, the path
  45. is an EFI-style path and directory elements must be separated with
  46. backslashes (\). For example, given the following directory layout::
  47. fs0:>
  48. Kernels\
  49. bzImage.efi
  50. initrd-large.img
  51. Ramdisks\
  52. initrd-small.img
  53. initrd-medium.img
  54. to boot with the initrd-large.img file if the current working
  55. directory is fs0:\Kernels, the following command must be used::
  56. fs0:\Kernels> bzImage.efi initrd=\Kernels\initrd-large.img
  57. Notice how bzImage.efi can be specified with a relative path. That's
  58. because the image we're executing is interpreted by the EFI shell,
  59. which understands relative paths, whereas the rest of the command line
  60. is passed to bzImage.efi.
  61. The "dtb=" option
  62. -----------------
  63. For the ARM and arm64 architectures, a device tree must be provided to
  64. the kernel. Normally firmware shall supply the device tree via the
  65. EFI CONFIGURATION TABLE. However, the "dtb=" command line option can
  66. be used to override the firmware supplied device tree, or to supply
  67. one when firmware is unable to.
  68. Please note: Firmware adds runtime configuration information to the
  69. device tree before booting the kernel. If dtb= is used to override
  70. the device tree, then any runtime data provided by firmware will be
  71. lost. The dtb= option should only be used either as a debug tool, or
  72. as a last resort when a device tree is not provided in the EFI
  73. CONFIGURATION TABLE.
  74. "dtb=" is processed in the same manner as the "initrd=" option that is
  75. described above.