]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: load device tree even if no original config exists
authorClayton Craft <clayton@craftyguy.net>
Fri, 27 Oct 2023 19:50:50 +0000 (12:50 -0700)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 10 Nov 2023 22:04:50 +0000 (22:04 +0000)
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>
src/boot/efi/devicetree.c

index 3916bca946f115132e4e04f2562a1b671f554143..b13978051035aa4a25db98d071fbd5ec0c92bdc0 100644 (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)