[PATCH v2 08/10] tpm: Add the RNG child device
Simon Glass
sjg at chromium.org
Thu Mar 3 04:47:47 CET 2022
Hi Sughosh,
On Tue, 1 Mar 2022 at 21:53, Sughosh Ganu <sughosh.ganu at linaro.org> wrote:
>
> hi Simon,
>
> On Tue, 1 Mar 2022 at 20:29, Simon Glass <sjg at chromium.org> wrote:
> >
> > Hi Sughosh,
> >
> > On Mon, 28 Feb 2022 at 05:07, Sughosh Ganu <sughosh.ganu at linaro.org> wrote:
> > >
> > > The TPM device comes with the random number generator(RNG)
> > > functionality which is built into the TPM device. Add logic to add the
> > > RNG child device in the TPM uclass post probe callback.
> > >
> > > The RNG device can then be used to pass a set of random bytes to the
> > > linux kernel, need for address space randomisation through the
> > > EFI_RNG_PROTOCOL interface.
> > >
> > > Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
> > > ---
> > >
> > > Changes since V1: None
> > >
> > > drivers/tpm/tpm-uclass.c | 58 +++++++++++++++++++++++++++++++++++++---
> > > 1 file changed, 54 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/tpm/tpm-uclass.c b/drivers/tpm/tpm-uclass.c
> > > index 8619da89d8..383cc7bc48 100644
> > > --- a/drivers/tpm/tpm-uclass.c
> > > +++ b/drivers/tpm/tpm-uclass.c
> > > @@ -16,6 +16,11 @@
> > > #include <tpm-v2.h>
> > > #include "tpm_internal.h"
> > >
> > > +#include <dm/lists.h>
> > > +
> > > +#define TPM_RNG1_DRV_NAME "tpm1-rng"
> > > +#define TPM_RNG2_DRV_NAME "tpm2-rng"
> > > +
> > > bool is_tpm1(struct udevice *dev)
> > > {
> > > return IS_ENABLED(CONFIG_TPM_V1) && tpm_get_version(dev) == TPM_V1;
> > > @@ -147,12 +152,57 @@ int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
> > > return 0;
> > > }
> > >
> > > +#if IS_ENABLED(CONFIG_TPM)
> >
> > This should be in the Makefile so that we only build this file if TPM
> > is enabled.
>
> The Makefile allows for the tpm uclass driver to be built for SPL and
> TPL stages as well. The addition of the RNG device is to be done only
> in the u-boot proper stage, since we enable RNG support only in u-boot
> proper. Thanks.
Well in that case, create a new SPL_TPM_RAND or similar to control
enabling it in SPL. It should be explicit.
Regards,
Simon
More information about the U-Boot
mailing list