linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Andre Przywara <andre.przywara@arm.com>,
	Will Deacon <will@kernel.org>, "Saidi, Ali" <alisaidi@amazon.com>,
	linux-arm-kernel@lists.infradead.org, benh@amazon.com
Subject: Re: RNDR/SS vs. SMCCC
Date: Fri, 28 May 2021 13:56:39 +0100	[thread overview]
Message-ID: <YLDohwwcZ/KXPYpM@sirena.org.uk> (raw)
In-Reply-To: <0339748b54e2faeddeec8d50e32a6c6ff4e8b3b7.camel@kernel.crashing.org>


[-- Attachment #1.1: Type: text/plain, Size: 4052 bytes --]

On Fri, May 28, 2021 at 09:12:38AM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2021-05-27 at 13:50 +0100, Mark Brown wrote:

> > Like the comments say the arm64 RNDR register is not intended to
> > be directly providing entropy but rather returning the output of
> > a DRBG which is seeded from an actual entropy source whereas the
> > SMCCC call is intended to return something from an actual entropy
> > source directly.

> Right, I was thinking about using RNDRSS instead.

Yeah, I *suspect* that's where we'll end up longer term now that
the random.c code is less enthusiastic about calling the
function - it was where the patches where initially until the
concerns about overloading were raised and it does seem to map
more naturally onto the API.  I do think we should hold off until
we've got some concrete information on how real systems perform
simply to avoid churn but I wouldn't be surprised to see us
making changes once we have data.  Sounds like you'll be able to
help out here!

Note that they do both get washed through the PRNG, not that I
think it makes a huge difference to the argument here.

> > In practice most of the non-seed arch_get_random usage is either
> > a fallback if there's no seed variant or mixed in with the CRNG
> > output anyway.

> Right but I still don't believe the end result makes a whole lot of
> sense. In absence of SMCCC we end up using RNDR as a seed which hits
> the "not a great match" comment. Not a huge deal I suppose, for our
> (EC2) case, we could just not implement the SMCCC call, and let it use
> RNDR, it's still going to be better than no HW random source, I just
> don't like those firmware calls much.

I do see them as useful for the seeding case, it shouldn't be in
quite such sensitive fast paths as the regular versions and 
it means that if a system has a better entropy source than the
one backing RNDR (especially if the one backing RNDR has some
actual problem) then we can override in software.  As you say if
the SMCCC isn't offering anything over the system registers then
platforms don't need to implement it.

> > The arch_get_random_ interfaces already provide a return code
> > which the callers can handle as needed, they can do something
> > appropriate for the scenario rather than the architecture code
> > having to pick.  Sometimes that's to retry later (random.c does
> > this when seeding for example), sometimes that's to just carry on
> > with whatever other entropy they've already got.
> 
> Ok. It's unfortunate that the ISA is so vague on the circumstances
> where the instructions are allowed to fail... it says "a reasonable
> amount of time", it may as well have said a "random amount of time" for
> the usefulness of it ;-)

> The implementation I'm aware of will fail extremely rarely when the HW
> detects an issues that requires corrective action, but I could imagine
> some implemetations just failing when there's no entropy at hand (esp.
> with RNDRSS).

Yes, I think there being inadequate entropy at hand to reseed is
the big concern here - some of that's going to be a quality
tradeoff and it's very hard to actually enforce any constraints
even if you define them so ultimately it all comes down to
quality of implementation issues.

> As long as the callers don't give up permanently, that's fine. I was
> just a bit concerned by cnrg_init_try_arch{_early}. It would be
> preferable for these to "try harder".

Yeah, there is some scope for retries there - unfortunately the
arch_get_random_ interface can't distinguish between temporary
and permanent failures, and people won't want to to slow down the
boot path at all by actually blocking.  Looking again there's
some scope for improving this process, we will continue to pull
seed values in crng_reseed() but not in quite the same way.  I'm
now wondering if it'd make sense to hook retries of the
architecture init into or alongside try_to_generate_entropy() in
wait_for_random_bytes() when trust_cpu is set.

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-05-28 13:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 23:54 RNDR/SS vs. SMCCC Benjamin Herrenschmidt
2021-05-27 12:50 ` Mark Brown
2021-05-27 23:12   ` Benjamin Herrenschmidt
2021-05-28 12:56     ` Mark Brown [this message]
2021-05-29  2:36       ` Benjamin Herrenschmidt
2021-05-31  1:02         ` Andre Przywara
2021-05-31  5:24           ` Ard Biesheuvel
2021-06-02 22:04             ` Benjamin Herrenschmidt
2021-06-03  0:19               ` Andre Przywara
2021-06-03  1:41                 ` Benjamin Herrenschmidt
2021-06-03  7:10                   ` Ard Biesheuvel
2021-06-03 21:30                     ` Benjamin Herrenschmidt

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=YLDohwwcZ/KXPYpM@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alisaidi@amazon.com \
    --cc=andre.przywara@arm.com \
    --cc=benh@amazon.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).