DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] crypto/qat: fix process type handling
@ 2022-02-28 17:36 Kai Ji
  2022-03-01  8:00 ` David Marchand
  2022-03-01 15:02 ` [dpdk-dev v2] " Kai Ji
  0 siblings, 2 replies; 5+ messages in thread
From: Kai Ji @ 2022-02-28 17:36 UTC (permalink / raw)
  To: dev; +Cc: roy.fan.zhang, gakhil, Kai Ji

This patch fix the process type handling in QAT PMDs where
only primary and secondary process are supported in qat
build request

Signed-off-by: Kai Ji <kai.ji@intel.com>
---
 drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c | 3 +++
 drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c | 3 +++
 drivers/crypto/qat/dev/qat_sym_pmd_gen1.c    | 3 +++
 drivers/crypto/qat/qat_sym.c                 | 8 ++++----
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
index 5084a5fcd1..739404b1d4 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
@@ -358,6 +358,9 @@ qat_sym_crypto_set_session_gen3(void *cdev __rte_unused, void *session)
 	enum rte_proc_type_t proc_type = rte_eal_process_type();
 	int ret;

+	if (proc_type < 0 || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;
+
 	ret = qat_sym_crypto_set_session_gen1(cdev, session);
 	/* special single pass build request for GEN3 */
 	if (ctx->is_single_pass)
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
index bd7f3785df..586f3d0344 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
@@ -189,6 +189,9 @@ qat_sym_crypto_set_session_gen4(void *cdev, void *session)
 	enum rte_proc_type_t proc_type = rte_eal_process_type();
 	int ret;

+	if (proc_type < 0 || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;
+
 	ret = qat_sym_crypto_set_session_gen1(cdev, session);
 	/* special single pass build request for GEN4 */
 	if (ctx->is_single_pass && ctx->is_ucs)
diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
index 3bcb53cf9f..857b5747db 100644
--- a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
+++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
@@ -1149,6 +1149,9 @@ qat_sym_crypto_set_session_gen1(void *cryptodev __rte_unused, void *session)
 	enum rte_proc_type_t proc_type = rte_eal_process_type();
 	int handle_mixed = 0;

+	if (proc_type < 0 || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;
+
 	if ((ctx->qat_cmd == ICP_QAT_FW_LA_CMD_HASH_CIPHER ||
 			ctx->qat_cmd == ICP_QAT_FW_LA_CMD_CIPHER_HASH) &&
 			!ctx->is_gmac) {
diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 1ccffad5ab..d846cc9ac4 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -60,6 +60,10 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 	uintptr_t build_request_p = (uintptr_t)opaque[1];
 	qat_sym_build_request_t build_request = (void *)build_request_p;
 	struct qat_sym_session *ctx = NULL;
+	enum rte_proc_type_t proc_type = rte_eal_process_type();
+
+	if (proc_type < 0 || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;

 	if (likely(op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)) {
 		ctx = get_sym_session_private_data(op->sym->session,
@@ -71,11 +75,9 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 		if (sess != (uintptr_t)ctx) {
 			struct rte_cryptodev *cdev;
 			struct qat_cryptodev_private *internals;
-			enum rte_proc_type_t proc_type;

 			cdev = rte_cryptodev_pmd_get_dev(ctx->dev_id);
 			internals = cdev->data->dev_private;
-			proc_type = rte_eal_process_type();

 			if (internals->qat_dev->qat_dev_gen != dev_gen) {
 				op->status =
@@ -105,7 +107,6 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 		if ((void *)sess != (void *)op->sym->sec_session) {
 			struct rte_cryptodev *cdev;
 			struct qat_cryptodev_private *internals;
-			enum rte_proc_type_t proc_type;

 			ctx = get_sec_session_private_data(
 					op->sym->sec_session);
@@ -130,7 +131,6 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 			}
 			cdev = rte_cryptodev_pmd_get_dev(ctx->dev_id);
 			internals = cdev->data->dev_private;
-			proc_type = rte_eal_process_type();

 			if (internals->qat_dev->qat_dev_gen != dev_gen) {
 				op->status =
--
2.30.2


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

* Re: [dpdk-dev] crypto/qat: fix process type handling
  2022-02-28 17:36 [dpdk-dev] crypto/qat: fix process type handling Kai Ji
@ 2022-03-01  8:00 ` David Marchand
  2022-03-01 10:51   ` Ji, Kai
  2022-03-01 15:02 ` [dpdk-dev v2] " Kai Ji
  1 sibling, 1 reply; 5+ messages in thread
From: David Marchand @ 2022-03-01  8:00 UTC (permalink / raw)
  To: Kai Ji; +Cc: dev, Fan Zhang, Akhil Goyal

On Mon, Feb 28, 2022 at 6:36 PM Kai Ji <kai.ji@intel.com> wrote:
>
> This patch fix the process type handling in QAT PMDs where
> only primary and secondary process are supported in qat
> build request
>
> Signed-off-by: Kai Ji <kai.ji@intel.com>
> ---
>  drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c | 3 +++
>  drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c | 3 +++
>  drivers/crypto/qat/dev/qat_sym_pmd_gen1.c    | 3 +++
>  drivers/crypto/qat/qat_sym.c                 | 8 ++++----
>  4 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
> index 5084a5fcd1..739404b1d4 100644
> --- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
> +++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
> @@ -358,6 +358,9 @@ qat_sym_crypto_set_session_gen3(void *cdev __rte_unused, void *session)
>         enum rte_proc_type_t proc_type = rte_eal_process_type();
>         int ret;
>
> +       if (proc_type < 0 || proc_type == RTE_PROC_INVALID)
> +               return -EINVAL;

This is not supposed to happen after rte_eal_init() is called.

I have a doubt on Windows init because I can't see where
rte_config.process_type is initialised.
Are you seeing this issue on Windows?

In any case, the commitlog needs more explanation.


-- 
David Marchand


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

* RE: [dpdk-dev] crypto/qat: fix process type handling
  2022-03-01  8:00 ` David Marchand
@ 2022-03-01 10:51   ` Ji, Kai
  0 siblings, 0 replies; 5+ messages in thread
From: Ji, Kai @ 2022-03-01 10:51 UTC (permalink / raw)
  To: David Marchand; +Cc: dev, Zhang, Roy Fan, Akhil Goyal

Hi 

> This is not supposed to happen after rte_eal_init() is called.
> 
> I have a doubt on Windows init because I can't see where
> rte_config.process_type is initialised.
> Are you seeing this issue on Windows?
> 
> In any case, the commitlog needs more explanation.
> 
> 
> --
> David Marchand

The process type should be either Primary or Secondary after the rte_eal_init(),
This check mainly fix of Memory corruptions issue reported by Coverity. 
I will update the commitlog of more info

Regards

Kai 

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

* [dpdk-dev v2] crypto/qat: fix process type handling
  2022-02-28 17:36 [dpdk-dev] crypto/qat: fix process type handling Kai Ji
  2022-03-01  8:00 ` David Marchand
@ 2022-03-01 15:02 ` Kai Ji
  2022-03-04 10:29   ` [EXT] " Akhil Goyal
  1 sibling, 1 reply; 5+ messages in thread
From: Kai Ji @ 2022-03-01 15:02 UTC (permalink / raw)
  To: dev; +Cc: gakhil, roy.fan.zhang, Kai Ji

This patch fix the memory corruptions issue reported by
coverity. The process type handling in QAT PMDs where only
primary and secondary process are supported in qat build
request.

Coverity issue: 376551, 376570, 376534
Fixes: b62d00d0d247 ("crypto/qat: rework burst data path")

Signed-off-by: Kai Ji <kai.ji@intel.com>
---
 drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c | 3 +++
 drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c | 3 +++
 drivers/crypto/qat/dev/qat_sym_pmd_gen1.c    | 3 +++
 drivers/crypto/qat/qat_sym.c                 | 8 ++++----
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
index 5084a5fcd1..2d5f10aeac 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen3.c
@@ -358,6 +358,9 @@ qat_sym_crypto_set_session_gen3(void *cdev __rte_unused, void *session)
 	enum rte_proc_type_t proc_type = rte_eal_process_type();
 	int ret;
 
+	if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;
+
 	ret = qat_sym_crypto_set_session_gen1(cdev, session);
 	/* special single pass build request for GEN3 */
 	if (ctx->is_single_pass)
diff --git a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
index bd7f3785df..3d8b2e377c 100644
--- a/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
+++ b/drivers/crypto/qat/dev/qat_crypto_pmd_gen4.c
@@ -189,6 +189,9 @@ qat_sym_crypto_set_session_gen4(void *cdev, void *session)
 	enum rte_proc_type_t proc_type = rte_eal_process_type();
 	int ret;
 
+	if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;
+
 	ret = qat_sym_crypto_set_session_gen1(cdev, session);
 	/* special single pass build request for GEN4 */
 	if (ctx->is_single_pass && ctx->is_ucs)
diff --git a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
index 3bcb53cf9f..99f5a22a06 100644
--- a/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
+++ b/drivers/crypto/qat/dev/qat_sym_pmd_gen1.c
@@ -1149,6 +1149,9 @@ qat_sym_crypto_set_session_gen1(void *cryptodev __rte_unused, void *session)
 	enum rte_proc_type_t proc_type = rte_eal_process_type();
 	int handle_mixed = 0;
 
+	if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;
+
 	if ((ctx->qat_cmd == ICP_QAT_FW_LA_CMD_HASH_CIPHER ||
 			ctx->qat_cmd == ICP_QAT_FW_LA_CMD_CIPHER_HASH) &&
 			!ctx->is_gmac) {
diff --git a/drivers/crypto/qat/qat_sym.c b/drivers/crypto/qat/qat_sym.c
index 1ccffad5ab..ca8c9a8124 100644
--- a/drivers/crypto/qat/qat_sym.c
+++ b/drivers/crypto/qat/qat_sym.c
@@ -60,6 +60,10 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 	uintptr_t build_request_p = (uintptr_t)opaque[1];
 	qat_sym_build_request_t build_request = (void *)build_request_p;
 	struct qat_sym_session *ctx = NULL;
+	enum rte_proc_type_t proc_type = rte_eal_process_type();
+
+	if (proc_type == RTE_PROC_AUTO || proc_type == RTE_PROC_INVALID)
+		return -EINVAL;
 
 	if (likely(op->sess_type == RTE_CRYPTO_OP_WITH_SESSION)) {
 		ctx = get_sym_session_private_data(op->sym->session,
@@ -71,11 +75,9 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 		if (sess != (uintptr_t)ctx) {
 			struct rte_cryptodev *cdev;
 			struct qat_cryptodev_private *internals;
-			enum rte_proc_type_t proc_type;
 
 			cdev = rte_cryptodev_pmd_get_dev(ctx->dev_id);
 			internals = cdev->data->dev_private;
-			proc_type = rte_eal_process_type();
 
 			if (internals->qat_dev->qat_dev_gen != dev_gen) {
 				op->status =
@@ -105,7 +107,6 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 		if ((void *)sess != (void *)op->sym->sec_session) {
 			struct rte_cryptodev *cdev;
 			struct qat_cryptodev_private *internals;
-			enum rte_proc_type_t proc_type;
 
 			ctx = get_sec_session_private_data(
 					op->sym->sec_session);
@@ -130,7 +131,6 @@ qat_sym_build_request(void *in_op, uint8_t *out_msg,
 			}
 			cdev = rte_cryptodev_pmd_get_dev(ctx->dev_id);
 			internals = cdev->data->dev_private;
-			proc_type = rte_eal_process_type();
 
 			if (internals->qat_dev->qat_dev_gen != dev_gen) {
 				op->status =
-- 
2.17.1


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

* RE: [EXT] [dpdk-dev v2] crypto/qat: fix process type handling
  2022-03-01 15:02 ` [dpdk-dev v2] " Kai Ji
@ 2022-03-04 10:29   ` Akhil Goyal
  0 siblings, 0 replies; 5+ messages in thread
From: Akhil Goyal @ 2022-03-04 10:29 UTC (permalink / raw)
  To: Kai Ji, dev, David Marchand; +Cc: roy.fan.zhang

> This patch fix the memory corruptions issue reported by
> coverity. The process type handling in QAT PMDs where only
> primary and secondary process are supported in qat build
> request.
> 
> Coverity issue: 376551, 376570, 376534
> Fixes: b62d00d0d247 ("crypto/qat: rework burst data path")
> 
> Signed-off-by: Kai Ji <kai.ji@intel.com>
Applied to dpdk-next-crypto


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

end of thread, other threads:[~2022-03-04 10:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 17:36 [dpdk-dev] crypto/qat: fix process type handling Kai Ji
2022-03-01  8:00 ` David Marchand
2022-03-01 10:51   ` Ji, Kai
2022-03-01 15:02 ` [dpdk-dev v2] " Kai Ji
2022-03-04 10:29   ` [EXT] " Akhil Goyal

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).