summaryrefslogtreecommitdiffstats
path: root/src/boot/efi/stub.c
diff options
context:
space:
mode:
authoranonymix007 <48598263+anonymix007@users.noreply.github.com>2024-10-22 13:41:55 +0200
committeranonymix007 <48598263+anonymix007@users.noreply.github.com>2024-11-05 22:47:04 +0100
commit1d79f667f4b5ce44dd8b742a7f521f9f50bf7532 (patch)
tree9020b77d3b4a336d9edea8e4516a7fe6a88a8260 /src/boot/efi/stub.c
parentmeasure: Introduce .dtbauto support (diff)
downloadsystemd-1d79f667f4b5ce44dd8b742a7f521f9f50bf7532.tar.xz
systemd-1d79f667f4b5ce44dd8b742a7f521f9f50bf7532.zip
stub: Handle .dtbauto sections
Diffstat (limited to '')
-rw-r--r--src/boot/efi/stub.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
index 9664c95d57..7261e942d3 100644
--- a/src/boot/efi/stub.c
+++ b/src/boot/efi/stub.c
@@ -614,12 +614,13 @@ static EFI_STATUS load_addons(
if (err != EFI_SUCCESS ||
(!PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_CMDLINE) &&
!PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTB) &&
+ !PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTBAUTO) &&
!PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_INITRD) &&
!PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_UCODE))) {
if (err == EFI_SUCCESS)
err = EFI_NOT_FOUND;
log_error_status(err,
- "Unable to locate embedded .cmdline/.dtb/.initrd/.ucode sections in %ls, ignoring: %m",
+ "Unable to locate embedded .cmdline/.dtb/.dtbauto/.initrd/.ucode sections in %ls, ignoring: %m",
items[i]);
continue;
}
@@ -647,7 +648,21 @@ static EFI_STATUS load_addons(
*cmdline = xasprintf("%ls%ls%ls", strempty(tmp), isempty(tmp) ? u"" : u" ", extra16);
}
- if (devicetree_addons && PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTB)) {
+ // FIXME: do we want to do something else here?
+ // This should behave exactly as .dtb/.dtbauto in the main UKI
+ if (devicetree_addons && PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTBAUTO)) {
+ *devicetree_addons = xrealloc(*devicetree_addons,
+ *n_devicetree_addons * sizeof(NamedAddon),
+ (*n_devicetree_addons + 1) * sizeof(NamedAddon));
+
+ (*devicetree_addons)[(*n_devicetree_addons)++] = (NamedAddon) {
+ .blob = {
+ .iov_base = xmemdup((const uint8_t*) loaded_addon->ImageBase + sections[UNIFIED_SECTION_DTBAUTO].memory_offset, sections[UNIFIED_SECTION_DTBAUTO].memory_size),
+ .iov_len = sections[UNIFIED_SECTION_DTBAUTO].memory_size,
+ },
+ .filename = xstrdup16(items[i]),
+ };
+ } else if (devicetree_addons && PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTB)) {
*devicetree_addons = xrealloc(*devicetree_addons,
*n_devicetree_addons * sizeof(NamedAddon),
(*n_devicetree_addons + 1) * sizeof(NamedAddon));
@@ -968,13 +983,20 @@ static void install_embedded_devicetree(
assert(sections);
assert(dt_state);
- if (!PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTB))
+ UnifiedSection section = _UNIFIED_SECTION_MAX;
+
+ /* Use automatically selected DT if available, otherwise go for "normal" one */
+ if (PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTBAUTO))
+ section = UNIFIED_SECTION_DTBAUTO;
+ else if (PE_SECTION_VECTOR_IS_SET(sections + UNIFIED_SECTION_DTB))
+ section = UNIFIED_SECTION_DTB;
+ else
return;
err = devicetree_install_from_memory(
dt_state,
- (const uint8_t*) loaded_image->ImageBase + sections[UNIFIED_SECTION_DTB].memory_offset,
- sections[UNIFIED_SECTION_DTB].memory_size);
+ (const uint8_t*) loaded_image->ImageBase + sections[section].memory_offset,
+ sections[section].memory_size);
if (err != EFI_SUCCESS)
log_error_status(err, "Error loading embedded devicetree, ignoring: %m");
}