blob: 41df801f9a507a851c781dffc9d477963df90834 [file] [log] [blame]
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -03001=================
2The EFI Boot Stub
3=================
Matt Fleming0c759662012-03-16 12:03:13 +00004
Roy Franz719e2842013-09-28 08:44:21 -07005On 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
Matt Fleming0c759662012-03-16 12:03:13 +000010arch/x86/boot/header.S and arch/x86/boot/compressed/eboot.c,
Roy Franz719e2842013-09-28 08:44:21 -070011respectively. 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
Alan Ott3bb9eee2015-11-30 09:36:54 -050014between architectures is in drivers/firmware/efi/libstub.
Matt Fleming0c759662012-03-16 12:03:13 +000015
Mark Saltercdd78572013-11-29 16:00:14 -050016For 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
Alan Ott3bb9eee2015-11-30 09:36:54 -050019and drivers/firmware/efi/libstub/arm64-stub.c.
Mark Saltercdd78572013-11-29 16:00:14 -050020
Matt Fleming0c759662012-03-16 12:03:13 +000021By 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
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030029How to install bzImage.efi
30--------------------------
Matt Fleming0c759662012-03-16 12:03:13 +000031
32The bzImage located in arch/x86/boot/bzImage must be copied to the EFI
Silvan Jegenbf651882013-12-18 20:16:31 +010033System Partition (ESP) and renamed with the extension ".efi". Without
Matt Fleming0c759662012-03-16 12:03:13 +000034the extension the EFI firmware loader will refuse to execute it. It's
35not possible to execute bzImage.efi from the usual Linux file systems
Roy Franz719e2842013-09-28 08:44:21 -070036because EFI firmware doesn't have support for them. For ARM the
37arch/arm/boot/zImage should be copied to the system partition, and it
Mark Saltercdd78572013-11-29 16:00:14 -050038may not need to be renamed. Similarly for arm64, arch/arm64/boot/Image
39should be copied but not necessarily renamed.
Matt Fleming0c759662012-03-16 12:03:13 +000040
41
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030042Passing kernel parameters from the EFI shell
43--------------------------------------------
Matt Fleming0c759662012-03-16 12:03:13 +000044
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030045Arguments to the kernel can be passed after bzImage.efi, e.g.::
Matt Fleming0c759662012-03-16 12:03:13 +000046
47 fs0:> bzImage.efi console=ttyS0 root=/dev/sda4
48
49
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030050The "initrd=" option
51--------------------
Matt Fleming0c759662012-03-16 12:03:13 +000052
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
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030061backslashes (\). For example, given the following directory layout::
Matt Fleming0c759662012-03-16 12:03:13 +000062
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030063 fs0:>
Matt Fleming0c759662012-03-16 12:03:13 +000064 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
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030073directory is fs0:\Kernels, the following command must be used::
Matt Fleming0c759662012-03-16 12:03:13 +000074
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.
Roy Franz719e2842013-09-28 08:44:21 -070081
82
Mauro Carvalho Chehabef16bcc2017-05-14 13:19:44 -030083The "dtb=" option
84-----------------
Roy Franz719e2842013-09-28 08:44:21 -070085
Mark Saltercdd78572013-11-29 16:00:14 -050086For 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,
Roy Franz719e2842013-09-28 08:44:21 -070088and is processed in the same manner as the "initrd=" option that is
89described above.