mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] crypto: ccp - code fixes/cleanup
@ 2013-12-10 16:38 Tom Lendacky
  2013-12-10 16:38 ` [PATCH 1/3] crypto: ccp - Fix sparse warnings in ccp-crypto-sha.c Tom Lendacky
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tom Lendacky @ 2013-12-10 16:38 UTC (permalink / raw)
  To: davem, linux-crypto, herbert; +Cc: linux-kernel

The following series implements fixes and cleanup for some reported
errors and suggestions (sparse errors, randconfig build errors and
pr_err usage).

This patch series is based on the cryptodev-2.6 kernel tree.

---

Tom Lendacky (3):
      crypto: ccp - Fix sparse warnings in ccp-crypto-sha.c
      crypto: ccp - CCP Kconfig fixes
      crypto: ccp - Remove user triggerable pr_err calls


 drivers/crypto/Kconfig                   |    2 +-
 drivers/crypto/ccp/Kconfig               |    1 +
 drivers/crypto/ccp/ccp-crypto-aes-cmac.c |    4 +---
 drivers/crypto/ccp/ccp-crypto-aes-xts.c  |   12 +++---------
 drivers/crypto/ccp/ccp-crypto-aes.c      |   12 +++---------
 drivers/crypto/ccp/ccp-crypto-sha.c      |    8 ++++----
 drivers/crypto/ccp/ccp-crypto.h          |    2 +-
 7 files changed, 14 insertions(+), 27 deletions(-)

-- 
Tom Lendacky


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

* [PATCH 1/3] crypto: ccp - Fix sparse warnings in ccp-crypto-sha.c
  2013-12-10 16:38 [PATCH 0/3] crypto: ccp - code fixes/cleanup Tom Lendacky
@ 2013-12-10 16:38 ` Tom Lendacky
  2013-12-10 16:38 ` [PATCH 2/3] crypto: ccp - CCP Kconfig fixes Tom Lendacky
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2013-12-10 16:38 UTC (permalink / raw)
  To: davem, linux-crypto, herbert; +Cc: linux-kernel

The sha initialization data generated the following sparse warnings:

   sparse: incorrect type in initializer (different base types)
      expected unsigned int
      got restricted __be32 [usertype] <noident>

Change the initialization data type from u32 to __be32.


Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/ccp-crypto-sha.c |    8 ++++----
 drivers/crypto/ccp/ccp-crypto.h     |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c
index a6ef183..b0881df 100644
--- a/drivers/crypto/ccp/ccp-crypto-sha.c
+++ b/drivers/crypto/ccp/ccp-crypto-sha.c
@@ -324,20 +324,20 @@ static void ccp_hmac_sha_cra_exit(struct crypto_tfm *tfm)
 	ccp_sha_cra_exit(tfm);
 }
 
-static const u32 sha1_init[CCP_SHA_CTXSIZE / sizeof(u32)] = {
+static const __be32 sha1_init[CCP_SHA_CTXSIZE / sizeof(__be32)] = {
 	cpu_to_be32(SHA1_H0), cpu_to_be32(SHA1_H1),
 	cpu_to_be32(SHA1_H2), cpu_to_be32(SHA1_H3),
 	cpu_to_be32(SHA1_H4), 0, 0, 0,
 };
 
-static const u32 sha224_init[CCP_SHA_CTXSIZE / sizeof(u32)] = {
+static const __be32 sha224_init[CCP_SHA_CTXSIZE / sizeof(__be32)] = {
 	cpu_to_be32(SHA224_H0), cpu_to_be32(SHA224_H1),
 	cpu_to_be32(SHA224_H2), cpu_to_be32(SHA224_H3),
 	cpu_to_be32(SHA224_H4), cpu_to_be32(SHA224_H5),
 	cpu_to_be32(SHA224_H6), cpu_to_be32(SHA224_H7),
 };
 
-static const u32 sha256_init[CCP_SHA_CTXSIZE / sizeof(u32)] = {
+static const __be32 sha256_init[CCP_SHA_CTXSIZE / sizeof(__be32)] = {
 	cpu_to_be32(SHA256_H0), cpu_to_be32(SHA256_H1),
 	cpu_to_be32(SHA256_H2), cpu_to_be32(SHA256_H3),
 	cpu_to_be32(SHA256_H4), cpu_to_be32(SHA256_H5),
@@ -347,7 +347,7 @@ static const u32 sha256_init[CCP_SHA_CTXSIZE / sizeof(u32)] = {
 struct ccp_sha_def {
 	const char *name;
 	const char *drv_name;
-	const u32 *init;
+	const __be32 *init;
 	enum ccp_sha_type type;
 	u32 digest_size;
 	u32 block_size;
diff --git a/drivers/crypto/ccp/ccp-crypto.h b/drivers/crypto/ccp/ccp-crypto.h
index 45f17c3..13ea6ea 100644
--- a/drivers/crypto/ccp/ccp-crypto.h
+++ b/drivers/crypto/ccp/ccp-crypto.h
@@ -39,7 +39,7 @@ struct ccp_crypto_ablkcipher_alg {
 struct ccp_crypto_ahash_alg {
 	struct list_head entry;
 
-	const u32 *init;
+	const __be32 *init;
 	u32 type;
 	u32 mode;
 



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

* [PATCH 2/3] crypto: ccp - CCP Kconfig fixes
  2013-12-10 16:38 [PATCH 0/3] crypto: ccp - code fixes/cleanup Tom Lendacky
  2013-12-10 16:38 ` [PATCH 1/3] crypto: ccp - Fix sparse warnings in ccp-crypto-sha.c Tom Lendacky
