patch 'crypto/qat: fix null algorithm digest placement' has been queued to stable release 22.11.3

Xueming Li xuemingl at nvidia.com
Thu Aug 10 01:59:12 CEST 2023


Hi,

FYI, your patch has been queued to stable release 22.11.3

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 08/11/23. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=60c1ca4fdefaca36eecba34e7b15ba907426543f

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 60c1ca4fdefaca36eecba34e7b15ba907426543f Mon Sep 17 00:00:00 2001
From: Ciara Power <ciara.power at intel.com>
Date: Fri, 23 Jun 2023 13:51:04 +0000
Subject: [PATCH] crypto/qat: fix null algorithm digest placement
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 8b4618a7b453dec02ca8ea40871fb124100f98f4 ]

QAT HW generates bytes of 0x00 digest, even when a digest of len 0 is
requested for NULL. This caused test failures when the test vector had
digest len 0, as the buffer has unexpected changed bytes.

By placing the digest into the cookie for NULL authentication,
the buffer remains unchanged as expected, and the digest
is placed to the side, as it won't be used anyway.

Fixes: db0e952a5c01 ("crypto/qat: add NULL capability")

Signed-off-by: Ciara Power <ciara.power at intel.com>
Acked-by: Arkadiusz Kusztal <arkadiuszx.kusztal at intel.com>
---
 drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c |  2 +-
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h | 18 ++++++++++++++----
 drivers/crypto/qat/dev/qat_sym_pmd_gen1.c    |  4 ++--
 drivers/crypto/qat/qat_sym.c                 |  5 +++++
 drivers/crypto/qat/qat_sym.h                 |  2 ++
 5 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
