mbox series

[0/4] efi: Improve command line initrd loader support

Message ID 20220927085842.2860715-1-ardb@kernel.org
Headers show
Series efi: Improve command line initrd loader support | expand

Message

Ard Biesheuvel Sept. 27, 2022, 8:58 a.m. UTC
Given that the command line initrd loader can only load files from the
same simple FS volume from which the kernel itself was loaded, it was
not flexible enough for use in loaders such as GRUB that don't even
implement the FS volume abstraction, and load images as anonymous
buffers in memory. As x86 mixed mode was based on a GRUB specific EFI
handover protocol, and the simple FS protocol method prototypes were not
mixed mode safe, the initrd command line loader did not work for mixed
mode at all.

For this reason, we support arch specific methods (bootparam, DT) as
well, and have added support for a generic method based on the LoadFile2
protocol, which is much easier to implement and use.

However, there are cases where the command line loader is useful,
especially when using fully generic loaders such as the UEFI shell.
Here, it is generally not possible to use Linux specific structs or data
structures, or implement the Linux specific LoadFile2 protocol
implementation for initrd loading.

So let's fix the issues with the initrd command line loader:
- add the ability to use fully qualified device paths as the initrd=
  argument, so that the initrd image can reside on any simple FS volume,
  even if the kernel itself was not loaded from one;
- fix the mixed mode issues, by using the mixed mode wrappers for the
  protocol invocations, and defining some recipes for the prototypes
  that cannot be marshalled 1:1

The above means that mixed mode loaders that boot via the compat entry
point (e.g., systemd-boot) can use the initrd= command line option as
before to pass the initrd, if desired.

With those fixes in place, let's remove the deprecation notice, and
permit the feature to be enabled on LoongArch and RISC-V as well.

Note that LoadFile2 is still preferred, and will continue to take
precedence. It is also the only generic method that cannot be compiled
out.

Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Atish Patra <atishp@atishpatra.org>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Ard Biesheuvel (4):
  efi: libstub: Implement devicepath support for initrd commandline
    loader
  efi: libstub: Permit mixed mode return types other than efi_status_t
  efi: libstub: Add mixed mode support to command line initrd loader
  efi: libstub: Undeprecate the command line initrd loader

 arch/x86/boot/compressed/efi_thunk_64.S        |   6 --
 arch/x86/include/asm/efi.h                     |  49 +++++----
 drivers/firmware/efi/Kconfig                   |  13 ++-
 drivers/firmware/efi/libstub/efi-stub-helper.c |   2 +-
 drivers/firmware/efi/libstub/efistub.h         | 112 ++++++++++++++------
 drivers/firmware/efi/libstub/file.c            | 105 +++++++++++++-----
 include/linux/efi.h                            |   6 ++
 7 files changed, 202 insertions(+), 91 deletions(-)