linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] crypto: caam - updates for 5.9
@ 2020-07-22 12:14 Horia Geantă
  2020-07-22 12:14 ` [PATCH 1/7] crypto: caam - remove deadcode on 32-bit platforms Horia Geantă
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

Hi Herbert,

This patch set contains a few caam driver updates.
The fixes are minor and thus ok to go through the cryptodev tree.

Dan Douglass (1):
  crypto: caam/jr - remove incorrect reference to caam_jr_register()

Franck LENORMAND (1):
  crypto: caam - remove deadcode on 32-bit platforms

Horia Geantă (5):
  crypto: caam/qi2 - fix error reporting for caam_hash_alloc
  crypto: caam/qi2 - create ahash shared descriptors only once
  crypto: caam - silence .setkey in case of bad key length
  crypto: caam - add more RNG hw error codes
  crypto: caam/qi2 - add module alias

 drivers/crypto/caam/caamalg.c     |  2 +-
 drivers/crypto/caam/caamalg_qi.c  |  2 +-
 drivers/crypto/caam/caamalg_qi2.c | 11 ++++++++---
 drivers/crypto/caam/error.c       |  3 +++
 drivers/crypto/caam/jr.c          |  3 +--
 drivers/crypto/caam/regs.h        | 11 ++++++++---
 6 files changed, 22 insertions(+), 10 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/7] crypto: caam - remove deadcode on 32-bit platforms
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
@ 2020-07-22 12:14 ` Horia Geantă
  2020-07-22 12:14 ` [PATCH 2/7] crypto: caam/qi2 - fix error reporting for caam_hash_alloc Horia Geantă
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

From: Franck LENORMAND <franck.lenormand@nxp.com>

When building on a platform with a 32bit DMA address, taking the
upper 32 bits makes no sense.

Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/regs.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h
index 0f810bc13b2b..af61f3a2c0d4 100644
--- a/drivers/crypto/caam/regs.h
+++ b/drivers/crypto/caam/regs.h
@@ -173,9 +173,14 @@ static inline u64 rd_reg64(void __iomem *reg)
 
 static inline u64 cpu_to_caam_dma64(dma_addr_t value)
 {
-	if (caam_imx)
-		return (((u64)cpu_to_caam32(lower_32_bits(value)) << 32) |
-			 (u64)cpu_to_caam32(upper_32_bits(value)));
+	if (caam_imx) {
+		u64 ret_val = (u64)cpu_to_caam32(lower_32_bits(value)) << 32;
+
+		if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+			ret_val |= (u64)cpu_to_caam32(upper_32_bits(value));
+
+		return ret_val;
+	}
 
 	return cpu_to_caam64(value);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/7] crypto: caam/qi2 - fix error reporting for caam_hash_alloc
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
  2020-07-22 12:14 ` [PATCH 1/7] crypto: caam - remove deadcode on 32-bit platforms Horia Geantă
@ 2020-07-22 12:14 ` Horia Geantă
  2020-07-22 12:14 ` [PATCH 3/7] crypto: caam/qi2 - create ahash shared descriptors only once Horia Geantă
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

Fix error reporting when preparation of an hmac algorithm
for registration fails: print the hmac algorithm name, not the unkeyed
hash algorithm name.

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg_qi2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index 1b0c28675906..811d34eee4f2 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -5238,7 +5238,7 @@ static int dpaa2_caam_probe(struct fsl_mc_device *dpseci_dev)
 		if (IS_ERR(t_alg)) {
 			err = PTR_ERR(t_alg);
 			dev_warn(dev, "%s hash alg allocation failed: %d\n",
-				 alg->driver_name, err);
+				 alg->hmac_driver_name, err);
 			continue;
 		}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/7] crypto: caam/qi2 - create ahash shared descriptors only once
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
  2020-07-22 12:14 ` [PATCH 1/7] crypto: caam - remove deadcode on 32-bit platforms Horia Geantă
  2020-07-22 12:14 ` [PATCH 2/7] crypto: caam/qi2 - fix error reporting for caam_hash_alloc Horia Geantă
@ 2020-07-22 12:14 ` Horia Geantă
  2020-07-22 12:14 ` [PATCH 4/7] crypto: caam - silence .setkey in case of bad key length Horia Geantă
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

For keyed hash algorithms, shared descriptors are currently generated
twice:
-at tfm initialization time, in cra_init() callback
-in setkey() callback

Since it's mandatory to call setkey() for keyed algorithms, drop the
generation in cra_init().

This is similar to the change in caamhash (caam/jr top-level library)
commit 9a2537d0ebc9 ("crypto: caam - create ahash shared descriptors only once")

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg_qi2.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index 811d34eee4f2..1e901344db67 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -4500,7 +4500,11 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
 	crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
 				 sizeof(struct caam_hash_state));
 
-	return ahash_set_sh_desc(ahash);
+	/*
+	 * For keyed hash algorithms shared descriptors
+	 * will be created later in setkey() callback
+	 */
+	return alg->setkey ? 0 : ahash_set_sh_desc(ahash);
 }
 
 static void caam_hash_cra_exit(struct crypto_tfm *tfm)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/7] crypto: caam - silence .setkey in case of bad key length
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
                   ` (2 preceding siblings ...)
  2020-07-22 12:14 ` [PATCH 3/7] crypto: caam/qi2 - create ahash shared descriptors only once Horia Geantă
