1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

boot: load device tree even if no original config exists

Firmware may not have loaded a devicetree, for example if the device
shipped with windows and exclusively supports ACPI.
We should always load the specified devicetree regardless of firmware
state to enable booting on platforms where Linux only supports DT.

Note: in _cleanup, the orig. config is NULL in this case, and passing
NULL to InstallConfigurationTable is permitted by the EFI spec.
See: https://uefi.org/specs/UEFI/2.10/07_Services_Boot_Services.html

Fixes #24059

Co-authored-by: Daniel Thompson <daniel.thompson@linaro.org>
This commit is contained in:
Clayton Craft 2023-10-27 12:50:50 -07:00 committed by Luca Boccassi
parent efe4303b5d
commit 0f781d2aa5

View File

@ -71,9 +71,10 @@ EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir
assert(root_dir);
assert(name);
/* Capture the original value for the devicetree table. NULL is not an error in this case so we don't
* need to check the return value. NULL simply means the system fw had no devicetree initially (and
* is the correct value to use to return to the initial state if needed). */
state->orig = find_configuration_table(MAKE_GUID_PTR(EFI_DTB_TABLE));
if (!state->orig)
return EFI_UNSUPPORTED;
err = root_dir->Open(root_dir, &handle, name, EFI_FILE_MODE_READ, EFI_FILE_READ_ONLY);
if (err != EFI_SUCCESS)
@ -112,9 +113,10 @@ EFI_STATUS devicetree_install_from_memory(
assert(state);
assert(dtb_buffer && dtb_length > 0);
/* Capture the original value for the devicetree table. NULL is not an error in this case so we don't
* need to check the return value. NULL simply means the system fw had no devicetree initially (and
* is the correct value to use to return to the initial state if needed). */
state->orig = find_configuration_table(MAKE_GUID_PTR(EFI_DTB_TABLE));
if (!state->orig)
return EFI_UNSUPPORTED;
err = devicetree_allocate(state, dtb_length);
if (err != EFI_SUCCESS)