mbox series

[v2,0/2] efi: Add generic magic number in header

Message ID 20221129175616.2089294-1-ardb@kernel.org
Headers show
Series efi: Add generic magic number in header | expand

Message

Ard Biesheuvel Nov. 29, 2022, 5:56 p.m. UTC
This is a minimal respin of the RFC patch I sent out a few week ago. No
changes were applied except the /0x30/0x38 typo fix and some additional
wording in the commit log. I also added a patch to make the command line
initrd loader always built-in.

The purpose of all of this is to create *and document* a common baseline
for EFI booting of Linux. (I know I promised some documentation myself,
but I simply don't have time for that, so if anyone feels so inclined,
please go ahead).

The idea is that EFI images with the LINUX_PE_MAGIC number are
guaranteed to support:
- initrd loading via LoadFile2
- initrd loading via the command line
- (on x86) mixed mode boot via the .compat entry point
- other things I missed?

Architectures such as arm64 and RISC-V already have their own magic
numbers, in which case the PE/COFF major/minor image version should be
inspected, where 1.1 corresponds with the set described above.

If other architectures want to create hybrid images as well, it would be
better to use a different offset to store the magic number, so that the
generic EFI one can be carried as well. The reason for deviating from
this for arm64 and RISC-V is the simple fact that existing images
already exist, so for those architectures, we have to consider both
anyway.

Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Atish Patra <atishp@rivosinc.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: Daniel Kiper <daniel.kiper@oracle.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>

Ard Biesheuvel (2):
  efi: libstub: Always enable initrd command line loader and bump
    version
  efi: Put Linux specific magic number in the DOS header

 arch/loongarch/kernel/head.S                   |  3 ++-
 arch/x86/boot/header.S                         |  3 ++-
 drivers/firmware/efi/Kconfig                   | 15 ---------------
 drivers/firmware/efi/libstub/efi-stub-helper.c |  3 +--
 drivers/firmware/efi/libstub/zboot-header.S    |  3 ++-
 include/linux/pe.h                             |  9 ++++++++-
 6 files changed, 15 insertions(+), 21 deletions(-)

Comments

Leif Lindholm Nov. 29, 2022, 7:58 p.m. UTC | #1
On Tue, Nov 29, 2022 at 18:56:14 +0100, Ard Biesheuvel wrote:
> This is a minimal respin of the RFC patch I sent out a few week ago. No
> changes were applied except the /0x30/0x38 typo fix and some additional
> wording in the commit log. I also added a patch to make the command line
> initrd loader always built-in.
> 
> The purpose of all of this is to create *and document* a common baseline
> for EFI booting of Linux. (I know I promised some documentation myself,
> but I simply don't have time for that, so if anyone feels so inclined,
> please go ahead).
> 
> The idea is that EFI images with the LINUX_PE_MAGIC number are
> guaranteed to support:
> - initrd loading via LoadFile2
> - initrd loading via the command line
> - (on x86) mixed mode boot via the .compat entry point
> - other things I missed?
> 
> Architectures such as arm64 and RISC-V already have their own magic
> numbers, in which case the PE/COFF major/minor image version should be
> inspected, where 1.1 corresponds with the set described above.
> 
> If other architectures want to create hybrid images as well, it would be
> better to use a different offset to store the magic number, so that the
> generic EFI one can be carried as well. The reason for deviating from
> this for arm64 and RISC-V is the simple fact that existing images
> already exist, so for those architectures, we have to consider both
> anyway.
> 
> Cc: Huacai Chen <chenhuacai@kernel.org>
> Cc: Atish Patra <atishp@rivosinc.com>
> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Cc: Daniel Kiper <daniel.kiper@oracle.com>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>

For the series:
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>

Thanks!

> 
> Ard Biesheuvel (2):
>   efi: libstub: Always enable initrd command line loader and bump
>     version
>   efi: Put Linux specific magic number in the DOS header
> 
>  arch/loongarch/kernel/head.S                   |  3 ++-
>  arch/x86/boot/header.S                         |  3 ++-
>  drivers/firmware/efi/Kconfig                   | 15 ---------------
>  drivers/firmware/efi/libstub/efi-stub-helper.c |  3 +--
>  drivers/firmware/efi/libstub/zboot-header.S    |  3 ++-
>  include/linux/pe.h                             |  9 ++++++++-
>  6 files changed, 15 insertions(+), 21 deletions(-)
> 
> -- 
> 2.35.1
>