[PATCH v3 0/8] tpm: rng: Move TPM RNG functionality to driver model
Sughosh Ganu
sughosh.ganu at linaro.org
Fri Mar 4 14:34:21 CET 2022
The TPM device provides the random number generator(RNG)
functionality, whereby sending a command to the TPM device results in
the TPM device responding with random bytes.
There was a discussion on the mailing list earlier[1], where it was
explained that platforms with a TPM device can install the
EFI_RNG_PROTOCOL for getting the random bytes instead of populating
the dtb with the kaslr-seed property. That would make it possible to
measure the dtb.
This patchset moves the already existing functions for getting random
bytes from the TPM device to drivers complying with the RNG
uclass. This is done since the EFI_RNG_PROTOCOL's get_rng routine uses
the RNG uclass's dm_rng_read api to get the random bytes.
The TPM uclass driver adds the RNG child device as part of it's
post_probe function. The TPM uclass driver's child_pre_probe function
initialises the TPM parent device for use -- this enables the RNG
child device to be used subsequently.
Some additional changes have also been made to facilitate the
use of the RNG devices, including extending the 'rng' command to take
the RNG device as one of the command-line parameters.
This series depends on a patch[2] from Simon Glass for moving the TPM
device version detection functions to the tpm_api.h header as static
inline functions. Using this patch, a couple of patches[3][4] from the
series are no longer needed.
[1] - https://lore.kernel.org/u-boot/20220103120738.47835-1-ilias.apalodimas@linaro.org/
[2] - https://lore.kernel.org/u-boot/20220301001125.1554442-2-sjg@chromium.org/T/#u
[3] - https://lore.kernel.org/u-boot/20220228120638.678137-7-sughosh.ganu@linaro.org/T/#u
[4] - https://lore.kernel.org/u-boot/20220228120638.678137-6-sughosh.ganu@linaro.org/T/#u
Changes since V2:
* Export the existing tpm*_get_random functions to the driver model
instead of moving them to the drivers/rng/ directory.
* Enable DM_RNG when CONFIG_TPM is enabled to build the RNG uclass
code
* Additional patch for a document for the 'rng' command as suggested
by Simon Glass
* Additional patch for unit test for the 'rng' command as suggested by
Simon Glass
Sughosh Ganu (8):
tpm: rng: Change tpm_get_random to return an int
tpm: Fix the return type of tpm_startup
tpm: rng: Add driver model interface for TPM RNG device
tpm: Add the RNG child device
qemu: arm: Remove platform specific function to get RNG device
cmd: rng: Add support for selecting RNG device
doc: rng: Add documentation for the rng command
test: rng: Add a UT testcase for the rng command
board/emulation/qemu-arm/qemu-arm.c | 42 --------------------
cmd/Kconfig | 1 +
cmd/rng.c | 31 +++++++++++----
doc/usage/index.rst | 1 +
doc/usage/rng.rst | 25 ++++++++++++
drivers/tpm/tpm-uclass.c | 60 +++++++++++++++++++++++++++--
include/tpm-v1.h | 4 +-
include/tpm-v2.h | 4 +-
include/tpm_api.h | 6 +--
lib/Kconfig | 1 +
lib/tpm-v1.c | 28 ++++++++++----
lib/tpm-v2.c | 21 +++++++---
lib/tpm_api.c | 28 +++++++++++---
test/dm/rng.c | 29 ++++++++++++++
14 files changed, 201 insertions(+), 80 deletions(-)
create mode 100644 doc/usage/rng.rst
--
2.25.1
More information about the U-Boot
mailing list