Hisilicon SEC crypto driver (hip06 / hip07)
cover Hisilicon SEC crypto driver (hip06 / hip07)
The driver provides in kernel support for hte Hisilicon SEC accelerator found in the hip06 and hip07 SoCs. There are 4 such units on the D05 board for which an appropriate DT binding has been provided. ACPI also works with an appropriate UEFI build.
The hardware does not update the IV in chaining or counting modes. This is done in the drive ron completion of the cipher operation.
The driver support AES, DES and 3DES block ciphers in a range of modes (others to follow). Hash and AAED support to follow.
Sorry for the delay on this one, other priorities and all that...
Changes since RFC.
1) Addition of backlog queuing as needed to support dm-crypt usecases.
2) iommu presence tests now done as Robin Murphy suggested.
3) Hardware limiation to 32MB requests worked aroud in driver so it will now support very large requests (512*32MB). Larger request handling than this would require a longer queue with the associate overheads and is considered unlikely to be necessary.
4) The specific handling related to the inline IV patch set from Stephan has been dropped for now.
5) Interrupt handler was previous more complex than necessary so has been reworked.
6) Use of the bounce buffer for small packeets is dropped for now. This is a performance optimization that made the code harder to review and can be reintroduced as necessary at a later date.
7) Restructuring of some code to simplify hash and aaed (hash implemented but not ready fo upstream at this time)
8) Various minor fixes and reworks of the code
* several off by one errors in the cleanup paths
* single template for enc and dec
* drop dec_key as not used (enc_key was used in both cases)
* drop dma pool for IVs as it breaks chaining.
* lots of spinlocks changed to mutexes as not taken in atomic context.
* nasty memory leak cleaned up.
Jonathan Cameron (3):
dt-bindings: Add bindings for Hisilicon SEC crypto accelerators.
crypto: hisilicon SEC security accelerator driver
arm64: dts: hisi: add SEC crypto accelerator nodes for hip07 SoC
.../bindings/crypto/hisilicon,hip07-sec.txt | 69 + arch/arm64/boot/dts/hisilicon/hip07.dtsi | 285 +++++ drivers/crypto/Kconfig | 2 + drivers/crypto/Makefile | 1 + drivers/crypto/hisilicon/Kconfig | 14 + drivers/crypto/hisilicon/Makefile | 2 + drivers/crypto/hisilicon/sec/Makefile | 3 + drivers/crypto/hisilicon/sec/sec_algs.c | 1116 +++++++++++++++++ drivers/crypto/hisilicon/sec/sec_drv.c | 1323 ++++++++++++++++++++ drivers/crypto/hisilicon/sec/sec_drv.h | 428 +++++++ 10 files changed, 3243 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt create mode 100644 drivers/crypto/hisilicon/Kconfig create mode 100644 drivers/crypto/hisilicon/Makefile create mode 100644 drivers/crypto/hisilicon/sec/Makefile create mode 100644 drivers/crypto/hisilicon/sec/sec_algs.c create mode 100644 drivers/crypto/hisilicon/sec/sec_drv.c create mode 100644 drivers/crypto/hisilicon/sec/sec_drv.h
Signature · 1 line
2.16.2
PATCH 1/3 dt-bindings: Add bindings for Hisilicon SEC crypto accelerators.
The hip06 and hip07 SoCs contain a number of these crypto units which accelerate AES and DES operations.
--- .../bindings/crypto/hisilicon,hip07-sec.txt | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+)
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +69 -0
@@ -0,0 +1,69 @@ +* Hisilicon hip07 Security Accelerator (SEC) + +Required properties: +- compatible: Must contain one of + - "hisilicon,hip06-sec" + - "hisilicon,hip07-sec" +- reg: Memory addresses and lengths of the memory regions used by the driver. + Region 0 has registers to control the backend processing engines. + Region 1 has registers for functionality common to all queues. + Regions 2-18 have registers for the individual queues which are isolated + both in hardware and within the driver. +- interrupts: Interrupt specifiers. + Refer to interrupt-controller/interrupts.txt for generic interrupt client node + bindings. + Interrupt 0 is for the SEC unit error queue. + Interrupt 2N + 1 is the completion interrupt for queue N. + Interrupt 2N + 2 is the error interrupt for queue N. +- dma-coherent: The driver assumes coherent dma is possible. + +Optional properties: +- iommus: The SEC units are behind smmu-v3 iommus. + Refer to iommu/arm,smmu-v3.txt for more information. + +Example: +Second socket, first unit chosen to illustrate need for 64 bit addresses. + +p1_sec_a: sec@d2000000 { + compatible = "hisilicon,hip07-sec"; + #address-cells = <2>; + #size-cells = <2>; + reg = <0x400 0xd0000000 0x0 0x10000 + 0x400 0xd2000000 0x0 0x10000 + 0x400 0xd2010000 0x0 0x10000 + 0x400 0xd2020000 0x0 0x10000 + 0x400 0xd2030000 0x0 0x10000 + 0x400 0xd2040000 0x0 0x10000 + 0x400 0xd2050000 0x0 0x10000 + 0x400 0xd2060000 0x0 0x10000 + 0x400 0xd2070000 0x0 0x10000 + 0x400 0xd2080000 0x0 0x10000 + 0x400 0xd2090000 0x0 0x10000 + 0x400 0xd20a0000 0x0 0x10000 + 0x400 0xd20b0000 0x0 0x10000 + 0x400 0xd20c0000 0x0 0x10000 + 0x400 0xd20d0000 0x0 0x10000 + 0x400 0xd20e0000 0x0 0x10000 + 0x400 0xd20f0000 0x0 0x10000 + 0x400 0xd2100000 0x0 0x10000>; + interrupt-parent = <&p1_mbigen_sec_a>; + iommus = <&p1_smmu_alg_a 0x600>; + dma-coherent; + interrupts = <576 4>, + <577 1>,<578 4>, + <579 1>,<580 4>, + <581 1>,<582 4>, + <583 1>,<584 4>, + <585 1>,<586 4>, + <587 1>,<588 4>, + <589 1>,<590 4>, + <591 1>,<592 4>, + <593 1>,<594 4>, + <595 1>,<596 4>, + <597 1>,<598 4>, + <599 1>,<600 4>, + <601 1>,<602 4>, + <603 1>,<604 4>, + <605 1>,<606 4>, + <607 1>,<608 4>; +};
Signature · 1 line
2.16.2
PATCH 2/3 crypto: hisilicon SEC security accelerator driver
In reply to Jonathan CameronThis accelerator is found inside hisilicon hip06 and hip07 SoCs. Each instance provides a number of queues which feed a different number of backend acceleration units.
The queues are operating in an out of order mode in the interests of throughput. The silicon does not do tracking of dependencies between multiple 'messages' or update of the IVs as appropriate for training. Hence where relevant we need to do this in software.
--- drivers/crypto/Kconfig | 2 + drivers/crypto/Makefile | 1 + drivers/crypto/hisilicon/Kconfig | 14 + drivers/crypto/hisilicon/Makefile | 2 + drivers/crypto/hisilicon/sec/Makefile | 3 + drivers/crypto/hisilicon/sec/sec_algs.c | 1116 ++++++++++++++++++++++++++ drivers/crypto/hisilicon/sec/sec_drv.c | 1323 +++++++++++++++++++++++++++++++ drivers/crypto/hisilicon/sec/sec_drv.h | 428 ++++++++++ 8 files changed, 2889 insertions(+)
drivers/crypto/Kconfig +2 -0
@@ -750,4 +750,6 @@ config CRYPTO_DEV_CCREE cryptographic operations on the system REE. If unsure say Y. +source "drivers/crypto/hisilicon/Kconfig" + endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -45,3 +45,4 @@ obj-$(CONFIG_CRYPTO_DEV_VMX) += vmx/ obj-$(CONFIG_CRYPTO_DEV_BCM_SPU) += bcm/ obj-$(CONFIG_CRYPTO_DEV_SAFEXCEL) += inside-secure/ obj-$(CONFIG_CRYPTO_DEV_ARTPEC6) += axis/ +obj-y += hisilicon/
drivers/crypto/hisilicon/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 + +config CRYPTO_DEV_HISI_SEC + tristate "Support for Hisilicon SEC crypto block cipher accelerator" + select CRYPTO_BLKCIPHER + select CRYPTO_ALGAPI + select SG_SPLIT + depends on ARM64 || COMPILE_TEST + depends on HAS_IOMEM + help + Support for Hisilicon SEC Engine in Hip06 and Hip07 + + To compile this as a module, choose M here: the module + will be called hisi_sec.
drivers/crypto/hisilicon/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_CRYPTO_DEV_HISI_SEC) += sec/
drivers/crypto/hisilicon/sec/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_CRYPTO_DEV_HISI_SEC) += hisi_sec.o +hisi_sec-y = sec_algs.o sec_drv.o
drivers/crypto/hisilicon/sec/sec_algs.c new file +1116 -0
1,116 lines not on this page · raw message
drivers/crypto/hisilicon/sec/sec_drv.c new file +1323 -0
1,323 lines not on this page · raw message
drivers/crypto/hisilicon/sec/sec_drv.h new file +428 -0
428 lines not on this page · raw message
Signature · 1 line
2.16.2
PATCH 3/3 arm64: dts: hisi: add SEC crypto accelerator nodes for hip07 SoC
In reply to Jonathan CameronEnable all 4 SEC units available on d05 boards.
--- arch/arm64/boot/dts/hisilicon/hip07.dtsi | 285 +++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+)
arch/arm64/boot/dts/hisilicon/hip07.dtsi +285 -0
@@ -1049,7 +1049,74 @@ num-pins = <2>; }; }; + p0_mbigen_alg_a:interrupt-controller@d0080000 { + compatible = "hisilicon,mbigen-v2"; + reg = <0x0 0xd0080000 0x0 0x10000>; + p0_mbigen_sec_a: intc_sec { + msi-parent = <&p0_its_dsa_a 0x40400>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <33>; + }; + p0_mbigen_smmu_alg_a: intc_smmu_alg { + msi-parent = <&p0_its_dsa_a 0x40b1b>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <3>; + }; + }; + p0_mbigen_alg_b:interrupt-controller@8,d0080000 { + compatible = "hisilicon,mbigen-v2"; + reg = <0x8 0xd0080000 0x0 0x10000>; + + p0_mbigen_sec_b: intc_sec { + msi-parent = <&p0_its_dsa_b 0x42400>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <33>; + }; + p0_mbigen_smmu_alg_b: intc_smmu_alg { + msi-parent = <&p0_its_dsa_b 0x42b1b>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <3>; + }; + }; + p1_mbigen_alg_a:interrupt-controller@400,d0080000 { + compatible = "hisilicon,mbigen-v2"; + reg = <0x400 0xd0080000 0x0 0x10000>; + + p1_mbigen_sec_a: intc_sec { + msi-parent = <&p1_its_dsa_a 0x44400>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <33>; + }; + p1_mbigen_smmu_alg_a: intc_smmu_alg { + msi-parent = <&p1_its_dsa_a 0x44b1b>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <3>; + }; + }; + p1_mbigen_alg_b:interrupt-controller@408,d0080000 { + compatible = "hisilicon,mbigen-v2"; + reg = <0x408 0xd0080000 0x0 0x10000>; + + p1_mbigen_sec_b: intc_sec { + msi-parent = <&p1_its_dsa_b 0x46400>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <33>; + }; + p1_mbigen_smmu_alg_b: intc_smmu_alg { + msi-parent = <&p1_its_dsa_b 0x46b1b>; + interrupt-controller; + #interrupt-cells = <2>; + num-pins = <3>; + }; + }; p0_mbigen_dsa_a: interrupt-controller@c0080000 { compatible = "hisilicon,mbigen-v2"; reg = <0x0 0xc0080000 0x0 0x10000>;
@@ -1107,6 +1174,58 @@ hisilicon,broken-prefetch-cmd; status = "disabled"; }; + p0_smmu_alg_a: smmu_alg@d0040000 { + compatible = "arm,smmu-v3"; + reg = <0x0 0xd0040000 0x0 0x20000>; + interrupt-parent = <&p0_mbigen_smmu_alg_a>; + interrupts = <733 1>, + <734 1>, + <735 1>; + interrupt-names = "eventq", "gerror", "priq"; + #iommu-cells = <1>; + dma-coherent; + hisilicon,broken-prefetch-cmd; + /* smmu-cb-memtype = <0x0 0x1>;*/ + }; + p0_smmu_alg_b: smmu_alg@8,d0040000 { + compatible = "arm,smmu-v3"; + reg = <0x8 0xd0040000 0x0 0x20000>; + interrupt-parent = <&p0_mbigen_smmu_alg_b>; + interrupts = <733 1>, + <734 1>, + <735 1>; + interrupt-names = "eventq", "gerror", "priq"; + #iommu-cells = <1>; + dma-coherent; + hisilicon,broken-prefetch-cmd; + /* smmu-cb-memtype = <0x0 0x1>;*/ + }; + p1_smmu_alg_a: smmu_alg@400,d0040000 { + compatible = "arm,smmu-v3"; + reg = <0x400 0xd0040000 0x0 0x20000>; + interrupt-parent = <&p1_mbigen_smmu_alg_a>; + interrupts = <733 1>, + <734 1>, + <735 1>; + interrupt-names = "eventq", "gerror", "priq"; + #iommu-cells = <1>; + dma-coherent; + hisilicon,broken-prefetch-cmd; + /* smmu-cb-memtype = <0x0 0x1>;*/ + }; + p1_smmu_alg_b: smmu_alg@408,d0040000 { + compatible = "arm,smmu-v3"; + reg = <0x408 0xd0040000 0x0 0x20000>; + interrupt-parent = <&p1_mbigen_smmu_alg_b>; + interrupts = <733 1>, + <734 1>, + <735 1>; + interrupt-names = "eventq", "gerror", "priq"; + #iommu-cells = <1>; + dma-coherent; + hisilicon,broken-prefetch-cmd; + /* smmu-cb-memtype = <0x0 0x1>;*/ + }; soc { compatible = "simple-bus";
@@ -1197,6 +1316,7 @@ reg-names = "ppe-base", "dsaf-base"; interrupt-parent = <&mbigen_dsaf0>; subctrl-syscon = <&dsa_subctrl>; + /*iommus = <&smmu1 0x0>;*/ reset-field-offset = <0>; interrupts = <576 1>, <577 1>, <578 1>, <579 1>, <580 1>,
@@ -1589,5 +1709,170 @@ 0x0 0 0 4 &mbigen_pcie2_a 671 4>; status = "disabled"; }; + p0_sec_a: sec@d2000000 { + compatible = "hisilicon,hip07-sec"; + reg = <0x0 0xd0000000 0x0 0x10000 + 0x0 0xd2000000 0x0 0x10000 + 0x0 0xd2010000 0x0 0x10000 + 0x0 0xd2020000 0x0 0x10000 + 0x0 0xd2030000 0x0 0x10000 + 0x0 0xd2040000 0x0 0x10000 + 0x0 0xd2050000 0x0 0x10000 + 0x0 0xd2060000 0x0 0x10000 + 0x0 0xd2070000 0x0 0x10000 + 0x0 0xd2080000 0x0 0x10000 + 0x0 0xd2090000 0x0 0x10000 + 0x0 0xd20a0000 0x0 0x10000 + 0x0 0xd20b0000 0x0 0x10000 + 0x0 0xd20c0000 0x0 0x10000 + 0x0 0xd20d0000 0x0 0x10000 + 0x0 0xd20e0000 0x0 0x10000 + 0x0 0xd20f0000 0x0 0x10000 + 0x0 0xd2100000 0x0 0x10000>; + interrupt-parent = <&p0_mbigen_sec_a>; + iommus = <&p0_smmu_alg_a 0x600>; + dma-coherent; + interrupts = <576 4>, + <577 1>,<578 4>, + <579 1>,<580 4>, + <581 1>,<582 4>, + <583 1>,<584 4>, + <585 1>,<586 4>, + <587 1>,<588 4>, + <589 1>,<590 4>, + <591 1>,<592 4>, + <593 1>,<594 4>, + <595 1>,<596 4>, + <597 1>,<598 4>, + <599 1>,<600 4>, + <601 1>,<602 4>, + <603 1>,<604 4>, + <605 1>,<606 4>, + <607 1>,<608 4>; + }; + p0_sec_b: sec@8,d2000000 { + compatible = "hisilicon,hip07-sec"; + reg = <0x8 0xd0000000 0x0 0x10000 + 0x8 0xd2000000 0x0 0x10000 + 0x8 0xd2010000 0x0 0x10000 + 0x8 0xd2020000 0x0 0x10000 + 0x8 0xd2030000 0x0 0x10000 + 0x8 0xd2040000 0x0 0x10000 + 0x8 0xd2050000 0x0 0x10000 + 0x8 0xd2060000 0x0 0x10000 + 0x8 0xd2070000 0x0 0x10000 + 0x8 0xd2080000 0x0 0x10000 + 0x8 0xd2090000 0x0 0x10000 + 0x8 0xd20a0000 0x0 0x10000 + 0x8 0xd20b0000 0x0 0x10000 + 0x8 0xd20c0000 0x0 0x10000 + 0x8 0xd20d0000 0x0 0x10000 + 0x8 0xd20e0000 0x0 0x10000 + 0x8 0xd20f0000 0x0 0x10000 + 0x8 0xd2100000 0x0 0x10000>; + interrupt-parent = <&p0_mbigen_sec_b>; + iommus = <&p0_smmu_alg_b 0x600>; + dma-coherent; + interrupts = <576 4>, + <577 1>,<578 4>, + <579 1>,<580 4>, + <581 1>,<582 4>, + <583 1>,<584 4>, + <585 1>,<586 4>, + <587 1>,<588 4>, + <589 1>,<590 4>, + <591 1>,<592 4>, + <593 1>,<594 4>, + <595 1>,<596 4>, + <597 1>,<598 4>, + <599 1>,<600 4>, + <601 1>,<602 4>, + <603 1>,<604 4>, + <605 1>,<606 4>, + <607 1>,<608 4>; + }; + p1_sec_a: sec@400,d2000000 { + compatible = "hisilicon,hip07-sec"; + reg = <0x400 0xd0000000 0x0 0x10000 + 0x400 0xd2000000 0x0 0x10000 + 0x400 0xd2010000 0x0 0x10000 + 0x400 0xd2020000 0x0 0x10000 + 0x400 0xd2030000 0x0 0x10000 + 0x400 0xd2040000 0x0 0x10000 + 0x400 0xd2050000 0x0 0x10000 + 0x400 0xd2060000 0x0 0x10000 + 0x400 0xd2070000 0x0 0x10000 + 0x400 0xd2080000 0x0 0x10000 + 0x400 0xd2090000 0x0 0x10000 + 0x400 0xd20a0000 0x0 0x10000 + 0x400 0xd20b0000 0x0 0x10000 + 0x400 0xd20c0000 0x0 0x10000 + 0x400 0xd20d0000 0x0 0x10000 + 0x400 0xd20e0000 0x0 0x10000 + 0x400 0xd20f0000 0x0 0x10000 + 0x400 0xd2100000 0x0 0x10000>; + interrupt-parent = <&p1_mbigen_sec_a>; + iommus = <&p1_smmu_alg_a 0x600>; + dma-coherent; + interrupts = <576 4>, + <577 1>,<578 4>, + <579 1>,<580 4>, + <581 1>,<582 4>, + <583 1>,<584 4>, + <585 1>,<586 4>, + <587 1>,<588 4>, + <589 1>,<590 4>, + <591 1>,<592 4>, + <593 1>,<594 4>, + <595 1>,<596 4>, + <597 1>,<598 4>, + <599 1>,<600 4>, + <601 1>,<602 4>, + <603 1>,<604 4>, + <605 1>,<606 4>, + <607 1>,<608 4>; + }; + p1_sec_b: sec@408,d2000000 { + compatible = "hisilicon,hip07-sec"; + reg = <0x408 0xd0000000 0x0 0x10000 + 0x408 0xd2000000 0x0 0x10000 + 0x408 0xd2010000 0x0 0x10000 + 0x408 0xd2020000 0x0 0x10000 + 0x408 0xd2030000 0x0 0x10000 + 0x408 0xd2040000 0x0 0x10000 + 0x408 0xd2050000 0x0 0x10000 + 0x408 0xd2060000 0x0 0x10000 + 0x408 0xd2070000 0x0 0x10000 + 0x408 0xd2080000 0x0 0x10000 + 0x408 0xd2090000 0x0 0x10000 + 0x408 0xd20a0000 0x0 0x10000 + 0x408 0xd20b0000 0x0 0x10000 + 0x408 0xd20c0000 0x0 0x10000 + 0x408 0xd20d0000 0x0 0x10000 + 0x408 0xd20e0000 0x0 0x10000 + 0x408 0xd20f0000 0x0 0x10000 + 0x408 0xd2100000 0x0 0x10000>; + interrupt-parent = <&p1_mbigen_sec_b>; + iommus = <&p1_smmu_alg_b 0x600>; + dma-coherent; + interrupts = <576 4>, + <577 1>,<578 4>, + <579 1>,<580 4>, + <581 1>,<582 4>, + <583 1>,<584 4>, + <585 1>,<586 4>, + <587 1>,<588 4>, + <589 1>,<590 4>, + <591 1>,<592 4>, + <593 1>,<594 4>, + <595 1>,<596 4>, + <597 1>,<598 4>, + <599 1>,<600 4>, + <601 1>,<602 4>, + <603 1>,<604 4>, + <605 1>,<606 4>, + <607 1>,<608 4>; + }; + }; };
Signature · 1 line
2.16.2
Rob Herring
maintainerRe: [PATCH 1/3] dt-bindings: Add bindings for Hisilicon SEC crypto accelerators.
In reply to Jonathan CameronQuoted 14 lines · Jonathan Cameron
The hip06 and hip07 SoCs contain a number of these crypto units which accelerate AES and DES operations.
Signed-off-by Jonathan Cameron <[email protected]>--- .../bindings/crypto/hisilicon,hip07-sec.txt | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+)Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +0
-0
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 7
Quoted 7 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +7
-0@@ -0,0 +1,69 @@ +* Hisilicon hip07 Security Accelerator (SEC) + +Required properties: +- compatible: Must contain one of + - "hisilicon,hip06-sec" + - "hisilicon,hip07-sec" +- reg: Memory addresses and lengths of the memory regions used by the driver.
You know my feelings about the word "driver" in bindings. :)
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 11
Quoted 4 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +4
-0+ Region 0 has registers to control the backend processing engines. + Region 1 has registers for functionality common to all queues. + Regions 2-18 have registers for the individual queues which are isolated + both in hardware and within the driver.
It's always 16 queues? Might state that somewhere.
Quoted 4 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +4
-0+- interrupts: Interrupt specifiers. + Refer to interrupt-controller/interrupts.txt for generic interrupt client node + bindings. + Interrupt 0 is for the SEC unit error queue.
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 25
Quoted 10 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +10
-0+ Interrupt 2N + 1 is the completion interrupt for queue N. + Interrupt 2N + 2 is the error interrupt for queue N. +- dma-coherent: The driver assumes coherent dma is possible. + +Optional properties: +- iommus: The SEC units are behind smmu-v3 iommus. + Refer to iommu/arm,smmu-v3.txt for more information. + +Example: +Second socket, first unit chosen to illustrate need for 64 bit addresses.
I don't follow the 64-bit address comment.
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 27
Quoted 2 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +2
-0+ +p1_sec_a: sec@d2000000 {
crypto@...
The unit-address should be from the 1st reg entry and why isn't the 0x400 part included?
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 30
Quoted 3 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +3
-0+ compatible = "hisilicon,hip07-sec"; + #address-cells = <2>; + #size-cells = <2>;
These aren't needed here as there are no child nodes.
Quoted 13 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +13
-0+ reg = <0x400 0xd0000000 0x0 0x10000 + 0x400 0xd2000000 0x0 0x10000 + 0x400 0xd2010000 0x0 0x10000 + 0x400 0xd2020000 0x0 0x10000 + 0x400 0xd2030000 0x0 0x10000 + 0x400 0xd2040000 0x0 0x10000 + 0x400 0xd2050000 0x0 0x10000 + 0x400 0xd2060000 0x0 0x10000 + 0x400 0xd2070000 0x0 0x10000 + 0x400 0xd2080000 0x0 0x10000 + 0x400 0xd2090000 0x0 0x10000 + 0x400 0xd20a0000 0x0 0x10000 + 0x400 0xd20b0000 0x0 0x10000
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 53
Quoted 10 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +10
-0+ 0x400 0xd20c0000 0x0 0x10000 + 0x400 0xd20d0000 0x0 0x10000 + 0x400 0xd20e0000 0x0 0x10000 + 0x400 0xd20f0000 0x0 0x10000 + 0x400 0xd2100000 0x0 0x10000>; + interrupt-parent = <&p1_mbigen_sec_a>; + iommus = <&p1_smmu_alg_a 0x600>; + dma-coherent; + interrupts = <576 4>, + <577 1>,<578 4>,
space needed after the comma.
Quoted 20 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +16
-0+ <579 1>,<580 4>, + <581 1>,<582 4>, + <583 1>,<584 4>, + <585 1>,<586 4>, + <587 1>,<588 4>, + <589 1>,<590 4>, + <591 1>,<592 4>, + <593 1>,<594 4>, + <595 1>,<596 4>, + <597 1>,<598 4>, + <599 1>,<600 4>, + <601 1>,<602 4>, + <603 1>,<604 4>, + <605 1>,<606 4>, + <607 1>,<608 4>; +};Signature · 1 line
2.16.2
Re: [PATCH 1/3] dt-bindings: Add bindings for Hisilicon SEC crypto accelerators.
Quoted 9 lines · On Fri, 20 Jul 2018 10:30:10 -0600 Rob Herring <[email protected]> wrote:
Quoted 8 lines · Jonathan Cameron
The hip06 and hip07 SoCs contain a number of these crypto units which accelerate AES and DES operations.
Signed-off-by Jonathan Cameron <[email protected]>--- .../bindings/crypto/hisilicon,hip07-sec.txt | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+)
Quoted 15 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 7
Quoted 13 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +7
-0@@ -0,0 +1,69 @@ +* Hisilicon hip07 Security Accelerator (SEC) + +Required properties: +- compatible: Must contain one of + - "hisilicon,hip06-sec" + - "hisilicon,hip07-sec" +- reg: Memory addresses and lengths of the memory regions used by the driver.You know my feelings about the word "driver" in bindings. :)
Oops. Will fix. Oddly rare I actually write one of these docs so making newbie mistakes :(
Quoted 7 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 11
Quoted 5 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +4
-0+ Region 0 has registers to control the backend processing engines. + Region 1 has registers for functionality common to all queues. + Regions 2-18 have registers for the individual queues which are isolated + both in hardware and within the driver.It's always 16 queues? Might state that somewhere.
Technically complex because some of them may be in use by the secure world and hence not available and not seen in the DT.
Right now the driver doesn't support that, and it's not happening on any existing platforms but I was trying to avoid stating there were definitely 16 available. I guess if that happens I'll fix the binding when they do it. (moderately unlikely to happen now given age of this platform, but you never know).
Quoted 17 lines
Quoted 5 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +4
-0+- interrupts: Interrupt specifiers. + Refer to interrupt-controller/interrupts.txt for generic interrupt client node + bindings. + Interrupt 0 is for the SEC unit error queue.Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 25
Quoted 10 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +10
-0+ Interrupt 2N + 1 is the completion interrupt for queue N. + Interrupt 2N + 2 is the error interrupt for queue N. +- dma-coherent: The driver assumes coherent dma is possible. + +Optional properties: +- iommus: The SEC units are behind smmu-v3 iommus. + Refer to iommu/arm,smmu-v3.txt for more information. + +Example: +Second socket, first unit chosen to illustrate need for 64 bit addresses.I don't follow the 64-bit address comment.
Without it the address is in the 32bit range so internal review raised the question of why we needed to provide 64 bit registers as 32 bit ones are more compact.
reg = <0xd000000 0x10000
etc
Quoted 8 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 27
Quoted 3 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +2
-0+ +p1_sec_a: sec@d2000000 {crypto@...
The unit-address should be from the 1st reg entry and why isn't the
0x400part included?
Will fix here an obviously in the DT patch itself.
Quoted 6 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 30
Quoted 4 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +3
-0+ compatible = "hisilicon,hip07-sec"; + #address-cells = <2>; + #size-cells = <2>;These aren't needed here as there are no child nodes.
Oops I always forget those.
Quoted 37 lines
Quoted 14 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +13
-0+ reg = <0x400 0xd0000000 0x0 0x10000 + 0x400 0xd2000000 0x0 0x10000 + 0x400 0xd2010000 0x0 0x10000 + 0x400 0xd2020000 0x0 0x10000 + 0x400 0xd2030000 0x0 0x10000 + 0x400 0xd2040000 0x0 0x10000 + 0x400 0xd2050000 0x0 0x10000 + 0x400 0xd2060000 0x0 0x10000 + 0x400 0xd2070000 0x0 0x10000 + 0x400 0xd2080000 0x0 0x10000 + 0x400 0xd2090000 0x0 0x10000 + 0x400 0xd20a0000 0x0 0x10000 + 0x400 0xd20b0000 0x0 0x10000Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt line 53
Quoted 10 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +10
-0+ 0x400 0xd20c0000 0x0 0x10000 + 0x400 0xd20d0000 0x0 0x10000 + 0x400 0xd20e0000 0x0 0x10000 + 0x400 0xd20f0000 0x0 0x10000 + 0x400 0xd2100000 0x0 0x10000>; + interrupt-parent = <&p1_mbigen_sec_a>; + iommus = <&p1_smmu_alg_a 0x600>; + dma-coherent; + interrupts = <576 4>, + <577 1>,<578 4>,space needed after the comma.
Quoted 10 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +10
-0+ <579 1>,<580 4>, + <581 1>,<582 4>, + <583 1>,<584 4>, + <585 1>,<586 4>, + <587 1>,<588 4>, + <589 1>,<590 4>, + <591 1>,<592 4>, + <593 1>,<594 4>, + <595 1>,<596 4>, + <597 1>,<598 4>,
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/crypto/hisilicon,hip07-sec.txt new file +6
-0+ <599 1>,<600 4>, + <601 1>,<602 4>, + <603 1>,<604 4>, + <605 1>,<606 4>, + <607 1>,<608 4>; +};Signature · 1 line
2.16.2
Thanks Rob.
Jonathan
Quoted 2 lines
Quoted 2 lines
Re: [PATCH 2/3] crypto: hisilicon SEC security accelerator driver
In reply to Jonathan CameronAm Montag, 16. Juli 2018, 12:43:41 CEST schrieb Jonathan Cameron:
Hi Jonathan,
Quoted 8 lines
(quoted diff) +2
-0+static int sec_alg_skcipher_setkey_aes_xts(struct crypto_skcipher *tfm, + const u8 *key, unsigned intkeylen) +{
drivers/crypto/hisilicon/sec/sec_algs.c new file +5
-0+enum sec_cipher_alg alg; + +switch (keylen) { +case AES_KEYSIZE_128 *2 : + alg =SEC_C_AES_XTS_128 ;
drivers/crypto/hisilicon/sec/sec_algs.c line 339
Quoted 10 lines
drivers/crypto/hisilicon/sec/sec_algs.c new file +10
-0+break ; +case AES_KEYSIZE_256 *2 : + alg =SEC_C_AES_XTS_256 ; +break ; +default : +return -EINVAL ; + } + +return sec_alg_skcipher_setkey (tfm, key, keylen, alg); +}
Can you please call the function xts_check_key or xts_verify_key before setting the key?
Ciao
Stephan
Re: [PATCH 2/3] crypto: hisilicon SEC security accelerator driver
Quoted 17 lines · On Fri, 20 Jul 2018 20:17:22 +0200 Stephan Müller <[email protected]> wrote:
Am Montag, 16. Juli 2018, 12:43:41 CEST schrieb Jonathan Cameron:
Hi Jonathan,
Quoted 13 lines
(quoted diff) +2
-0+static int sec_alg_skcipher_setkey_aes_xts(struct crypto_skcipher *tfm, + const u8 *key, unsigned intkeylen) +{
drivers/crypto/hisilicon/sec/sec_algs.c new file +10
-0+enum sec_cipher_alg alg; + +switch (keylen) { +case AES_KEYSIZE_128 *2 : + alg =SEC_C_AES_XTS_128 ; +break ; +case AES_KEYSIZE_256 *2 : + alg =SEC_C_AES_XTS_256 ; +break ; +default :
Quoted 9 lines
drivers/crypto/hisilicon/sec/sec_algs.c line 276
Quoted 5 lines
drivers/crypto/hisilicon/sec/sec_algs.c new file +5
-0+return -EINVAL ; + } + +return sec_alg_skcipher_setkey (tfm, key, keylen, alg); +}Can you please call the function
xts_check_keyorxts_verify_keybefore setting the key?
Will do.
Thanks,
Jonathan