Add Tegra Security Engine driver
Subsystems (6)
Akhil R
maintainerv3 cover Add Tegra Security Engine driver
Add support for Tegra Security Engine which can accelerates various crypto algorithms. The Engine has two separate instances within for AES and HASH algorithms respectively.
The driver registers two crypto engines - one for AES and another for HASH algorithms and these operate independently and both uses the host1x bus. Additionally, it provides hardware-assisted key protection for up to 15 symmetric keys which it can use for the cipher operations.
v2->v3:
* Update compatible in driver and device trees.
* Remove extra new lines and symbols in binding doc. v1->v2:
* Update probe errors with 'dev_err_probe'.
* Clean up function prototypes and redundant prints.
* Remove readl/writel wrappers.
* Fix test bot warnings.
Akhil R (5):
dt-bindings: crypto: Add Tegra Security Engine
gpu: host1x: Add Tegra SE to SID table
crypto: tegra: Add Tegra Security Engine driver
arm64: defconfig: Enable Tegra Security Engine
arm64: tegra: Add Tegra Security Engine DT nodes
.../crypto/nvidia,tegra234-se-aes.yaml | 53 + .../crypto/nvidia,tegra234-se-hash.yaml | 53 + MAINTAINERS | 5 + arch/arm64/boot/dts/nvidia/tegra234.dtsi | 16 + arch/arm64/configs/defconfig | 1 + drivers/crypto/Kconfig | 8 + drivers/crypto/Makefile | 1 + drivers/crypto/tegra/Makefile | 9 + drivers/crypto/tegra/tegra-se-aes.c | 1932 +++++++++++++++++ drivers/crypto/tegra/tegra-se-hash.c | 1022 +++++++++ drivers/crypto/tegra/tegra-se-key.c | 155 ++ drivers/crypto/tegra/tegra-se-main.c | 439 ++++ drivers/crypto/tegra/tegra-se.h | 569 +++++ drivers/gpu/host1x/dev.c | 24 + 14 files changed, 4287 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml create mode 100644 Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml create mode 100644 drivers/crypto/tegra/Makefile create mode 100644 drivers/crypto/tegra/tegra-se-aes.c create mode 100644 drivers/crypto/tegra/tegra-se-hash.c create mode 100644 drivers/crypto/tegra/tegra-se-key.c create mode 100644 drivers/crypto/tegra/tegra-se-main.c create mode 100644 drivers/crypto/tegra/tegra-se.h
Signature · 1 line
2.17.1
Akhil R
maintainerPATCH v3 1/5 dt-bindings: crypto: Add Tegra Security Engine
Add DT binding document for Tegra Security Engine.
The AES and HASH algorithms are handled independently by separate engines within the Security Engine. These engines are registered as two separate crypto engine drivers.
--- .../crypto/nvidia,tegra234-se-aes.yaml | 53 +++++++++++++++++++ .../crypto/nvidia,tegra234-se-hash.yaml | 53 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml create mode 100644 Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml new file +53 -0
@@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/nvidia,tegra234-se-aes.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra Security Engine for AES algorithms + +description: + The Tegra Security Engine accelerates the following AES encryption/decryption + algorithms - AES-ECB, AES-CBC, AES-OFB, AES-XTS, AES-CTR, AES-GCM, AES-CCM, + AES-CMAC + +maintainers: + - Akhil R <[email protected]> + +properties: + compatible: + const: nvidia,tegra234-se-aes + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + +required: + - compatible + - reg + - clocks + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/memory/tegra234-mc.h> + #include <dt-bindings/clock/tegra234-clock.h> + + crypto@15820000 { + compatible = "nvidia,tegra234-se-aes"; + reg = <0x15820000 0x10000>; + clocks = <&bpmp TEGRA234_CLK_SE>; + iommus = <&smmu TEGRA234_SID_SES_SE1>; + dma-coherent; + }; +...
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.17.1
Akhil R
maintainerPATCH v3 2/5 gpu: host1x: Add Tegra SE to SID table
In reply to Akhil RAdd Tegra Security Engine details to the SID table in host1x driver. These will be referred when registering the SE as host1x device.
--- drivers/gpu/host1x/dev.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/gpu/host1x/dev.c +24 -0
@@ -214,6 +214,30 @@ static const struct host1x_info host1x07_info = {* and firmware stream ID in the MMIO path table. */ static const struct host1x_sid_entry tegra234_sid_table[] = { + { +/* SE2 MMIO */ + .base =0x1658 , + .offset =0x90 , + .limit =0x90 + }, + { +/* SE4 MMIO */ + .base =0x1660 , + .offset =0x90 , + .limit =0x90 + }, + { +/* SE2 channel */ + .base =0x1738 , + .offset =0x90 , + .limit =0x90 + }, + { +/* SE4 channel */ + .base =0x1740 , + .offset =0x90 , + .limit =0x90 + }, {/* VIC channel */ .base =0x17b8 ,
Signature · 1 line
2.17.1
Akhil R
maintainerPATCH v3 3/5 crypto: tegra: Add Tegra Security Engine driver
In reply to Akhil RAdd support for Tegra Security Engine which can accelerate various crypto algorithms. The Engine has two separate instances within for AES and HASH algorithms respectively.
The driver registers two crypto engines - one for AES and another for HASH algorithms and these operate independently and both uses the host1x bus. Additionally, it provides hardware-assisted key protection for up to 15 symmetric keys which it can use for the cipher operations.
--- MAINTAINERS | 5 + drivers/crypto/Kconfig | 8 + drivers/crypto/Makefile | 1 + drivers/crypto/tegra/Makefile | 9 + drivers/crypto/tegra/tegra-se-aes.c | 1932 ++++++++++++++++++++++++++ drivers/crypto/tegra/tegra-se-hash.c | 1022 ++++++++++++++ drivers/crypto/tegra/tegra-se-key.c | 155 +++ drivers/crypto/tegra/tegra-se-main.c | 439 ++++++ drivers/crypto/tegra/tegra-se.h | 569 ++++++++ 9 files changed, 4140 insertions(+) create mode 100644 drivers/crypto/tegra/Makefile create mode 100644 drivers/crypto/tegra/tegra-se-aes.c create mode 100644 drivers/crypto/tegra/tegra-se-hash.c create mode 100644 drivers/crypto/tegra/tegra-se-key.c create mode 100644 drivers/crypto/tegra/tegra-se-main.c create mode 100644 drivers/crypto/tegra/tegra-se.h
MAINTAINERS +5 -0
@@ -21462,6 +21462,11 @@ M: Prashant Gaikwad <[email protected]> S: Supported F: drivers/clk/tegra/ +TEGRA CRYPTO DRIVERS +M: Akhil R <[email protected]> +S: Supported +F: drivers/crypto/tegra/* + TEGRA DMA DRIVERS M: Laxman Dewangan <[email protected]> M: Jon Hunter <[email protected]>
drivers/crypto/Kconfig +8 -0
@@ -659,6 +659,14 @@ config CRYPTO_DEV_ROCKCHIP_DEBUG This will create /sys/kernel/debug/rk3288_crypto/stats for displaying the number of requests per algorithm and other internal stats. +config CRYPTO_DEV_TEGRA + tristate "Enable Tegra Security Engine" + depends on TEGRA_HOST1X + select CRYPTO_ENGINE + + help + Select this to enable Tegra Security Engine which accelerates various + AES encryption/decryption and HASH algorithms. config CRYPTO_DEV_ZYNQMP_AES tristate "Support for Xilinx ZynqMP AES hw accelerator"
drivers/crypto/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_CRYPTO_DEV_SAHARA) += sahara.o obj-$(CONFIG_CRYPTO_DEV_SL3516) += gemini/ obj-y += stm32/ obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o +obj-$(CONFIG_CRYPTO_DEV_TEGRA) += tegra/ obj-$(CONFIG_CRYPTO_DEV_VIRTIO) += virtio/ obj-$(CONFIG_CRYPTO_DEV_VMX) += vmx/ obj-$(CONFIG_CRYPTO_DEV_BCM_SPU) += bcm/
drivers/crypto/tegra/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + +tegra-se-objs := tegra-se-key.o tegra-se-main.o + +tegra-se-y += tegra-se-aes.o +tegra-se-y += tegra-se-hash.o + +obj-$(CONFIG_CRYPTO_DEV_TEGRA) += tegra-se.o
drivers/crypto/tegra/tegra-se-aes.c new file +1932 -0
1,932 lines not on this page · raw message
drivers/crypto/tegra/tegra-se-hash.c new file +1022 -0
1,022 lines not on this page · raw message
drivers/crypto/tegra/tegra-se-key.c new file +155 -0
5 lines not on this page · raw message
drivers/crypto/tegra/tegra-se-main.c new file +439 -0
439 lines not on this page · raw message
drivers/crypto/tegra/tegra-se.h new file +569 -0
569 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
Akhil R
maintainerPATCH v3 4/5 arm64: defconfig: Enable Tegra Security Engine
In reply to Akhil REnable Tegra Security Engine which can accelerate various AES and HASH algorithms on supported hardware.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -1602,6 +1602,7 @@ CONFIG_CRYPTO_DEV_FSL_CAAM=m CONFIG_CRYPTO_DEV_FSL_DPAA2_CAAM=m CONFIG_CRYPTO_DEV_QCE=m CONFIG_CRYPTO_DEV_QCOM_RNG=m +CONFIG_CRYPTO_DEV_TEGRA=m CONFIG_CRYPTO_DEV_CCREE=m CONFIG_CRYPTO_DEV_HISI_SEC2=m CONFIG_CRYPTO_DEV_HISI_ZIP=m
Signature · 1 line
2.17.1
Akhil R
maintainerPATCH v3 5/5 arm64: tegra: Add Tegra Security Engine DT nodes
In reply to Akhil RAdd device tree nodes for Tegra AES and HASH engines.
--- arch/arm64/boot/dts/nvidia/tegra234.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/nvidia/tegra234.dtsi +16 -0
@@ -2304,6 +2304,22 @@ */ status = "disabled"; }; + + crypto@15820000 { + compatible = "nvidia,tegra234-se-aes"; + reg = <0x00 0x15820000 0x00 0x10000>; + clocks = <&bpmp TEGRA234_CLK_SE>; + iommus = <&smmu_niso1 TEGRA234_SID_SES_SE1>; + dma-coherent; + }; + + crypto@15840000 { + compatible = "nvidia,tegra234-se-hash"; + reg = <0x00 0x15840000 0x00 0x10000>; + clocks = <&bpmp TEGRA234_CLK_SE>; + iommus = <&smmu_niso1 TEGRA234_SID_SES_SE1>; + dma-coherent; + }; }; pcie@140a0000 {
Signature · 1 line
2.17.1
Re: [PATCH v3 1/5] dt-bindings: crypto: Add Tegra Security Engine
In reply to Akhil RQuoted 5 lines · Akhil R
Add DT binding document for Tegra Security Engine.
The AES and HASH algorithms are handled independently by separate engines within the Security Engine. These engines are registered as two separate crypto engine drivers.
...
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml line 42
Quoted 11 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml new file +11
-0+required: + - compatible + - reg + - clocks + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>
This does not look used.
Quoted 49 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml new file +11
-0+ #include <dt-bindings/memory/tegra234-mc.h> + #include <dt-bindings/clock/tegra234-clock.h> + + crypto@15820000 { + compatible = "nvidia,tegra234-se-aes"; + reg = <0x15820000 0x10000>; + clocks = <&bpmp TEGRA234_CLK_SE>; + iommus = <&smmu TEGRA234_SID_SES_SE1>; + dma-coherent; + }; +...Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml new file +32
-0@@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/nvidia,tegra234-se-hash.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra Security Engine for HASH algorithms + +description: + The Tegra Security HASH Engine accelerates the following HASH functions - + SHA1, SHA224, SHA256, SHA384, SHA512, SHA3-224, SHA3-256, SHA3-384, SHA3-512 + HMAC(SHA224), HMAC(SHA256), HMAC(SHA384), HMAC(SHA512) + +maintainers: + - Akhil R <[email protected]> + +properties: + compatible: + const: nvidia,tegra234-se-hash + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + +required:
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml line 42
Quoted 10 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml new file +10
-0+ - compatible + - reg + - clocks + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>
This does not look used.
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml line 45
Quoted 3 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml new file +3
-0+ #include <dt-bindings/memory/tegra234-mc.h> + #include <dt-bindings/clock/tegra234-clock.h> +
With both above fixed:
---
This is an automated instruction, just in case, because many review tags are being ignored. If you know the process, you can skip it (please do not feel offended by me posting it here - no bad intentions intended). If you do not know the process, here is a short explanation:
Please add Acked-by/Reviewed-by/Tested-by tags when posting new versions, under or above your Signed-off-by tag. Tag is "received", when provided in a message replied to you on the mailing list. Tools like b4 can help here. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for tags received on the version they apply.
https://elixir.bootlin.com/linux/v6.5-rc3/source/Documentation/process/submitting-patches.rst#L577
Best regards,
Krzysztof
Akhil R
maintainerRE: [PATCH v3 1/5] dt-bindings: crypto: Add Tegra Security Engine
Quoted 112 lines · Akhil R
Quoted 5 lines
Add DT binding document for Tegra Security Engine.
The AES and HASH algorithms are handled independently by separate engines within the Security Engine. These engines are registered as two separate crypto engine drivers....
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml line 42
Quoted 11 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml new file +11
-0+required: + - compatible + - reg + - clocks + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>This does not look used.
Review
Quoted 12 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml new file +11
-0+ #include <dt-bindings/memory/tegra234-mc.h> + #include <dt-bindings/clock/tegra234-clock.h> + + crypto@15820000 { + compatible = "nvidia,tegra234-se-aes"; + reg = <0x15820000 0x10000>; + clocks = <&bpmp TEGRA234_CLK_SE>; + iommus = <&smmu TEGRA234_SID_SES_SE1>; + dma-coherent; + }; +...(quoted diff) +0
-0
hash.yamlb/Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yamlDocumentation/devicetree/bindings/crypto/nvidia,tegra234-se-
Quoted 4 lines
new file mode 100644
index 000000000000..7fb32568756dDocumentation/devicetree/bindings/crypto/nvidia,tegra234-se- new file +0
-0
hash.yamlDocumentation/devicetree/bindings/crypto/nvidia,tegra234-se- line 11
Quoted 12 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se- new file +11
-0@@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/nvidia,tegra234-se-hash.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra Security Engine for HASH algorithms + +description: + The Tegra Security HASH Engine accelerates the following HASH functions - + SHA1, SHA224, SHA256, SHA384, SHA512, SHA3-224, SHA3-256, SHA3-384,SHA3-512
Quoted 21 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se- new file +21
-0+ HMAC(SHA224), HMAC(SHA256), HMAC(SHA384), HMAC(SHA512) + +maintainers: + - Akhil R <[email protected]> + +properties: + compatible: + const: nvidia,tegra234-se-hash + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + iommus: + maxItems: 1 + + dma-coherent: true + +required:Documentation/devicetree/bindings/crypto/nvidia,tegra234-se- line 42
Quoted 10 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se- new file +10
-0+ - compatible + - reg + - clocks + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h>This does not look used.
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se- line 45
Quoted 3 lines
Documentation/devicetree/bindings/crypto/nvidia,tegra234-se- new file +3
-0+ #include <dt-bindings/memory/tegra234-mc.h> + #include <dt-bindings/clock/tegra234-clock.h> +With both above fixed:
Reviewed-by Krzysztof Kozlowski <[email protected]>---
This is an automated instruction, just in case, because many review tags are being ignored. If you know the process, you can skip it (please do not feel offended by me posting it here - no bad intentions intended). If you do not know the process, here is a short explanation:
Please add Acked-by/Reviewed-by/Tested-by tags when posting new versions, under or above your Signed-off-by tag. Tag is "received", when provided in a message replied to you on the mailing list. Tools like b4 can help here. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for tags received on the version they apply.
Quoted 3 lines
https://elixir.bootlin.com/linux/v6.5-
rc3/source/Documentation/process/submitting-patches.rst#L577
Thanks. Noted. Will update them.
Best Regards,
Akhil
kernel test robot
build botRe: [PATCH v3 3/5] crypto: tegra: Add Tegra Security Engine driver
In reply to Akhil Rkernel test robot noticed the following build warnings:
Hi Akhil,
kernel test robot noticed the following build warnings:
[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master tegra/for-next linus/master v6.7 next-20240112] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Akhil-R/dt-bindings-crypto-Add-Tegra-Security-Engine/20240109-172454 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/20240109091708.66977-4-akhilrajeev%40nvidia.com patch subject: [PATCH v3 3/5] crypto: tegra: Add Tegra Security Engine driver config: powerpc64-randconfig-r123-20240112 (https://download.01.org/0day-ci/archive/20240113/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce: (https://download.01.org/0day-ci/archive/20240113/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/crypto/tegra/tegra-se-key.c:20:1: sparse: sparse: symbol 'kslt_lock' was not declared. Should it be static?
drivers/crypto/tegra/tegra-se-key.c: note: in included file (through include/linux/mmzone.h, include/linux/gfp.h, include/linux/umh.h, include/linux/kmod.h, ...):
include/linux/page-flags.h:242:46: sparse: sparse: self-comparison always evaluates to false
vim +/kslt_lock +20 drivers/crypto/tegra/tegra-se-key.c
18
19 /* Mutex lock to guard keyslots */
> 20 DEFINE_MUTEX(kslt_lock);
21 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v3 2/5] gpu: host1x: Add Tegra SE to SID table
In reply to Akhil RQuoted 2 lines · Akhil R
Add Tegra Security Engine details to the SID table in host1x driver. These will be referred when registering the SE as host1x device.
Technically, these entries are required to be in place any time we want to configure SE's stream ID. Register writes to stream ID registers fail otherwise.
Quoted 31 lines
Signed-off-by Akhil R <[email protected]>--- drivers/gpu/host1x/dev.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)drivers/gpu/host1x/dev.c +17
-0@@ -214,6 +214,30 @@ static const struct host1x_info host1x07_info = {* and firmware stream ID in the MMIO path table. */ static const struct host1x_sid_entry tegra234_sid_table[] = { + { +/* SE2 MMIO */ + .base =0x1658 , + .offset =0x90 , + .limit =0x90 + }, + { +/* SE4 MMIO */ + .base =0x1660 , + .offset =0x90 , + .limit =0x90 + }, + { +/* SE2 channel */ + .base =0x1738 , + .offset =0x90 , + .limit =0x90
drivers/gpu/host1x/dev.c static const struct host1x_info host1x07_info = { · line 243
Quoted 10 lines
drivers/gpu/host1x/dev.c +7
-0+ }, + { +/* SE4 channel */ + .base = 0x1740, + .offset = 0x90, + .limit = 0x90 + }, {/* VIC channel */ .base = 0x17b8,
With the commit message slightly adjusted,