[PATCH v2 1/4] qemu: overlay signature nodes

Ludwig Nussel ludwig.nussel at siemens.com
Thu Apr 30 14:26:00 CEST 2026


The keys trusted for FIT signature verification are supposed to be
embedded in the device tree built into u-boot. When running in Qemu it's
convenient to use the device tree provided by the VM which doesn't know
about signatures though. So merge the signature nodes at run time.

Needs
  CONFIG_OF_OMIT_DTB=n
  CONFIG_OF_LIBFDT_OVERLAY=y

Signed-off-by: Ludwig Nussel <ludwig.nussel at siemens.com>

---

(no changes since v1)

 board/emulation/qemu-arm/qemu-arm.c | 33 ++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c
index 38f0ec5f2fb..460958b04a1 100644
--- a/board/emulation/qemu-arm/qemu-arm.c
+++ b/board/emulation/qemu-arm/qemu-arm.c
@@ -147,7 +147,38 @@ int dram_init_banksize(void)
 int board_fdt_blob_setup(void **fdtp)
 {
 	/* QEMU loads a generated DTB for us at the start of RAM. */
-	*fdtp = (void *)CFG_SYS_SDRAM_BASE;
+	void *qemu_fdt = (void *)CFG_SYS_SDRAM_BASE;
+	int ret;
+
+	if (!*fdtp)
+		goto out;
+
+	if (!CONFIG_IS_ENABLED(OF_LIBFDT_OVERLAY)) {
+		log_err("found built-in dt but CONFIG_OF_LIBFDT_OVERLAY isn't enabled");
+		goto out;
+	}
+
+	if (fdt_check_header(*fdtp) != 0) {
+		log_err("invalid built-in fdt, skipped.\n");
+		goto out;
+	}
+
+	log_debug("found built-in dt %p merging into qemu's at %p...\n", *fdtp, qemu_fdt);
+
+	ret = fdt_increase_size(qemu_fdt, 1024 + fdt_totalsize(*fdtp));
+	if (ret) {
+		log_err("Failed to resize overlay: %d", ret);
+		goto out;
+	}
+
+	ret = fdt_overlay_apply_node(qemu_fdt, 0, (void *)*fdtp, 0);
+	if (ret) {
+		log_err("Failed to apply overlay: %d\n", ret);
+		goto out;
+	}
+
+out:
+	*fdtp = qemu_fdt;
 
 	return 0;
 }
-- 
2.43.0



More information about the U-Boot mailing list