From 7b21973c42054dcdcfc3d0dcbf78cbb3525563f7 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 10 Mar 2022 12:32:15 +0100 Subject: [PATCH] boot: Use correct device root when loading device trees 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index ca43f007398..747a0e0bbe7 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -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); -- 2.47.3