[PATCH] boot/pxe-utils: populate initrd_filesize for extlinux boot

Ryan Lahfa ryan-uboot at lahfa.xyz
Sat Sep 16 15:14:58 CEST 2023


Currently, it seems like the `initrd_filesize` was uninitialized for a
while.

This is particularly problematic when attempting to `zboot` with a
initrd with a size coming from `label->initrd`, because it will provide
you with a 0-long initrd at boot time, making the kernel fail to
continue the boot.

This fixes the issue and I confirmed it enable me booting a U-Boot on
QEMU x86_64 q35 with NixOS kernel and initrds.

Signed-off-by: Ryan Lahfa <ryan-uboot at lahfa.xyz>
Cc: Tom Rini <trini at konsulko.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Bin Meng <bmeng.cn at gmail.com>
Cc: Zhaofeng Li <hello at zhaofeng.li>
Cc: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Artem Lapkin <email2tema at gmail.com>
---
 boot/pxe_utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index d13c47dd94..fa5e88ab95 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -556,6 +556,8 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 		}
 
 		initrd_addr_str = env_get("ramdisk_addr_r");
+		/* Copy the actual initrd size inside the initrd_filesize */
+		snprintf(initrd_filesize, sizeof(initrd_filesize), "%lx", size);
 		size = snprintf(initrd_str, sizeof(initrd_str), "%s:%lx",
 				initrd_addr_str, size);
 		if (size >= sizeof(initrd_str))
-- 
2.42.0



More information about the U-Boot mailing list