All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <marek.behun@nic.cz>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Max Resch <resch.max@gmail.com>, Stefan Roese <sr@denx.de>,
	u-boot@lists.denx.de
Subject: Re: [PATCH v4] rng: Add Turris Mox rTWM RNG driver
Date: Tue, 13 Feb 2024 11:08:26 +0100	[thread overview]
Message-ID: <20240213110826.030e1363@dellmb> (raw)
In-Reply-To: <c00f48a7-ef7b-4f82-aa6f-f7cadc6eb496@gmx.de>

On Tue, 13 Feb 2024 10:49:43 +0100
Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:

> On 2/13/24 10:16, Stefan Roese wrote:
> > Hi Max,
> >
> > mostly some nitpicking comments below.
> >
> > On 2/11/24 14:04, Max Resch wrote:  
> >> A RNG driver for Armada 3720 boards running the Turris Mox rWTM firmware
> >> from CZ.NIC in the secure processor.
> >>
> >> Signed-off-by: Max Resch <resch.max@gmail.com>
> >> ---
> >>
> >> Changes in v4:
> >>   - wrongful/missing git rebase
> >>
> >> Changes in v3:
> >>   - More meaningful variable names in accordance with review
> >>
> >> Changes in v2:
> >>   - Removed ring buffer implementation
> >>
> >>   drivers/rng/Kconfig           |   8 +++
> >>   drivers/rng/Makefile          |   1 +
> >>   drivers/rng/turris_rwtm_rng.c | 122 ++++++++++++++++++++++++++++++++++
> >>   3 files changed, 131 insertions(+)
> >>   create mode 100644 drivers/rng/turris_rwtm_rng.c
> >>
> >> diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig
> >> index a89c899568..cd72852a47 100644
> >> --- a/drivers/rng/Kconfig
> >> +++ b/drivers/rng/Kconfig
> >> @@ -105,4 +105,12 @@ config RNG_JH7110
> >>       help
> >>         Enable True Random Number Generator in StarFive JH7110 SoCs.
> >> +config RNG_TURRIS_RWTM
> >> +    bool "Turris Mox TRNG in Secure Processor"
> >> +    depends on DM_RNG && ARMADA_3700
> >> +    help
> >> +      Use TRNG in Turris Mox Secure Processor Firmware. Can be used
> >> +      on other Armada-3700 devices (like EspressoBin) if Secure
> >> +      Firmware from CZ.NIC is used.
> >> +
> >>   endif
> >> diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile
> >> index 7e64c4cdfc..ecae1a3da3 100644
> >> --- a/drivers/rng/Makefile
> >> +++ b/drivers/rng/Makefile
> >> @@ -17,3 +17,4 @@ obj-$(CONFIG_RNG_SMCCC_TRNG) += smccc_trng.o
> >>   obj-$(CONFIG_RNG_ARM_RNDR) += arm_rndr.o
> >>   obj-$(CONFIG_TPM_RNG) += tpm_rng.o
> >>   obj-$(CONFIG_RNG_JH7110) += jh7110_rng.o
> >> +obj-$(CONFIG_RNG_TURRIS_RWTM) += turris_rwtm_rng.o
> >> diff --git a/drivers/rng/turris_rwtm_rng.c
> >> b/drivers/rng/turris_rwtm_rng.c
> >> new file mode 100644
> >> index 0000000000..ec2cb0bca3
> >> --- /dev/null
> >> +++ b/drivers/rng/turris_rwtm_rng.c
> >> @@ -0,0 +1,122 @@
> >> +// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
> >> +/*
> >> + * Copyright (c) 2024, Max Resch
> >> + */
> >> +
> >> +#include <dm.h>
> >> +#include <malloc.h>
> >> +#include <rng.h>
> >> +#include <asm/dma-mapping.h>
> >> +#include <asm/types.h>
> >> +#include <mach/mbox.h>
> >> +
> >> +/* size of entropy buffer */
> >> +#define RNG_BUFFER_SIZE    128U
> >> +
> >> +struct turris_rwtm_rng_priv {
> >> +    phys_addr_t buffer;
> >> +};
> >> +
> >> +static int turris_rwtm_rng_fill_entropy(phys_addr_t entropy, size_t
> >> size)
> >> +{
> >> +    u32 args[3] = { 1, (u32)entropy, size };  
> 
> On a device with memory above 4 GiB this (u32) conversion may point to a
> different location than rwtm_rng_priv.
> 
> Is the Armada 3700 family restricted to below 4 GiB?

Indeed it is. Only virtual memory can be mapped to higher locations,
all physical resources (DDR, registers, PCIe, DMA, rWTM) can only be
confiured with 32 bits.

> Should we add a check in the probe function?

No need.

      reply	other threads:[~2024-02-13 10:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-11 13:04 [PATCH v4] rng: Add Turris Mox rTWM RNG driver Max Resch
2024-02-13  9:16 ` Stefan Roese
2024-02-13  9:49   ` Heinrich Schuchardt
2024-02-13 10:08     ` Marek Behún [this message]

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=20240213110826.030e1363@dellmb \
    --to=marek.behun@nic.cz \
    --cc=resch.max@gmail.com \
    --cc=sr@denx.de \
    --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 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.