Merge 4.14.80 into android-4.14-p
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / Documentation / efi-stub.txt
CommitLineData
ef16bcc7
MCC
1=================
2The EFI Boot Stub
3=================
0c759662 4
719e2843
RF
5On the x86 and ARM platforms, a kernel zImage/bzImage can masquerade
6as a PE/COFF image, thereby convincing EFI firmware loaders to load
7it as an EFI executable. The code that modifies the bzImage header,
8along with the EFI-specific entry point that the firmware loader
9jumps to are collectively known as the "EFI boot stub", and live in
0c759662 10arch/x86/boot/header.S and arch/x86/boot/compressed/eboot.c,
719e2843
RF
11respectively. For ARM the EFI stub is implemented in
12arch/arm/boot/compressed/efi-header.S and
13arch/arm/boot/compressed/efi-stub.c. EFI stub code that is shared
3bb9eee6 14between architectures is in drivers/firmware/efi/libstub.
0c759662 15
cdd78578
MS
16For arm64, there is no compressed kernel support, so the Image itself
17masquerades as a PE/COFF image and the EFI stub is linked into the
18kernel. The arm64 EFI stub lives in arch/arm64/kernel/efi-entry.S
3bb9eee6 19and drivers/firmware/efi/libstub/arm64-stub.c.
cdd78578 20
0c759662
MF
21By using the EFI boot stub it's possible to boot a Linux kernel
22without the use of a conventional EFI boot loader, such as grub or
23elilo. Since the EFI boot stub performs the jobs of a boot loader, in
24a certain sense it *IS* the boot loader.
25
26The EFI boot stub is enabled with the CONFIG_EFI_STUB kernel option.
27
28
ef16bcc7
MCC
29How to install bzImage.efi
30--------------------------
0c759662
MF
31
32The bzImage located in arch/x86/boot/bzImage must be copied to the EFI
bf651883 33System Partition (ESP) and renamed with the extension ".efi". Without
0c759662
MF
34the extension the EFI firmware loader will refuse to execute it. It's
35not possible to execute bzImage.efi from the usual Linux file systems
719e2843
RF
36because EFI firmware doesn't have support for them. For ARM the
37arch/arm/boot/zImage should be copied to the system partition, and it
cdd78578
MS
38may not need to be renamed. Similarly for arm64, arch/arm64/boot/Image
39should be copied but not necessarily renamed.
0c759662
MF
40
41
ef16bcc7
MCC
42Passing kernel parameters from the EFI shell
43--------------------------------------------
0c759662 44
ef16bcc7 45Arguments to the kernel can be passed after bzImage.efi, e.g.::
0c759662
MF
46
47 fs0:> bzImage.efi console=ttyS0 root=/dev/sda4
48
49
ef16bcc7
MCC
50The "initrd=" option
51--------------------
0c759662
MF
52
53Like most boot loaders, the EFI stub allows the user to specify
54multiple initrd files using the "initrd=" option. This is the only EFI
55stub-specific command line parameter, everything else is passed to the
56kernel when it boots.
57
58The path to the initrd file must be an absolute path from the
59beginning of the ESP, relative path names do not work. Also, the path
60is an EFI-style path and directory elements must be separated with
ef16bcc7 61backslashes (\). For example, given the following directory layout::
0c759662 62
ef16bcc7 63 fs0:>
0c759662
MF
64 Kernels\
65 bzImage.efi
66 initrd-large.img
67
68 Ramdisks\
69 initrd-small.img
70 initrd-medium.img
71
72to boot with the initrd-large.img file if the current working
ef16bcc7 73directory is fs0:\Kernels, the following command must be used::
0c759662
MF
74
75 fs0:\Kernels> bzImage.efi initrd=\Kernels\initrd-large.img
76
77Notice how bzImage.efi can be specified with a relative path. That's
78because the image we're executing is interpreted by the EFI shell,
79which understands relative paths, whereas the rest of the command line
80is passed to bzImage.efi.
719e2843
RF
81
82
ef16bcc7
MCC
83The "dtb=" option
84-----------------
719e2843 85
cdd78578
MS
86For the ARM and arm64 architectures, we also need to be able to provide a
87device tree to the kernel. This is done with the "dtb=" command line option,
719e2843
RF
88and is processed in the same manner as the "initrd=" option that is
89described above.