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>,
	benh@amazon.com, linux-arm-kernel@lists.infradead.org
Subject: Re: RNDR/SS vs. SMCCC
Date: Thu, 27 May 2021 13:50:16 +0100	[thread overview]
Message-ID: <YK+ViBXTiB/bQOCF@sirena.org.uk> (raw)
In-Reply-To: <7d5697f3994fc1f9cf39d332525269056e3649b3.camel@kernel.crashing.org>


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

On Thu, May 27, 2021 at 09:54:03AM +1000, Benjamin Herrenschmidt wrote:

> I'm trying to understand the rationale for having SMCCC take precedence
> over the architected instruction in
> arch/arm64/include/asm/archrandom.h 

> Especially I don't quite get the comment about SMCCC being more in the
> "spirit" than let's say RNDRSS. It's definitely MUCH slower.

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.  The thinking was that the latter is more in
line with what the callers are expecting for the _seed variants,
it's kind of unclear what the performance/quality tradeoff is
supposed to be though.

See the thread at

   https://lore.kernel.org/r/CAKv+Gu8y4zwpesytU7vffSCuq8YAjWcHwFHwa_LhTW_cLiSfQw@mail.gmail.com

for discussion of the use of RNDR rather than RNDRRS - the main
concern was the potential for issues with excessive use of
entropy especially on bigger systems, possibly amplified if
there's lots of VMs, though in the meantime the random.c code got
updated to read seeds a lot less often (390596c9959c2a4f5b4
"random: avoid arch_get_random_seed_long() when collecting IRQ
randomness") so the considerations have changed a bit since the
original discussion and we could probably already revisit that
one already.

> Also, why not implement arch_get_random_* using RNDR rather than
> forcing these through the kernel CNRG ?

That was the same consideration with potential issues due to
excessive usage, it was dropped at the same time as switching to
RNDR for the _seed variants.  

This was all before I started looking at the series but my
understanding is that the general idea was to go for a
conservative implementation initially and then reevaluate once
we've got actual systems and can measure how things perform in
practice.

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.

> Finally, RNDR/RNDRSS can fail occasionally, we should probably
> implement some kind of delay+retry here. I'm not super familiar with
> the context in which arch_get_random_* can be called (are they allowed
> to sleep ?) but from the implementation I'm aware of at least, the idea
> is that they might under some HW recovery scenarii so we should sleep a
> couple of ms and try again a few times.

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.

[-- 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-27 12:52 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 [this message]
2021-05-27 23:12   ` Benjamin Herrenschmidt
2021-05-28 12:56     ` Mark Brown
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=YK+ViBXTiB/bQOCF@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).