HiSilicon TRNG fix and simplification
Subsystems (5)
cover HiSilicon TRNG fix and simplification
This series fixes and greatly simplifies the HiSilicon TRNG driver by removing the gratuitous crypto_rng interface, leaving just hwrng which is the one that actually matters.
Note that this mirrors similar changes in other drivers such as qcom-rng
(https://lore.kernel.org/r/[email protected])
Eric Biggers (2):
crypto: hisi-trng - Remove crypto_rng interface
hwrng: hisi-trng - Move hisi-trng into drivers/char/hw_random/
MAINTAINERS | 2 +- arch/arm64/configs/defconfig | 2 +- drivers/char/hw_random/Kconfig | 10 + drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/hisi-trng-v2.c | 98 +++++++ drivers/crypto/hisilicon/Kconfig | 8 - drivers/crypto/hisilicon/Makefile | 1 - drivers/crypto/hisilicon/trng/Makefile | 2 - drivers/crypto/hisilicon/trng/trng.c | 390 ------------------------- 9 files changed, 111 insertions(+), 403 deletions(-) create mode 100644 drivers/char/hw_random/hisi-trng-v2.c delete mode 100644 drivers/crypto/hisilicon/trng/Makefile delete mode 100644 drivers/crypto/hisilicon/trng/trng.c
base-commit: 5624ea54f3ba5c83d2e5503411a31a8be0278c1e
prerequisite-patch-id: 07e982b663ac3f8312ca524f6b91b5b38661df5e
prerequisite-patch-id: 72064361a8f36e015ab0b7e1fa4d364b40d90506
prerequisite-patch-id: 8978b8e0db7f47935e5f6f0aff14a97f55d3073c
prerequisite-patch-id: 6aa0e3e93a008279d71e535a3d0cf48643f55e19
Signature · 1 line
2.54.0
PATCH 1/2 crypto: hisi-trng - Remove crypto_rng interface
drivers/crypto/hisilicon/trng/trng.c exposes the same hardware through two completely separate interfaces, crypto_rng and hwrng. However, the implementation of this is buggy because it permits generation operations from these interfaces to run concurrently with each other, accessing the same registers. That is, hisi_trng_generate() synchronizes with itself but not with hisi_trng_read(). This results in potential repetition of output from the RNG, output of non-random values, etc.
Fortunately, there's actually no point in hardware RNG drivers implementing the crypto_rng interface. It's not actually used by anything besides the "rng" algorithm type of AF_ALG, which in turn is not actually used in practice. Other crypto_rng hardware drivers are likewise being phased out, leaving just the hwrng support.
Thus, remove it to simplify the code and avoid conflict (and confusion) with the hwrng interface which is the one that actually matters.
--- drivers/crypto/hisilicon/Kconfig | 1 - drivers/crypto/hisilicon/trng/trng.c | 296 +-------------------------- 2 files changed, 2 insertions(+), 295 deletions(-)
drivers/crypto/hisilicon/Kconfig +0 -1
@@ -78,8 +78,7 @@ config CRYPTO_DEV_HISI_HPRE config CRYPTO_DEV_HISI_TRNG tristate "Support for HISI TRNG Driver" depends on ARM64 && ACPI select HW_RANDOM - select CRYPTO_RNG help Support for HiSilicon TRNG Driver.
drivers/crypto/hisilicon/trng/trng.c +2 -294
364 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH 2/2 hwrng: hisi-trng - Move hisi-trng into drivers/char/hw_random/
In reply to Eric BiggersSince this file just implements a hwrng driver, move it into drivers/char/hw_random/. Rename the kconfig option accordingly as well.
Note that this moves the file back to its original location.
---
MAINTAINERS | 2 +-
arch/arm64/configs/defconfig | 2 +-
drivers/char/hw_random/Kconfig | 10 ++++++++++
drivers/char/hw_random/Makefile | 1 +
.../trng/trng.c => char/hw_random/hisi-trng-v2.c} | 0
drivers/crypto/hisilicon/Kconfig | 7 -------
drivers/crypto/hisilicon/Makefile | 1 -
drivers/crypto/hisilicon/trng/Makefile | 2 --
8 files changed, 13 insertions(+), 12 deletions(-)
rename drivers/{crypto/hisilicon/trng/trng.c => char/hw_random/hisi-trng-v2.c} (100%)
delete mode 100644 drivers/crypto/hisilicon/trng/MakefileMAINTAINERS +1 -1
@@ -11703,11 +11703,11 @@ F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml F: drivers/mfd/hi6421-spmi-pmic.c HISILICON TRUE RANDOM NUMBER GENERATOR V2 SUPPORT M: Weili Qian <[email protected]> S: Maintained -F: drivers/crypto/hisilicon/trng/trng.c +F: drivers/char/hw_random/hisi-trng-v2.c HISILICON V3XX SPI NOR FLASH Controller Driver M: Yang Shen <[email protected]> S: Maintained W: http://www.hisilicon.com
arch/arm64/configs/defconfig +1 -1
@@ -548,10 +548,11 @@ CONFIG_VIRTIO_CONSOLE=y CONFIG_IPMI_HANDLER=m CONFIG_IPMI_DEVICE_INTERFACE=m CONFIG_IPMI_SI=m CONFIG_HW_RANDOM=y CONFIG_HW_RANDOM_VIRTIO=y +CONFIG_HW_RANDOM_HISI_TRNG=m CONFIG_HW_RANDOM_QCOM=m CONFIG_TCG_TPM=y CONFIG_TCG_TIS=m CONFIG_TCG_TIS_SPI=m CONFIG_TCG_TIS_SPI_CR50=y
@@ -1960,11 +1961,10 @@ CONFIG_CRYPTO_DEV_ZYNQMP_AES=m CONFIG_CRYPTO_DEV_ZYNQMP_SHA3=m CONFIG_CRYPTO_DEV_CCREE=m CONFIG_CRYPTO_DEV_HISI_SEC2=m CONFIG_CRYPTO_DEV_HISI_ZIP=m CONFIG_CRYPTO_DEV_HISI_HPRE=m -CONFIG_CRYPTO_DEV_HISI_TRNG=m CONFIG_CRYPTO_DEV_SA2UL=m CONFIG_DMA_RESTRICTED_POOL=y CONFIG_CMA_SIZE_MBYTES=32 CONFIG_PRINTK_TIME=y CONFIG_DEBUG_KERNEL=y
drivers/char/hw_random/Kconfig +10 -0
@@ -371,10 +371,20 @@ config HW_RANDOM_HISTB Generator hardware found on Hisilicon Hi37xx SoC. To compile this driver as a module, choose M here: the module will be called histb-rng. +config HW_RANDOM_HISI_TRNG + tristate "HiSilicon True Random Number Generator support" + depends on ARM64 && ACPI + help + This driver provides kernel-side support for the True Random Number + Generator hardware found on some HiSilicon SoCs. + + To compile this driver as a module, choose M here: the module will be + called hisi-trng-v2. + config HW_RANDOM_ST tristate "ST Microelectronics HW Random Number Generator support" depends on ARCH_STI || COMPILE_TEST help This driver provides kernel-side support for the Random Number
drivers/char/hw_random/Makefile +1 -0
@@ -29,10 +29,11 @@ obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o obj-$(CONFIG_HW_RANDOM_HISI) += hisi-rng.o obj-$(CONFIG_HW_RANDOM_HISTB) += histb-rng.o +obj-$(CONFIG_HW_RANDOM_HISI_TRNG) += hisi-trng-v2.o obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o obj-$(CONFIG_HW_RANDOM_BCM74110) += bcm74110-rng.o obj-$(CONFIG_HW_RANDOM_IPROC_RNG200) += iproc-rng200.o obj-$(CONFIG_HW_RANDOM_ST) += st-rng.o obj-$(CONFIG_HW_RANDOM_XGENE) += xgene-rng.o
drivers/char/hw_random/hisi-trng-v2.c renamed from drivers/crypto/hisilicon/trng/trng.c +0 -0
drivers/crypto/hisilicon/Kconfig +0 -7
@@ -73,12 +73,5 @@ config CRYPTO_DEV_HISI_HPRE select CRYPTO_RSA select CRYPTO_ECDH help Support for HiSilicon HPRE(High Performance RSA Engine) accelerator, which can accelerate RSA and DH algorithms. - -config CRYPTO_DEV_HISI_TRNG - tristate "Support for HISI TRNG Driver" - depends on ARM64 && ACPI - select HW_RANDOM - help - Support for HiSilicon TRNG Driver.
drivers/crypto/hisilicon/Makefile +0 -1
@@ -3,6 +3,5 @@ obj-$(CONFIG_CRYPTO_DEV_HISI_HPRE) += hpre/ obj-$(CONFIG_CRYPTO_DEV_HISI_SEC) += sec/ obj-$(CONFIG_CRYPTO_DEV_HISI_SEC2) += sec2/ obj-$(CONFIG_CRYPTO_DEV_HISI_QM) += hisi_qm.o hisi_qm-objs = qm.o sgl.o debugfs.o obj-$(CONFIG_CRYPTO_DEV_HISI_ZIP) += zip/ -obj-$(CONFIG_CRYPTO_DEV_HISI_TRNG) += trng/
drivers/crypto/hisilicon/trng/Makefile deleted +0 -2
@@ -1,2 +0,0 @@ -obj-$(CONFIG_CRYPTO_DEV_HISI_TRNG) += hisi-trng-v2.o -hisi-trng-v2-objs = trng.o
Signature · 1 line
2.54.0
Quoted 26 lines · Eric Biggers
This series fixes and greatly simplifies the HiSilicon TRNG driver by removing the gratuitous
crypto_rnginterface, leaving just hwrng which is the one that actually matters.Note that this mirrors similar changes in other drivers such as qcom-rng
(https://lore.kernel.org/r/[email protected])Eric Biggers (2):
crypto: hisi-trng - Removecrypto_rnginterface
hwrng: hisi-trng - Move hisi-trng intodrivers/char/hw_random/MAINTAINERS | 2 +- arch/arm64/configs/defconfig | 2 +- drivers/char/hw_random/Kconfig | 10 + drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/hisi-trng-v2.c | 98 +++++++ drivers/crypto/hisilicon/Kconfig | 8 - drivers/crypto/hisilicon/Makefile | 1 - drivers/crypto/hisilicon/trng/Makefile | 2 - drivers/crypto/hisilicon/trng/trng.c | 390 ------------------------- 9 files changed, 111 insertions(+), 403 deletions(-) create mode 100644 drivers/char/hw_random/hisi-trng-v2.c delete mode 100644 drivers/crypto/hisilicon/trng/Makefile delete mode 100644 drivers/crypto/hisilicon/trng/trng.c
Quoted 6 lines
base-commit:
5624ea54f3ba5c83d2e5503411a31a8be0278c1e
prerequisite-patch-id:07e982b663ac3f8312ca524f6b91b5b38661df5e
prerequisite-patch-id:72064361a8f36e015ab0b7e1fa4d364b40d90506
prerequisite-patch-id:8978b8e0db7f47935e5f6f0aff14a97f55d3073c
prerequisite-patch-id:6aa0e3e93a008279d71e535a3d0cf48643f55e19
Thanks.
Herbert Xu
maintainerQuoted 26 lines · Eric Biggers
This series fixes and greatly simplifies the HiSilicon TRNG driver by removing the gratuitous
crypto_rnginterface, leaving just hwrng which is the one that actually matters.Note that this mirrors similar changes in other drivers such as qcom-rng
(https://lore.kernel.org/r/[email protected])Eric Biggers (2):
crypto: hisi-trng - Removecrypto_rnginterface
hwrng: hisi-trng - Move hisi-trng intodrivers/char/hw_random/MAINTAINERS | 2 +- arch/arm64/configs/defconfig | 2 +- drivers/char/hw_random/Kconfig | 10 + drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/hisi-trng-v2.c | 98 +++++++ drivers/crypto/hisilicon/Kconfig | 8 - drivers/crypto/hisilicon/Makefile | 1 - drivers/crypto/hisilicon/trng/Makefile | 2 - drivers/crypto/hisilicon/trng/trng.c | 390 ------------------------- 9 files changed, 111 insertions(+), 403 deletions(-) create mode 100644 drivers/char/hw_random/hisi-trng-v2.c delete mode 100644 drivers/crypto/hisilicon/trng/Makefile delete mode 100644 drivers/crypto/hisilicon/trng/trng.c
Quoted 7 lines
base-commit:
5624ea54f3ba5c83d2e5503411a31a8be0278c1e
prerequisite-patch-id:07e982b663ac3f8312ca524f6b91b5b38661df5e
prerequisite-patch-id:72064361a8f36e015ab0b7e1fa4d364b40d90506
prerequisite-patch-id:8978b8e0db7f47935e5f6f0aff14a97f55d3073c
prerequisite-patch-id:6aa0e3e93a008279d71e535a3d0cf48643f55e19Signature · 1 line
2.54.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt