On 2026-10-06T15:52:14, Michael Haener <[email protected]> wrote: > tpm: Add an option to start the TPM during init > > Add CONFIG_TPM_AUTOSTART, which runs the TPM startup and self-test > sequence from an EVT_LAST_STAGE_INIT handler. This is the same thing the > 'tpm autostart' command does, but it does not depend on a boot script or > on the environment. > > Today a TPM is only started automatically when either CONFIG_MEASURED_BOOT > is used (and then only from bootm) or when booting via EFI with > CONFIG_EFI_TCG2_PROTOCOL. A plain booti/bootm therefore leaves the chip > uninitialised and the OS has to start it itself, which Linux reports as > "A TPM error (256) occurred attempting the self test". Boards have worked > around this by putting 'tpm autostart' into their environment, see > board/xilinx/zynqmp/zynqmp_kria.env. > > The startup is done from an event rather than in the uclass probe: > nothing probes the TPM on a plain booti/bootm, and the event runs exactly > once in U-Boot proper without changing what probing a TPM means for the > existing callers. > > Boards that share one binary between variants with and without a TPM > fitted can enable this safely: when no TPM device is found the startup is > skipped silently. Other errors are reported as warnings but do not stop > the boot. Note that the full self-test adds to the boot time. > > Signed-off-by: Michael Haener <[email protected]> > > doc/usage/measured_boot.rst | 18 ++++++++++++++++++ > lib/Kconfig | 19 +++++++++++++++++++ > lib/Makefile | 1 + > lib/tpm_autostart.c | 37 +++++++++++++++++++++++++++++++++++++ > 4 files changed, 75 insertions(+)
Reviewed-by: Simon Glass <[email protected]>
