Hi Ludwig, On 2026-05-28T11:47:57, Ludwig Nussel <[email protected]> wrote: > qemu-arm: merge built-in DT > > 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 both device trees at startup. > > Signed-off-by: Ludwig Nussel <[email protected]> > > board/emulation/qemu-arm/qemu-arm.c | 47 +++++++++++++++++++++++++++++++++++-- > configs/qemu_arm64_defconfig | 1 + > 2 files changed, 46 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass <[email protected]> > diff --git a/board/emulation/qemu-arm/qemu-arm.c > b/board/emulation/qemu-arm/qemu-arm.c > @@ -144,10 +144,53 @@ int dram_init_banksize(void) > +/* QEMU loads a generated DTB for us at the start of RAM. > + * When using signatures we may have a built-in FDT that contains > + * our known public keys nevertheless. So merge the built in FDT > + * into QEMU's. We cannot merge the other way around (eg in > + * fdtdec_board_setup()) or board_fix_fdt() at this stage as U-Boot > + * might be started from a ROM location. At the same time U-Boot > + * needs QEMU's FDT to initialize serial devices even before > + * relocation. > + */ Please use kernel multi-line comment style: '/*' on its own line, prose starting on the next. Also 'eg' should be 'e.g.' and 'built in' as an adjective is 'built-in'. > diff --git a/board/emulation/qemu-arm/qemu-arm.c > b/board/emulation/qemu-arm/qemu-arm.c > @@ -144,10 +144,53 @@ int dram_init_banksize(void) > + ret = fdt_increase_size(qemu_fdt, 1024 + fdt_totalsize(*fdtp)); > + if (ret) { > + log_err("Failed to resize FDT overlay: %s", fdt_strerror(ret)); > + goto out; > + } Missing trailing '\n' - the next log_err() has one. Also, qemu_fdt is the base we're growing to receive the overlay, not the overlay itself; "Failed to grow QEMU FDT" would be clearer. > diff --git a/board/emulation/qemu-arm/qemu-arm.c > b/board/emulation/qemu-arm/qemu-arm.c > @@ -144,10 +144,53 @@ int dram_init_banksize(void) > + ret = fdt_overlay_apply_node(qemu_fdt, 0, (void *)*fdtp, 0); > + if (ret) { > + log_err("Failed to apply FDT overlay: %s\n", fdt_strerror(ret)); > + goto out; > + } > + > +out: > + *fdtp = qemu_fdt; > + > return 0; > } On failure we log and return 0 with a partially-modified qemu_fdt. Please propagate the error - otherwise a board with FIT_SIGNATURE_REQUIRED (added later in the series) silently boots without keys merged and presumably fails much later. The (void *) cast on *fdtp is also redundant, isn't it? > diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig > @@ -38,6 +38,7 @@ CONFIG_CMD_EFIDEBUG=y > +# CONFIG_OF_OMIT_DTB is not set The commit message doesn't mention this. Please add a sentence explaining that OF_OMIT_DTB must be off so the built-in DT is present to merge from, and note whether qemu_arm_defconfig needs the same treatment. Regards, Simon