@ 2013-12-10 16:38 ` Tom Lendacky
  2013-12-10 16:38 ` [PATCH 3/3] crypto: ccp - Remove user triggerable pr_err calls Tom Lendacky
  2013-12-20 14:07 ` [PATCH 0/3] crypto: ccp - code fixes/cleanup Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2013-12-10 16:38 UTC (permalink / raw)
  To: davem, linux-crypto, herbert; +Cc: linux-kernel

Update the Kconfig to include PCI on the 'depends on'
and add 'select HW_RANDOM' to insure the necessary PCI
and HW_RANDOM functions are available/included in the
build.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/Kconfig     |    2 +-
 drivers/crypto/ccp/Kconfig |    1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 4954d75..9dee00f 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -401,7 +401,7 @@ config CRYPTO_DEV_ATMEL_SHA
 
 config CRYPTO_DEV_CCP
 	bool "Support for AMD Cryptographic Coprocessor"
-	depends on X86
+	depends on X86 && PCI
 	default n
 	help
 	  The AMD Cryptographic Coprocessor provides hardware support
diff --git a/drivers/crypto/ccp/Kconfig b/drivers/crypto/ccp/Kconfig
index 335ed5c..7639ffc 100644
--- a/drivers/crypto/ccp/Kconfig
+++ b/drivers/crypto/ccp/Kconfig
@@ -2,6 +2,7 @@ config CRYPTO_DEV_CCP_DD
 	tristate "Cryptographic Coprocessor device driver"
 	depends on CRYPTO_DEV_CCP
 	default m
+	select HW_RANDOM
 	help
 	  Provides the interface to use the AMD Cryptographic Coprocessor
 	  which can be used to accelerate or offload encryption operations



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

* [PATCH 3/3] crypto: ccp - Remove user triggerable pr_err calls
  2013-12-10 16:38 [PATCH 0/3] crypto: ccp - code fixes/cleanup Tom Lendacky
  2013-12-10 16:38 ` [PATCH 1/3] crypto: ccp - Fix sparse warnings in ccp-crypto-sha.c Tom Lendacky
  2013-12-10 16:38 ` [PATCH 2/3] crypto: ccp - CCP Kconfig fixes Tom Lendacky
@ 2013-12-10 16:38 ` Tom Lendacky
  2013-12-20 14:07 ` [PATCH 0/3] crypto: ccp - code fixes/cleanup Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2013-12-10 16:38 UTC (permalink / raw)
  To: davem, linux-crypto, herbert; +Cc: linux-kernel

Remove the pr_err calls that are issued during parameter
checking in some AES operations. This will eliminate the
possibility of filling up syslog through these paths.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/ccp-crypto-aes-cmac.c |    4 +---
 drivers/crypto/ccp/ccp-crypto-aes-xts.c  |   12 +++---------
 drivers/crypto/ccp/ccp-crypto-aes.c      |   12 +++---------
 3 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
index 5b9cd98..64dd35e 100644
--- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
+++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c
@@ -63,10 +63,8 @@ static int ccp_do_cmac_update(struct ahash_request *req, unsigned int nbytes,
 	unsigned int len, need_pad, sg_count;
 	int ret;
 
-	if (!ctx->u.aes.key_len) {
-		pr_err("AES key not set\n");
+	if (!ctx->u.aes.key_len)
 		return -EINVAL;
-	}
 
 	if (nbytes)
 		rctx->null_msg = 0;
diff --git a/drivers/crypto/ccp/ccp-crypto-aes-xts.c b/drivers/crypto/ccp/ccp-crypto-aes-xts.c
index d100b48..0237ab5 100644
--- a/drivers/crypto/ccp/ccp-crypto-aes-xts.c
+++ b/drivers/crypto/ccp/ccp-crypto-aes-xts.c
@@ -125,20 +125,14 @@ static int ccp_aes_xts_crypt(struct ablkcipher_request *req,
 	unsigned int unit;
 	int ret;
 
-	if (!ctx->u.aes.key_len) {
-		pr_err("AES key not set\n");
+	if (!ctx->u.aes.key_len)
 		return -EINVAL;
-	}
 
-	if (req->nbytes & (AES_BLOCK_SIZE - 1)) {
-		pr_err("AES request size is not a multiple of the block size\n");
+	if (req->nbytes & (AES_BLOCK_SIZE - 1))
 		return -EINVAL;
-	}
 
-	if (!req->info) {
-		pr_err("AES IV not supplied");
+	if (!req->info)
 		return -EINVAL;
-	}
 
 	for (unit = 0; unit < ARRAY_SIZE(unit_size_map); unit++)
 		if (!(req->nbytes & (unit_size_map[unit].size - 1)))
diff --git a/drivers/crypto/ccp/ccp-crypto-aes.c b/drivers/crypto/ccp/ccp-crypto-aes.c
index c0befdb..e46490d 100644
--- a/drivers/crypto/ccp/ccp-crypto-aes.c
+++ b/drivers/crypto/ccp/ccp-crypto-aes.c
@@ -76,24 +76,18 @@ static int ccp_aes_crypt(struct ablkcipher_request *req, bool encrypt)
 	unsigned int iv_len = 0;
 	int ret;
 
-	if (!ctx->u.aes.key_len) {
-		pr_err("AES key not set\n");
+	if (!ctx->u.aes.key_len)
 		return -EINVAL;
-	}
 
 	if (((ctx->u.aes.mode == CCP_AES_MODE_ECB) ||
 	     (ctx->u.aes.mode == CCP_AES_MODE_CBC) ||
 	     (ctx->u.aes.mode == CCP_AES_MODE_CFB)) &&
-	    (req->nbytes & (AES_BLOCK_SIZE - 1))) {
-		pr_err("AES request size is not a multiple of the block size\n");
+	    (req->nbytes & (AES_BLOCK_SIZE - 1)))
 		return -EINVAL;
-	}
 
 	if (ctx->u.aes.mode != CCP_AES_MODE_ECB) {
-		if (!req->info) {
-			pr_err("AES IV not supplied");
+		if (!req->info)
 			return -EINVAL;
-		}
 
 		memcpy(rctx->iv, req->info, AES_BLOCK_SIZE);
 		iv_sg = &rctx->iv_sg;



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

* Re: [PATCH 0/3] crypto: ccp - code fixes/cleanup
  2013-12-10 16:38 [PATCH 0/3] crypto: ccp - code fixes/cleanup Tom Lendacky
                   ` (2 preceding siblings ...)
  2013-12-10 16:38 ` [PATCH 3/3] crypto: ccp - Remove user triggerable pr_err calls Tom Lendacky
@ 2013-12-20 14:07 ` Herbert Xu
  3 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2013-12-20 14:07 UTC (permalink / raw)
  To: Tom Lendacky; +Cc: davem, linux-crypto, linux-kernel

On Tue, Dec 10, 2013 at 10:38:27AM -0600, Tom Lendacky wrote:
> The following series implements fixes and cleanup for some reported
> errors and suggestions (sparse errors, randconfig build errors and
> pr_err usage).
> 
> This patch series is based on the cryptodev-2.6 kernel tree.

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] 5+ messages in thread

end of thread, other threads:[~2013-12-20 14:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 16:38 [PATCH 0/3] crypto: ccp - code fixes/cleanup Tom Lendacky
2013-12-10 16:38 ` [PATCH 1/3] crypto: ccp - Fix sparse warnings in ccp-crypto-sha.c Tom Lendacky
2013-12-10 16:38 ` [PATCH 2/3] crypto: ccp - CCP Kconfig fixes Tom Lendacky
2013-12-10 16:38 ` [PATCH 3/3] crypto: ccp - Remove user triggerable pr_err calls Tom Lendacky
2013-12-20 14:07 ` [PATCH 0/3] crypto: ccp - code fixes/cleanup Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®