@ 2020-07-22 12:14 ` Horia Geantă
  2020-07-22 12:14 ` [PATCH 5/7] crypto: caam/jr - remove incorrect reference to caam_jr_register() Horia Geantă
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

In case of bad key length, driver emits "key size mismatch" messages,
but only for xts(aes) algorithms.

Reduce verbosity by making them visible only when debugging.
This way crypto fuzz testing log cleans up a bit.

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg.c     | 2 +-
 drivers/crypto/caam/caamalg_qi.c  | 2 +-
 drivers/crypto/caam/caamalg_qi2.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index e94e7f27f1d0..91feda5b63f6 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -832,7 +832,7 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
 	u32 *desc;
 
 	if (keylen != 2 * AES_MIN_KEY_SIZE  && keylen != 2 * AES_MAX_KEY_SIZE) {
-		dev_err(jrdev, "key size mismatch\n");
+		dev_dbg(jrdev, "key size mismatch\n");
 		return -EINVAL;
 	}
 
diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c
index efe8f15a4a51..bb1c0106a95c 100644
--- a/drivers/crypto/caam/caamalg_qi.c
+++ b/drivers/crypto/caam/caamalg_qi.c
@@ -728,7 +728,7 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
 	int ret = 0;
 
 	if (keylen != 2 * AES_MIN_KEY_SIZE  && keylen != 2 * AES_MAX_KEY_SIZE) {
-		dev_err(jrdev, "key size mismatch\n");
+		dev_dbg(jrdev, "key size mismatch\n");
 		return -EINVAL;
 	}
 
diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index 1e901344db67..700e1d50211f 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -1058,7 +1058,7 @@ static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key,
 	u32 *desc;
 
 	if (keylen != 2 * AES_MIN_KEY_SIZE  && keylen != 2 * AES_MAX_KEY_SIZE) {
-		dev_err(dev, "key size mismatch\n");
+		dev_dbg(dev, "key size mismatch\n");
 		return -EINVAL;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/7] crypto: caam/jr - remove incorrect reference to caam_jr_register()
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
                   ` (3 preceding siblings ...)
  2020-07-22 12:14 ` [PATCH 4/7] crypto: caam - silence .setkey in case of bad key length Horia Geantă
@ 2020-07-22 12:14 ` Horia Geantă
  2020-07-22 12:14 ` [PATCH 6/7] crypto: caam - add more RNG hw error codes Horia Geantă
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

From: Dan Douglass <dan.douglass@nxp.com>

caam_jr_register() function is no longer part of the driver since
commit 6dad41158db6 ("crypto: caam - Remove unused functions from Job Ring")

This patch removes a comment referencing the function.

Signed-off-by: Dan Douglass <dan.douglass@nxp.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/jr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 4af22e7ceb4f..bf6b03b17251 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -339,8 +339,7 @@ EXPORT_SYMBOL(caam_jr_free);
  * caam_jr_enqueue() - Enqueue a job descriptor head. Returns -EINPROGRESS
  * if OK, -ENOSPC if the queue is full, -EIO if it cannot map the caller's
  * descriptor.
- * @dev:  device of the job ring to be used. This device should have
- *        been assigned prior by caam_jr_register().
+ * @dev:  struct device of the job ring to be used
  * @desc: points to a job descriptor that execute our request. All
  *        descriptors (and all referenced data) must be in a DMAable
  *        region, and all data references must be physical addresses
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/7] crypto: caam - add more RNG hw error codes
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
                   ` (4 preceding siblings ...)
  2020-07-22 12:14 ` [PATCH 5/7] crypto: caam/jr - remove incorrect reference to caam_jr_register() Horia Geantă
@ 2020-07-22 12:14 ` Horia Geantă
  2020-07-22 12:25   ` Horia Geantă
  2020-07-22 12:14 ` [PATCH 7/7] crypto: caam/qi2 - add module alias Horia Geantă
  2020-07-31 13:30 ` [PATCH 0/7] crypto: caam - updates for 5.9 Herbert Xu
  7 siblings, 1 reply; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

In some cases, e.g. when TRNG is not properly configured,
the RNG module could issue a "Hardware error" at runtime.

"Continuos check" error is emitted when some of the BISTs fail.

Signed-off-by: Horia Geantă <horia.geanta@freescale.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/error.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c
index 17c6108b6d41..72db90176b1a 100644
--- a/drivers/crypto/caam/error.c
+++ b/drivers/crypto/caam/error.c
@@ -212,6 +212,9 @@ static const char * const rng_err_id_list[] = {
 	"Prediction resistance and test request",
 	"Uninstantiate",
 	"Secure key generation",
+	"",
+	"Hardware error",
+	"Continuous check"
 };
 
 static int report_ccb_status(struct device *jrdev, const u32 status,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/7] crypto: caam/qi2 - add module alias
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
                   ` (5 preceding siblings ...)
  2020-07-22 12:14 ` [PATCH 6/7] crypto: caam - add more RNG hw error codes Horia Geantă
