Skip to contentSkip to conversation

bootstd: efi: Handle prior-stage FDT in network path

PATCH New Simon Glass 1 participant 1 message Apr 5

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bootstd: efi: Handle prior-stage FDT in network path

When CONFIG_OF_HAS_PRIOR_STAGE is enabled and fdtfile is not set, efi_get_distro_fdt_name() returns -EALREADY to indicate the prior-stage FDT should be used. The block-device EFI path handles this by setting BOOTFLOWF_USE_PRIOR_FDT, but the network path treats it as an error, causing the bootflow to stay in 'base' state with a -EALREADY error.

This also means fdt_addr_r is required even when no FDT download is needed, giving a spurious -EINVAL error.

Fix this by calling efi_get_distro_fdt_name() before checking fdt_addr_r, and handling -EALREADY by setting BOOTFLOWF_USE_PRIOR_FDT to skip the FDT download, matching the block-device behaviour.

THere is no test for this at present, since sandbox does not enable CONFIG_OF_HAS_PRIOR_STAGE and lacks infra for network-based EFI boot.

---

Changes in v2:
- Return early in the -EALREADY case instead of using a big else block

 boot/bootmeth_efi.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
boot/bootmeth_efi.c +10 -5
index f592fec07f6..e187dc39912 100644
@@ -269,17 +269,22 @@ static int distro_efi_read_bootflow_net(struct bootflow *bflow)
 		return log_msg_ret("fi0", -ENOMEM);
 
 	/* read the DT file also */
+	ret = efi_get_distro_fdt_name(fname, sizeof(fname), 0);
+	if (ret == -EALREADY) {
+		/* Prior-stage FDT is used, no download needed */
+		bflow->flags |= BOOTFLOWF_USE_PRIOR_FDT;
+		bflow->state = BOOTFLOWST_READY;
+		return 0;
+	} else if (ret) {
+		return log_msg_ret("nam", ret);
+	}
+
 	fdt_addr_str = env_get("fdt_addr_r");
 	if (!fdt_addr_str)
 		return log_msg_ret("fdt", -EINVAL);
 	fdt_addr = hextoul(fdt_addr_str, NULL);
 	sprintf(file_addr, "%lx", fdt_addr);
 
-	/* We only allow the first prefix with PXE */
-	ret = efi_get_distro_fdt_name(fname, sizeof(fname), 0);
-	if (ret)
-		return log_msg_ret("nam", ret);
-
 	bflow->fdt_fname = strdup(fname);
 	if (!bflow->fdt_fname)
 		return log_msg_ret("fil", -ENOMEM);
Signature · 4 lines
2.43.0

base-commit: 1c1bfb1cf34bbb2a5717eb6995c55093279f9341
branch: bootstd-fix-us2