]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Use correct device root when loading device trees 23073/head
authorJan Janssen <medhefgo@web.de>
Thu, 10 Mar 2022 11:32:15 +0000 (12:32 +0100)
committerJan Janssen <medhefgo@web.de>
Wed, 13 Apr 2022 21:08:13 +0000 (23:08 +0200)
If the boot entry comes from a XBOOT partition, we have to load the device
tree from that instead of the ESP.

src/boot/efi/boot.c

index ca43f0073982ec405619efcd0d9eb0642051adb5..747a0e0bbe766c26118ceee46ff384335bcd73ec 100644 (file)
@@ -2316,7 +2316,6 @@ static void config_load_xbootldr(
 }
 
 static EFI_STATUS image_start(
-                EFI_FILE *root_dir,
                 EFI_HANDLE parent_image,
                 const Config *config,
                 const ConfigEntry *entry) {
@@ -2334,6 +2333,10 @@ static EFI_STATUS image_start(
         if (entry->call)
                 (void) entry->call();
 
+        _cleanup_(file_closep) EFI_FILE *image_root = LibOpenRoot(entry->device);
+        if (!image_root)
+                return log_error_status_stall(EFI_DEVICE_ERROR, L"Error opening root path.");
+
         path = FileDevicePath(entry->device, entry->loader);
         if (!path)
                 return log_error_status_stall(EFI_INVALID_PARAMETER, L"Error getting device path.");
@@ -2343,7 +2346,7 @@ static EFI_STATUS image_start(
                 return log_error_status_stall(err, L"Error loading %s: %r", entry->loader, err);
 
         if (entry->devicetree) {
-                err = devicetree_install(&dtstate, root_dir, entry->devicetree);
+                err = devicetree_install(&dtstate, image_root, entry->devicetree);
                 if (EFI_ERROR(err))
                         return log_error_status_stall(err, L"Error loading %s: %r", entry->devicetree, err);
         }
@@ -2618,7 +2621,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
                 /* Optionally, read a random seed off the ESP and pass it to the OS */
                 (void) process_random_seed(root_dir, config.random_seed_mode);
 
-                err = image_start(root_dir, image, &config, entry);
+                err = image_start(image, &config, entry);
                 if (EFI_ERROR(err)) {
                         graphics_mode(FALSE);
                         log_error_stall(L"Failed to execute %s (%s): %r", entry->title_show, entry->loader, err);