All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] efi: device tree fix-up
@ 2021-02-04 13:15 Heinrich Schuchardt
  2021-02-04 13:15 ` [PATCH 1/2] efi: EFI Device Tree Fixup Protocol Heinrich Schuchardt
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Heinrich Schuchardt @ 2021-02-04 13:15 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: Leif Lindholm, Grant Likely, grub-devel, Heinrich Schuchardt

Operating systems need a description of the hardware. This description can
either be supplied via ACPI tables or via device-trees. On the ARM
architecture ACPI tables are not avaialable for most devices.

In an ideal world device-trees would be defined once by the hardware
manufacturer and would not be subject to change.

In reality device-trees or subject to frequent changes. Linux has a long
record of breaking forward and backwards compatibility between device-
trees and the kernel. So for booting it is wise to use the specific device-
tree that comes with the operation system. This requires reading the
device-tree from file.

One approach is to leave loading the device-tree file to the firmware. This
works fine if the firmware is loading the triple of kernel, initrd, and
device-tree. This is what Debian does with the flash-kernel package. It
provides a boot script for U-Boot that loads the most recent kernel,
initrd, and device-tree.

Before passing the device-tree to the operating as an EFI configuration
table the firmware goes through the following steps:

* Fix-ups are applied to the device-tree. Examples of the changes include
  the memory size and the RISC-V boot hart. Without the changes the
  operating system may not boot at all or crash later.

* Memory reservations are added to the memory map according to the
  /reserved-memory node and the memory reservation block of the
  device-tree. Without these reservations the operating system may crash.

When using GRUB it is not known beforehand which operating system the user
will choose. To guarantee compatibility with the operating system GRUB has
to take control of the device-tree loading.

GRUB has a devicetree command to load a device-tree which is then passed as
EFI configuration table to the operating systems. But GRUB lacks the
information needed to apply fix-ups to the device-tree. Further memory
reservations are not executed.

What is needed is to pass the device-tree loaded by GRUB via the
devicetree command to the firmware to execute fix-ups and memory
reservations.

U-Boot v2020.04-rc1 provides an EFI protocol for this purpose which has
been defined in the EFI_DT_FIXUP_PROTOCOL specification [1].

With the first patch in the series the devicetree command is enhanced. It
checks if an instance of the EFI_DT_FIXUP_PROTOCOL is available. If yes,
the Fixup() method of the protocol is called when the boot command is
invoked. The fixed-up device-tree is passed to the operating system as
EFI configuration table.

The second patch adjusts the 10_linux template for grub-mkconfig. If
GRUB_LOAD_DEVICETREE=true in /etc/default/grub, it looks for file
dtb-${version} matching the Linux version. If the file (or file dtb as
fallback) is found, a devicetree command is added to grub.cfg.

[1] EFI_DT_FIXUP_PROTOCOL specification
    https://github.com/U-Boot-EFI/EFI_DT_FIXUP_PROTOCOL

Heinrich Schuchardt (2):
  efi: EFI Device Tree Fixup Protocol
  10_linux: support loading device trees

 docs/grub.texi             |  6 ++++++
 grub-core/loader/efi/fdt.c | 35 ++++++++++++++++++++++++++++++++++-
 include/grub/efi/api.h     | 22 ++++++++++++++++++++++
 util/grub-mkconfig.in      |  1 +
 util/grub.d/10_linux.in    | 23 +++++++++++++++++++++++
 5 files changed, 86 insertions(+), 1 deletion(-)

--
2.30.0



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-08-16  9:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 13:15 [PATCH 0/2] efi: device tree fix-up Heinrich Schuchardt
2021-02-04 13:15 ` [PATCH 1/2] efi: EFI Device Tree Fixup Protocol Heinrich Schuchardt
2021-02-04 13:15 ` [PATCH 2/2] 10_linux: support loading device trees Heinrich Schuchardt
2021-08-02 13:00 ` [PATCH 0/2] efi: device tree fix-up Heinrich Schuchardt
2021-08-02 15:18   ` Daniel Kiper
2021-08-13 16:22     ` Heinrich Schuchardt
2021-08-13 20:22       ` Daniel Kiper
2021-08-13 22:38         ` Heinrich Schuchardt
2021-08-16  7:04           ` Ard Biesheuvel
2021-08-16  8:58             ` Heinrich Schuchardt
2021-08-16  9:26               ` Ard Biesheuvel

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.