Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Add FCS Random Number Generator (RNG) driver
@ 2026-11-20  9:51 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
  0 siblings, 2 replies; 3+ messages in thread
From: hang.suan.wang @ 2026-11-20  9:51 UTC (permalink / raw)
  To: Dinh Nguyen, linux-kernel, Olivia Mackall, Herbert Xu,
	Eric Biggers, Miquel Raynal, Wolfram Sang, Frank Li,
	Jean-Michel Hautbois, linux-crypto
  Cc: muhammad.nazim.amirul.nazle.asmade, tze.yee.ng, chee.nouk.phoon,
	genevieve.chan, adrian.ho.yin.ng

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-20  9:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox