* [PATCH 0/3] crypto: ccree: add CryptoCell 713 baseline support
@ 2018-10-16 13:35 Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 1/3] crypto: ccree: add support for CryptoCell 713 Gilad Ben-Yossef
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Gilad Ben-Yossef @ 2018-10-16 13:35 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Rob Herring, Mark Rutland
Cc: Ofir Drang, Yael Chemla, linux-crypto, devicetree, linux-kernel
Add first batch of patches for support of Arm TrustZone CryptoCell 713.
Gilad Ben-Yossef (3):
crypto: ccree: add support for CryptoCell 713
crypto: ccree: add dt bindings for ccree 713
crypto: ccree: add SM4 support
.../devicetree/bindings/crypto/arm-cryptocell.txt | 5 +-
drivers/crypto/Kconfig | 3 +-
drivers/crypto/ccree/cc_cipher.c | 66 ++++++++++++++++++++++
drivers/crypto/ccree/cc_driver.c | 23 +++++---
drivers/crypto/ccree/cc_driver.h | 5 +-
drivers/crypto/ccree/cc_hw_queue_defs.h | 3 +
6 files changed, 92 insertions(+), 13 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] crypto: ccree: add support for CryptoCell 713
2018-10-16 13:35 [PATCH 0/3] crypto: ccree: add CryptoCell 713 baseline support Gilad Ben-Yossef
@ 2018-10-16 13:35 ` Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713 Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 3/3] crypto: ccree: add SM4 support Gilad Ben-Yossef
2 siblings, 0 replies; 7+ messages in thread
From: Gilad Ben-Yossef @ 2018-10-16 13:35 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Rob Herring, Mark Rutland
Cc: Ofir Drang, Yael Chemla, linux-crypto, devicetree, linux-kernel
Add support for Arm TrustZone CryptoCell 713.
Note that this patch just enables using a 713 in backwards compatible mode
to 712. Newer 713 specific features will follow.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
drivers/crypto/Kconfig | 2 +-
drivers/crypto/ccree/cc_driver.c | 23 +++++++++++++++--------
drivers/crypto/ccree/cc_driver.h | 5 +++--
3 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index a8c4ce0..bea4de6 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -754,7 +754,7 @@ config CRYPTO_DEV_CCREE
help
Say 'Y' to enable a driver for the REE interface of the Arm
TrustZone CryptoCell family of processors. Currently the
- CryptoCell 712, 710 and 630 are supported.
+ CryptoCell 713, 712, 710 and 630 are supported.
Choose this if you wish to use hardware acceleration of
cryptographic operations on the system REE.
If unsure say Y.
diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c
index 1ff229c..630c598 100644
--- a/drivers/crypto/ccree/cc_driver.c
+++ b/drivers/crypto/ccree/cc_driver.c
@@ -43,6 +43,10 @@ struct cc_hw_data {
/* Hardware revisions defs. */
+static const struct cc_hw_data cc713_hw = {
+ .name = "713", .rev = CC_HW_REV_713
+};
+
static const struct cc_hw_data cc712_hw = {
.name = "712", .rev = CC_HW_REV_712, .sig = 0xDCC71200U
};
@@ -56,6 +60,7 @@ static const struct cc_hw_data cc630p_hw = {
};
static const struct of_device_id arm_ccree_dev_of_match[] = {
+ { .compatible = "arm,cryptocell-713-ree", .data = &cc713_hw },
{ .compatible = "arm,cryptocell-712-ree", .data = &cc712_hw },
{ .compatible = "arm,cryptocell-710-ree", .data = &cc710_hw },
{ .compatible = "arm,cryptocell-630p-ree", .data = &cc630p_hw },
@@ -297,15 +302,17 @@ static int init_cc_resources(struct platform_device *plat_dev)
return rc;
}
- /* Verify correct mapping */
- signature_val = cc_ioread(new_drvdata, new_drvdata->sig_offset);
- if (signature_val != hw_rev->sig) {
- dev_err(dev, "Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n",
- signature_val, hw_rev->sig);
- rc = -EINVAL;
- goto post_clk_err;
+ if (hw_rev->rev <= CC_HW_REV_712) {
+ /* Verify correct mapping */
+ signature_val = cc_ioread(new_drvdata, new_drvdata->sig_offset);
+ if (signature_val != hw_rev->sig) {
+ dev_err(dev, "Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n",
+ signature_val, hw_rev->sig);
+ rc = -EINVAL;
+ goto post_clk_err;
+ }
+ dev_dbg(dev, "CC SIGNATURE=0x%08X\n", signature_val);
}
- dev_dbg(dev, "CC SIGNATURE=0x%08X\n", signature_val);
/* Display HW versions */
dev_info(dev, "ARM CryptoCell %s Driver: HW version 0x%08X, Driver version %s\n",
diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h
index d608a4f..a06e5c9 100644
--- a/drivers/crypto/ccree/cc_driver.h
+++ b/drivers/crypto/ccree/cc_driver.h
@@ -36,12 +36,13 @@
extern bool cc_dump_desc;
extern bool cc_dump_bytes;
-#define DRV_MODULE_VERSION "4.0"
+#define DRV_MODULE_VERSION "5.0"
enum cc_hw_rev {
CC_HW_REV_630 = 630,
CC_HW_REV_710 = 710,
- CC_HW_REV_712 = 712
+ CC_HW_REV_712 = 712,
+ CC_HW_REV_713 = 713
};
#define CC_COHERENT_CACHE_PARAMS 0xEEE
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713
2018-10-16 13:35 [PATCH 0/3] crypto: ccree: add CryptoCell 713 baseline support Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 1/3] crypto: ccree: add support for CryptoCell 713 Gilad Ben-Yossef
@ 2018-10-16 13:35 ` Gilad Ben-Yossef
2018-10-25 0:12 ` Rob Herring
2018-10-16 13:35 ` [PATCH 3/3] crypto: ccree: add SM4 support Gilad Ben-Yossef
2 siblings, 1 reply; 7+ messages in thread
From: Gilad Ben-Yossef @ 2018-10-16 13:35 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Rob Herring, Mark Rutland
Cc: Ofir Drang, Yael Chemla, linux-crypto, devicetree, linux-kernel
Add device tree bindings associating Arm TrustZone CryptoCell 713 with the
ccree driver.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
Documentation/devicetree/bindings/crypto/arm-cryptocell.txt | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
index 999fb2a..880de07 100644
--- a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
+++ b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
@@ -1,8 +1,9 @@
Arm TrustZone CryptoCell cryptographic engine
Required properties:
-- compatible: Should be one of: "arm,cryptocell-712-ree",
- "arm,cryptocell-710-ree" or "arm,cryptocell-630p-ree".
+- compatible: Should be one of: "arm,cryptocell-713-ree",
+ "arm,cryptocell-712-ree", "arm,cryptocell-710-ree" or
+ "arm,cryptocell-630p-ree".
- reg: Base physical address of the engine and length of memory mapped region.
- interrupts: Interrupt number for the device.
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] crypto: ccree: add SM4 support
2018-10-16 13:35 [PATCH 0/3] crypto: ccree: add CryptoCell 713 baseline support Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 1/3] crypto: ccree: add support for CryptoCell 713 Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713 Gilad Ben-Yossef
@ 2018-10-16 13:35 ` Gilad Ben-Yossef
2 siblings, 0 replies; 7+ messages in thread
From: Gilad Ben-Yossef @ 2018-10-16 13:35 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Rob Herring, Mark Rutland
Cc: Ofir Drang, Yael Chemla, linux-crypto, devicetree, linux-kernel
Add support for SM4 cipher in CryptoCell 713.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
---
drivers/crypto/Kconfig | 1 +
drivers/crypto/ccree/cc_cipher.c | 66 +++++++++++++++++++++++++++++++++
drivers/crypto/ccree/cc_hw_queue_defs.h | 3 ++
3 files changed, 70 insertions(+)
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index bea4de6..c7e6f5d 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -751,6 +751,7 @@ config CRYPTO_DEV_CCREE
select CRYPTO_ECB
select CRYPTO_CTR
select CRYPTO_XTS
+ select CRYPTO_SM4
help
Say 'Y' to enable a driver for the REE interface of the Arm
TrustZone CryptoCell family of processors. Currently the
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
index 7623b299..989e70f 100644
--- a/drivers/crypto/ccree/cc_cipher.c
+++ b/drivers/crypto/ccree/cc_cipher.c
@@ -7,6 +7,7 @@
#include <crypto/internal/skcipher.h>
#include <crypto/des.h>
#include <crypto/xts.h>
+#include <crypto/sm4.h>
#include <crypto/scatterwalk.h>
#include "cc_driver.h"
@@ -83,6 +84,9 @@ static int validate_keys_sizes(struct cc_cipher_ctx *ctx_p, u32 size)
if (size == DES3_EDE_KEY_SIZE || size == DES_KEY_SIZE)
return 0;
break;
+ case S_DIN_to_SM4:
+ if (size == SM4_KEY_SIZE)
+ return 0;
default:
break;
}
@@ -122,6 +126,17 @@ static int validate_data_size(struct cc_cipher_ctx *ctx_p,
if (IS_ALIGNED(size, DES_BLOCK_SIZE))
return 0;
break;
+ case S_DIN_to_SM4:
+ switch (ctx_p->cipher_mode) {
+ case DRV_CIPHER_CTR:
+ return 0;
+ case DRV_CIPHER_ECB:
+ case DRV_CIPHER_CBC:
+ if (IS_ALIGNED(size, SM4_BLOCK_SIZE))
+ return 0;
+ default:
+ break;
+ }
default:
break;
}
@@ -522,6 +537,9 @@ static void cc_setup_cipher_data(struct crypto_tfm *tfm,
case S_DIN_to_DES:
flow_mode = DIN_DES_DOUT;
break;
+ case S_DIN_to_SM4:
+ flow_mode = DIN_SM4_DOUT;
+ break;
default:
dev_err(dev, "invalid flow mode, flow_mode = %d\n", flow_mode);
return;
@@ -1324,6 +1342,54 @@ static const struct cc_alg_template skcipher_algs[] = {
.flow_mode = S_DIN_to_DES,
.min_hw_rev = CC_HW_REV_630,
},
+ {
+ .name = "cbc(sm4)",
+ .driver_name = "cbc-sm4-ccree",
+ .blocksize = SM4_BLOCK_SIZE,
+ .template_skcipher = {
+ .setkey = cc_cipher_setkey,
+ .encrypt = cc_cipher_encrypt,
+ .decrypt = cc_cipher_decrypt,
+ .min_keysize = SM4_KEY_SIZE,
+ .max_keysize = SM4_KEY_SIZE,
+ .ivsize = SM4_BLOCK_SIZE,
+ },
+ .cipher_mode = DRV_CIPHER_CBC,
+ .flow_mode = S_DIN_to_SM4,
+ .min_hw_rev = CC_HW_REV_713,
+ },
+ {
+ .name = "ecb(sm4)",
+ .driver_name = "ecb-sm4-ccree",
+ .blocksize = SM4_BLOCK_SIZE,
+ .template_skcipher = {
+ .setkey = cc_cipher_setkey,
+ .encrypt = cc_cipher_encrypt,
+ .decrypt = cc_cipher_decrypt,
+ .min_keysize = SM4_KEY_SIZE,
+ .max_keysize = SM4_KEY_SIZE,
+ .ivsize = 0,
+ },
+ .cipher_mode = DRV_CIPHER_ECB,
+ .flow_mode = S_DIN_to_SM4,
+ .min_hw_rev = CC_HW_REV_713,
+ },
+ {
+ .name = "ctr(sm4)",
+ .driver_name = "ctr-sm4-ccree",
+ .blocksize = SM4_BLOCK_SIZE,
+ .template_skcipher = {
+ .setkey = cc_cipher_setkey,
+ .encrypt = cc_cipher_encrypt,
+ .decrypt = cc_cipher_decrypt,
+ .min_keysize = SM4_KEY_SIZE,
+ .max_keysize = SM4_KEY_SIZE,
+ .ivsize = SM4_BLOCK_SIZE,
+ },
+ .cipher_mode = DRV_CIPHER_CTR,
+ .flow_mode = S_DIN_to_SM4,
+ .min_hw_rev = CC_HW_REV_713,
+ },
};
static struct cc_crypto_alg *cc_create_alg(const struct cc_alg_template *tmpl,
diff --git a/drivers/crypto/ccree/cc_hw_queue_defs.h b/drivers/crypto/ccree/cc_hw_queue_defs.h
index a091ae5..6bd1922 100644
--- a/drivers/crypto/ccree/cc_hw_queue_defs.h
+++ b/drivers/crypto/ccree/cc_hw_queue_defs.h
@@ -107,6 +107,7 @@ enum cc_flow_mode {
AES_to_AES_to_HASH_and_DOUT = 13,
AES_to_AES_to_HASH = 14,
AES_to_HASH_and_AES = 15,
+ DIN_SM4_DOUT = 16,
DIN_AES_AESMAC = 17,
HASH_to_DOUT = 18,
/* setup flows */
@@ -114,9 +115,11 @@ enum cc_flow_mode {
S_DIN_to_AES2 = 33,
S_DIN_to_DES = 34,
S_DIN_to_RC4 = 35,
+ S_DIN_to_SM4 = 36,
S_DIN_to_HASH = 37,
S_AES_to_DOUT = 38,
S_AES2_to_DOUT = 39,
+ S_SM4_to_DOUT = 40,
S_RC4_to_DOUT = 41,
S_DES_to_DOUT = 42,
S_HASH_to_DOUT = 43,
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713
2018-10-16 13:35 ` [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713 Gilad Ben-Yossef
@ 2018-10-25 0:12 ` Rob Herring
2018-10-29 9:49 ` Gilad Ben-Yossef
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2018-10-25 0:12 UTC (permalink / raw)
To: Gilad Ben-Yossef
Cc: Herbert Xu, David S. Miller, Mark Rutland, Ofir Drang,
Yael Chemla, linux-crypto, devicetree, linux-kernel
On Tue, Oct 16, 2018 at 02:35:32PM +0100, Gilad Ben-Yossef wrote:
> Add device tree bindings associating Arm TrustZone CryptoCell 713 with the
> ccree driver.
"dt-bindings: crypto: ..." for the subject.
>
> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> ---
> Documentation/devicetree/bindings/crypto/arm-cryptocell.txt | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> index 999fb2a..880de07 100644
> --- a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> +++ b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> @@ -1,8 +1,9 @@
> Arm TrustZone CryptoCell cryptographic engine
>
> Required properties:
> -- compatible: Should be one of: "arm,cryptocell-712-ree",
> - "arm,cryptocell-710-ree" or "arm,cryptocell-630p-ree".
> +- compatible: Should be one of: "arm,cryptocell-713-ree",
> + "arm,cryptocell-712-ree", "arm,cryptocell-710-ree" or
> + "arm,cryptocell-630p-ree".
Please format 1 per line.
> - reg: Base physical address of the engine and length of memory mapped region.
> - interrupts: Interrupt number for the device.
>
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713
@ 2018-10-29 9:49 ` Gilad Ben-Yossef
0 siblings, 0 replies; 7+ messages in thread
From: Gilad Ben-Yossef @ 2018-10-29 9:49 UTC (permalink / raw)
To: robh
Cc: Herbert Xu, David Miller, Mark Rutland, Ofir Drang, Yael Chemla,
Linux Crypto Mailing List,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Linux kernel mailing list
On Thu, Oct 25, 2018 at 3:12 AM Rob Herring <robh@kernel.org> wrote:
>
> On Tue, Oct 16, 2018 at 02:35:32PM +0100, Gilad Ben-Yossef wrote:
> > Add device tree bindings associating Arm TrustZone CryptoCell 713 with the
> > ccree driver.
>
> "dt-bindings: crypto: ..." for the subject.
> >
> > Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> > ---
> > Documentation/devicetree/bindings/crypto/arm-cryptocell.txt | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> > index 999fb2a..880de07 100644
> > --- a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> > +++ b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> > @@ -1,8 +1,9 @@
> > Arm TrustZone CryptoCell cryptographic engine
> >
> > Required properties:
> > -- compatible: Should be one of: "arm,cryptocell-712-ree",
> > - "arm,cryptocell-710-ree" or "arm,cryptocell-630p-ree".
> > +- compatible: Should be one of: "arm,cryptocell-713-ree",
> > + "arm,cryptocell-712-ree", "arm,cryptocell-710-ree" or
> > + "arm,cryptocell-630p-ree".
>
> Please format 1 per line.
>
Will do.
Thanks for the review.
I will send a corrected patch.
Gilad
--
Gilad Ben-Yossef
Chief Coffee Drinker
values of β will give rise to dom!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713
@ 2018-10-29 9:49 ` Gilad Ben-Yossef
0 siblings, 0 replies; 7+ messages in thread
From: Gilad Ben-Yossef @ 2018-10-29 9:49 UTC (permalink / raw)
To: robh
Cc: Herbert Xu, David Miller, Mark Rutland, Ofir Drang, Yael Chemla,
Linux Crypto Mailing List,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Linux kernel mailing list
On Thu, Oct 25, 2018 at 3:12 AM Rob Herring <robh@kernel.org> wrote:
>
> On Tue, Oct 16, 2018 at 02:35:32PM +0100, Gilad Ben-Yossef wrote:
> > Add device tree bindings associating Arm TrustZone CryptoCell 713 with the
> > ccree driver.
>
> "dt-bindings: crypto: ..." for the subject.
> >
> > Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> > ---
> > Documentation/devicetree/bindings/crypto/arm-cryptocell.txt | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> > index 999fb2a..880de07 100644
> > --- a/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> > +++ b/Documentation/devicetree/bindings/crypto/arm-cryptocell.txt
> > @@ -1,8 +1,9 @@
> > Arm TrustZone CryptoCell cryptographic engine
> >
> > Required properties:
> > -- compatible: Should be one of: "arm,cryptocell-712-ree",
> > - "arm,cryptocell-710-ree" or "arm,cryptocell-630p-ree".
> > +- compatible: Should be one of: "arm,cryptocell-713-ree",
> > + "arm,cryptocell-712-ree", "arm,cryptocell-710-ree" or
> > + "arm,cryptocell-630p-ree".
>
> Please format 1 per line.
>
Will do.
Thanks for the review.
I will send a corrected patch.
Gilad
--
Gilad Ben-Yossef
Chief Coffee Drinker
values of β will give rise to dom!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-10-29 18:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-16 13:35 [PATCH 0/3] crypto: ccree: add CryptoCell 713 baseline support Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 1/3] crypto: ccree: add support for CryptoCell 713 Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 2/3] crypto: ccree: add dt bindings for ccree 713 Gilad Ben-Yossef
2018-10-25 0:12 ` Rob Herring
2018-10-29 9:49 ` Gilad Ben-Yossef
2018-10-29 9:49 ` Gilad Ben-Yossef
2018-10-16 13:35 ` [PATCH 3/3] crypto: ccree: add SM4 support Gilad Ben-Yossef
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.