@ 2020-07-22 12:14 ` Horia Geantă
  2020-07-31 13:30 ` [PATCH 0/7] crypto: caam - updates for 5.9 Herbert Xu
  7 siblings, 0 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

Add a module alias, to enable udev-based module autoloading:

$ modinfo -F alias drivers/crypto/caam/dpaa2_caam.ko
fsl-mc:v00001957ddpseci

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
---
 drivers/crypto/caam/caamalg_qi2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index 700e1d50211f..66ae1d581168 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -5405,6 +5405,7 @@ static const struct fsl_mc_device_id dpaa2_caam_match_id_table[] = {
 	},
 	{ .vendor = 0x0 }
 };
+MODULE_DEVICE_TABLE(fslmc, dpaa2_caam_match_id_table);
 
 static struct fsl_mc_driver dpaa2_caam_driver = {
 	.driver = {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 6/7] crypto: caam - add more RNG hw error codes
  2020-07-22 12:14 ` [PATCH 6/7] crypto: caam - add more RNG hw error codes Horia Geantă
@ 2020-07-22 12:25   ` Horia Geantă
  0 siblings, 0 replies; 10+ messages in thread
From: Horia Geantă @ 2020-07-22 12:25 UTC (permalink / raw)
  To: Herbert Xu
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, dl-linux-imx

On 7/22/2020 3:15 PM, Horia Geantă wrote:
> In some cases, e.g. when TRNG is not properly configured,
> the RNG module could issue a "Hardware error" at runtime.
> 
> "Continuos check" error is emitted when some of the BISTs fail.
> 
> Signed-off-by: Horia Geantă <horia.geanta@freescale.com>
> Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Oops, somehow the deprecated freescale address made its way through.

If there won't be other objections to the patch set, maybe you could fix this
so that a v2 is not needed.

Thanks,
Horia

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/7] crypto: caam - updates for 5.9
  2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
                   ` (6 preceding siblings ...)
  2020-07-22 12:14 ` [PATCH 7/7] crypto: caam/qi2 - add module alias Horia Geantă
@ 2020-07-31 13:30 ` Herbert Xu
  7 siblings, 0 replies; 10+ messages in thread
From: Herbert Xu @ 2020-07-31 13:30 UTC (permalink / raw)
  To: Horia Geantă
  Cc: David S. Miller, Aymen Sghaier, Franck Lenormand, Dan Douglass,
	linux-crypto, linux-kernel, NXP Linux Team

On Wed, Jul 22, 2020 at 03:14:51PM +0300, Horia Geantă wrote:
> Hi Herbert,
> 
> This patch set contains a few caam driver updates.
> The fixes are minor and thus ok to go through the cryptodev tree.
> 
> Dan Douglass (1):
>   crypto: caam/jr - remove incorrect reference to caam_jr_register()
> 
> Franck LENORMAND (1):
>   crypto: caam - remove deadcode on 32-bit platforms
> 
> Horia Geantă (5):
>   crypto: caam/qi2 - fix error reporting for caam_hash_alloc
>   crypto: caam/qi2 - create ahash shared descriptors only once
>   crypto: caam - silence .setkey in case of bad key length
>   crypto: caam - add more RNG hw error codes
>   crypto: caam/qi2 - add module alias
> 
>  drivers/crypto/caam/caamalg.c     |  2 +-
>  drivers/crypto/caam/caamalg_qi.c  |  2 +-
>  drivers/crypto/caam/caamalg_qi2.c | 11 ++++++++---
>  drivers/crypto/caam/error.c       |  3 +++
>  drivers/crypto/caam/jr.c          |  3 +--
>  drivers/crypto/caam/regs.h        | 11 ++++++++---
>  6 files changed, 22 insertions(+), 10 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-07-31 13:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 12:14 [PATCH 0/7] crypto: caam - updates for 5.9 Horia Geantă
2020-07-22 12:14 ` [PATCH 1/7] crypto: caam - remove deadcode on 32-bit platforms Horia Geantă
2020-07-22 12:14 ` [PATCH 2/7] crypto: caam/qi2 - fix error reporting for caam_hash_alloc Horia Geantă
2020-07-22 12:14 ` [PATCH 3/7] crypto: caam/qi2 - create ahash shared descriptors only once Horia Geantă
2020-07-22 12:14 ` [PATCH 4/7] crypto: caam - silence .setkey in case of bad key length Horia Geantă
2020-07-22 12:14 ` [PATCH 5/7] crypto: caam/jr - remove incorrect reference to caam_jr_register() Horia Geantă
2020-07-22 12:14 ` [PATCH 6/7] crypto: caam - add more RNG hw error codes Horia Geantă
2020-07-22 12:25   ` Horia Geantă
2020-07-22 12:14 ` [PATCH 7/7] crypto: caam/qi2 - add module alias Horia Geantă
2020-07-31 13:30 ` [PATCH 0/7] crypto: caam - updates for 5.9 Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).