index 2a0ddab8af..1f6f63c831 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
@@ -407,7 +407,7 @@ qat_sym_build_op_auth_gen3(void *in_op, struct qat_sym_session *ctx,
 	rte_mov128((uint8_t *)req, (const uint8_t *)&(ctx->fw_req));
 
 	ofs.raw = qat_sym_convert_op_to_vec_auth(op, ctx, &in_sgl, &out_sgl,
-			NULL, &auth_iv, &digest);
+			NULL, &auth_iv, &digest, op_cookie);
 	if (unlikely(ofs.raw == UINT64_MAX)) {
 		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 		return -EINVAL;
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
index 092265631b..7972c7cfeb 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gens.h
@@ -290,7 +290,8 @@ qat_sym_convert_op_to_vec_auth(struct rte_crypto_op *op,
 		struct rte_crypto_sgl *in_sgl, struct rte_crypto_sgl *out_sgl,
 		struct rte_crypto_va_iova_ptr *cipher_iv __rte_unused,
 		struct rte_crypto_va_iova_ptr *auth_iv,
-		struct rte_crypto_va_iova_ptr *digest)
+		struct rte_crypto_va_iova_ptr *digest,
+		struct qat_sym_op_cookie *cookie)
 {
 	uint32_t auth_ofs = 0, auth_len = 0;
 	int n_src, ret;
@@ -355,7 +356,11 @@ qat_sym_convert_op_to_vec_auth(struct rte_crypto_op *op,
 		out_sgl->num = 0;
 
 	digest->va = (void *)op->sym->auth.digest.data;
-	digest->iova = op->sym->auth.digest.phys_addr;
+
+	if (ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_NULL)
+		digest->iova = cookie->digest_null_phys_addr;
+	else
+		digest->iova = op->sym->auth.digest.phys_addr;
 
 	return 0;
 }
@@ -366,7 +371,8 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op,
 		struct rte_crypto_sgl *in_sgl, struct rte_crypto_sgl *out_sgl,
 		struct rte_crypto_va_iova_ptr *cipher_iv,
 		struct rte_crypto_va_iova_ptr *auth_iv_or_aad,
-		struct rte_crypto_va_iova_ptr *digest)
+		struct rte_crypto_va_iova_ptr *digest,
+		struct qat_sym_op_cookie *cookie)
 {
 	union rte_crypto_sym_ofs ofs;
 	uint32_t max_len = 0;
@@ -390,7 +396,11 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op,
 	auth_iv_or_aad->iova = rte_crypto_op_ctophys_offset(op,
 			ctx->auth_iv.offset);
 	digest->va = (void *)op->sym->auth.digest.data;
-	digest->iova = op->sym->auth.digest.phys_addr;
+
+	if (ctx->qat_hash_alg == ICP_QAT_HW_AUTH_ALGO_NULL)
+		digest->iova = cookie->digest_null_phys_addr;
+	else
+		digest->iova = op->sym->auth.digest.phys_addr;
 
 	ret = qat_cipher_is_len_in_bits(ctx, op);
 	switch (ret) {
diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
index 91d5cfa71d..2709b0ab04 100644
--- a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
+++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
@@ -274,7 +274,7 @@ qat_sym_build_op_auth_gen1(void *in_op, struct qat_sym_session *ctx,
 	rte_mov128((uint8_t *)req, (const uint8_t *)&(ctx->fw_req));
 
 	ofs.raw = qat_sym_convert_op_to_vec_auth(op, ctx, &in_sgl, &out_sgl,
-			NULL, &auth_iv, &digest);
+			NULL, &auth_iv, &digest, op_cookie);
 	if (unlikely(ofs.raw == UINT64_MAX)) {
 		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 		return -EINVAL;
@@ -368,7 +368,7 @@ qat_sym_build_op_chain_gen1(void *in_op, struct qat_sym_session *ctx,
 	rte_mov128((uint8_t *)req, (const uint8_t *)&(ctx->fw_req));
 
 	ofs.raw = qat_sym_convert_op_to_vec_chain(op, ctx, &in_sgl, &out_sgl,
-			&cipher_iv, &auth_iv, &digest);
+			&cipher_iv, &auth_iv, &digest, cookie);
 	if (unlikely(ofs.raw == UINT64_MAX)) {
 		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
 		return -EINVAL;
diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 2450f042c8..18f99089e8 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -51,6 +51,11 @@ qat_sym_init_op_cookie(void *op_cookie)
 			rte_mempool_virt2iova(cookie) +
 			offsetof(struct qat_sym_op_cookie,
 			opt.spc_gmac.cd_cipher);
+
+	cookie->digest_null_phys_addr =
+			rte_mempool_virt2iova(cookie) +
+			offsetof(struct qat_sym_op_cookie,
+			digest_null);
 }
 
 static __rte_always_inline int
diff --git a/drivers/crypto/qat/qat_sym.h b/drivers/crypto/qat/qat_sym.h
index 9a4251e08b..a45bddf848 100644
--- a/drivers/crypto/qat/qat_sym.h
+++ b/drivers/crypto/qat/qat_sym.h
@@ -116,6 +116,8 @@ struct qat_sym_op_cookie {
 			phys_addr_t cd_phys_addr;
 		} spc_gmac;
 	} opt;
+	uint8_t digest_null[4];
+	phys_addr_t digest_null_phys_addr;
 };
 
 struct qat_sym_dp_ctx {
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-08-09 21:51:20.586620100 +0800
+++ 0093-crypto-qat-fix-null-algorithm-digest-placement.patch	2023-08-09 21:51:18.264352000 +0800
@@ -1 +1 @@
-From 8b4618a7b453dec02ca8ea40871fb124100f98f4 Mon Sep 17 00:00:00 2001
+From 60c1ca4fdefaca36eecba34e7b15ba907426543f Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 8b4618a7b453dec02ca8ea40871fb124100f98f4 ]
@@ -15 +17,0 @@
-Cc: stable at dpdk.org
@@ -28 +30 @@
-index aeca1db4b8..bc71665a50 100644
+index 2a0ddab8af..1f6f63c831 100644
@@ -31 +33 @@
-@@ -444,7 +444,7 @@ qat_sym_build_op_auth_gen3(void *in_op, struct qat_sym_session *ctx,
+@@ -407,7 +407,7 @@ qat_sym_build_op_auth_gen3(void *in_op, struct qat_sym_session *ctx,
@@ -41 +43 @@
-index 1bafeb4a53..cab7e214c0 100644
+index 092265631b..7972c7cfeb 100644
@@ -44 +46 @@
-@@ -300,7 +300,8 @@ qat_sym_convert_op_to_vec_auth(struct rte_crypto_op *op,
+@@ -290,7 +290,8 @@ qat_sym_convert_op_to_vec_auth(struct rte_crypto_op *op,
@@ -54 +56 @@
-@@ -365,7 +366,11 @@ qat_sym_convert_op_to_vec_auth(struct rte_crypto_op *op,
+@@ -355,7 +356,11 @@ qat_sym_convert_op_to_vec_auth(struct rte_crypto_op *op,
@@ -67 +69 @@
-@@ -376,7 +381,8 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op,
+@@ -366,7 +371,8 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op,
@@ -77 +79 @@
-@@ -401,7 +407,11 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op,
+@@ -390,7 +396,11 @@ qat_sym_convert_op_to_vec_chain(struct rte_crypto_op *op,
@@ -91 +93 @@
-index 580c245482..70938ba508 100644
+index 91d5cfa71d..2709b0ab04 100644
@@ -94 +96 @@
-@@ -278,7 +278,7 @@ qat_sym_build_op_auth_gen1(void *in_op, struct qat_sym_session *ctx,
+@@ -274,7 +274,7 @@ qat_sym_build_op_auth_gen1(void *in_op, struct qat_sym_session *ctx,
@@ -113 +115 @@
-index 5c3cdd8183..936c2615e4 100644
+index 2450f042c8..18f99089e8 100644
@@ -129 +131 @@
-index 193281cd91..d19cadde86 100644
+index 9a4251e08b..a45bddf848 100644
@@ -132 +134 @@
-@@ -113,6 +113,8 @@ struct qat_sym_op_cookie {
+@@ -116,6 +116,8 @@ struct qat_sym_op_cookie {


More information about the stable mailing list