public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Simon Glass <sjg@chromium.org>, Rob Herring <robh@kernel.org>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	U-Boot Mailing List <u-boot@lists.denx.de>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>
Subject: Re: [PATCH v6 3/7] tpm: Add the RNG child device
Date: Thu, 14 Jul 2022 12:04:01 -0400	[thread overview]
Message-ID: <20220714160401.GA1146598@bill-the-cat> (raw)
In-Reply-To: <CAC_iWj+HVH2yqHMLeW41Nz0Hd646YJgtZysgQvyzfEVEYG3nJg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4922 bytes --]

On Thu, Jul 14, 2022 at 06:47:28PM +0300, Ilias Apalodimas wrote:
> Hi Simon,
> 
> [...]
> > > > > > > > > > The driver needs a compatible string so it can be in the device tree.
> > > > > > > > >
> > > > > > > > > Why?  I've tried to hint this on the previous iteration of the patch.
> > > > > > > > > The RNG here is not a *device*.  The TPM is the device and you are
> > > > > > > > > guaranteed to have an RNG.  The way to get a random number is send a
> > > > > > > > > special command to the TPM. So all that we should do here is leverage
> > > > > > > > > the fact that the TPM is already in the device tree.
> > > > > > > > >
> > > > > > > > > And fwiw we should stick to try to stick to what the DT spec defines
> > > > > > > > > as much as possible.  I personally don't see this as a special usecase
> > > > > > > > > were deviating from the spec is justified.
> > > > > > > >
> > > > > > > > This is not a deviation from a spec. What spec? Also, I don't want to
> > > > > > > > get into another discussion about what a device is. We can disagree on
> > > > > > > > that if you like.
> > > > > > > >
> > > > > > > > One reason is that U-Boot generally requires compatible strings, e.g.
> > > > > > > > with of-platdata. But also we can refer to the rand device from
> > > > > > > > elsewhere in the tree. I know that Linux does lots of ad-hoc device
> > > > > > > > creation and doesn't really have the concept of a uclass consistently
> > > > > > > > applied, but this is U-Boot.
> > > > > > >
> > > > > > > You are letting client/OS details define your binding. Doing so
> > > > > > > doesn't result in OS agnostic bindings. Sure, it would be nice if DT
> > > > > > > nodes and drivers were always a nice clean 1:1 ratio, but h/w is messy
> > > > > > > sometimes and DT is not an abstraction layer. The general guidance on
> > > > > > > whether there are child nodes for sub-blocks is do they have their own
> > > > > > > resources in DT or are the sub-blocks reusable on multiple devices.
> > > > > > > Neither of those are the case here.
> > > > > > >
> > > > > > > Besides, we already have TPM device bindings defined. Requiring
> > > > > > > binding changes when adding a new client/OS feature is not good
> > > > > > > practice either.
> > > > > >
> > > > > > I'm not sure what to do with this, but in general the practice of
> > > > > > implied subnodes is not friendly to U-Boot. Yet it seems like a common
> > > > > > feature of the bindings at present, for example GPIOs.
> > > > > >
> > > > > > The device tree is how U-Boot determines which random-number generator
> > > > > > to use for a particular function. For example, for VBE, if we need to
> > > > > > generate some random numbers we'd like to specify which device creates
> > > > > > them. It can't just be 'use the TPM if you find one'. I'm not sure how
> > > > > > that works in Linux?
> > > > >
> > > > > Why can't it be "use the TPM if you find one" since a TPM is a superset
> > > > > of an RNG?
> > > >
> > > > You mean look through the available rand devices and choose the one
> > > > whose parent is a TPM?
> > > >
> > > > Sure. There are lots of things you can do. But device tree is supposed
> > > > to provide the tree of devices and allow such things to be configured
> > > > deterministically.
> > >
> > > No, I mean pick the TPM device because by definition it is an RNG.
> >
> > I think that is what I said, or meant. The TPM is not a rand device,
> > it is the child of the TPM which might be.
> 
> The design principle of the tpm1.2 says that it must have an rng [1].
> I think something similar is implied on 2.0 architecture as well [2].
> Looking at the cr50 description is says "TPM-like" [3]  not TPM.  I
> assume an RNG exists internally since the TPM requires and RNG for
> nonces, key generation etc.
> 
> Any idea what happens if you run tpm_getrandom() against a cr50? If
> you get back garbage then we got a problem since you can't really tell
> if it's garbage or a random seed.  But if it returns something sane
> along the lines of 'not supported' then I guess we can use that and
> try the next RNG?
> 
> [1] https://trustedcomputinggroup.org/wp-content/uploads/TPM-Main-Part-1-Design-Principles_v1.2_rev116_01032011.pdf
> 4.2.5 random number generator
> [2] https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.07-2014-03-13.pdf
> 11.4.10 RNG module
> [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/security/tpm/google%2Ccr50.txt

What I'm saying is from what I understand a spec compliant TPM is an
RNG, so we should be able to match on that existing compatible.  What
the cr50 does or doesn't do (or is or is not compliant about) would
indeed make things more complex but I think also maybe helps the rest of
us understand where you've been coming from.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  reply	other threads:[~2022-07-14 16:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 13:34 [PATCH v6 0/7] tpm: rng: Move TPM RNG functionality to driver model Sughosh Ganu
2022-07-04 13:34 ` [PATCH v6 1/7] tpm: Export the TPM-version functions Sughosh Ganu
2022-07-06  8:59   ` Ilias Apalodimas
2022-07-04 13:34 ` [PATCH v6 2/7] tpm: rng: Add driver model interface for TPM RNG device Sughosh Ganu
2022-07-05  9:47   ` Simon Glass
2022-07-05 17:23     ` Sughosh Ganu
2022-07-12 10:58       ` Simon Glass
2022-07-06 13:26   ` Ilias Apalodimas
2022-07-04 13:34 ` [PATCH v6 3/7] tpm: Add the RNG child device Sughosh Ganu
2022-07-05  9:47   ` Simon Glass
2022-07-08  8:23     ` Ilias Apalodimas
2022-07-12 10:58       ` Simon Glass
2022-07-12 14:11         ` Rob Herring
2022-07-13 15:28           ` Simon Glass
2022-07-13 18:09             ` Tom Rini
2022-07-14 10:21               ` Simon Glass
2022-07-14 11:19                 ` Tom Rini
2022-07-14 14:51                   ` Simon Glass
2022-07-14 15:47                     ` Ilias Apalodimas
2022-07-14 16:04                       ` Tom Rini [this message]
2022-07-14 17:55             ` Rob Herring
2022-07-15 15:38               ` Simon Glass
2022-07-04 13:34 ` [PATCH v6 4/7] cmd: rng: Add support for selecting RNG device Sughosh Ganu
2022-07-04 13:34 ` [PATCH v6 5/7] cmd: rng: Use a statically allocated array for random bytes Sughosh Ganu
2022-07-05  9:47   ` Simon Glass
2022-07-06 13:31   ` Ilias Apalodimas
2022-07-04 13:34 ` [PATCH v6 6/7] doc: rng: Add documentation for the rng command Sughosh Ganu
2022-07-04 13:34 ` [PATCH v6 7/7] test: rng: Add a UT testcase " Sughosh Ganu
2022-07-06 13:32   ` Ilias Apalodimas
2022-07-05  9:47 ` [PATCH v6 0/7] tpm: rng: Move TPM RNG functionality to driver model Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220714160401.GA1146598@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=robh@kernel.org \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox