Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: hang.suan.wang@altera.com
Cc: Dinh Nguyen <dinguyen@kernel.org>,
	linux-kernel@vger.kernel.org, Olivia Mackall <olivia@selenic.com>,
	Eric Biggers <ebiggers@kernel.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Frank Li <Frank.Li@nxp.com>,
	Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>,
	linux-crypto@vger.kernel.org,
	muhammad.nazim.amirul.nazle.asmade@altera.com,
	tze.yee.ng@altera.com, chee.nouk.phoon@altera.com,
	genevieve.chan@altera.com, adrian.ho.yin.ng@altera.com
Subject: Re: [PATCH v1 0/2] Add FCS Random Number Generator (RNG) driver
Date: Fri, 27 Nov 2026 12:47:08 +0800	[thread overview]
Message-ID: <awkLTH9XLvWLBjdJ@gondor.apana.org.au> (raw)
In-Reply-To: <cover.1795167624.git.hang.suan.wang@altera.com>

On Fri, Nov 20, 2026 at 01:51:31AM -0800, hang.suan.wang@altera.com wrote:
> From: Hang Suan Wang <hang.suan.wang@altera.com>
> 
> This series adds a hw_random front-end for the random-number service of
> the Altera SoCFPGA Crypto Service (FCS).
> 
> The driver owns no session or service-layer state: every request goes
> through the FCS core, which serializes access to the SDM crypto session
> and forwards it to the SDM through ATF.
> 
> The SDM is the hardware security controller in Altera SoCFPGA devices. Host
> software reaches it through the existing stratix10-svc mailbox, which uses
> Arm Trusted Firmware SIP SMC calls.
> 
> The Agilex FPGA series generator is an SP 800-90A compliant DRNG hardware
> block in the SDM, in particular, Agilex 7 is SP 800-90A compliant DRBG
> generation flow and is seeded with the TRNG hardware block.
> 
> Unlike existing hw_random drivers, this RNG produces data only while an
> SDM crypto session is open (for example, via FCS_IOC_OPEN_SESSION on
> /dev/socfpga-fcs). The session belongs to the file that opened it, not
> to this driver. With no session open, socfpga_fcs_core_engine() returns
> -ENOTCONN and the error is passed through unchanged: read() on
> /dev/hwrng fails with that error, and the hw_random entropy thread treats
> it as a transient failure and retries. The open and close session ioctl
> was added in the previous series:
> https://lore.kernel.org/all/179492434088.3111216.6016447945055810112.b4-ty@kernel.org/
> 
> The ATF accepts only a non-zero, 4-byte-aligned length, from 4 bytes up
> to 4080 bytes per request.
> 
> hwrng.quality is left at 0. The hw_random core documents 0 as the maximum
> (1024 bits of entropy per 1024 bits of input), and with the default
> quality of 1024 that is the value applied at registration. That matches
> a conditioned SP 800-90A DRNG, so the driver does not publish a separate
> estimate.
> 
> The series is organized as follows:
> Patch 1 (prerequisite) extends the stratix10-svc service layer with the
> FCS command codes and matching SIP SMC function IDs.
> 
> Patch 2 adds the RNG driver: socfpga-fcs-rng hw_random driver. Add
> FCS_DEV_RANDOM_NUMBER_GEN_EXT in the FCS core. The socfpga-fcs-rng child
> device registered by the FCS driver. Also, add MAINTAINERS entry for
> this new driver.
> 
> Testing:
> Built for arm64 (defconfig + CONFIG_HW_RANDOM_SOCFPGA_FCS=m).
> Tested on an Agilex 5 SoC FPGA board
> root@testsocfpga# ./fcs_client -R dbg.bin -j 64 && hexdump -C dbg.bin
> 00000000 15 fc 77 a9 86 17 0b b5 91 b3 db ce a9 39 48 f1 |..w..........9H.|
> 00000010 65 00 80 9a 63 b8 1e 99 df 56 6f b4 ef 66 73 f9 |e...c....Vo..fs.|
> 00000020 91 66 c6 94 94 38 f1 9f cd 3a c7 6e b1 63 1d e2 |.f...8...:.n.c..|
> 00000030 03 ec 29 01 4f 27 4a de e7 7e 67 95 c2 44 e7 04 |..).O'J..~g..D..|
> 00000040
> 
> Set timeout to 1000s for operation: rngtest
> cat /dev/hwrng | rngtest -c 2000 2>&1
> rngtest 6.17
> Copyright (c) 2004 by Henrique de Moraes Holschuh
> This is free software; see the source for copying conditions. There is NO 
> warranty;
> not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> 	rngtest: starting FIPS tests...
> 	rngtest: bits received from input: 40000032
> 	rngtest: FIPS 140-2 successes: 1998
> 	rngtest: FIPS 140-2 failures: 2
> 	rngtest: FIPS 140-2(2001-10-10) Monobit: 0
> 	rngtest: FIPS 140-2(2001-10-10) Poker: 0
> 	rngtest: FIPS 140-2(2001-10-10) Runs: 1
> 	rngtest: FIPS 140-2(2001-10-10) Long run: 1
> 	rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
> 	rngtest: input channel speed: (min=495.429; avg=52178.721; 
> 								   max=10000000000.000)bits/s
> 	rngtest: FIPS tests speed: (min=47.329; avg=70.926; max=91.699)Mibits/s
> 	rngtest: Program run time: 807497698 microseconds
> 
> ---
> Hang Suan Wang (2):
>   firmware: stratix10-svc: add FCS random-number command for Agilex 5
>   hwrng: socfpga-fcs - Add FCS random number generator driver
> 
>  MAINTAINERS                                   |   1 +
>  drivers/char/hw_random/Kconfig                |  12 ++
>  drivers/char/hw_random/Makefile               |   1 +
>  drivers/char/hw_random/socfpga-fcs-rng.c      | 133 ++++++++++++++++++
>  drivers/firmware/socfpga-fcs-core.c           |  71 +++++++---
>  drivers/firmware/socfpga-fcs.c                |  33 +++++
>  drivers/firmware/stratix10-svc.c              |   8 ++
>  include/linux/firmware/intel/socfpga-fcs.h    |  23 ++-
>  include/linux/firmware/intel/stratix10-smc.h  |  46 ++++++
>  .../firmware/intel/stratix10-svc-client.h     |   1 +
>  10 files changed, 300 insertions(+), 29 deletions(-)
>  create mode 100644 drivers/char/hw_random/socfpga-fcs-rng.c
> 
> -- 
> 2.43.7

Sashiko failed to apply your patches.  Please rebase and resubmit;

https://sashiko.dev/#/patchset/cover.1795167624.git.hang.suan.wang%40altera.com

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      parent reply	other threads:[~2026-11-27  4:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  9:51 [PATCH v1 0/2] Add FCS Random Number Generator (RNG) driver hang.suan.wang
2026-11-20  9:51 ` [PATCH v1 1/2] firmware: stratix10-svc: add FCS random-number command for Agilex 5 hang.suan.wang
2026-11-20  9:51 ` [PATCH v1 2/2] hwrng: socfpga-fcs - Add FCS random number generator driver hang.suan.wang
2026-11-27  4:47 ` Herbert Xu [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=awkLTH9XLvWLBjdJ@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=Frank.Li@nxp.com \
    --cc=adrian.ho.yin.ng@altera.com \
    --cc=chee.nouk.phoon@altera.com \
    --cc=dinguyen@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=genevieve.chan@altera.com \
    --cc=hang.suan.wang@altera.com \
    --cc=jeanmichel.hautbois@yoseli.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=muhammad.nazim.amirul.nazle.asmade@altera.com \
    --cc=olivia@selenic.com \
    --cc=tze.yee.ng@altera.com \
    --cc=wsa+renesas@sang-engineering.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox