1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-18 17:57:27 +03:00

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.
This commit is contained in:
Jan Janssen 2022-03-10 12:32:15 +01:00
parent ec4106afa0
commit 7b21973c42

@ -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);