U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/7] fit: dm-verity support
@ 2026-05-07 16:40 Daniel Golle
  2026-05-07 16:40 ` [PATCH v3 1/7] image: fit: add dm-verity property name constants Daniel Golle
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: Daniel Golle @ 2026-05-07 16:40 UTC (permalink / raw)
  To: Tom Rini, Simon Glass, Quentin Schulz, Kory Maincent,
	Mattijs Korpershoek, Anshul Dalal, Martin Schwan, Daniel Golle,
	Ilias Apalodimas, Sughosh Ganu, Benjamin ROBIN, Ludwig Nussel,
	Marek Vasut, James Hilliard, Kunihiko Hayashi, Frank Wunderlich,
	Mayuresh Chitale, Neil Armstrong, Wolfgang Wallner, Shiji Yang,
	Aristo Chen, Rasmus Villemoes, Francois Berder, u-boot

This series adds dm-verity support to U-Boot's FIT image infrastructure.
It is the first logical subset of the larger OpenWrt boot method series
posted as an RFC in February 2026 [1], extracted here for independent
review and merging.

OpenWrt's firmware model embeds a read-only squashfs or erofs root
filesystem directly inside a uImage.FIT container as a FILESYSTEM-type
loadable FIT image. At boot the kernel maps this sub-image directly from
the underlying block device via the fitblk driver (/dev/fit0, /dev/fit1,
...), the goal is that the bootloader never even copies it to RAM.

dm-verity enables the kernel to verify the integrity of those mapped
filesystems at read time, with a Merkle hash tree stored contiguously in
the same sub-image just after the data. Two kernel command-line
parameters are required:

  dm-mod.create=   -- the device-mapper target table for the verity device
  dm-mod.waitfor=  -- a comma-separated list of block devices to wait for
                      before dm-init sets up the targets (needed when fitblk
                      probes late, e.g. because it depends on NVMEM
                      calibration data)

The FIT dm-verity node schema was upstreamed into the flat-image-tree
specification [2], which this implementation tries to follow exactly.

The runtime feature is guarded behind CONFIG_FIT_VERITY. If not
enabled the resulting binary size remains unchanged. If enabled the
binary size increases by about 3kB.

[1] previous submissions:
    RFC: https://www.mail-archive.com/u-boot@lists.denx.de/msg565945.html
    v1:  https://www.mail-archive.com/u-boot@lists.denx.de/msg569472.html
    v2:  https://www.mail-archive.com/u-boot@lists.denx.de/msg570599.html
[2] flat-image-tree dm-verity node spec:
    https://github.com/open-source-firmware/flat-image-tree/commit/795fd5fd7f0121d0cb03efb1900aafc61c704771

v3: address comments by Heinrich Schuchardt and Simon Glass
 * use unsigned int instead of int for data-block-size and hash-block-size
 * replace printf() with log_err() for the "broken dm-verity metadata"
   diagnostic
 * use FIT_VERITY_*_PROP, FIT_TYPE_PROP and FIT_LOADABLE_PROP constants
   in the unit test instead of literal strings
 * extend the mkimage block-count overflow check to also cover
   hash_start_block (matters when hash-block-size < data-block-size)
 * doc: clarify that hash-start-block only equals num-data-blocks when
   data-block-size == hash-block-size
 * pytest: drop unused 'struct' import and the home-rolled
   have_veritysetup() helper in favour of
   @pytest.mark.requiredtool('veritysetup')

v2: address comments by Simon Glass
 * use is_power_of_2() for pre-boot sanity check
 * let fit_verity_build_cmdline() return 0 on success
 * add comment explaining why bootm_start() calls fit_verity_free()
 * use existing hex2bin() (and adapt it to be usable for host-tools)
 * fix stale comment still including superblock despite veritysetup
   being called with --no-superblock
 * add power-of-two check for data-block-size and hash-block-size to
   mkimage
 * don't ignore return value of fdt_delprop()
 * various documentation fixes, minimal example
 * add pytest for mkimage part
 * add run-time unit test for cmdline generation part

Daniel Golle (7):
  image: fit: add dm-verity property name constants
  boot: fit: support generating DM verity cmdline parameters
  include: hexdump: make hex2bin() usable from host tools
  tools: mkimage: add dm-verity Merkle-tree generation
  doc: fit: add dm-verity boot parameter documentation
  test: boot: add runtime unit test for fit_verity_build_cmdline()
  test: py: add mkimage dm-verity round-trip test

 boot/Kconfig                     |  20 ++
 boot/bootm.c                     |  13 ++
 boot/image-board.c               |   5 +
 boot/image-fit.c                 | 337 +++++++++++++++++++++++++++++
 doc/usage/fit/dm-verity.rst      | 284 +++++++++++++++++++++++++
 doc/usage/fit/index.rst          |   1 +
 include/hexdump.h                |   8 +-
 include/image.h                  |  97 ++++++++-
 test/boot/Makefile               |   1 +
 test/boot/fit_verity.c           | 306 +++++++++++++++++++++++++++
 test/cmd_ut.c                    |   2 +
 test/py/tests/test_fit_verity.py | 145 +++++++++++++
 tools/fit_image.c                | 116 +++++++++-
 tools/image-host.c               | 350 ++++++++++++++++++++++++++++++-
 14 files changed, 1672 insertions(+), 13 deletions(-)
 create mode 100644 doc/usage/fit/dm-verity.rst
 create mode 100644 test/boot/fit_verity.c
 create mode 100644 test/py/tests/test_fit_verity.py

-- 
2.54.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-05-08 18:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 16:40 [PATCH v3 0/7] fit: dm-verity support Daniel Golle
2026-05-07 16:40 ` [PATCH v3 1/7] image: fit: add dm-verity property name constants Daniel Golle
2026-05-07 16:40 ` [PATCH v3 2/7] boot: fit: support generating DM verity cmdline parameters Daniel Golle
2026-05-07 16:41 ` [PATCH v3 3/7] include: hexdump: make hex2bin() usable from host tools Daniel Golle
2026-05-07 16:43 ` [PATCH v3 4/7] tools: mkimage: add dm-verity Merkle-tree generation Daniel Golle
2026-05-07 16:43 ` [PATCH v3 5/7] doc: fit: add dm-verity boot parameter documentation Daniel Golle
2026-05-07 16:43 ` [PATCH v3 6/7] test: boot: add runtime unit test for fit_verity_build_cmdline() Daniel Golle
2026-05-08 17:40   ` Simon Glass
2026-05-07 16:43 ` [PATCH v3 7/7] test: py: add mkimage dm-verity round-trip test Daniel Golle
2026-05-08 17:49   ` Simon Glass
2026-05-08 18:57 ` [PATCH v3 0/7] fit: dm-verity support Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox