]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Merge tag 'tpm-next-27102023' of https://source.denx.de/u-boot/custodians/u-boot-tpm
authorTom Rini <trini@konsulko.com>
Fri, 27 Oct 2023 23:27:29 +0000 (19:27 -0400)
committerTom Rini <trini@konsulko.com>
Fri, 27 Oct 2023 23:27:29 +0000 (19:27 -0400)
bootX measurements and measurement API moved to u-boot core:

Up to now, U-Boot could perform measurements and EventLog creation as
described by the TCG spec when booting via EFI.

The EFI code was residing in lib/efi_loader/efi_tcg2.c and contained
both EFI specific code + the API needed to access the TPM, extend PCRs
and create an EventLog. The non-EFI part proved modular enough and
moving it around to the TPM subsystem was straightforward.

With that in place we can have a common API for measuring binaries
regardless of the boot command, EFI or boot(m|i|z), and contructing an
EventLog.

I've tested all of the EFI cases -- booting with an empty EventLog and
booting with a previous stage loader providing one and found no
regressions.  Eddie tested the bootX part.

Eddie also fixed the sandbox TPM which couldn't be used for the EFI code
and it now supports all the required capabilities. This had a slight
sideeffect in our testing since the EFI subsystem initializes the TPM
early and 'tpm2 init' failed during some python tests. That code only
opens the device though, so we can replace it with 'tpm2 autostart'
which doesn't error out and still allows you to perfom the rest of the
tests but doesn't report an error if the device is already opened.

There's a few minor issues with this PR as well but since testing and
verifying the changes takes a considerable amount of time, I prefer
merging it now.

Heinrich has already sent a PR for -master containing "efi_loader: fix
EFI_ENTRY point on get_active_pcr_banks" and I am not sure if that will
cause any conflicts, but in any case they should be trivial to resolve.

Both the EFI and non-EFI code have a Kconfig for measuring the loaded
Device Tree.  The reason this is optional is that we can't reason
when/if devices add random info like kaslr-seed, mac addresses etc in
the DT. In that case measurements are random, board specific and
eventually useless.  The reason it was difficult to fix it prior to this
patchset is because the EFI subsystem and thus measurements was brought
up late and DT fixups might have already been applied. With this
patchset we can measure the DT really early in the future.

Heinrich also pointed out that the two Kconfigs for the DTB measurements
can be squashed in a single one and that the documentation only explains
the non-EFI case.  I agree on both but as I said this is a sane working
version, so let's pull this first it's aleady big enough and painful to
test.

1  2 
arch/sandbox/dts/test.dts
boot/bootm.c
cmd/booti.c
cmd/bootm.c
cmd/bootz.c
configs/sandbox_defconfig
doc/usage/index.rst
include/test/suites.h
lib/Kconfig
test/cmd_ut.c

Simple merge
diff --cc boot/bootm.c
Simple merge
diff --cc cmd/booti.c
Simple merge
diff --cc cmd/bootm.c
Simple merge
diff --cc cmd/bootz.c
Simple merge
index e3a2f9eb17089c0f2cc0753fc5f5dc978547a019,6e32649bc7ad587dc1a8d0a3d9970b7e9aa6f4f1..c8a46690503c02755dfaa0f61a67be3150133037
@@@ -14,6 -14,6 +14,7 @@@ CONFIG_FIT_RSASSA_PSS=
  CONFIG_FIT_CIPHER=y
  CONFIG_FIT_VERBOSE=y
  CONFIG_LEGACY_IMAGE_FORMAT=y
++CONFIG_MEASURED_BOOT=y
  CONFIG_DISTRO_DEFAULTS=y
  CONFIG_BOOTSTAGE=y
  CONFIG_BOOTSTAGE_REPORT=y
Simple merge
index 51acbe47b2f919c01cc6c9c6968ac31af0b68db6,48ed549c13f65814fc175f5fb371886b8eb91504..ad4fc926f48f15a20675c4f89a816c492c2e24fd
@@@ -45,7 -45,7 +45,8 @@@ int do_ut_font(struct cmd_tbl *cmdtp, i
  int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
 +int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+ int do_ut_measurement(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
  int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
  int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
diff --cc lib/Kconfig
Simple merge
diff --cc test/cmd_ut.c
Simple merge