All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: loongarch@lists.linux.dev, linux@armlinux.org.uk,
	Ard Biesheuvel <ardb@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH 00/12] efi: disentangle the generic EFI stub from FDT
Date: Sun, 18 Sep 2022 23:35:32 +0200	[thread overview]
Message-ID: <20220918213544.2176249-1-ardb@kernel.org> (raw)

EFI architectures other than x86 rely on FDT to pass information between
the stub and the core kernel. In hindsight, this is probably a mistake,
given the issues around abuse of the internal ABI, and potential
inconsistencies between two sources of information that both originate
in the firmware (memory map, command line, etc)

Another reason for avoiding updates to the DT is the fact that it
interferes with secure boot and measured boot. Even if we measure the
original firmware provided DT into the TPM, the DT that the kernel
receives is a completely different blob, and verifying it against the
TPM event log is currently impossible.

So let's start hacking away at this, and refactor the generic stub so
that all the FDT pieces are isolated in a singe source file, and rely on
generic EFI config tables for passing the initrd base and size.
Ultimately, this should permit all EFI architectures doing DT boot to
perform the handover to the core kernel in a different way, and pass on
the firmware provided DT unmodified, but this requires some future work
for ARM/arm64 and RISC-V.

However, we can easily convert the newly added LoongArch code to adopt
this approach, and to consume the DT strictly for hardware descriptions
(if not doing ACPI boot), and pass the initrd, memory map and everything
else via EFI config tables. Generating empty DTBs on ACPI platforms will
no longer be needed.

The first six patches as well as patch #10 are general cleanup, and can
be merged separately. The remaining patches refactor the FDT code in the
EFI stub so that we can avoid it on platforms that don't need it for
other reasons. Finally, LoongArch is updated to use DT only for hardware
descriptions when doing EFI boot.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Xi Ruoyao <xry111@xry111.site>

Ard Biesheuvel (12):
  efi: libstub: drop pointless get_memory_map() call
  efi/arm: libstub: move ARM specific code out of generic routines
  efi: libstub: fix up the last remaining open coded boot service call
  efi: libstub: fix type confusion for load_options_size
  efi: libstub: avoid efi_get_memory_map() for allocating the virt map
  efi: libstub: simplify efi_get_memory_map() and struct efi_boot_memmap
  efi: libstub: unify initrd loading between architectures
  efi: libstub: remove DT dependency from generic stub
  efi: libstub: install boot-time memory map as config table
  efi: libstub: remove pointless goto kludge
  efi/loongarch: libstub: remove dependency on flattened DT
  efi: loongarch: add support for DT hardware descriptions

 Documentation/arm/uefi.rst                     |   4 -
 arch/arm/include/asm/efi.h                     |   3 +-
 arch/arm/kernel/efi.c                          |  79 +++++++++
 arch/arm/kernel/setup.c                        |   2 +-
 arch/loongarch/Kconfig                         |   1 -
 arch/loongarch/include/asm/bootinfo.h          |   2 +-
 arch/loongarch/kernel/efi.c                    |  44 ++++-
 arch/loongarch/kernel/env.c                    |  24 +--
 arch/loongarch/kernel/head.S                   |   2 +
 arch/loongarch/kernel/setup.c                  |   4 +-
 drivers/firmware/efi/efi-init.c                |  61 +------
 drivers/firmware/efi/efi.c                     |  15 ++
 drivers/firmware/efi/libstub/Makefile          |  13 +-
 drivers/firmware/efi/libstub/arm64-stub.c      |  19 +--
 drivers/firmware/efi/libstub/efi-stub-helper.c | 127 +++++++-------
 drivers/firmware/efi/libstub/efi-stub.c        |  94 ++++-------
 drivers/firmware/efi/libstub/efistub.h         |  32 +---
 drivers/firmware/efi/libstub/fdt.c             | 175 +++++++++++---------
 drivers/firmware/efi/libstub/loongarch-stub.c  |  56 ++++++-
 drivers/firmware/efi/libstub/mem.c             |  85 +++++-----
 drivers/firmware/efi/libstub/randomalloc.c     |  25 +--
 drivers/firmware/efi/libstub/relocate.c        |  21 +--
 drivers/firmware/efi/libstub/x86-stub.c        |  30 +---
 include/linux/efi.h                            |  15 ++
 24 files changed, 492 insertions(+), 441 deletions(-)

-- 
2.35.1


             reply	other threads:[~2022-09-18 21:35 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18 21:35 Ard Biesheuvel [this message]
2022-09-18 21:35 ` [PATCH 01/12] efi: libstub: drop pointless get_memory_map() call Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 02/12] efi/arm: libstub: move ARM specific code out of generic routines Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 03/12] efi: libstub: fix up the last remaining open coded boot service call Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 04/12] efi: libstub: fix type confusion for load_options_size Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 05/12] efi: libstub: avoid efi_get_memory_map() for allocating the virt map Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 06/12] efi: libstub: simplify efi_get_memory_map() and struct efi_boot_memmap Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 07/12] efi: libstub: unify initrd loading between architectures Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 08/12] efi: libstub: remove DT dependency from generic stub Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 09/12] efi: libstub: install boot-time memory map as config table Ard Biesheuvel
2022-09-20 10:40   ` Joey Gouly
2022-09-20 11:37     ` Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 10/12] efi: libstub: remove pointless goto kludge Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 11/12] efi/loongarch: libstub: remove dependency on flattened DT Ard Biesheuvel
2022-09-19  1:58   ` Huacai Chen
2022-09-19  5:15     ` Ard Biesheuvel
2022-09-19  6:06       ` Huacai Chen
2022-09-19  6:22         ` Ard Biesheuvel
2022-09-19  6:33           ` Ard Biesheuvel
2022-09-19 10:33           ` Huacai Chen
2022-09-19 10:37             ` Ard Biesheuvel
2022-09-19 10:47               ` Huacai Chen
2022-09-19 10:49                 ` Ard Biesheuvel
2022-09-19 11:15                   ` Huacai Chen
2022-09-19 11:21                     ` Ard Biesheuvel
2022-09-19 11:57                       ` Huacai Chen
2022-09-19 12:10                         ` Ard Biesheuvel
2022-09-19 12:14                           ` Huacai Chen
2022-09-19 12:27                             ` Ard Biesheuvel
2022-09-19 14:25                               ` Huacai Chen
2022-09-19 14:32                                 ` Ard Biesheuvel
2022-09-19 14:43                                   ` Huacai Chen
2022-09-19 14:44                                     ` Ard Biesheuvel
2022-09-19 15:08                                       ` Huacai Chen
2022-09-19 15:50                                         ` Ard Biesheuvel
2022-09-20  1:44                                           ` Huacai Chen
2022-09-20  8:04                                             ` Ard Biesheuvel
2022-09-20 13:12                                               ` Huacai Chen
2022-09-20 14:53                                                 ` Ard Biesheuvel
2022-09-18 21:35 ` [PATCH 12/12] efi: loongarch: add support for DT hardware descriptions Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220918213544.2176249-1-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@loongson.cn \
    --cc=ilias.apalodimas@linaro.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=loongarch@lists.linux.dev \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.