All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Spencer <spencercw@gmail.com>
To: Horia Geanta <horia.geanta@nxp.com>
Cc: Aymen Sghaier <aymen.sghaier@nxp.com>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
	Chris Spencer <christopher.spencer@sea.co.uk>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [RFC 4/4] crypto: caam - use job ring for RNG instantiation instead of DECO
Date: Tue, 26 Feb 2019 16:24:13 +0000	[thread overview]
Message-ID: <CAGUNXRRcaiGAaKkUs2Tw_aZD4QKHtJMFLwkfu92pMu3jCBo5gw@mail.gmail.com> (raw)
In-Reply-To: <VI1PR0402MB34857504705A898A59085B4B987B0@VI1PR0402MB3485.eurprd04.prod.outlook.com>

On Tue, 26 Feb 2019 at 14:53, Horia Geanta <horia.geanta@nxp.com> wrote:
> On 2/25/2019 4:37 PM, Chris Spencer wrote:
> > On Mon, 25 Feb 2019 at 14:22, Horia Geanta <horia.geanta@nxp.com> wrote:
> >>
> >> On 2/22/2019 12:07 PM, spencercw@gmail.com wrote:
> >>> From: Chris Spencer <christopher.spencer@sea.co.uk>
> >>>
> >>> This is required to support the i.MX8.
> >>>
> >> Why exactly is this required?
> >> You should provide more details.
> >
> > I don't know. :) These changes were made in [1], although the change
> > is actually described in [2] where it says: "Use a Job ring for RNG
> > instantiation rather than DECO, even for i.MX6/7 families." This does
> > indeed seem to be necessary to get it to work, but I can only
> > speculate why.
> >
> The commit messages you refer are indeed rather poor, however you need to
> understand the context: the history reflects NXP internal development.
>
> It's expected for the changes to be clearly explained, justified when reaching
> mainline kernel.

Ok, I will expand the commit message for the next version.

> > The original commit which added the run_descriptor_deco0 function [3]
> > states "[...] and another function that performs the running of the
> > said descriptor using the DECO debug mechanism." My best guess is that
> > the DECO debug mechanism is no longer available so it has to go via
> > the job ring.
> >
> This change is actually orthogonal to i.MX8 MQ support and is related to
> SECO-based i.MX8 SoCs (QXP, QM) and/or OP-TEE support.
>
> Access to CAAM global registers (CCSR page 0) won't be allowed in cases when
> Linux runs in Normal World.
> From this perspective, it makes sense to eliminate accesses to these registers.
> Some of the accesses are done for RNG initialization via the DECO debug
> mechanism; to remove them, RNG is initialized via the Job Ring interface.
> However, I still see some illegal accesses - for e.g. reading RDSTA register to
> check which virtual RNGs ("state handles" in RM terms) are already initialized.
>
> It looks like cutting access to CAAM global registers must come with some
> assumptions (since it implies some checks can no longer be performed, see RDSTA
> above).
> For e.g. in case OP-TEE is detected, we could assume that RNG was already
> initialized. Similar for other cases like SECO f/w (i.MX8 QM and QXP).
> If we make this assumption, it actually means RNG initialization is no longer
> needed:
>
> if (!ctrlpriv->mc_en && rng_vid >= 4 && !normal_world) {
>         ... // rng init as before - using DECO debug mechanism
> }

Thanks for the information. This is more problematic than I had
anticipated. It sounds like these are the possible scenarios:

1. Linux is running in the normal world without OP-TEE/SECO; RNG must
be initialised via the job ring. No way of checking whether the RNG is
already initialised.
2. Linux is running in the normal world with OP-TEE/SECO; RNG
initialisation is not required.
3. Linux is running in the secure world without OP-TEE/SECO; RNG can
be initialised via DECO debug mechanism or job ring.
4. Linux is running in the secure world with OP-TEE/SECO; RNG
initialisation is not required. This sounds like a very unlikely
configuration.

My build is currently sitting in scenario 1, which would explain why
the RNG initialisation via DECO was failing. Clearly it can be made to
work by running the initialisation via the job ring and assuming the
RNG has not already been initialised, but I'm getting the impression
that this may not be a sensible configuration.

Is running Linux in the secure world a typical configuration? It's not
a conscious choice I've made to run it in the normal world; that's
just what the TF-A is doing. I suppose it's either that or start using
OP-TEE so it can initialise the RNG.

As far as driver support goes, are we only interested in scenarios 2
and 3? I'm not really sure how we would detect which world we are
running in, or whether OP-TEE has initialised the RNG.

Thanks,
Chris

  reply	other threads:[~2019-02-26 16:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 10:06 [RFC 0/4] crypto: caam - Add i.MX8MQ support spencercw
2019-02-22 10:06 ` [RFC 1/4] crypto: caam - fix detection of i.MX8 SoC spencercw
2019-02-25  7:50   ` Chris Spencer
2019-02-22 10:06 ` [RFC 2/4] crypto: caam - do not initialise clocks on the i.MX8 spencercw
2019-02-22 10:06 ` [RFC 3/4] crypto: caam - correct DMA address size for " spencercw
2019-02-22 10:06 ` [RFC 4/4] crypto: caam - use job ring for RNG instantiation instead of DECO spencercw
2019-02-25 14:22   ` Horia Geanta
2019-02-25 14:36     ` Chris Spencer
2019-02-26 14:53       ` Horia Geanta
2019-02-26 16:24         ` Chris Spencer [this message]
2019-02-28 11:33           ` Chris Spencer
2019-03-04 18:13             ` Horia Geanta
2019-03-05  8:54               ` Chris Spencer
2019-02-25 14:03 ` [RFC 0/4] crypto: caam - Add i.MX8MQ support Horia Geanta
2019-02-25 14:17   ` Chris Spencer
2019-02-25 19:28     ` Chris Spencer

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=CAGUNXRRcaiGAaKkUs2Tw_aZD4QKHtJMFLwkfu92pMu3jCBo5gw@mail.gmail.com \
    --to=spencercw@gmail.com \
    --cc=aymen.sghaier@nxp.com \
    --cc=christopher.spencer@sea.co.uk \
    --cc=horia.geanta@nxp.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.