brintos

brintos / linux-shallow public Read only

0
0
Text · 3.8 KiB · 090f3a1 Raw
101 lines · plain
1=================2The EFI Boot Stub3=================4 5On the x86 and ARM platforms, a kernel zImage/bzImage can masquerade6as a PE/COFF image, thereby convincing EFI firmware loaders to load7it as an EFI executable. The code that modifies the bzImage header,8along with the EFI-specific entry point that the firmware loader9jumps to are collectively known as the "EFI boot stub", and live in10arch/x86/boot/header.S and drivers/firmware/efi/libstub/x86-stub.c,11respectively. For ARM the EFI stub is implemented in12arch/arm/boot/compressed/efi-header.S and13drivers/firmware/efi/libstub/arm32-stub.c. EFI stub code that is shared14between architectures is in drivers/firmware/efi/libstub.15 16For arm64, there is no compressed kernel support, so the Image itself17masquerades as a PE/COFF image and the EFI stub is linked into the18kernel. The arm64 EFI stub lives in drivers/firmware/efi/libstub/arm64.c19and drivers/firmware/efi/libstub/arm64-stub.c.20 21By using the EFI boot stub it's possible to boot a Linux kernel22without the use of a conventional EFI boot loader, such as grub or23elilo. Since the EFI boot stub performs the jobs of a boot loader, in24a certain sense it *IS* the boot loader.25 26The EFI boot stub is enabled with the CONFIG_EFI_STUB kernel option.27 28 29How to install bzImage.efi30--------------------------31 32The bzImage located in arch/x86/boot/bzImage must be copied to the EFI33System Partition (ESP) and renamed with the extension ".efi". Without34the extension the EFI firmware loader will refuse to execute it. It's35not possible to execute bzImage.efi from the usual Linux file systems36because EFI firmware doesn't have support for them. For ARM the37arch/arm/boot/zImage should be copied to the system partition, and it38may not need to be renamed. Similarly for arm64, arch/arm64/boot/Image39should be copied but not necessarily renamed.40 41 42Passing kernel parameters from the EFI shell43--------------------------------------------44 45Arguments to the kernel can be passed after bzImage.efi, e.g.::46 47	fs0:> bzImage.efi console=ttyS0 root=/dev/sda448 49 50The "initrd=" option51--------------------52 53Like most boot loaders, the EFI stub allows the user to specify54multiple initrd files using the "initrd=" option. This is the only EFI55stub-specific command line parameter, everything else is passed to the56kernel when it boots.57 58The path to the initrd file must be an absolute path from the59beginning of the ESP, relative path names do not work. Also, the path60is an EFI-style path and directory elements must be separated with61backslashes (\). For example, given the following directory layout::62 63  fs0:>64	Kernels\65			bzImage.efi66			initrd-large.img67 68	Ramdisks\69			initrd-small.img70			initrd-medium.img71 72to boot with the initrd-large.img file if the current working73directory is fs0:\Kernels, the following command must be used::74 75	fs0:\Kernels> bzImage.efi initrd=\Kernels\initrd-large.img76 77Notice how bzImage.efi can be specified with a relative path. That's78because the image we're executing is interpreted by the EFI shell,79which understands relative paths, whereas the rest of the command line80is passed to bzImage.efi.81 82 83The "dtb=" option84-----------------85 86For the ARM and arm64 architectures, a device tree must be provided to87the kernel. Normally firmware shall supply the device tree via the88EFI CONFIGURATION TABLE. However, the "dtb=" command line option can89be used to override the firmware supplied device tree, or to supply90one when firmware is unable to.91 92Please note: Firmware adds runtime configuration information to the93device tree before booting the kernel. If dtb= is used to override94the device tree, then any runtime data provided by firmware will be95lost. The dtb= option should only be used either as a debug tool, or96as a last resort when a device tree is not provided in the EFI97CONFIGURATION TABLE.98 99"dtb=" is processed in the same manner as the "initrd=" option that is100described above.101