linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests
@ 2020-02-05  5:18 Ayush Sawal
  2020-02-05  5:18 ` [PATCH crypto/chcr 1/2] This fixes the libkcapi's cbc(aes) aio fail test cases Ayush Sawal
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ayush Sawal @ 2020-02-05  5:18 UTC (permalink / raw)
  To: herbert, linux-crypto; +Cc: manojmalviya, Ayush Sawal

Patch1: This fixes the libkcapi's cbc(aes) aio fail case.
Patch2: This fixes the kernel panic which occurs during 
	aead asynchronous vmsplice multiple test.


Ayush Sawal (2):
  This fixes the libkcapi's cbc(aes) aio fail test cases
  This fixes the kernel panic which occurs during a libkcapi test

 drivers/crypto/chelsio/chcr_algo.c   | 25 ++++++++++++++++++++++---
 drivers/crypto/chelsio/chcr_crypto.h |  1 +
 2 files changed, 23 insertions(+), 3 deletions(-)

-- 
2.25.0.114.g5b0ca87


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

* [PATCH crypto/chcr 1/2] This fixes the libkcapi's cbc(aes) aio fail test cases
  2020-02-05  5:18 [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests Ayush Sawal
@ 2020-02-05  5:18 ` Ayush Sawal
  2020-02-05  5:18 ` [PATCH crypto/chcr 2/2] This fixes the kernel panic which occurs during a libkcapi test Ayush Sawal
  2020-02-13  9:24 ` [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Ayush Sawal @ 2020-02-05  5:18 UTC (permalink / raw)
  To: herbert, linux-crypto; +Cc: manojmalviya, Ayush Sawal

The libkcapi "cbc(aes)" failed tests are
symmetric asynchronous cipher one shot multiple test,
symmetric asynchronous cipher stream multiple test,
Symmetric asynchronous cipher vmsplice multiple test

In this patch a wait_for_completion is added in the chcr_aes_encrypt function,
which completes when the response of comes from the hardware.
This adds serialization for encryption in cbc(aes) aio case.

Signed-off-by: Ayush Sawal <ayush.sawal@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c   | 20 +++++++++++++++++++-
 drivers/crypto/chelsio/chcr_crypto.h |  1 +
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index b4b9b22125d1..699e3053895a 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -1102,6 +1102,7 @@ static int chcr_handle_cipher_resp(struct skcipher_request *req,
 				   unsigned char *input, int err)
 {
 	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
+	struct chcr_context *ctx = c_ctx(tfm);
 	struct uld_ctx *u_ctx = ULD_CTX(c_ctx(tfm));
 	struct ablk_ctx *ablkctx = ABLK_CTX(c_ctx(tfm));
 	struct sk_buff *skb;
@@ -1166,10 +1167,20 @@ static int chcr_handle_cipher_resp(struct skcipher_request *req,
 	chcr_send_wr(skb);
 	reqctx->last_req_len = bytes;
 	reqctx->processed += bytes;
+	if (get_cryptoalg_subtype(tfm) ==
+		CRYPTO_ALG_SUB_TYPE_CBC && req->base.flags ==
+			CRYPTO_TFM_REQ_MAY_SLEEP ) {
+		complete(&ctx->cbc_aes_aio_done);
+	}
 	return 0;
 unmap:
 	chcr_cipher_dma_unmap(&ULD_CTX(c_ctx(tfm))->lldi.pdev->dev, req);
 complete:
+	if (get_cryptoalg_subtype(tfm) ==
+		CRYPTO_ALG_SUB_TYPE_CBC && req->base.flags ==
+			CRYPTO_TFM_REQ_MAY_SLEEP ) {
+		complete(&ctx->cbc_aes_aio_done);
+	}
 	chcr_dec_wrcount(dev);
 	req->base.complete(&req->base, err);
 	return err;
@@ -1289,6 +1300,7 @@ static int process_cipher(struct skcipher_request *req,
 static int chcr_aes_encrypt(struct skcipher_request *req)
 {
 	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
+	struct chcr_context *ctx;
 	struct chcr_dev *dev = c_ctx(tfm)->dev;
 	struct sk_buff *skb = NULL;
 	int err, isfull = 0;
@@ -1313,6 +1325,12 @@ static int chcr_aes_encrypt(struct skcipher_request *req)
 	skb->dev = u_ctx->lldi.ports[0];
 	set_wr_txq(skb, CPL_PRIORITY_DATA, c_ctx(tfm)->tx_qidx);
 	chcr_send_wr(skb);
+	if (get_cryptoalg_subtype(tfm) ==
+		CRYPTO_ALG_SUB_TYPE_CBC && req->base.flags ==
+			CRYPTO_TFM_REQ_MAY_SLEEP ) {
+			ctx=c_ctx(tfm);
+			wait_for_completion(&ctx->cbc_aes_aio_done);
+        }
 	return isfull ? -EBUSY : -EINPROGRESS;
 error:
 	chcr_dec_wrcount(dev);
@@ -1401,7 +1419,7 @@ static int chcr_init_tfm(struct crypto_skcipher *tfm)
 		pr_err("failed to allocate fallback for %s\n", alg->base.cra_name);
 		return PTR_ERR(ablkctx->sw_cipher);
 	}
-
+	init_completion(&ctx->cbc_aes_aio_done);
 	crypto_skcipher_set_reqsize(tfm, sizeof(struct chcr_skcipher_req_ctx));
 
 	return chcr_device_init(ctx);
diff --git a/drivers/crypto/chelsio/chcr_crypto.h b/drivers/crypto/chelsio/chcr_crypto.h
index 6db2df8c8a05..9207d88c5538 100644
--- a/drivers/crypto/chelsio/chcr_crypto.h
+++ b/drivers/crypto/chelsio/chcr_crypto.h
@@ -254,6 +254,7 @@ struct chcr_context {
 	unsigned char rx_qidx;
 	unsigned char tx_chan_id;
 	unsigned char pci_chan_id;
+	struct completion cbc_aes_aio_done;
 	struct __crypto_ctx crypto_ctx[0];
 };
 
-- 
2.25.0.114.g5b0ca87


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

* [PATCH crypto/chcr 2/2] This fixes the kernel panic which occurs during a libkcapi test
  2020-02-05  5:18 [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests Ayush Sawal
  2020-02-05  5:18 ` [PATCH crypto/chcr 1/2] This fixes the libkcapi's cbc(aes) aio fail test cases Ayush Sawal
@ 2020-02-05  5:18 ` Ayush Sawal
  2020-02-13  9:24 ` [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Ayush Sawal @ 2020-02-05  5:18 UTC (permalink / raw)
  To: herbert, linux-crypto; +Cc: manojmalviya, Ayush Sawal

The libkcapi test which causes kernel panic is
aead asynchronous vmsplice multiple test.

./bin/kcapi  -v -d 4 -x 10   -c "ccm(aes)"
-q 4edb58e8d5eb6bc711c43a6f3693daebde2e5524f1b55297abb29f003236e43d
-t a7877c99 -n 674742abd0f5ba -k 2861fd0253705d7875c95ba8a53171b4
-a fb7bc304a3909e66e2e0c5ef952712dd884ce3e7324171369f2c5db1adc48c7d

This patch avoids dma_mapping of a zero length sg which causes the panic,
by using sg_nents_for_len which maps only upto a specific length

Signed-off-by: Ayush Sawal <ayush.sawal@chelsio.com>
---
 drivers/crypto/chelsio/chcr_algo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c
index 699e3053895a..02b0ddb785a4 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -2489,8 +2489,9 @@ int chcr_aead_dma_map(struct device *dev,
 	else
 		reqctx->b0_dma = 0;
 	if (req->src == req->dst) {
-		error = dma_map_sg(dev, req->src, sg_nents(req->src),
-				   DMA_BIDIRECTIONAL);
+		error = dma_map_sg(dev, req->src,
+				sg_nents_for_len(req->src, dst_size),
+					DMA_BIDIRECTIONAL);
 		if (!error)
 			goto err;
 	} else {
-- 
2.25.0.114.g5b0ca87


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

* Re: [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests
  2020-02-05  5:18 [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests Ayush Sawal
  2020-02-05  5:18 ` [PATCH crypto/chcr 1/2] This fixes the libkcapi's cbc(aes) aio fail test cases Ayush Sawal
  2020-02-05  5:18 ` [PATCH crypto/chcr 2/2] This fixes the kernel panic which occurs during a libkcapi test Ayush Sawal
@ 2020-02-13  9:24 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2020-02-13  9:24 UTC (permalink / raw)
  To: Ayush Sawal; +Cc: linux-crypto, manojmalviya

On Wed, Feb 05, 2020 at 10:48:40AM +0530, Ayush Sawal wrote:
> Patch1: This fixes the libkcapi's cbc(aes) aio fail case.
> Patch2: This fixes the kernel panic which occurs during 
> 	aead asynchronous vmsplice multiple test.
> 
> 
> Ayush Sawal (2):
>   This fixes the libkcapi's cbc(aes) aio fail test cases
>   This fixes the kernel panic which occurs during a libkcapi test
> 
>  drivers/crypto/chelsio/chcr_algo.c   | 25 ++++++++++++++++++++++---
>  drivers/crypto/chelsio/chcr_crypto.h |  1 +
>  2 files changed, 23 insertions(+), 3 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] 4+ messages in thread

end of thread, other threads:[~2020-02-13  9:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05  5:18 [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests Ayush Sawal
2020-02-05  5:18 ` [PATCH crypto/chcr 1/2] This fixes the libkcapi's cbc(aes) aio fail test cases Ayush Sawal
2020-02-05  5:18 ` [PATCH crypto/chcr 2/2] This fixes the kernel panic which occurs during a libkcapi test Ayush Sawal
2020-02-13  9:24 ` [PATCH crypto/chcr 0/2] Bug fixes for libkcapi's fail tests 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).