]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[efi] Claim fixed device paths by uninstalling device path protocol initrd
authorMichael Brown <mcb30@ipxe.org>
Wed, 15 Mar 2023 16:20:16 +0000 (16:20 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 15 Mar 2023 16:48:35 +0000 (16:48 +0000)
commit09e8a154084c57311463408e3f2e412c305a9638
tree2347ba3264eceb391e0eb5c1f1c4ad4a582beb2e
parentbf25e23d07f16be62825650c0826c4eadf2699b6
[efi] Claim fixed device paths by uninstalling device path protocol

As documented in commits 6a004be ("[efi] Support the initrd
autodetection mechanism in newer Linux kernels") and 04e60a2 ("[efi]
Omit EFI_LOAD_FILE2_PROTOCOL for a zero-length initrd"), the choice in
Linux of using a fixed device path requires bootloaders to allow for
the fact that a previous bootloader may have already installed a
handle with the fixed device path.

We currently deal with this situation by reusing the existing handle,
replacing the EFI_LOAD_FILE2_PROTOCOL instance with our own.  Simplify
the code by instead uninstalling the EFI_DEVICE_PATH_PROTOCOL instance
from the existing handle (if present), thereby allowing the creation
of a new handle to succeed.

Create the new handle only if we have a non-empty initrd to provide.
This works around bugs in bootloaders such as the systemd EFI stub
that fail to allow for the existence of multiple-bootloader chains.
(The workaround is not comprehensive: if the user has downloaded other
images in iPXE before invoking the systemd Unified Kernel Image (UKI),
then the systemd EFI stub will still crash and burn since it fails to
allow for the fact that a previous bootloader has already installed a
handle with the fixed device path.)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_file.c