spinlock: extend guard with spinlock_bh variants
Subsystems (7)
Christian Marangi
maintainerPATCH v4 1/3 spinlock: extend guard with spinlock_bh variants
Extend guard APIs with missing raw/spinlock_bh variants.
---
Changes v4:
- Out of RFC
Changes v2:
- Add this patch
include/linux/spinlock.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/spinlock.h +13 -0
@@ -548,6 +548,12 @@ DEFINE_LOCK_GUARD_1(raw_spinlock_irq, raw_spinlock_t, DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq(_T->lock)) +DEFINE_LOCK_GUARD_1 (raw_spinlock_bh, raw_spinlock_t, +raw_spin_lock_bh (_T->lock), + raw_spin_unlock_bh(_T->lock)) + +DEFINE_LOCK_GUARD_1_COND(raw_spinlock_bh, _try, raw_spin_trylock_bh(_T->lock)) + DEFINE_LOCK_GUARD_1(raw_spinlock_irqsave, raw_spinlock_t, raw_spin_lock_irqsave(_T->lock, _T->flags), raw_spin_unlock_irqrestore(_T->lock, _T->flags),
@@ -569,6 +575,13 @@ DEFINE_LOCK_GUARD_1(spinlock_irq, spinlock_t,DEFINE_LOCK_GUARD_1_COND (spinlock_irq, _try, spin_trylock_irq(_T->lock)) +DEFINE_LOCK_GUARD_1 (spinlock_bh, spinlock_t, +spin_lock_bh (_T->lock), + spin_unlock_bh(_T->lock)) + +DEFINE_LOCK_GUARD_1_COND (spinlock_bh, _try, + spin_trylock_bh(_T->lock)) + DEFINE_LOCK_GUARD_1(spinlock_irqsave, spinlock_t, spin_lock_irqsave(_T->lock, _T->flags), spin_unlock_irqrestore(_T->lock, _T->flags),
Signature · 1 line
2.45.2
Christian Marangi
maintainerPATCH v4 2/3 dt-bindings: crypto: Add Inside Secure SafeXcel EIP-93 crypto engine
Add bindings for the Inside Secure SafeXcel EIP-93 crypto engine.
The IP is present on Airoha SoC and on various Mediatek devices and other SoC under different names like mtk-eip93 or PKTE.
---
Changes v4:
- Out of RFC
Changes v3:
- Add SoC compatible with generic one
Changes v2:
- Change to better compatible
- Add description for EIP93 models
.../crypto/inside-secure,safexcel-eip93.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +63 -0
@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/inside-secure,safexcel-eip93.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Inside Secure SafeXcel EIP-93 cryptographic engine + +maintainers: + - Christian Marangi <[email protected]> + +description: | + The Inside Secure SafeXcel EIP-93 is a cryptographic engine IP block + integrated in varios devices with very different and generic name from + PKTE to simply vendor+EIP93. The real IP under the hood is actually + developed by Inside Secure and given to license to vendors. + + The IP block is sold with different model based on what feature are + needed and are identified with the final letter. Each letter correspond + to a specific set of feature and multiple letter reflect the sum of the + feature set. + + EIP-93 models: + - EIP-93i: (basic) DES/Triple DES, AES, PRNG, IPsec ESP, SRTP, SHA1 + - EIP-93ie: i + SHA224/256, AES-192/256 + - EIP-93is: i + SSL/DTLS/DTLS, MD5, ARC4 + - EIP-93ies: i + e + s + - EIP-93iw: i + AES-XCB-MAC, AES-CCM + +properties: + compatible: + items: + - const: airoha,crypto-eip93 + - enum: + - inside-secure,safexcel-eip93i + - inside-secure,safexcel-eip93ie + - inside-secure,safexcel-eip93is + - inside-secure,safexcel-eip93ies + - inside-secure,safexcel-eip93iw + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + crypto@1e004000 { + compatible = "airoha,crypto-eip93", "inside-secure,safexcel-eip93ies"; + reg = <0x1fb70000 0x1000>; + + interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>; + };
Signature · 1 line
2.45.2
Re: [PATCH v4 2/3] dt-bindings: crypto: Add Inside Secure SafeXcel EIP-93 crypto engine
Quoted 9 lines · Christian Marangi
Add bindings for the Inside Secure SafeXcel EIP-93 crypto engine.
The IP is present on Airoha SoC and on various Mediatek devices and other SoC under different names like mtk-eip93 or PKTE.
Signed-off-by Christian Marangi <[email protected]>---
Changes v4:
- Out of RFC
I left comments on v3, that I do not see addressed here.
Quoted 82 lines
Changes v3:
- Add SoC compatible with generic one
Changes v2:
- Change to better compatible
- Add description for EIP93 models.../crypto/inside-secure,safexcel-eip93.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yamlDocumentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +63
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/inside-secure,safexcel-eip93.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Inside Secure SafeXcel EIP-93 cryptographic engine + +maintainers: + - Christian Marangi <[email protected]> + +description: | + The Inside Secure SafeXcel EIP-93 is a cryptographic engine IP block + integrated in varios devices with very different and generic name from + PKTE to simply vendor+EIP93. The real IP under the hood is actually + developed by Inside Secure and given to license to vendors. + + The IP block is sold with different model based on what feature are + needed and are identified with the final letter. Each letter correspond + to a specific set of feature and multiple letter reflect the sum of the + feature set. + + EIP-93 models: + - EIP-93i: (basic) DES/Triple DES, AES, PRNG, IPsec ESP, SRTP, SHA1 + - EIP-93ie: i + SHA224/256, AES-192/256 + - EIP-93is: i + SSL/DTLS/DTLS, MD5, ARC4 + - EIP-93ies: i + e + s + - EIP-93iw: i + AES-XCB-MAC, AES-CCM + +properties: + compatible: + items: + - const: airoha,crypto-eip93 + - enum: + - inside-secure,safexcel-eip93i + - inside-secure,safexcel-eip93ie + - inside-secure,safexcel-eip93is + - inside-secure,safexcel-eip93ies + - inside-secure,safexcel-eip93iw + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + crypto@1e004000 { + compatible = "airoha,crypto-eip93", "inside-secure,safexcel-eip93ies"; + reg = <0x1fb70000 0x1000>; + + interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>; + };Signature · 1 line
2.45.2
Christian Marangi
maintainerRe: [PATCH v4 2/3] dt-bindings: crypto: Add Inside Secure SafeXcel EIP-93 crypto engine
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Christian Marangi
Add bindings for the Inside Secure SafeXcel EIP-93 crypto engine.
The IP is present on Airoha SoC and on various Mediatek devices and other SoC under different names like mtk-eip93 or PKTE.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Christian Marangi <[email protected]>---
Changes v4:
- Out of RFCI left comments on v3, that I do not see addressed here.
I missed them sorry, I was confused with the other reply about RFC not asking for comments. Let me copy the comments here so we can continue here.
Quoted 48 lines
Quoted 35 lines
Changes v3:
- Add SoC compatible with generic one
Changes v2:
- Change to better compatible
- Add description for EIP93 models.../crypto/inside-secure,safexcel-eip93.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yamlDocumentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +18
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/inside-secure,safexcel-eip93.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Inside Secure SafeXcel EIP-93 cryptographic engine + +maintainers: + - Christian Marangi <[email protected]> + +description: | + The Inside Secure SafeXcel EIP-93 is a cryptographic engine IP block + integrated in varios devices with very different and generic name from + PKTE to simply vendor+EIP93. The real IP under the hood is actually + developed by Inside Secure and given to license to vendors. + + The IP block is sold with different model based on what feature areDocumentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +10
-0+ needed and are identified with the final letter. Each letter correspond + to a specific set of feature and multiple letter reflect the sum of the + feature set. + + EIP-93 models: + - EIP-93i: (basic) DES/Triple DES, AES, PRNG, IPsec ESP, SRTP, SHA1 + - EIP-93ie: i + SHA224/256, AES-192/256 + - EIP-93is: i + SSL/DTLS/DTLS, MD5, ARC4 + - EIP-93ies: i + e + s + - EIP-93iw: i + AES-XCB-MAC, AES-CCMThis implies that you should have a non-trivial set of fallbacks, with the "i" model as the base for that. eg:
Quoted 5 lines
"ie", "i"
"is", "i"
"iw", "i"
"ies", "ie, "is", "i" (I dunno which would be a better order here)
These info are what I found around since informations about models are very scarce. The driver itself makes use of a bitmap in the IP to detect the supported stuff so the meaning of this is really to comunicate the set of feature mounted on the system.
Any hint on how to describe this better? I assume you refer to some kind of yaml logic structure to put in the compatible?
Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +9
-0+ +properties: + compatible: + items: + - const: airoha,crypto-eip93 + - enum: + - inside-secure,safexcel-eip93i + - inside-secure,safexcel-eip93ie + - inside-secure,safexcel-eip93is
Quoted 9 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml line 40
Quoted 3 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +3
-0+ - inside-secure,safexcel-eip93ies + - inside-secure,safexcel-eip93iw +I don't really get what's going on here. Why is the first compatible the generic one? That seems suspect to me, as I doubt the crypto block on a particular SoC varies? I'd expect to see some soc-specific compatibles with a fallback to the inside-secure IP version that it integrates.
This was already discussed and hoped this solution was accepted (I didn't get any reply in the other revision, so I'm probably wrong)
Everything started with:
- airoha,mtk-eip93
Was wrong as the compatible wasn't clear on what mtk was and if the IP was from airoha (it's not, it's licensed to...)
Then only the inside-secure ones, following how it's done for the newer inside-secure eip197.
Krzysztof then suggested that, since it's licensed but OEM can make modification, it should be sensible to put a compatible of the SoC where the thing is mounted at the front of the other compatible. Eip197 should have received the same treatement but for some reason it didn't.
So here in v3/v4 with this proposed solution.
First compatible is SoC name, useful if the Vendor made modification to the IP. Then the generic model that describe the set of feature supported.
I checked the register of 3 different device where EIP93 is implemented and they ALL match them. ONLY additional register are added for debug purpose and never conflicting bits are introduced.
Hence why IMHO it's OK to use the combo of Vendor + second compatible for the generic implementation.
From both comments I'm not really sure what do you mean about fallback, anyway hope it's clear now.
Quoted 26 lines
Quoted 26 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +23
-0+ reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + + crypto@1e004000 { + compatible = "airoha,crypto-eip93", "inside-secure,safexcel-eip93ies"; + reg = <0x1fb70000 0x1000>; + + interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>; + };Signature · 1 line
2.45.2
Signature · 1 line
Ansuel
Rob Herring
maintainerRe: [PATCH v4 2/3] dt-bindings: crypto: Add Inside Secure SafeXcel EIP-93 crypto engine
Quoted 73 lines · Christian Marangi
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Christian Marangi
Add bindings for the Inside Secure SafeXcel EIP-93 crypto engine.
The IP is present on Airoha SoC and on various Mediatek devices and other SoC under different names like mtk-eip93 or PKTE.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Christian Marangi <[email protected]>---
Changes v4:
- Out of RFCI left comments on v3, that I do not see addressed here.
I missed them sorry, I was confused with the other reply about RFC not asking for comments. Let me copy the comments here so we can continue here.
Quoted 48 lines
Quoted 35 lines
Changes v3:
- Add SoC compatible with generic one
Changes v2:
- Change to better compatible
- Add description for EIP93 models.../crypto/inside-secure,safexcel-eip93.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yamlDocumentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +18
-0@@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/inside-secure,safexcel-eip93.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Inside Secure SafeXcel EIP-93 cryptographic engine + +maintainers: + - Christian Marangi <[email protected]> + +description: | + The Inside Secure SafeXcel EIP-93 is a cryptographic engine IP block + integrated in varios devices with very different and generic name from + PKTE to simply vendor+EIP93. The real IP under the hood is actually + developed by Inside Secure and given to license to vendors. + + The IP block is sold with different model based on what feature areDocumentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +10
-0+ needed and are identified with the final letter. Each letter correspond + to a specific set of feature and multiple letter reflect the sum of the + feature set. + + EIP-93 models: + - EIP-93i: (basic) DES/Triple DES, AES, PRNG, IPsec ESP, SRTP, SHA1 + - EIP-93ie: i + SHA224/256, AES-192/256 + - EIP-93is: i + SSL/DTLS/DTLS, MD5, ARC4 + - EIP-93ies: i + e + s + - EIP-93iw: i + AES-XCB-MAC, AES-CCMThis implies that you should have a non-trivial set of fallbacks, with the "i" model as the base for that. eg:
Quoted 5 lines
"ie", "i"
"is", "i"
"iw", "i"
"ies", "ie, "is", "i" (I dunno which would be a better order here)
Quoted 7 lines
These info are what I found around since informations about models are very scarce. The driver itself makes use of a bitmap in the IP to detect the supported stuff so the meaning of this is really to comunicate the set of feature mounted on the system.
Any hint on how to describe this better? I assume you refer to some kind of yaml logic structure to put in the compatible?
I think the list is fine as-is. If we already had support for the 'i' version and then added new 'iX' versions, then having the fallback makes sense. But since this is all new and defined at one time, I don't think defining all those combinations buys us anything. And an OS can still choose to only support the 'i' features even if the h/w supports the e, s, and/or w features.
Quoted 47 lines
Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +9
-0+ +properties: + compatible: + items: + - const: airoha,crypto-eip93 + - enum: + - inside-secure,safexcel-eip93i + - inside-secure,safexcel-eip93ie + - inside-secure,safexcel-eip93isQuoted 9 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml line 40
Quoted 3 lines
Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml new file +3
-0+ - inside-secure,safexcel-eip93ies + - inside-secure,safexcel-eip93iw +I don't really get what's going on here. Why is the first compatible the generic one? That seems suspect to me, as I doubt the crypto block on a particular SoC varies? I'd expect to see some soc-specific compatibles with a fallback to the inside-secure IP version that it integrates.
This was already discussed and hoped this solution was accepted (I didn't get any reply in the other revision, so I'm probably wrong)
Everything started with:
- airoha,mtk-eip93Was wrong as the compatible wasn't clear on what mtk was and if the IP was from airoha (it's not, it's licensed to...)
Then only the inside-secure ones, following how it's done for the newer inside-secure eip197.
Krzysztof then suggested that, since it's licensed but OEM can make modification, it should be sensible to put a compatible of the SoC where the thing is mounted at the front of the other compatible. Eip197 should have received the same treatement but for some reason it didn't.
So here in v3/v4 with this proposed solution.
First compatible is SoC name, useful if the Vendor made modification to the IP. Then the generic model that describe the set of feature supported.
I checked the register of 3 different device where EIP93 is implemented and they ALL match them. ONLY additional register are added for debug purpose and never conflicting bits are introduced.
Quoted 5 lines
Hence why IMHO it's OK to use the combo of Vendor + second compatible for the generic implementation.
Quoted 1 line
From both comments I'm not really sure what do you mean about fallback,
anyway hope it's clear now.
The issue is that airoha only has 1 implementation of safexcel, not any of them which is what you defined. Well, at least if that's an SoC specific compatible which it doesn't look like either.
The issue is that you probably don't have an actual user for all the variants. I would just list them commented out or like this:
items:
- false (tools might complain with this. "not: {}" may work instead)
- enum:
# IP versions without an SoC specific compatible defined yet
- inside-secure,safexcel-eip93i
- inside-secure,safexcel-eip93ie
- inside-secure,safexcel-eip93is
- inside-secure,safexcel-eip93ies
- inside-secure,safexcel-eip93iw
(So remove the one you use in this list)
Rob
Christian Marangi
maintainerPATCH v4 3/3 crypto: Add Mediatek EIP-93 crypto engine support
In reply to Christian MarangiAdd support for the Mediatek EIP-93 crypto engine used on MT7621 and new Airoha SoC.
EIP-93 IP supports AES/DES/3DES ciphers in ECB/CBC and CTR modes as well as authenc(HMAC(x), cipher(y)) using HMAC MD5, SHA1, SHA224 and SHA256.
EIP-93 provide regs to signal support for specific chipers and the driver dynamically register only the supported one by the chip.
---
Changes v4:
- Out of RFC
- Add missing bitfield.h
- Drop useless header
Changes v3:
- Mute warning from Clang about C23
- Fix not inizialized err
- Drop unused variable
Changes v2:
- Rename all variables from mtk to eip93
- Move to inside-secure directory
- Check DMA map errors
- Use guard API for spinlock
- Minor improvements to code
MAINTAINERS | 7 + drivers/crypto/Kconfig | 1 + drivers/crypto/Makefile | 1 + drivers/crypto/inside-secure/eip93/Kconfig | 20 + drivers/crypto/inside-secure/eip93/Makefile | 5 + .../crypto/inside-secure/eip93/eip93-aead.c | 702 ++++++++++++++ .../crypto/inside-secure/eip93/eip93-aead.h | 38 + .../crypto/inside-secure/eip93/eip93-aes.h | 16 + .../crypto/inside-secure/eip93/eip93-cipher.c | 407 ++++++++ .../crypto/inside-secure/eip93/eip93-cipher.h | 60 ++ .../crypto/inside-secure/eip93/eip93-common.c | 824 ++++++++++++++++ .../crypto/inside-secure/eip93/eip93-common.h | 23 + .../crypto/inside-secure/eip93/eip93-des.h | 16 + .../crypto/inside-secure/eip93/eip93-hash.c | 912 ++++++++++++++++++ .../crypto/inside-secure/eip93/eip93-hash.h | 72 ++ .../crypto/inside-secure/eip93/eip93-main.c | 502 ++++++++++ .../crypto/inside-secure/eip93/eip93-main.h | 152 +++ .../crypto/inside-secure/eip93/eip93-regs.h | 335 +++++++ 18 files changed, 4093 insertions(+) create mode 100644 drivers/crypto/inside-secure/eip93/Kconfig create mode 100644 drivers/crypto/inside-secure/eip93/Makefile create mode 100644 drivers/crypto/inside-secure/eip93/eip93-aead.c create mode 100644 drivers/crypto/inside-secure/eip93/eip93-aead.h create mode 100644 drivers/crypto/inside-secure/eip93/eip93-aes.h create mode 100644 drivers/crypto/inside-secure/eip93/eip93-cipher.c create mode 100644 drivers/crypto/inside-secure/eip93/eip93-cipher.h create mode 100644 drivers/crypto/inside-secure/eip93/eip93-common.c create mode 100644 drivers/crypto/inside-secure/eip93/eip93-common.h create mode 100644 drivers/crypto/inside-secure/eip93/eip93-des.h create mode 100644 drivers/crypto/inside-secure/eip93/eip93-hash.c create mode 100644 drivers/crypto/inside-secure/eip93/eip93-hash.h create mode 100644 drivers/crypto/inside-secure/eip93/eip93-main.c create mode 100644 drivers/crypto/inside-secure/eip93/eip93-main.h create mode 100644 drivers/crypto/inside-secure/eip93/eip93-regs.h
MAINTAINERS +7 -0
@@ -11322,6 +11322,13 @@ L: [email protected] S: Maintained F: drivers/crypto/inside-secure/ +INSIDE SECURE EIP93 CRYPTO DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/crypto/inside-secure,safexcel-eip93.yaml +F: drivers/crypto/inside-secure/eip93/ + INTEGRITY MEASUREMENT ARCHITECTURE (IMA) M: Mimi Zohar <[email protected]> M: Roberto Sassu <[email protected]>
drivers/crypto/Kconfig +1 -0
@@ -851,5 +851,6 @@ config CRYPTO_DEV_SA2UL source "drivers/crypto/aspeed/Kconfig" source "drivers/crypto/starfive/Kconfig" +source "drivers/crypto/inside-secure/eip93/Kconfig" endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -52,3 +52,4 @@ obj-y += hisilicon/ obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/ obj-y += intel/ obj-y += starfive/ +obj-y += inside-secure/eip93/
drivers/crypto/inside-secure/eip93/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 +config CRYPTO_DEV_EIP93 + tristate "Support for EIP93 crypto HW accelerators" + depends on SOC_MT7621 || ARCH_AIROHA ||COMPILE_TEST + select CRYPTO_LIB_AES + select CRYPTO_LIB_DES + select CRYPTO_SKCIPHER + select CRYPTO_AEAD + select CRYPTO_AUTHENC + select CRYPTO_MD5 + select CRYPTO_SHA1 + select CRYPTO_SHA256 + help + EIP93 have various crypto HW accelerators. Select this if + you want to use the EIP93 modules for any of the crypto algorithms. + + If the IP supports it, this provide offload for AES - ECB, CBC and + CTR crypto. Also provide DES and 3DES ECB and CBC. + + Also provide AEAD authenc(hmac(x), cipher(y)) for supported algo.
drivers/crypto/inside-secure/eip93/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +obj-$(CONFIG_CRYPTO_DEV_EIP93) += crypto-hw-eip93.o + +crypto-hw-eip93-y += eip93-main.o eip93-common.o +crypto-hw-eip93-y += eip93-cipher.o eip93-aead.o +crypto-hw-eip93-y += eip93-hash.o
drivers/crypto/inside-secure/eip93/eip93-aead.c new file +702 -0
702 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-aead.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +* Christian Marangi <[email protected] +*/ +#ifndef _EIP93_AEAD_H_ +#define _EIP93_AEAD_H_ + +extern struct eip93_alg_template eip93_alg_authenc_hmac_md5_cbc_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha1_cbc_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha224_cbc_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha256_cbc_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_md5_ctr_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha1_ctr_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha224_ctr_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha256_ctr_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_md5_rfc3686_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha1_rfc3686_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha224_rfc3686_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha256_rfc3686_aes; +extern struct eip93_alg_template eip93_alg_authenc_hmac_md5_cbc_des; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha1_cbc_des; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha224_cbc_des; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha256_cbc_des; +extern struct eip93_alg_template eip93_alg_authenc_hmac_md5_cbc_des3_ede; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha1_cbc_des3_ede; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha224_cbc_des3_ede; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha256_cbc_des3_ede; +extern struct eip93_alg_template eip93_alg_authenc_hmac_md5_ecb_null; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha1_ecb_null; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha224_ecb_null; +extern struct eip93_alg_template eip93_alg_authenc_hmac_sha256_ecb_null; + +void eip93_aead_handle_result (struct crypto_async_request *async,int err); + +#endif /* _EIP93_AEAD_H_ */
drivers/crypto/inside-secure/eip93/eip93-aes.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +* Christian Marangi <[email protected] +*/ +#ifndef _EIP93_AES_H_ +#define _EIP93_AES_H_ + +extern struct eip93_alg_template eip93_alg_ecb_aes; +extern struct eip93_alg_template eip93_alg_cbc_aes; +extern struct eip93_alg_template eip93_alg_ctr_aes; +extern struct eip93_alg_template eip93_alg_rfc3686_aes; + +#endif /* _EIP93_AES_H_ */
drivers/crypto/inside-secure/eip93/eip93-cipher.c new file +407 -0
407 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-cipher.h new file +60 -0
60 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-common.c new file +824 -0
824 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-common.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +* Christian Marangi <[email protected] +*/ + +#ifndef _EIP93_COMMON_H_ +#define _EIP93_COMMON_H_ + +void *eip93_get_descriptor (struct eip93_device *mtk); +int eip93_put_descriptor (struct eip93_device *mtk,struct eip93_descriptor *desc); + +void eip93_set_sa_record (struct sa_record *sa_record,const unsigned int keylen, +const u32 flags); + +int eip93_parse_ctrl_stat_err (struct eip93_device *mtk,int err); + +int eip93_authenc_setkey (struct crypto_aead *aead,struct sa_record *sa, +const u8 *authkey,unsigned int authkeylen); + +#endif /* _EIP93_COMMON_H_ */
drivers/crypto/inside-secure/eip93/eip93-des.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +* Christian Marangi <[email protected] +*/ +#ifndef _EIP93_DES_H_ +#define _EIP93_DES_H_ + +extern struct eip93_alg_template eip93_alg_ecb_des; +extern struct eip93_alg_template eip93_alg_cbc_des; +extern struct eip93_alg_template eip93_alg_ecb_des3_ede; +extern struct eip93_alg_template eip93_alg_cbc_des3_ede; + +#endif /* _EIP93_DES_H_ */
drivers/crypto/inside-secure/eip93/eip93-hash.c new file +912 -0
866 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-hash.h new file +72 -0
72 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-main.c new file +502 -0
502 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-main.h new file +152 -0
152 lines not on this page · raw message
drivers/crypto/inside-secure/eip93/eip93-regs.h new file +335 -0
335 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.45.2
Part of the diff is not shown here. View the raw message.
kernel test robot
build botRe: [PATCH v4 3/3] crypto: Add Mediatek EIP-93 crypto engine support
kernel test robot noticed the following build warnings:
Hi Christian,
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 tip/locking/core linus/master v6.12-rc4 next-20241025] [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/Christian-Marangi/dt-bindings-crypto-Add-Inside-Secure-SafeXcel-EIP-93-crypto-engine/20241025-175032 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/20241025094734.1614-3-ansuelsmth%40gmail.com patch subject: [PATCH v4 3/3] crypto: Add Mediatek EIP-93 crypto engine support config: powerpc64-randconfig-r123-20241026 (https://download.01.org/0day-ci/archive/20241026/[email protected]/config) compiler: powerpc64-linux-gcc (GCC) 14.1.0 reproduce: (https://download.01.org/0day-ci/archive/20241026/[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/inside-secure/eip93/eip93-hash.c:423:37: sparse: sparse: cast to restricted __be32 >> drivers/crypto/inside-secure/eip93/eip93-hash.c:596:38: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] @@ got restricted __be32 [usertype] @@ drivers/crypto/inside-secure/eip93/eip93-hash.c:596:38: sparse: expected unsigned int [usertype] drivers/crypto/inside-secure/eip93/eip93-hash.c:596:38: sparse: got restricted __be32 [usertype] -- >> drivers/crypto/inside-secure/eip93/eip93-common.c:542:39: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restricted __be32 [usertype] @@ drivers/crypto/inside-secure/eip93/eip93-common.c:542:39: sparse: expected unsigned int drivers/crypto/inside-secure/eip93/eip93-common.c:542:39: sparse: got restricted __be32 [usertype] >> drivers/crypto/inside-secure/eip93/eip93-common.c:546:23: sparse: sparse: cast to restricted __be32 drivers/crypto/inside-secure/eip93/eip93-common.c:668:43: sparse: sparse: cast to restricted __be32 >> drivers/crypto/inside-secure/eip93/eip93-common.c:811:38: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] @@ got restricted __be32 [usertype] @@
drivers/crypto/inside-secure/eip93/eip93-common.c:811:38: sparse: expected unsigned int [usertype]
drivers/crypto/inside-secure/eip93/eip93-common.c:811:38: sparse: got restricted __be32 [usertype]
drivers/crypto/inside-secure/eip93/eip93-common.c:812:38: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] @@ got restricted __be32 [usertype] @@
drivers/crypto/inside-secure/eip93/eip93-common.c:812:38: sparse: expected unsigned int [usertype]
drivers/crypto/inside-secure/eip93/eip93-common.c:812:38: sparse: got restricted __be32 [usertype]
drivers/crypto/inside-secure/eip93/eip93-common.c:101:5: sparse: sparse: context imbalance in 'eip93_put_descriptor' - wrong count at exit drivers/crypto/inside-secure/eip93/eip93-common.c:127:6: sparse: sparse: context imbalance in 'eip93_get_descriptor' - wrong count at exit
vim +423 drivers/crypto/inside-secure/eip93/eip93-hash.c
396
397 void eip93_hash_handle_result(struct crypto_async_request *async, int err)
398 {
399 struct ahash_request *req = ahash_request_cast(async);
400 struct eip93_hash_reqctx *rctx = ahash_request_ctx(req);
401 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
402 struct eip93_hash_ctx *ctx = crypto_ahash_ctx(ahash);
403 int digestsize = crypto_ahash_digestsize(ahash);
404 struct sa_state *sa_state = rctx->sa_state;
405 int i;
406
407 /* Unmap and sync sa_state for host */
408 dma_unmap_single(rctx->mtk->dev, rctx->sa_state_base,
409 sizeof(*sa_state), DMA_FROM_DEVICE);
410
411 /*
412 * With no_finalize assume SHA256_DIGEST_SIZE buffer is passed.
413 * This is to handle SHA224 that have a 32 byte intermediate digest.
414 */
415 if (rctx->no_finalize)
416 digestsize = SHA256_DIGEST_SIZE;
417
418 /* bytes needs to be swapped for req->result */
419 if (!IS_HASH_MD5(ctx->flags)) {
420 for (i = 0; i < digestsize / sizeof(u32); i++) {
421 u32 *digest = (u32 *)sa_state->state_i_digest;
422
> 423 digest[i] = be32_to_cpu(digest[i]);
424 }
425 }
426
427 memcpy(req->result, sa_state->state_i_digest, digestsize);
428
429 kfree(sa_state);
430 eip93_hash_free_data_blocks(req);
431 eip93_hash_free_sa_record(req);
432
433 ahash_request_complete(req, err);
434 }
435
436 static int eip93_hash_final(struct ahash_request *req)
437 {
438 struct eip93_hash_reqctx *rctx = ahash_request_ctx(req);
439 struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
440 struct eip93_hash_ctx *ctx = crypto_ahash_ctx(ahash);
441 struct crypto_async_request *async = &req->base;
442 struct eip93_device *mtk = rctx->mtk;
443 struct mkt_hash_block *block;
444 int ret;
445
446 /* EIP93 can't handle zero bytes hash */
447 if (!rctx->len && !IS_HMAC(ctx->flags)) {
448 switch ((ctx->flags & EIP93_HASH_MASK)) {
449 case EIP93_HASH_SHA256:
450 memcpy(req->result, sha256_zero_message_hash,
451 SHA256_DIGEST_SIZE);
452 break;
453 case EIP93_HASH_SHA224:
454 memcpy(req->result, sha224_zero_message_hash,
455 SHA224_DIGEST_SIZE);
456 break;
457 case EIP93_HASH_SHA1:
458 memcpy(req->result, sha1_zero_message_hash,
459 SHA1_DIGEST_SIZE);
460 break;
461 case EIP93_HASH_MD5:
462 memcpy(req->result, md5_zero_message_hash,
463 MD5_DIGEST_SIZE);
464 break;
465 default: /* Impossible */
466 return -EINVAL;
467 }
468
469 eip93_hash_free_sa_state(req);
470 eip93_hash_free_sa_record(req);
471
472 return 0;
473 }
474
475 /* Send last block */
476 block = list_first_entry(&rctx->blocks, struct mkt_hash_block, list);
477
478 block->data_dma = dma_map_single(mtk->dev, block->data,
479 SHA256_BLOCK_SIZE, DMA_TO_DEVICE);
480 ret = dma_mapping_error(mtk->dev, block->data_dma);
481 if (ret)
482 return ret;
483
484 eip93_send_hash_req(async, block->data_dma,
485 SHA256_BLOCK_SIZE - rctx->left_last,
486 true);
487
488 return -EINPROGRESS;
489 }
490
491 static int eip93_hash_finup(struct ahash_request *req)
492 {
493 int ret;
494
495 ret = eip93_hash_update(req);
496 if (ret)
497 return ret;
498
499 return eip93_hash_final(req);
500 }
501
502 static int eip93_hash_hmac_setkey(struct crypto_ahash *ahash, const u8 *key,
503 u32 keylen)
504 {
505 unsigned int digestsize = crypto_ahash_digestsize(ahash);
506 struct crypto_tfm *tfm = crypto_ahash_tfm(ahash);
507 struct eip93_hash_ctx *ctx = crypto_tfm_ctx(tfm);
508 struct crypto_ahash *ahash_tfm;
509 struct eip93_hash_reqctx *rctx;
510 struct scatterlist sg[1];
511 struct ahash_request *req;
512 DECLARE_CRYPTO_WAIT(wait);
513 const char *alg_name;
514 int i, ret = 0;
515 u8 *opad;
516
517 switch ((ctx->flags & EIP93_HASH_MASK)) {
518 case EIP93_HASH_SHA256:
519 alg_name = "sha256-eip93";
520 break;
521 case EIP93_HASH_SHA224:
522 alg_name = "sha224-eip93";
523 break;
524 case EIP93_HASH_SHA1:
525 alg_name = "sha1-eip93";
526 break;
527 case EIP93_HASH_MD5:
528 alg_name = "md5-eip93";
529 break;
530 default: /* Impossible */
531 return -EINVAL;
532 }
533
534 ahash_tfm = crypto_alloc_ahash(alg_name, 0, 0);
535 if (IS_ERR(ahash_tfm))
536 return PTR_ERR(ahash_tfm);
537
538 req = ahash_request_alloc(ahash_tfm, GFP_KERNEL);
539 if (!req) {
540 ret = -ENOMEM;
541 goto err_ahash;
542 }
543
544 opad = kzalloc(SHA256_BLOCK_SIZE, GFP_KERNEL);
545 if (!opad) {
546 ret = -ENOMEM;
547 goto err_req;
548 }
549
550 rctx = ahash_request_ctx(req);
551 crypto_init_wait(&wait);
552 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
553 crypto_req_done, &wait);
554
555 /* Hash the key if > SHA256_BLOCK_SIZE */
556 if (keylen > SHA256_BLOCK_SIZE) {
557 sg_init_one(&sg[0], key, keylen);
558
559 ahash_request_set_crypt(req, sg, ctx->ipad, keylen);
560 ret = crypto_wait_req(crypto_ahash_digest(req), &wait);
561
562 keylen = digestsize;
563 } else {
564 memcpy(ctx->ipad, key, keylen);
565 }
566
567 /* Copy to opad */
568 memset(ctx->ipad + keylen, 0, SHA256_BLOCK_SIZE - keylen);
569 memcpy(opad, ctx->ipad, SHA256_BLOCK_SIZE);
570
571 /* Pad with HMAC constants */
572 for (i = 0; i < SHA256_BLOCK_SIZE; i++) {
573 ctx->ipad[i] ^= HMAC_IPAD_VALUE;
574 opad[i] ^= HMAC_OPAD_VALUE;
575 }
576
577 sg_init_one(&sg[0], opad, SHA256_BLOCK_SIZE);
578
579 /* Hash opad */
580 ahash_request_set_crypt(req, sg, ctx->opad, SHA256_BLOCK_SIZE);
581 ret = crypto_ahash_init(req);
582 if (ret)
583 goto exit;
584
585 /* Disable HASH_FINALIZE for opad hash */
586 rctx->no_finalize = true;
587
588 ret = crypto_wait_req(crypto_ahash_finup(req), &wait);
589 if (ret)
590 goto exit;
591
592 if (!IS_HASH_MD5(ctx->flags)) {
593 u32 *opad_hash = (u32 *)ctx->opad;
594
595 for (i = 0; i < SHA256_DIGEST_SIZE / sizeof(u32); i++)
> 596 opad_hash[i] = cpu_to_be32(opad_hash[i]); 597 }
598
599 exit:
600 kfree(opad);
601 err_req:
602 ahash_request_free(req);
603 err_ahash:
604 crypto_free_ahash(ahash_tfm);
605
606 return ret;
607 }
608
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v4 3/3] crypto: Add Mediatek EIP-93 crypto engine support
In reply to Christian MarangiHi Christian,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-crypto-Add-Inside-Secure-SafeXcel-EIP-93-crypto-engine/20241025-175032 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master patch link: https://lore.kernel.org/r/20241025094734.1614-3-ansuelsmth%40gmail.com patch subject: [PATCH v4 3/3] crypto: Add Mediatek EIP-93 crypto engine support config: csky-randconfig-r071-20241028 (https://download.01.org/0day-ci/archive/20241028/[email protected]/config) compiler: csky-linux-gcc (GCC) 14.1.0
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]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
New smatch warnings:drivers/crypto/inside-secure/eip93/eip93-cipher.c:118 eip93_skcipher_setkey() error: uninitialized symbol 'ret'. drivers/crypto/inside-secure/eip93/eip93-aead.c:125 eip93_aead_setkey() error: uninitialized symbol 'ret'. drivers/crypto/inside-secure/eip93/eip93-hash.c:26 eip93_hash_free_data_blocks() error: dereferencing freed memory 'block' drivers/crypto/inside-secure/eip93/eip93-hash.c:162 _eip93_hash_init() error: uninitialized symbol 'sa_record_hmac'.
Old smatch warnings:drivers/crypto/inside-secure/eip93/eip93-hash.c:285 eip93_send_hash_req() error: uninitialized symbol 'crypto_async_idr'.
vim +/ret +118 drivers/crypto/inside-secure/eip93/eip93-cipher.c
883ad7684f17d2 Christian Marangi 2024-10-25 78 static int eip93_skcipher_setkey(struct crypto_skcipher *ctfm, const u8 *key,
883ad7684f17d2 Christian Marangi 2024-10-25 79 unsigned int len)
883ad7684f17d2 Christian Marangi 2024-10-25 80 {
883ad7684f17d2 Christian Marangi 2024-10-25 81 struct crypto_tfm *tfm = crypto_skcipher_tfm(ctfm);
883ad7684f17d2 Christian Marangi 2024-10-25 82 struct eip93_crypto_ctx *ctx = crypto_tfm_ctx(tfm);
883ad7684f17d2 Christian Marangi 2024-10-25 83 struct eip93_alg_template *tmpl = container_of(tfm->__crt_alg,
883ad7684f17d2 Christian Marangi 2024-10-25 84 struct eip93_alg_template,
883ad7684f17d2 Christian Marangi 2024-10-25 85 alg.skcipher.base);
883ad7684f17d2 Christian Marangi 2024-10-25 86 struct sa_record *sa_record = ctx->sa_record;
883ad7684f17d2 Christian Marangi 2024-10-25 87 unsigned int keylen = len;
883ad7684f17d2 Christian Marangi 2024-10-25 88 u32 flags = tmpl->flags;
883ad7684f17d2 Christian Marangi 2024-10-25 89 u32 nonce = 0;
883ad7684f17d2 Christian Marangi 2024-10-25 90 int ret;
883ad7684f17d2 Christian Marangi 2024-10-25 91
883ad7684f17d2 Christian Marangi 2024-10-25 92 if (!key || !keylen)
883ad7684f17d2 Christian Marangi 2024-10-25 93 return -EINVAL;
883ad7684f17d2 Christian Marangi 2024-10-25 94
883ad7684f17d2 Christian Marangi 2024-10-25 95 if (IS_RFC3686(flags)) {
883ad7684f17d2 Christian Marangi 2024-10-25 96 if (len < CTR_RFC3686_NONCE_SIZE)
883ad7684f17d2 Christian Marangi 2024-10-25 97 return -EINVAL;
883ad7684f17d2 Christian Marangi 2024-10-25 98
883ad7684f17d2 Christian Marangi 2024-10-25 99 keylen = len - CTR_RFC3686_NONCE_SIZE;
883ad7684f17d2 Christian Marangi 2024-10-25 100 memcpy(&nonce, key + keylen, CTR_RFC3686_NONCE_SIZE);
883ad7684f17d2 Christian Marangi 2024-10-25 101 }
883ad7684f17d2 Christian Marangi 2024-10-25 102
883ad7684f17d2 Christian Marangi 2024-10-25 103 if (flags & EIP93_ALG_DES) {
883ad7684f17d2 Christian Marangi 2024-10-25 104 ctx->blksize = DES_BLOCK_SIZE;
883ad7684f17d2 Christian Marangi 2024-10-25 105 ret = verify_skcipher_des_key(ctfm, key);
883ad7684f17d2 Christian Marangi 2024-10-25 106 }
883ad7684f17d2 Christian Marangi 2024-10-25 107 if (flags & EIP93_ALG_3DES) {
883ad7684f17d2 Christian Marangi 2024-10-25 108 ctx->blksize = DES3_EDE_BLOCK_SIZE;
883ad7684f17d2 Christian Marangi 2024-10-25 109 ret = verify_skcipher_des3_key(ctfm, key);
883ad7684f17d2 Christian Marangi 2024-10-25 110 }
883ad7684f17d2 Christian Marangi 2024-10-25 111
883ad7684f17d2 Christian Marangi 2024-10-25 112 if (flags & EIP93_ALG_AES) {
883ad7684f17d2 Christian Marangi 2024-10-25 113 struct crypto_aes_ctx aes;
883ad7684f17d2 Christian Marangi 2024-10-25 114
883ad7684f17d2 Christian Marangi 2024-10-25 115 ctx->blksize = AES_BLOCK_SIZE;
883ad7684f17d2 Christian Marangi 2024-10-25 116 ret = aes_expandkey(&aes, key, keylen);
883ad7684f17d2 Christian Marangi 2024-10-25 117 }What about if none the flags are set?
883ad7684f17d2 Christian Marangi 2024-10-25 @118 if (ret)
883ad7684f17d2 Christian Marangi 2024-10-25 119 return ret; 883ad7684f17d2 Christian Marangi 2024-10-25 120 883ad7684f17d2 Christian Marangi 2024-10-25 121 eip93_set_sa_record(sa_record, keylen, flags); 883ad7684f17d2 Christian Marangi 2024-10-25 122 883ad7684f17d2 Christian Marangi 2024-10-25 123 memcpy(sa_record->sa_key, key, keylen); 883ad7684f17d2 Christian Marangi 2024-10-25 124 ctx->sa_nonce = nonce; 883ad7684f17d2 Christian Marangi 2024-10-25 125 sa_record->sa_nonce = nonce; 883ad7684f17d2 Christian Marangi 2024-10-25 126 883ad7684f17d2 Christian Marangi 2024-10-25 127 return 0; 883ad7684f17d2 Christian Marangi 2024-10-25 128 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v4 3/3] crypto: Add Mediatek EIP-93 crypto engine support
Quoted 1 line · Dan Carpenter
drivers/crypto/inside-secure/eip93/eip93-hash.c:162_eip93_hash_init()error: uninitialized symbol 'sa_record_hmac'.
This one is a false positive. Smatch doesn't understand bit flags very well.
regards,
dan carpenter
Re: [PATCH v4 3/3] crypto: Add Mediatek EIP-93 crypto engine support
In reply to Christian Marangidrivers/crypto/inside-secure/eip93/eip93-hash.c line 29
Quoted 9 lines · Christian Marangi
drivers/crypto/inside-secure/eip93/eip93-hash.c new file +9
-0+static void eip93_hash_free_data_blocks (struct ahash_request *req) +{ +struct eip93_hash_reqctx *rctx =ahash_request_ctx (req); +struct mkt_hash_block *block; + +list_for_each_entry (block, &rctx->blocks, list) { +dma_unmap_single (rctx->mtk->dev, block->data_dma, +SHA256_BLOCK_SIZE ,DMA_TO_DEVICE ); +kfree (block);
You need to use list_for_each_entry_safe() to avoid a use after free.
Review
Quoted 2 lines
(quoted diff) +2
-0+ } +}
regards,
dan carpenter
Quoted 3 lines · Christian Marangi
Extend guard APIs with missing raw/spinlock_bh variants.
Signed-off-by Christian Marangi <[email protected]>
Feel free to take this through whatever tree the rest of the patches are targeted at. I don't think I've seen conflicting 'demand' so far.
Quoted 43 lines
---
Changes v4:
- Out of RFC
Changes v2:
- Add this patchinclude/linux/spinlock.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)include/linux/spinlock.h +13
-0@@ -548,6 +548,12 @@ DEFINE_LOCK_GUARD_1(raw_spinlock_irq, raw_spinlock_t, DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq(_T->lock)) +DEFINE_LOCK_GUARD_1 (raw_spinlock_bh, raw_spinlock_t, +raw_spin_lock_bh (_T->lock), + raw_spin_unlock_bh(_T->lock)) + +DEFINE_LOCK_GUARD_1_COND(raw_spinlock_bh, _try, raw_spin_trylock_bh(_T->lock)) + DEFINE_LOCK_GUARD_1(raw_spinlock_irqsave, raw_spinlock_t, raw_spin_lock_irqsave(_T->lock, _T->flags), raw_spin_unlock_irqrestore(_T->lock, _T->flags),@@ -569,6 +575,13 @@ DEFINE_LOCK_GUARD_1(spinlock_irq, spinlock_t,DEFINE_LOCK_GUARD_1_COND (spinlock_irq, _try, spin_trylock_irq(_T->lock)) +DEFINE_LOCK_GUARD_1 (spinlock_bh, spinlock_t, +spin_lock_bh (_T->lock), + spin_unlock_bh(_T->lock)) + +DEFINE_LOCK_GUARD_1_COND (spinlock_bh, _try, + spin_trylock_bh(_T->lock)) + DEFINE_LOCK_GUARD_1(spinlock_irqsave, spinlock_t, spin_lock_irqsave(_T->lock, _T->flags), spin_unlock_irqrestore(_T->lock, _T->flags),Signature · 1 line
2.45.2