mutiny wrote:That is understood. However I am trying to build a UKI, not boot a stub kernel directly. The UKI itself includes a boot stub (systemd-stub) separately from the kernel, so why does it seem like the kernel still needs EFI_STUB itself to work in a UKI?
I am interest to know this too. So I did some research and I learn,
1. systemd-stub is a "chain-loader". It is stored in the PE+ file (usually the linux kernel image file. however this is
NOT always the case). At the end of systemd-stub function it will eventually call linux_exec_efi_handover() which execute UEFI Handover protocol. therefor require the payload be EFI ready hence linux kernel need to have EFI_STUB support.
2. The "UKI" have blurred recognition, it could be a simple impression of linux kernel with embedded initramfs and linux own bootload stub (EFI_STUB) or it is
UAPI Group Specifications (Unified Kernel Image),
2.1 For the first simple impression because Linux kernel build system can embed a initramfs cpio archive directly in to kernel image file using CONFIG_INITRAMFS_SOURCE kernel configuration option. Now add CONFIG_EFI_STUB you can have one file that can boot by EFI firmware therefor a unified kernel image.
2.2 Whereas the UAPI Group Specifications (Unified Kernel Image) create a EFI program using PE+ format which contain many sections for different objects, for example there is .linux section to store linux kernel binary (with EFI_STUB) and .initd section for initrd object (initramfs cpio archives) and .cmdline section to store kernel command line options text and .ucode section to store CPU microcode for early loading. and there are some more section I will not bring up here.
2.2.1 BTW,
one of interesting UKI specification is "profile" which allow that single PE+ file have multiple version kernel/initrd/etc... and the systemd-stub implemetation allow select which profile to boot. (control by a
EFI variable "StubProfile")
3. systemd-boot which is a standalone EFI program (Note. it is not linux program). It's function to present selection from stored disk configuration and finally execute selected bootloader on the ESP. in this regard it is
Second-stage bootloader under
Wikipedia Bootloader definition. So systemd-boot in its own have nothing to do with UKI.