mbox series

[v4,0/2] hwrng: Add Arm SMCCC TRNG based driver

Message ID 20210731204845.21196-1-andre.przywara@arm.com
Headers show
Series hwrng: Add Arm SMCCC TRNG based driver | expand

Message

Andre Przywara July 31, 2021, 8:48 p.m. UTC
The "Arm True Random Number Generator Firmware Interface"[1] provides
an SMCCC based interface to a true hardware random number generator.
So far we are using that in arch_get_random_seed(), but it might be
useful to expose the entropy through the /dev/hwrng device as well. This
allows to assess the quality of the implementation, by using "rngtest"
from the rng-tools package, for example.

Patch 1 creates a platform device, triggered by the previous discovery
of the SMCCC TRNG service.
Patch 2 implements a hw_random platform driver, which is instantiated
through this said platform device.

The driver can be loaded as module, or built into the kernel.

[1] https://developer.arm.com/documentation/den0098/latest/

Changelog v3 ... v4:
- drop pointless driver loading message
- drop unneeded init() routine

Changelog v2 ... v3:
- split platform device and driver

Changelog v1 ... v2:
- fix building as a module
- de-register device upon exit
- mention module name in Kconfig

Andre Przywara (2):
  firmware: smccc: Register smccc_trng platform device
  hwrng: Add Arm SMCCC TRNG based driver

 drivers/char/hw_random/Kconfig          |  14 +++
 drivers/char/hw_random/Makefile         |   1 +
 drivers/char/hw_random/arm_smccc_trng.c | 123 ++++++++++++++++++++++++
 drivers/firmware/smccc/smccc.c          |  17 ++++
 4 files changed, 155 insertions(+)
 create mode 100644 drivers/char/hw_random/arm_smccc_trng.c

Comments

Ard Biesheuvel Aug. 1, 2021, 4:26 p.m. UTC | #1
On Sat, 31 Jul 2021 at 22:49, Andre Przywara <andre.przywara@arm.com> wrote:
>

> The "Arm True Random Number Generator Firmware Interface"[1] provides

> an SMCCC based interface to a true hardware random number generator.

> So far we are using that in arch_get_random_seed(), but it might be

> useful to expose the entropy through the /dev/hwrng device as well. This

> allows to assess the quality of the implementation, by using "rngtest"

> from the rng-tools package, for example.

>

> Patch 1 creates a platform device, triggered by the previous discovery

> of the SMCCC TRNG service.

> Patch 2 implements a hw_random platform driver, which is instantiated

> through this said platform device.

>

> The driver can be loaded as module, or built into the kernel.

>

> [1] https://developer.arm.com/documentation/den0098/latest/

>

> Changelog v3 ... v4:

> - drop pointless driver loading message

> - drop unneeded init() routine

>

> Changelog v2 ... v3:

> - split platform device and driver

>

> Changelog v1 ... v2:

> - fix building as a module

> - de-register device upon exit

> - mention module name in Kconfig

>

> Andre Przywara (2):

>   firmware: smccc: Register smccc_trng platform device

>   hwrng: Add Arm SMCCC TRNG based driver

>


Reviewed-by: Ard Biesheuvel <ardb@kernel.org>



>  drivers/char/hw_random/Kconfig          |  14 +++

>  drivers/char/hw_random/Makefile         |   1 +

>  drivers/char/hw_random/arm_smccc_trng.c | 123 ++++++++++++++++++++++++

>  drivers/firmware/smccc/smccc.c          |  17 ++++

>  4 files changed, 155 insertions(+)

>  create mode 100644 drivers/char/hw_random/arm_smccc_trng.c

>

> --

> 2.17.6

>
Mark Brown Aug. 2, 2021, 10:40 a.m. UTC | #2
On Sat, Jul 31, 2021 at 09:48:43PM +0100, Andre Przywara wrote:
> The "Arm True Random Number Generator Firmware Interface"[1] provides

> an SMCCC based interface to a true hardware random number generator.

> So far we are using that in arch_get_random_seed(), but it might be

> useful to expose the entropy through the /dev/hwrng device as well. This

> allows to assess the quality of the implementation, by using "rngtest"

> from the rng-tools package, for example.


Reviewed-by: Mark Brown <broonie@kernel.org>
Herbert Xu Aug. 6, 2021, 12:14 p.m. UTC | #3
On Sat, Jul 31, 2021 at 09:48:43PM +0100, Andre Przywara wrote:
> The "Arm True Random Number Generator Firmware Interface"[1] provides

> an SMCCC based interface to a true hardware random number generator.

> So far we are using that in arch_get_random_seed(), but it might be

> useful to expose the entropy through the /dev/hwrng device as well. This

> allows to assess the quality of the implementation, by using "rngtest"

> from the rng-tools package, for example.

> 

> Patch 1 creates a platform device, triggered by the previous discovery

> of the SMCCC TRNG service.

> Patch 2 implements a hw_random platform driver, which is instantiated

> through this said platform device.

> 

> The driver can be loaded as module, or built into the kernel.

> 

> [1] https://developer.arm.com/documentation/den0098/latest/

> 

> Changelog v3 ... v4:

> - drop pointless driver loading message

> - drop unneeded init() routine

> 

> Changelog v2 ... v3:

> - split platform device and driver

> 

> Changelog v1 ... v2:

> - fix building as a module

> - de-register device upon exit

> - mention module name in Kconfig

> 

> Andre Przywara (2):

>   firmware: smccc: Register smccc_trng platform device

>   hwrng: Add Arm SMCCC TRNG based driver

> 

>  drivers/char/hw_random/Kconfig          |  14 +++

>  drivers/char/hw_random/Makefile         |   1 +

>  drivers/char/hw_random/arm_smccc_trng.c | 123 ++++++++++++++++++++++++

>  drivers/firmware/smccc/smccc.c          |  17 ++++

>  4 files changed, 155 insertions(+)

>  create mode 100644 drivers/char/hw_random/arm_smccc_trng.c


All applied.  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