summaryrefslogtreecommitdiff
path: root/boot/bootm.c
diff options
context:
space:
mode:
authorDaniel Golle <[email protected]>2026-05-16 00:37:52 +0100
committerTom Rini <[email protected]>2026-05-27 13:41:33 -0600
commitcafe3d6e90e661bd9d42b19f1e2d891da48f3fce (patch)
tree85085002dc369ed6eeeda9901983bb8fe898a1f2 /boot/bootm.c
parentd3eee4d3b120f2fe30932b2f29d935cc9ac9ddb3 (diff)
boot: fit: support generating DM verity cmdline parameters
Add fit_verity_build_cmdline(): when a FILESYSTEM loadable carries a dm-verity subnode, construct the dm-mod.create= kernel cmdline parameter from the verity metadata (block-size, data-blocks, algo, root-hash, salt) and append it to bootargs. Also add dm-mod.waitfor=/dev/fit0[,/dev/fitN] for each dm-verity device so the kernel waits for the underlying FIT block device to appear before setting up device-mapper targets. This is needed when the block driver probes late, e.g. because it depends on NVMEM calibration data. The dm-verity target references /dev/fitN where N is the loadable's index in the configuration -- matching the order Linux's FIT block driver assigns block devices. hash-start-block is read directly from the FIT dm-verity node; mkimage ensures its value equals num-data-blocks by invoking veritysetup with --no-superblock. Signed-off-by: Daniel Golle <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'boot/bootm.c')
-rw-r--r--boot/bootm.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/boot/bootm.c b/boot/bootm.c
index 4836d6b2d41..ec74873b503 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -243,6 +243,13 @@ static int boot_get_kernel(const char *addr_fit, struct bootm_headers *images,
static int bootm_start(void)
{
+ /*
+ * Free dm-verity allocations from a prior boot attempt before
+ * zeroing the structure. The pointers are guaranteed to be valid
+ * or NULL: .bss is zero-initialised, and memset() below zeroes
+ * them again after every boot.
+ */
+ fit_verity_free(&images);
memset((void *)&images, 0, sizeof(images));
images.verify = env_get_yesno("verify");
@@ -1071,6 +1078,12 @@ int bootm_run_states(struct bootm_info *bmi, int states)
/* For Linux OS do all substitutions at console processing */
if (images->os.os == IH_OS_LINUX)
flags = BOOTM_CL_ALL;
+ ret = fit_verity_apply_bootargs(images);
+ if (ret) {
+ printf("dm-verity bootargs failed (err=%d)\n", ret);
+ ret = CMD_RET_FAILURE;
+ goto err;
+ }
ret = bootm_process_cmdline_env(flags);
if (ret) {
printf("Cmdline setup failed (err=%d)\n", ret);