diff --git a/0114-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch b/0086-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch similarity index 79% rename from 0114-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch rename to 0086-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch index e03993b..4d024c4 100644 --- a/0114-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch +++ b/0086-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch @@ -1,7 +1,7 @@ -From d491b5480de01ea64360c24b6a89db3ddaf640e1 Mon Sep 17 00:00:00 2001 +From 81796060fc415722c40b4db114f2009d76d12ba4 Mon Sep 17 00:00:00 2001 From: Yang Shen Date: Thu, 30 Nov 2023 14:25:14 +0800 -Subject: [PATCH 114/114] uadk: zlibwrapper - fix return value for +Subject: [PATCH 086/123] uadk: zlibwrapper - fix return value for wd_zlib_uadk_init It means the UADK compression library has been initialized when @@ -15,7 +15,7 @@ Signed-off-by: Yang Shen 1 file changed, 1 insertion(+) diff --git a/wd_zlibwrapper.c b/wd_zlibwrapper.c -index 7189b7f..e562910 100644 +index afa8ee7..953837a 100644 --- a/wd_zlibwrapper.c +++ b/wd_zlibwrapper.c @@ -73,6 +73,7 @@ static int wd_zlib_uadk_init(void) @@ -27,5 +27,5 @@ index 7189b7f..e562910 100644 out_freebmp: -- -2.25.1 +2.31.1.windows.1 diff --git a/0107-v1-hpre-fix-key-transfer-error-issue.patch b/0087-v1-hpre-fix-key-transfer-error-issue.patch similarity index 95% rename from 0107-v1-hpre-fix-key-transfer-error-issue.patch rename to 0087-v1-hpre-fix-key-transfer-error-issue.patch index 21d733d..fc747b0 100644 --- a/0107-v1-hpre-fix-key-transfer-error-issue.patch +++ b/0087-v1-hpre-fix-key-transfer-error-issue.patch @@ -1,7 +1,7 @@ -From d465cfbe854a2b0719de48e9973f1a3aa091c3f7 Mon Sep 17 00:00:00 2001 +From 9c06ef805f5905a1701de47236f6bc872d5a8b69 Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Thu, 30 Nov 2023 15:51:26 +0800 -Subject: [PATCH 107/114] v1/hpre: fix key transfer error issue +Subject: [PATCH 087/123] v1/hpre: fix key transfer error issue Currently, the RSA algorithm calls qm_crypto_bin_to_hpre_bin() to transfer the key when sending request. However, the key @@ -83,5 +83,5 @@ index 193ba56..0d0c3b4 100644 *data = wd_e->data; return (int)(wd_n->bsize + wd_e->bsize); -- -2.25.1 +2.31.1.windows.1 diff --git a/0108-uadk-hisi_hpre-fix-key-transfer-error-issue.patch b/0088-uadk-hisi_hpre-fix-key-transfer-error-issue.patch similarity index 94% rename from 0108-uadk-hisi_hpre-fix-key-transfer-error-issue.patch rename to 0088-uadk-hisi_hpre-fix-key-transfer-error-issue.patch index 9b7e98b..9de4c13 100644 --- a/0108-uadk-hisi_hpre-fix-key-transfer-error-issue.patch +++ b/0088-uadk-hisi_hpre-fix-key-transfer-error-issue.patch @@ -1,7 +1,7 @@ -From 40a78df99ab6e13ca8a2fda51a885c089c811f2e Mon Sep 17 00:00:00 2001 +From f7ae3c7bd7e7214bd27616c33f6c16c6be962b2a Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Thu, 30 Nov 2023 16:40:39 +0800 -Subject: [PATCH 108/114] uadk/hisi_hpre: fix key transfer error issue +Subject: [PATCH 088/123] uadk/hisi_hpre: fix key transfer error issue Currently, the RSA algorithm calls crypto_bin_to_hpre_bin() to transfer the key when sending request. However, the key @@ -83,5 +83,5 @@ index c7bb70e..61c7855 100644 *data = wd_e->data; -- -2.25.1 +2.31.1.windows.1 diff --git a/0109-uadk-v1-remove-duplicate-header-files.patch b/0089-uadk-v1-remove-duplicate-header-files.patch similarity index 89% rename from 0109-uadk-v1-remove-duplicate-header-files.patch rename to 0089-uadk-v1-remove-duplicate-header-files.patch index 75b88df..1e49350 100644 --- a/0109-uadk-v1-remove-duplicate-header-files.patch +++ b/0089-uadk-v1-remove-duplicate-header-files.patch @@ -1,7 +1,7 @@ -From 6bb23a7d5d8bf7afda47bddd52e16bf72b446f6b Mon Sep 17 00:00:00 2001 +From ccb0b04804fe8ba3404521f168ebe86eef064db7 Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Thu, 30 Nov 2023 15:51:28 +0800 -Subject: [PATCH 109/114] uadk/v1: remove duplicate header files +Subject: [PATCH 089/123] uadk/v1: remove duplicate header files Some of the header files are already included in wd.h, and hisi_rng_udrv.h already includes wd.h. Therefore, @@ -50,5 +50,5 @@ index 93f2f91..56814a4 100644 #include "v1/wd_util.h" #include "v1/wd_rng.h" -- -2.25.1 +2.31.1.windows.1 diff --git a/0110-uadk-fix-error-writing-data-to-uninitialized-memory.patch b/0090-uadk-fix-error-writing-data-to-uninitialized-memory.patch similarity index 87% rename from 0110-uadk-fix-error-writing-data-to-uninitialized-memory.patch rename to 0090-uadk-fix-error-writing-data-to-uninitialized-memory.patch index de177b6..f131c79 100644 --- a/0110-uadk-fix-error-writing-data-to-uninitialized-memory.patch +++ b/0090-uadk-fix-error-writing-data-to-uninitialized-memory.patch @@ -1,7 +1,7 @@ -From 4d64eedcb418802a8c6ae376b8d6fdda62ea61eb Mon Sep 17 00:00:00 2001 +From 4f7a10584db39dea3fbd5aad60dff507b512922a Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 15:51:29 +0800 -Subject: [PATCH 110/114] uadk: fix error writing data to uninitialized memory +Subject: [PATCH 090/123] uadk: fix error writing data to uninitialized memory After the memory is applied for, the memory must be initialized before being written. @@ -12,7 +12,7 @@ Signed-off-by: Qi Tao 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c -index d86a692..8e4c0bb 100644 +index 13db3f0..0baa85c 100644 --- a/drv/hisi_qm_udrv.c +++ b/drv/hisi_qm_udrv.c @@ -252,11 +252,10 @@ static int hisi_qm_setup_db(handle_t h_ctx, struct hisi_qm_queue_info *q_info) @@ -38,5 +38,5 @@ index d86a692..8e4c0bb 100644 config->sqn = qp_ctx.id; -- -2.25.1 +2.31.1.windows.1 diff --git a/0111-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch b/0091-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch similarity index 81% rename from 0111-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch rename to 0091-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch index fd1553b..9e3ca1b 100644 --- a/0111-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch +++ b/0091-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch @@ -1,7 +1,7 @@ -From d1b4b282c104cc2643e8d2eb83ec74df796b2c24 Mon Sep 17 00:00:00 2001 +From 9472d9abd068fea0a60a31d0ddd83a2aba1423cb Mon Sep 17 00:00:00 2001 From: Hao Fang Date: Thu, 30 Nov 2023 15:51:30 +0800 -Subject: [PATCH 111/114] uadk: drv/qm: fix resource leak by add qp info clear +Subject: [PATCH 091/123] uadk: drv/qm: fix resource leak by add qp info clear process The spin_lock need to destroy and mem region need @@ -13,7 +13,7 @@ Signed-off-by: Hao Fang 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c -index 8e4c0bb..76a270e 100644 +index 0baa85c..4c80959 100644 --- a/drv/hisi_qm_udrv.c +++ b/drv/hisi_qm_udrv.c @@ -449,10 +449,10 @@ void hisi_qm_free_qp(handle_t h_qp) @@ -32,5 +32,5 @@ index 8e4c0bb..76a270e 100644 free(qp); } -- -2.25.1 +2.31.1.windows.1 diff --git a/0112-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch b/0092-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch similarity index 85% rename from 0112-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch rename to 0092-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch index bd64ee8..fbf9044 100644 --- a/0112-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch +++ b/0092-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch @@ -1,7 +1,7 @@ -From fef7c7a3191e55c6daeb67df5c29b4b841445efe Mon Sep 17 00:00:00 2001 +From 831d59dcb71cfa15d0503c0fd1ac41cfdbd781ca Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 15:51:31 +0800 -Subject: [PATCH 112/114] uadk/v1: fix error writing data to uninitialized +Subject: [PATCH 092/123] uadk/v1: fix error writing data to uninitialized memory After the memory is applied for, the memory @@ -28,5 +28,5 @@ index 6cbcdf5..0ca38d2 100644 info->sq_tail_index = 0; -- -2.25.1 +2.31.1.windows.1 diff --git a/0113-uadk-check-queue-status-before-sending-doorbells.patch b/0093-uadk-check-queue-status-before-sending-doorbells.patch similarity index 96% rename from 0113-uadk-check-queue-status-before-sending-doorbells.patch rename to 0093-uadk-check-queue-status-before-sending-doorbells.patch index 0e9ab14..20c3874 100644 --- a/0113-uadk-check-queue-status-before-sending-doorbells.patch +++ b/0093-uadk-check-queue-status-before-sending-doorbells.patch @@ -1,7 +1,7 @@ -From 3e309b7dbcb2f9308a8ccb1b7cb7876f808a7394 Mon Sep 17 00:00:00 2001 +From cf6d321107cbbb91e440395c0a26075e500ed5be Mon Sep 17 00:00:00 2001 From: Weili Qian Date: Thu, 30 Nov 2023 16:41:27 +0800 -Subject: [PATCH] uadk: check queue status before sending doorbells +Subject: [PATCH 093/123] uadk: check queue status before sending doorbells When the device needs to be reset, the queue status is set to disable before resetting. The user process checks @@ -151,5 +151,5 @@ index 0e67cad..0a654d6 100644 } -- -2.25.1 +2.31.1.windows.1 diff --git a/0094-uadk-remove-drivers-alloc-and-free-resources.patch b/0094-uadk-remove-drivers-alloc-and-free-resources.patch new file mode 100644 index 0000000..a547776 --- /dev/null +++ b/0094-uadk-remove-drivers-alloc-and-free-resources.patch @@ -0,0 +1,1246 @@ +From 34ddd7607abcbc8de955eb68908bbbd09ef1d092 Mon Sep 17 00:00:00 2001 +From: Younger +Date: Sat, 9 Dec 2023 15:28:15 +0800 +Subject: [PATCH 094/123] uadk - remove drivers alloc and free resources + +Remove drivers alloc and free resources. + +Signed-off-by: Yang Shen +--- + drv/hisi_comp.c | 35 +++++++------------------ + drv/hisi_hpre.c | 67 ++++++++++++++--------------------------------- + drv/hisi_sec.c | 56 ++++++++++++++++----------------------- + include/wd_alg.h | 33 +++++------------------ + include/wd_util.h | 14 +++++----- + wd_aead.c | 25 ++++++++---------- + wd_cipher.c | 20 +++++++------- + wd_comp.c | 20 +++++++------- + wd_dh.c | 20 +++++++++----- + wd_digest.c | 26 +++++++++--------- + wd_ecc.c | 20 +++++++++----- + wd_rsa.c | 20 +++++++++----- + wd_util.c | 30 +++++++++++++++------ + 13 files changed, 174 insertions(+), 212 deletions(-) + +diff --git a/drv/hisi_comp.c b/drv/hisi_comp.c +index 2cb9a6b..d6c0a2a 100644 +--- a/drv/hisi_comp.c ++++ b/drv/hisi_comp.c +@@ -785,30 +785,21 @@ static void hisi_zip_sqe_ops_adapt(handle_t h_qp) + } + } + +-static int hisi_zip_init(struct wd_alg_driver *drv, void *conf) ++static int hisi_zip_init(void *conf, void *priv) + { +- struct hisi_zip_ctx *priv = (struct hisi_zip_ctx *)drv->priv; + struct wd_ctx_config_internal *config = conf; ++ struct hisi_zip_ctx *zip_ctx = (struct hisi_zip_ctx *)priv; + struct hisi_qm_priv qm_priv; + handle_t h_qp = 0; + handle_t h_ctx; + __u32 i, j; + +- if (priv) { +- /* return if already inited */ +- return 0; +- } +- + if (!config->ctx_num) { + WD_ERR("invalid: zip init config ctx num is 0!\n"); + return -WD_EINVAL; + } + +- priv = malloc(sizeof(struct hisi_zip_ctx)); +- if (!priv) +- return -WD_EINVAL; +- +- memcpy(&priv->config, config, sizeof(struct wd_ctx_config_internal)); ++ memcpy(&zip_ctx->config, config, sizeof(struct wd_ctx_config_internal)); + /* allocate qp for each context */ + for (i = 0; i < config->ctx_num; i++) { + h_ctx = config->ctxs[i].ctx; +@@ -826,7 +817,6 @@ static int hisi_zip_init(struct wd_alg_driver *drv, void *conf) + } + + hisi_zip_sqe_ops_adapt(h_qp); +- drv->priv = priv; + + return 0; + out: +@@ -834,28 +824,20 @@ out: + h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[j].ctx); + hisi_qm_free_qp(h_qp); + } +- free(priv); + return -WD_EINVAL; + } + +-static void hisi_zip_exit(struct wd_alg_driver *drv) ++static void hisi_zip_exit(void *priv) + { +- struct hisi_zip_ctx *priv = (struct hisi_zip_ctx *)drv->priv; +- struct wd_ctx_config_internal *config = &priv->config; ++ struct hisi_zip_ctx *zip_ctx = (struct hisi_zip_ctx *)priv; ++ struct wd_ctx_config_internal *config = &zip_ctx->config; + handle_t h_qp; + __u32 i; + +- if (!priv) { +- /* return if already exit */ +- return; +- } +- + for (i = 0; i < config->ctx_num; i++) { + h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[i].ctx); + hisi_qm_free_qp(h_qp); + } +- free(priv); +- drv->priv = NULL; + } + + static int fill_zip_comp_sqe(struct hisi_qp *qp, struct wd_comp_msg *msg, +@@ -935,7 +917,7 @@ static void free_hw_sgl(handle_t h_qp, struct hisi_zip_sqe *sqe, + } + } + +-static int hisi_zip_comp_send(struct wd_alg_driver *drv, handle_t ctx, void *comp_msg) ++static int hisi_zip_comp_send(handle_t ctx, void *comp_msg) + { + struct hisi_qp *qp = wd_ctx_get_priv(ctx); + struct wd_comp_msg *msg = comp_msg; +@@ -1075,7 +1057,7 @@ static int parse_zip_sqe(struct hisi_qp *qp, struct hisi_zip_sqe *sqe, + return 0; + } + +-static int hisi_zip_comp_recv(struct wd_alg_driver *drv, handle_t ctx, void *comp_msg) ++static int hisi_zip_comp_recv(handle_t ctx, void *comp_msg) + { + struct hisi_qp *qp = wd_ctx_get_priv(ctx); + struct wd_comp_msg *recv_msg = comp_msg; +@@ -1097,6 +1079,7 @@ static int hisi_zip_comp_recv(struct wd_alg_driver *drv, handle_t ctx, void *com + .alg_name = (zip_alg_name),\ + .calc_type = UADK_ALG_HW,\ + .priority = 100,\ ++ .priv_size = sizeof(struct hisi_zip_ctx),\ + .queue_num = ZIP_CTX_Q_NUM_DEF,\ + .op_type_num = 2,\ + .fallback = 0,\ +diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c +index 61c7855..2f8a5d6 100644 +--- a/drv/hisi_hpre.c ++++ b/drv/hisi_hpre.c +@@ -506,90 +506,60 @@ out: + return -WD_EINVAL; + } + +-static int hpre_rsa_dh_init(struct wd_alg_driver *drv, void *conf) ++static int hpre_rsa_dh_init(void *conf, void *priv) + { + struct wd_ctx_config_internal *config = (struct wd_ctx_config_internal *)conf; +- struct hisi_hpre_ctx *priv = (struct hisi_hpre_ctx *)drv->priv; ++ struct hisi_hpre_ctx *hpre_ctx = (struct hisi_hpre_ctx *)priv; + struct hisi_qm_priv qm_priv; + int ret; + +- if (priv) { +- /* return if already inited */ +- return 0; +- } +- + if (!config->ctx_num) { + WD_ERR("invalid: hpre rsa/dh init config ctx num is 0!\n"); + return -WD_EINVAL; + } + +- drv->priv = malloc(sizeof(struct hisi_hpre_ctx)); +- if (!drv->priv) +- return -WD_EINVAL; +- + qm_priv.op_type = HPRE_HW_V2_ALG_TYPE; +- ret = hpre_init_qm_priv(config, drv->priv, &qm_priv); +- if (ret) { +- free(drv->priv); ++ ret = hpre_init_qm_priv(config, hpre_ctx, &qm_priv); ++ if (ret) + return ret; +- } + + return 0; + } + +-static int hpre_ecc_init(struct wd_alg_driver *drv, void *conf) ++static int hpre_ecc_init(void *conf, void *priv) + { + struct wd_ctx_config_internal *config = (struct wd_ctx_config_internal *)conf; +- struct hisi_hpre_ctx *priv = (struct hisi_hpre_ctx *)drv->priv; ++ struct hisi_hpre_ctx *hpre_ctx = (struct hisi_hpre_ctx *)priv; + struct hisi_qm_priv qm_priv; + int ret; + +- if (priv) { +- /* return if already inited */ +- return 0; +- } +- + if (!config->ctx_num) { + WD_ERR("invalid: hpre ecc init config ctx num is 0!\n"); + return -WD_EINVAL; + } + +- drv->priv = malloc(sizeof(struct hisi_hpre_ctx)); +- if (!drv->priv) +- return -WD_EINVAL; +- + qm_priv.op_type = HPRE_HW_V3_ECC_ALG_TYPE; +- ret = hpre_init_qm_priv(config, drv->priv, &qm_priv); +- if (ret) { +- free(drv->priv); ++ ret = hpre_init_qm_priv(config, hpre_ctx, &qm_priv); ++ if (ret) + return ret; +- } + + return 0; + } + +-static void hpre_exit(struct wd_alg_driver *drv) ++static void hpre_exit(void *priv) + { +- struct hisi_hpre_ctx *priv = (struct hisi_hpre_ctx *)drv->priv; +- struct wd_ctx_config_internal *config = &priv->config; ++ struct hisi_hpre_ctx *hpre_ctx = (struct hisi_hpre_ctx *)priv; ++ struct wd_ctx_config_internal *config = &hpre_ctx->config; + handle_t h_qp; + __u32 i; + +- if (!priv) { +- /* return if already exit */ +- return; +- } +- + for (i = 0; i < config->ctx_num; i++) { + h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[i].ctx); + hisi_qm_free_qp(h_qp); + } +- +- free(priv); +- drv->priv = NULL; + } + +-static int rsa_send(struct wd_alg_driver *drv, handle_t ctx, void *rsa_msg) ++static int rsa_send(handle_t ctx, void *rsa_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_rsa_msg *msg = rsa_msg; +@@ -645,7 +615,7 @@ static void hpre_result_check(struct hisi_hpre_sqe *hw_msg, + } + } + +-static int rsa_recv(struct wd_alg_driver *drv, handle_t ctx, void *rsa_msg) ++static int rsa_recv(handle_t ctx, void *rsa_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; +@@ -743,7 +713,7 @@ static int dh_out_transfer(struct wd_dh_msg *msg, + return WD_SUCCESS; + } + +-static int dh_send(struct wd_alg_driver *drv, handle_t ctx, void *dh_msg) ++static int dh_send(handle_t ctx, void *dh_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_dh_msg *msg = dh_msg; +@@ -788,7 +758,7 @@ static int dh_send(struct wd_alg_driver *drv, handle_t ctx, void *dh_msg) + return hisi_qm_send(h_qp, &hw_msg, 1, &send_cnt); + } + +-static int dh_recv(struct wd_alg_driver *drv, handle_t ctx, void *dh_msg) ++static int dh_recv(handle_t ctx, void *dh_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; +@@ -1879,7 +1849,7 @@ free_dst: + return ret; + } + +-static int ecc_send(struct wd_alg_driver *drv, handle_t ctx, void *ecc_msg) ++static int ecc_send(handle_t ctx, void *ecc_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_ecc_msg *msg = ecc_msg; +@@ -2451,7 +2421,7 @@ fail: + return ret; + } + +-static int ecc_recv(struct wd_alg_driver *drv, handle_t ctx, void *ecc_msg) ++static int ecc_recv(handle_t ctx, void *ecc_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_ecc_msg *msg = ecc_msg; +@@ -2488,6 +2458,7 @@ static int hpre_get_usage(void *param) + .alg_name = (hpre_alg_name),\ + .calc_type = UADK_ALG_HW,\ + .priority = 100,\ ++ .priv_size = sizeof(struct hisi_hpre_ctx),\ + .queue_num = HPRE_CTX_Q_NUM_DEF,\ + .op_type_num = 1,\ + .fallback = 0,\ +@@ -2511,6 +2482,7 @@ static struct wd_alg_driver hpre_rsa_driver = { + .alg_name = "rsa", + .calc_type = UADK_ALG_HW, + .priority = 100, ++ .priv_size = sizeof(struct hisi_hpre_ctx), + .queue_num = HPRE_CTX_Q_NUM_DEF, + .op_type_num = 1, + .fallback = 0, +@@ -2526,6 +2498,7 @@ static struct wd_alg_driver hpre_dh_driver = { + .alg_name = "dh", + .calc_type = UADK_ALG_HW, + .priority = 100, ++ .priv_size = sizeof(struct hisi_hpre_ctx), + .queue_num = HPRE_CTX_Q_NUM_DEF, + .op_type_num = 1, + .fallback = 0, +diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c +index 03e7037..341e91a 100644 +--- a/drv/hisi_sec.c ++++ b/drv/hisi_sec.c +@@ -536,8 +536,8 @@ static __u32 g_sec_hmac_full_len[WD_DIGEST_TYPE_MAX] = { + SEC_HMAC_SHA512_MAC_LEN, SEC_HMAC_SHA512_224_MAC_LEN, SEC_HMAC_SHA512_256_MAC_LEN + }; + +-static int hisi_sec_init(struct wd_alg_driver *drv, void *conf); +-static void hisi_sec_exit(struct wd_alg_driver *drv); ++static int hisi_sec_init(void *conf, void *priv); ++static void hisi_sec_exit(void *priv); + + static int hisi_sec_get_usage(void *param) + { +@@ -550,6 +550,7 @@ static int hisi_sec_get_usage(void *param) + .alg_name = (sec_alg_name),\ + .calc_type = UADK_ALG_HW,\ + .priority = 100,\ ++ .priv_size = sizeof(struct hisi_sec_ctx),\ + .queue_num = SEC_CTX_Q_NUM_DEF,\ + .op_type_num = 1,\ + .fallback = 0,\ +@@ -1092,7 +1093,7 @@ static int fill_cipher_bd2(struct wd_cipher_msg *msg, struct hisi_sec_sqe *sqe) + return 0; + } + +-int hisi_sec_cipher_send(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) ++int hisi_sec_cipher_send(handle_t ctx, void *cipher_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_cipher_msg *msg = cipher_msg; +@@ -1137,7 +1138,7 @@ int hisi_sec_cipher_send(struct wd_alg_driver *drv, handle_t ctx, void *cipher_m + return 0; + } + +-int hisi_sec_cipher_recv(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) ++int hisi_sec_cipher_recv(handle_t ctx, void *cipher_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_cipher_msg *recv_msg = cipher_msg; +@@ -1295,7 +1296,7 @@ static int fill_cipher_bd3(struct wd_cipher_msg *msg, struct hisi_sec_sqe3 *sqe) + return 0; + } + +-int hisi_sec_cipher_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) ++int hisi_sec_cipher_send_v3(handle_t ctx, void *cipher_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_cipher_msg *msg = cipher_msg; +@@ -1385,7 +1386,7 @@ static void parse_cipher_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, + dump_sec_msg(temp_msg, "cipher"); + } + +-int hisi_sec_cipher_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) ++int hisi_sec_cipher_recv_v3(handle_t ctx, void *cipher_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_cipher_msg *recv_msg = cipher_msg; +@@ -1658,7 +1659,7 @@ static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type) + return 0; + } + +-int hisi_sec_digest_send(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) ++int hisi_sec_digest_send(handle_t ctx, void *digest_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_digest_msg *msg = digest_msg; +@@ -1725,7 +1726,7 @@ put_sgl: + return ret; + } + +-int hisi_sec_digest_recv(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) ++int hisi_sec_digest_recv(handle_t ctx, void *digest_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_digest_msg *recv_msg = digest_msg; +@@ -1902,7 +1903,7 @@ static void fill_digest_v3_scene(struct hisi_sec_sqe3 *sqe, + sqe->bd_param |= (__u16)(de | scene); + } + +-int hisi_sec_digest_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) ++int hisi_sec_digest_send_v3(handle_t ctx, void *digest_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_digest_msg *msg = digest_msg; +@@ -2001,7 +2002,7 @@ static void parse_digest_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, + dump_sec_msg(temp_msg, "digest"); + } + +-int hisi_sec_digest_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) ++int hisi_sec_digest_recv_v3(handle_t ctx, void *digest_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_digest_msg *recv_msg = digest_msg; +@@ -2473,7 +2474,7 @@ int aead_msg_state_check(struct wd_aead_msg *msg) + return 0; + } + +-int hisi_sec_aead_send(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) ++int hisi_sec_aead_send(handle_t ctx, void *aead_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_aead_msg *msg = aead_msg; +@@ -2595,7 +2596,7 @@ static bool soft_compute_check(struct hisi_qp *qp, struct wd_aead_msg *msg) + qp->q_info.qp_mode == CTX_MODE_SYNC; + } + +-int hisi_sec_aead_recv(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) ++int hisi_sec_aead_recv(handle_t ctx, void *aead_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_aead_msg *recv_msg = aead_msg; +@@ -2857,7 +2858,7 @@ static int fill_aead_bd3(struct wd_aead_msg *msg, struct hisi_sec_sqe3 *sqe) + return 0; + } + +-int hisi_sec_aead_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) ++int hisi_sec_aead_send_v3(handle_t ctx, void *aead_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_aead_msg *msg = aead_msg; +@@ -2957,7 +2958,7 @@ static void parse_aead_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, + dump_sec_msg(temp_msg, "aead"); + } + +-int hisi_sec_aead_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) ++int hisi_sec_aead_recv_v3(handle_t ctx, void *aead_msg) + { + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct wd_aead_msg *recv_msg = aead_msg; +@@ -3029,29 +3030,20 @@ static void hisi_sec_driver_adapter(struct hisi_qp *qp) + } + } + +-static int hisi_sec_init(struct wd_alg_driver *drv, void *conf) ++static int hisi_sec_init(void *conf, void *priv) + { +- struct hisi_sec_ctx *priv = (struct hisi_sec_ctx *)drv->priv; + struct wd_ctx_config_internal *config = conf; ++ struct hisi_sec_ctx *sec_ctx = priv; + struct hisi_qm_priv qm_priv; + handle_t h_qp = 0; + handle_t h_ctx; + __u32 i, j; + +- if (priv) { +- /* return if already inited */ +- return 0; +- } +- + if (!config->ctx_num) { + WD_ERR("invalid: sec init config ctx num is 0!\n"); + return -WD_EINVAL; + } + +- priv = malloc(sizeof(struct hisi_sec_ctx)); +- if (!priv) +- return -WD_EINVAL; +- + qm_priv.sqe_size = sizeof(struct hisi_sec_sqe); + /* allocate qp for each context */ + for (i = 0; i < config->ctx_num; i++) { +@@ -3068,9 +3060,8 @@ static int hisi_sec_init(struct wd_alg_driver *drv, void *conf) + goto out; + config->ctxs[i].sqn = qm_priv.sqn; + } +- memcpy(&priv->config, config, sizeof(struct wd_ctx_config_internal)); ++ memcpy(&sec_ctx->config, config, sizeof(struct wd_ctx_config_internal)); + hisi_sec_driver_adapter((struct hisi_qp *)h_qp); +- drv->priv = priv; + + return 0; + +@@ -3079,29 +3070,26 @@ out: + h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[j].ctx); + hisi_qm_free_qp(h_qp); + } +- free(priv); + return -WD_EINVAL; + } + +-static void hisi_sec_exit(struct wd_alg_driver *drv) ++static void hisi_sec_exit(void *priv) + { +- struct hisi_sec_ctx *priv = (struct hisi_sec_ctx *)drv->priv; ++ struct hisi_sec_ctx *sec_ctx = priv; + struct wd_ctx_config_internal *config; + handle_t h_qp; + __u32 i; + + if (!priv) { +- /* return if already exit */ ++ WD_ERR("invalid: input parameter is NULL!\n"); + return; + } + +- config = &priv->config; ++ config = &sec_ctx->config; + for (i = 0; i < config->ctx_num; i++) { + h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[i].ctx); + hisi_qm_free_qp(h_qp); + } +- free(priv); +- drv->priv = NULL; + } + + static void __attribute__((constructor)) hisi_sec2_probe(void) +diff --git a/include/wd_alg.h b/include/wd_alg.h +index f8b136e..e71a6f9 100644 +--- a/include/wd_alg.h ++++ b/include/wd_alg.h +@@ -41,7 +41,8 @@ enum alg_dev_type { + * execute the algorithm task + * @op_type_num: number of modes in which the device executes the + * algorithm business and requires queues to be executed separately +- * @priv: pointer of priv ctx ++ * @priv_size: parameter memory size passed between the internal ++ * interfaces of the driver + * @fallback: soft calculation driver handle when performing soft + * calculation supplement + * @init: callback interface for initializing device drivers +@@ -60,36 +61,16 @@ struct wd_alg_driver { + int calc_type; + int queue_num; + int op_type_num; +- void *priv; ++ int priv_size; + handle_t fallback; + +- int (*init)(struct wd_alg_driver *drv, void *conf); +- void (*exit)(struct wd_alg_driver *drv); +- int (*send)(struct wd_alg_driver *drv, handle_t ctx, void *drv_msg); +- int (*recv)(struct wd_alg_driver *drv, handle_t ctx, void *drv_msg); ++ int (*init)(void *conf, void *priv); ++ void (*exit)(void *priv); ++ int (*send)(handle_t ctx, void *drv_msg); ++ int (*recv)(handle_t ctx, void *drv_msg); + int (*get_usage)(void *param); + }; + +-inline int wd_alg_driver_init(struct wd_alg_driver *drv, void *conf) +-{ +- return drv->init(drv, conf); +-} +- +-inline void wd_alg_driver_exit(struct wd_alg_driver *drv) +-{ +- drv->exit(drv); +-} +- +-inline int wd_alg_driver_send(struct wd_alg_driver *drv, handle_t ctx, void *msg) +-{ +- return drv->send(drv, ctx, msg); +-} +- +-inline int wd_alg_driver_recv(struct wd_alg_driver *drv, handle_t ctx, void *msg) +-{ +- return drv->recv(drv, ctx, msg); +-} +- + /** + * wd_alg_driver_register() - Register a device driver. + * @wd_alg_driver: a device driver that supports an algorithm. +diff --git a/include/wd_util.h b/include/wd_util.h +index be9798c..0f35ccf 100644 +--- a/include/wd_util.h ++++ b/include/wd_util.h +@@ -115,8 +115,8 @@ struct wd_ctx_attr { + }; + + struct wd_msg_handle { +- int (*send)(struct wd_alg_driver *drv, handle_t ctx, void *drv_msg); +- int (*recv)(struct wd_alg_driver *drv, handle_t ctx, void *drv_msg); ++ int (*send)(handle_t sess, void *msg); ++ int (*recv)(handle_t sess, void *msg); + }; + + struct wd_init_attrs { +@@ -361,7 +361,6 @@ int wd_set_epoll_en(const char *var_name, bool *epoll_en); + + /** + * wd_handle_msg_sync() - recv msg from hardware +- * @drv: the driver to handle msg. + * @msg_handle: callback of msg handle ops. + * @ctx: the handle of context. + * @msg: the msg of task. +@@ -370,8 +369,8 @@ int wd_set_epoll_en(const char *var_name, bool *epoll_en); + * + * Return 0 if successful or less than 0 otherwise. + */ +-int wd_handle_msg_sync(struct wd_alg_driver *drv, struct wd_msg_handle *msg_handle, +- handle_t ctx, void *msg, __u64 *balance, bool epoll_en); ++int wd_handle_msg_sync(struct wd_msg_handle *msg_handle, handle_t ctx, ++ void *msg, __u64 *balance, bool epoll_en); + + /** + * wd_init_check() - Check input parameters for wd__init. +@@ -469,13 +468,14 @@ void wd_alg_drv_unbind(struct wd_alg_driver *drv); + * to the obtained queue resource and the applied driver. + * @config: device resources requested by the current algorithm. + * @driver: device driver for the current algorithm application. ++ * @drv_priv: the parameter pointer of the current device driver. + * + * Return 0 if succeed and other error number if fail. + */ + int wd_alg_init_driver(struct wd_ctx_config_internal *config, +- struct wd_alg_driver *driver); ++ struct wd_alg_driver *driver, void **drv_priv); + void wd_alg_uninit_driver(struct wd_ctx_config_internal *config, +- struct wd_alg_driver *driver); ++ struct wd_alg_driver *driver, void **drv_priv); + + /** + * wd_dlopen_drv() - Open the dynamic library file of the device driver. +diff --git a/wd_aead.c b/wd_aead.c +index 87d61c3..20d1109 100644 +--- a/wd_aead.c ++++ b/wd_aead.c +@@ -43,6 +43,7 @@ struct wd_aead_setting { + struct wd_sched sched; + struct wd_alg_driver *driver; + struct wd_async_msg_pool pool; ++ void *priv; + void *dlhandle; + void *dlh_list; + } wd_aead_setting; +@@ -434,7 +435,8 @@ static int wd_aead_init_nolock(struct wd_ctx_config *config, struct wd_sched *sc + goto out_clear_sched; + + ret = wd_alg_init_driver(&wd_aead_setting.config, +- wd_aead_setting.driver); ++ wd_aead_setting.driver, ++ &wd_aead_setting.priv); + if (ret) + goto out_clear_pool; + +@@ -488,15 +490,13 @@ static void wd_aead_uninit_nolock(void) + wd_uninit_async_request_pool(&wd_aead_setting.pool); + wd_clear_sched(&wd_aead_setting.sched); + wd_alg_uninit_driver(&wd_aead_setting.config, +- wd_aead_setting.driver); ++ wd_aead_setting.driver, ++ &wd_aead_setting.priv); + } + + void wd_aead_uninit(void) + { +- enum wd_status status; +- +- wd_alg_get_init(&wd_aead_setting.status, &status); +- if (status == WD_UNINIT) ++ if (!wd_aead_setting.priv) + return; + + wd_aead_uninit_nolock(); +@@ -612,10 +612,7 @@ out_uninit: + + void wd_aead_uninit2(void) + { +- enum wd_status status; +- +- wd_alg_get_init(&wd_aead_setting.status, &status); +- if (status == WD_UNINIT) ++ if (!wd_aead_setting.priv) + return; + + wd_aead_uninit_nolock(); +@@ -705,8 +702,8 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, + msg_handle.recv = wd_aead_setting.driver->recv; + + pthread_spin_lock(&ctx->lock); +- ret = wd_handle_msg_sync(wd_aead_setting.driver, &msg_handle, ctx->ctx, +- msg, NULL, wd_aead_setting.config.epoll_en); ++ ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, msg, NULL, ++ wd_aead_setting.config.epoll_en); + pthread_spin_unlock(&ctx->lock); + + return ret; +@@ -781,7 +778,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req) + fill_request_msg(msg, req, sess); + msg->tag = msg_id; + +- ret = wd_alg_driver_send(wd_aead_setting.driver, ctx->ctx, msg); ++ ret = wd_aead_setting.driver->send(ctx->ctx, msg); + if (unlikely(ret < 0)) { + if (ret != -WD_EBUSY) + WD_ERR("failed to send BD, hw is err!\n"); +@@ -830,7 +827,7 @@ int wd_aead_poll_ctx(__u32 idx, __u32 expt, __u32 *count) + ctx = config->ctxs + idx; + + do { +- ret = wd_alg_driver_recv(wd_aead_setting.driver, ctx->ctx, &resp_msg); ++ ret = wd_aead_setting.driver->recv(ctx->ctx, &resp_msg); + if (ret == -WD_EAGAIN) { + return ret; + } else if (ret < 0) { +diff --git a/wd_cipher.c b/wd_cipher.c +index 58d34f7..76b9bad 100644 +--- a/wd_cipher.c ++++ b/wd_cipher.c +@@ -60,6 +60,7 @@ struct wd_cipher_setting { + struct wd_sched sched; + struct wd_async_msg_pool pool; + struct wd_alg_driver *driver; ++ void *priv; + void *dlhandle; + void *dlh_list; + } wd_cipher_setting; +@@ -323,7 +324,8 @@ static int wd_cipher_common_init(struct wd_ctx_config *config, + goto out_clear_sched; + + ret = wd_alg_init_driver(&wd_cipher_setting.config, +- wd_cipher_setting.driver); ++ wd_cipher_setting.driver, ++ &wd_cipher_setting.priv); + if (ret) + goto out_clear_pool; + +@@ -340,10 +342,9 @@ out_clear_ctx_config: + + static int wd_cipher_common_uninit(void) + { +- enum wd_status status; ++ void *priv = wd_cipher_setting.priv; + +- wd_alg_get_init(&wd_cipher_setting.status, &status); +- if (status == WD_UNINIT) ++ if (!priv) + return -WD_EINVAL; + + /* uninit async request pool */ +@@ -353,7 +354,8 @@ static int wd_cipher_common_uninit(void) + wd_clear_sched(&wd_cipher_setting.sched); + + wd_alg_uninit_driver(&wd_cipher_setting.config, +- wd_cipher_setting.driver); ++ wd_cipher_setting.driver, ++ &wd_cipher_setting.priv); + + return 0; + } +@@ -619,8 +621,8 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, + msg_handle.recv = wd_cipher_setting.driver->recv; + + pthread_spin_lock(&ctx->lock); +- ret = wd_handle_msg_sync(wd_cipher_setting.driver, &msg_handle, ctx->ctx, +- msg, NULL, wd_cipher_setting.config.epoll_en); ++ ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, msg, NULL, ++ wd_cipher_setting.config.epoll_en); + pthread_spin_unlock(&ctx->lock); + + return ret; +@@ -695,7 +697,7 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req) + fill_request_msg(msg, req, sess); + msg->tag = msg_id; + +- ret = wd_alg_driver_send(wd_cipher_setting.driver, ctx->ctx, msg); ++ ret = wd_cipher_setting.driver->send(ctx->ctx, msg); + if (unlikely(ret < 0)) { + if (ret != -WD_EBUSY) + WD_ERR("wd cipher async send err!\n"); +@@ -744,7 +746,7 @@ int wd_cipher_poll_ctx(__u32 idx, __u32 expt, __u32 *count) + ctx = config->ctxs + idx; + + do { +- ret = wd_alg_driver_recv(wd_cipher_setting.driver, ctx->ctx, &resp_msg); ++ ret = wd_cipher_setting.driver->recv(ctx->ctx, &resp_msg); + if (ret == -WD_EAGAIN) + return ret; + else if (ret < 0) { +diff --git a/wd_comp.c b/wd_comp.c +index 6e71d35..b6fe85c 100644 +--- a/wd_comp.c ++++ b/wd_comp.c +@@ -47,6 +47,7 @@ struct wd_comp_setting { + struct wd_sched sched; + struct wd_async_msg_pool pool; + struct wd_alg_driver *driver; ++ void *priv; + void *dlhandle; + void *dlh_list; + } wd_comp_setting; +@@ -136,7 +137,8 @@ static int wd_comp_init_nolock(struct wd_ctx_config *config, struct wd_sched *sc + goto out_clear_sched; + + ret = wd_alg_init_driver(&wd_comp_setting.config, +- wd_comp_setting.driver); ++ wd_comp_setting.driver, ++ &wd_comp_setting.priv); + if (ret) + goto out_clear_pool; + +@@ -153,10 +155,9 @@ out_clear_ctx_config: + + static int wd_comp_uninit_nolock(void) + { +- enum wd_status status; ++ void *priv = wd_comp_setting.priv; + +- wd_alg_get_init(&wd_comp_setting.status, &status); +- if (status == WD_UNINIT) ++ if (!priv) + return -WD_EINVAL; + + /* Uninit async request pool */ +@@ -166,7 +167,8 @@ static int wd_comp_uninit_nolock(void) + wd_clear_sched(&wd_comp_setting.sched); + + wd_alg_uninit_driver(&wd_comp_setting.config, +- wd_comp_setting.driver); ++ wd_comp_setting.driver, ++ &wd_comp_setting.priv); + + return 0; + } +@@ -354,7 +356,7 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count) + ctx = config->ctxs + idx; + + do { +- ret = wd_alg_driver_recv(wd_comp_setting.driver, ctx->ctx, &resp_msg); ++ ret = wd_comp_setting.driver->recv(ctx->ctx, &resp_msg); + if (unlikely(ret < 0)) { + if (ret == -WD_HW_EACCESS) + WD_ERR("wd comp recv hw error!\n"); +@@ -588,8 +590,8 @@ static int wd_comp_sync_job(struct wd_comp_sess *sess, + msg_handle.recv = wd_comp_setting.driver->recv; + + pthread_spin_lock(&ctx->lock); +- ret = wd_handle_msg_sync(wd_comp_setting.driver, &msg_handle, ctx->ctx, +- msg, NULL, config->epoll_en); ++ ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, msg, ++ NULL, config->epoll_en); + pthread_spin_unlock(&ctx->lock); + + return ret; +@@ -843,7 +845,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req) + msg->tag = tag; + msg->stream_mode = WD_COMP_STATELESS; + +- ret = wd_alg_driver_send(wd_comp_setting.driver, ctx->ctx, msg); ++ ret = wd_comp_setting.driver->send(ctx->ctx, msg); + if (unlikely(ret < 0)) { + WD_ERR("wd comp send error, ret = %d!\n", ret); + goto fail_with_msg; +diff --git a/wd_dh.c b/wd_dh.c +index 40a52e5..157f7c6 100644 +--- a/wd_dh.c ++++ b/wd_dh.c +@@ -34,6 +34,7 @@ static struct wd_dh_setting { + struct wd_sched sched; + struct wd_async_msg_pool pool; + struct wd_alg_driver *driver; ++ void *priv; + void *dlhandle; + void *dlh_list; + } wd_dh_setting; +@@ -110,7 +111,8 @@ static int wd_dh_common_init(struct wd_ctx_config *config, struct wd_sched *sche + goto out_clear_sched; + + ret = wd_alg_init_driver(&wd_dh_setting.config, +- wd_dh_setting.driver); ++ wd_dh_setting.driver, ++ &wd_dh_setting.priv); + if (ret) + goto out_clear_pool; + +@@ -127,13 +129,19 @@ out_clear_ctx_config: + + static int wd_dh_common_uninit(void) + { ++ if (!wd_dh_setting.priv) { ++ WD_ERR("invalid: repeat uninit dh!\n"); ++ return -WD_EINVAL; ++ } ++ + /* uninit async request pool */ + wd_uninit_async_request_pool(&wd_dh_setting.pool); + + /* unset config, sched, driver */ + wd_clear_sched(&wd_dh_setting.sched); + wd_alg_uninit_driver(&wd_dh_setting.config, +- wd_dh_setting.driver); ++ wd_dh_setting.driver, ++ &wd_dh_setting.priv); + + return 0; + } +@@ -356,8 +364,8 @@ int wd_do_dh_sync(handle_t sess, struct wd_dh_req *req) + msg_handle.recv = wd_dh_setting.driver->recv; + + pthread_spin_lock(&ctx->lock); +- ret = wd_handle_msg_sync(wd_dh_setting.driver, &msg_handle, ctx->ctx, +- &msg, &balance, wd_dh_setting.config.epoll_en); ++ ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, &msg, &balance, ++ wd_dh_setting.config.epoll_en); + pthread_spin_unlock(&ctx->lock); + if (unlikely(ret)) + return ret; +@@ -401,7 +409,7 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req) + goto fail_with_msg; + msg->tag = mid; + +- ret = wd_alg_driver_send(wd_dh_setting.driver, ctx->ctx, msg); ++ ret = wd_dh_setting.driver->send(ctx->ctx, msg); + if (unlikely(ret)) { + if (ret != -WD_EBUSY) + WD_ERR("failed to send dh BD, hw is err!\n"); +@@ -452,7 +460,7 @@ int wd_dh_poll_ctx(__u32 idx, __u32 expt, __u32 *count) + ctx = config->ctxs + idx; + + do { +- ret = wd_alg_driver_recv(wd_dh_setting.driver, ctx->ctx, &rcv_msg); ++ ret = wd_dh_setting.driver->recv(ctx->ctx, &rcv_msg); + if (ret == -WD_EAGAIN) { + return ret; + } else if (unlikely(ret)) { +diff --git a/wd_digest.c b/wd_digest.c +index 2307bf1..e523331 100644 +--- a/wd_digest.c ++++ b/wd_digest.c +@@ -50,6 +50,7 @@ struct wd_digest_setting { + struct wd_sched sched; + struct wd_alg_driver *driver; + struct wd_async_msg_pool pool; ++ void *priv; + void *dlhandle; + void *dlh_list; + } wd_digest_setting; +@@ -249,7 +250,8 @@ static int wd_digest_init_nolock(struct wd_ctx_config *config, + goto out_clear_sched; + + ret = wd_alg_init_driver(&wd_digest_setting.config, +- wd_digest_setting.driver); ++ wd_digest_setting.driver, ++ &wd_digest_setting.priv); + if (ret) + goto out_clear_pool; + +@@ -303,15 +305,13 @@ static void wd_digest_uninit_nolock(void) + wd_uninit_async_request_pool(&wd_digest_setting.pool); + wd_clear_sched(&wd_digest_setting.sched); + wd_alg_uninit_driver(&wd_digest_setting.config, +- wd_digest_setting.driver); ++ wd_digest_setting.driver, ++ &wd_digest_setting.priv); + } + + void wd_digest_uninit(void) + { +- enum wd_status status; +- +- wd_alg_get_init(&wd_digest_setting.status, &status); +- if (status == WD_UNINIT) ++ if (!wd_digest_setting.priv) + return; + + wd_digest_uninit_nolock(); +@@ -421,10 +421,7 @@ out_uninit: + + void wd_digest_uninit2(void) + { +- enum wd_status status; +- +- wd_alg_get_init(&wd_digest_setting.status, &status); +- if (status == WD_UNINIT) ++ if (!wd_digest_setting.priv) + return; + + wd_digest_uninit_nolock(); +@@ -576,8 +573,8 @@ static int send_recv_sync(struct wd_ctx_internal *ctx, struct wd_digest_sess *ds + msg_handle.recv = wd_digest_setting.driver->recv; + + pthread_spin_lock(&ctx->lock); +- ret = wd_handle_msg_sync(wd_digest_setting.driver, &msg_handle, ctx->ctx, +- msg, NULL, wd_digest_setting.config.epoll_en); ++ ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, msg, ++ NULL, wd_digest_setting.config.epoll_en); + pthread_spin_unlock(&ctx->lock); + if (unlikely(ret)) + return ret; +@@ -666,7 +663,7 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req) + fill_request_msg(msg, req, dsess); + msg->tag = msg_id; + +- ret = wd_alg_driver_send(wd_digest_setting.driver, ctx->ctx, msg); ++ ret = wd_digest_setting.driver->send(ctx->ctx, msg); + if (unlikely(ret < 0)) { + if (ret != -WD_EBUSY) + WD_ERR("failed to send BD, hw is err!\n"); +@@ -715,7 +712,8 @@ int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count) + ctx = config->ctxs + idx; + + do { +- ret = wd_alg_driver_recv(wd_digest_setting.driver, ctx->ctx, &recv_msg); ++ ret = wd_digest_setting.driver->recv(ctx->ctx, ++ &recv_msg); + if (ret == -WD_EAGAIN) { + return ret; + } else if (ret < 0) { +diff --git a/wd_ecc.c b/wd_ecc.c +index 4323e54..a1d4dae 100644 +--- a/wd_ecc.c ++++ b/wd_ecc.c +@@ -65,6 +65,7 @@ static struct wd_ecc_setting { + struct wd_sched sched; + struct wd_async_msg_pool pool; + struct wd_alg_driver *driver; ++ void *priv; + void *dlhandle; + void *dlh_list; + } wd_ecc_setting; +@@ -173,7 +174,8 @@ static int wd_ecc_common_init(struct wd_ctx_config *config, struct wd_sched *sch + goto out_clear_sched; + + ret = wd_alg_init_driver(&wd_ecc_setting.config, +- wd_ecc_setting.driver); ++ wd_ecc_setting.driver, ++ &wd_ecc_setting.priv); + if (ret) + goto out_clear_pool; + +@@ -190,13 +192,19 @@ out_clear_ctx_config: + + static int wd_ecc_common_uninit(void) + { ++ if (!wd_ecc_setting.priv) { ++ WD_ERR("invalid: repeat uninit ecc!\n"); ++ return -WD_EINVAL; ++ } ++ + /* uninit async request pool */ + wd_uninit_async_request_pool(&wd_ecc_setting.pool); + + /* unset config, sched, driver */ + wd_clear_sched(&wd_ecc_setting.sched); + wd_alg_uninit_driver(&wd_ecc_setting.config, +- wd_ecc_setting.driver); ++ wd_ecc_setting.driver, ++ &wd_ecc_setting.priv); + + return 0; + } +@@ -1559,8 +1567,8 @@ int wd_do_ecc_sync(handle_t h_sess, struct wd_ecc_req *req) + msg_handle.recv = wd_ecc_setting.driver->recv; + + pthread_spin_lock(&ctx->lock); +- ret = wd_handle_msg_sync(wd_ecc_setting.driver, &msg_handle, ctx->ctx, &msg, +- &balance, wd_ecc_setting.config.epoll_en); ++ ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, &msg, &balance, ++ wd_ecc_setting.config.epoll_en); + pthread_spin_unlock(&ctx->lock); + if (unlikely(ret)) + return ret; +@@ -2237,7 +2245,7 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req) + goto fail_with_msg; + msg->tag = mid; + +- ret = wd_alg_driver_send(wd_ecc_setting.driver, ctx->ctx, msg); ++ ret = wd_ecc_setting.driver->send(ctx->ctx, msg); + if (unlikely(ret)) { + if (ret != -WD_EBUSY) + WD_ERR("failed to send ecc BD, hw is err!\n"); +@@ -2286,7 +2294,7 @@ int wd_ecc_poll_ctx(__u32 idx, __u32 expt, __u32 *count) + ctx = config->ctxs + idx; + + do { +- ret = wd_alg_driver_recv(wd_ecc_setting.driver, ctx->ctx, &recv_msg); ++ ret = wd_ecc_setting.driver->recv(ctx->ctx, &recv_msg); + if (ret == -WD_EAGAIN) { + return ret; + } else if (ret < 0) { +diff --git a/wd_rsa.c b/wd_rsa.c +index 1813676..b986855 100644 +--- a/wd_rsa.c ++++ b/wd_rsa.c +@@ -73,6 +73,7 @@ static struct wd_rsa_setting { + struct wd_sched sched; + struct wd_async_msg_pool pool; + struct wd_alg_driver *driver; ++ void *priv; + void *dlhandle; + void *dlh_list; + } wd_rsa_setting; +@@ -148,7 +149,8 @@ static int wd_rsa_common_init(struct wd_ctx_config *config, struct wd_sched *sch + goto out_clear_sched; + + ret = wd_alg_init_driver(&wd_rsa_setting.config, +- wd_rsa_setting.driver); ++ wd_rsa_setting.driver, ++ &wd_rsa_setting.priv); + if (ret) + goto out_clear_pool; + +@@ -165,13 +167,19 @@ out_clear_ctx_config: + + static int wd_rsa_common_uninit(void) + { ++ if (!wd_rsa_setting.priv) { ++ WD_ERR("invalid: repeat uninit rsa!\n"); ++ return -WD_EINVAL; ++ } ++ + /* uninit async request pool */ + wd_uninit_async_request_pool(&wd_rsa_setting.pool); + + /* unset config, sched, driver */ + wd_clear_sched(&wd_rsa_setting.sched); + wd_alg_uninit_driver(&wd_rsa_setting.config, +- wd_rsa_setting.driver); ++ wd_rsa_setting.driver, ++ &wd_rsa_setting.priv); + + return 0; + } +@@ -415,8 +423,8 @@ int wd_do_rsa_sync(handle_t h_sess, struct wd_rsa_req *req) + msg_handle.recv = wd_rsa_setting.driver->recv; + + pthread_spin_lock(&ctx->lock); +- ret = wd_handle_msg_sync(wd_rsa_setting.driver, &msg_handle, ctx->ctx, &msg, +- &balance, wd_rsa_setting.config.epoll_en); ++ ret = wd_handle_msg_sync(&msg_handle, ctx->ctx, &msg, &balance, ++ wd_rsa_setting.config.epoll_en); + pthread_spin_unlock(&ctx->lock); + if (unlikely(ret)) + return ret; +@@ -460,7 +468,7 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req) + goto fail_with_msg; + msg->tag = mid; + +- ret = wd_alg_driver_send(wd_rsa_setting.driver, ctx->ctx, msg); ++ ret = wd_rsa_setting.driver->send(ctx->ctx, msg); + if (unlikely(ret)) { + if (ret != -WD_EBUSY) + WD_ERR("failed to send rsa BD, hw is err!\n"); +@@ -509,7 +517,7 @@ int wd_rsa_poll_ctx(__u32 idx, __u32 expt, __u32 *count) + ctx = config->ctxs + idx; + + do { +- ret = wd_alg_driver_recv(wd_rsa_setting.driver, ctx->ctx, &recv_msg); ++ ret = wd_rsa_setting.driver->recv(ctx->ctx, &recv_msg); + if (ret == -WD_EAGAIN) { + return ret; + } else if (ret < 0) { +diff --git a/wd_util.c b/wd_util.c +index bfa3af0..989c99a 100644 +--- a/wd_util.c ++++ b/wd_util.c +@@ -1792,8 +1792,8 @@ int wd_set_epoll_en(const char *var_name, bool *epoll_en) + return 0; + } + +-int wd_handle_msg_sync(struct wd_alg_driver *drv, struct wd_msg_handle *msg_handle, +- handle_t ctx, void *msg, __u64 *balance, bool epoll_en) ++int wd_handle_msg_sync(struct wd_msg_handle *msg_handle, handle_t ctx, ++ void *msg, __u64 *balance, bool epoll_en) + { + __u64 timeout = WD_RECV_MAX_CNT_NOSLEEP; + __u64 rx_cnt = 0; +@@ -1802,7 +1802,7 @@ int wd_handle_msg_sync(struct wd_alg_driver *drv, struct wd_msg_handle *msg_hand + if (balance) + timeout = WD_RECV_MAX_CNT_SLEEP; + +- ret = msg_handle->send(drv, ctx, msg); ++ ret = msg_handle->send(ctx, msg); + if (unlikely(ret < 0)) { + WD_ERR("failed to send msg to hw, ret = %d!\n", ret); + return ret; +@@ -1815,7 +1815,7 @@ int wd_handle_msg_sync(struct wd_alg_driver *drv, struct wd_msg_handle *msg_hand + WD_ERR("wd ctx wait timeout(%d)!\n", ret); + } + +- ret = msg_handle->recv(drv, ctx, msg); ++ ret = msg_handle->recv(ctx, msg); + if (ret == -WD_EAGAIN) { + if (unlikely(rx_cnt++ >= timeout)) { + WD_ERR("failed to recv msg: timeout!\n"); +@@ -1920,10 +1920,16 @@ static void wd_alg_uninit_fallback(struct wd_alg_driver *fb_driver) + } + + int wd_alg_init_driver(struct wd_ctx_config_internal *config, +- struct wd_alg_driver *driver) ++ struct wd_alg_driver *driver, void **drv_priv) + { ++ void *priv; + int ret; + ++ /* Init ctx related resources in specific driver */ ++ priv = calloc(1, driver->priv_size); ++ if (!priv) ++ return -WD_ENOMEM; ++ + if (!driver->init) { + driver->fallback = 0; + WD_ERR("driver have no init interface.\n"); +@@ -1931,7 +1937,7 @@ int wd_alg_init_driver(struct wd_ctx_config_internal *config, + goto err_alloc; + } + +- ret = driver->init(driver, config); ++ ret = driver->init(config, priv); + if (ret < 0) { + WD_ERR("driver init failed.\n"); + goto err_alloc; +@@ -1944,24 +1950,32 @@ int wd_alg_init_driver(struct wd_ctx_config_internal *config, + WD_ERR("soft alg driver init failed.\n"); + } + } ++ *drv_priv = priv; + + return 0; + + err_alloc: ++ free(priv); + return ret; + } + + void wd_alg_uninit_driver(struct wd_ctx_config_internal *config, +- struct wd_alg_driver *driver) ++ struct wd_alg_driver *driver, void **drv_priv) + { ++ void *priv = *drv_priv; + +- driver->exit(driver); ++ driver->exit(priv); + /* Ctx config just need clear once */ + if (driver->calc_type == UADK_ALG_HW) + wd_clear_ctx_config(config); + + if (driver->fallback) + wd_alg_uninit_fallback((struct wd_alg_driver *)driver->fallback); ++ ++ if (priv) { ++ free(priv); ++ *drv_priv = NULL; ++ } + } + + void wd_dlclose_drv(void *dlh_list) +-- +2.31.1.windows.1 + diff --git a/0086-uadk-v1-comp-add-comp-ctx-parameters-check.patch b/0095-uadk-v1-comp-add-comp-ctx-parameters-check.patch similarity index 93% rename from 0086-uadk-v1-comp-add-comp-ctx-parameters-check.patch rename to 0095-uadk-v1-comp-add-comp-ctx-parameters-check.patch index ac949ec..c7730bf 100644 --- a/0086-uadk-v1-comp-add-comp-ctx-parameters-check.patch +++ b/0095-uadk-v1-comp-add-comp-ctx-parameters-check.patch @@ -1,7 +1,7 @@ -From 4c08e19a760e2095a441e4f4e54449be090323c5 Mon Sep 17 00:00:00 2001 +From 217fcc4b6ee0e4c0c32e2c81fba972de2d2e761b Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Fri, 24 Nov 2023 11:53:49 +0800 -Subject: [PATCH 086/114] uadk/v1/comp: add comp ctx parameters check +Subject: [PATCH 095/123] uadk/v1/comp: add comp ctx parameters check Add the check of ctx parameters before create ctx pool. @@ -11,7 +11,7 @@ Signed-off-by: Qi Tao 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/v1/wd_comp.c b/v1/wd_comp.c -index f898c1d..154db19 100644 +index fb9e413..dd838eb 100644 --- a/v1/wd_comp.c +++ b/v1/wd_comp.c @@ -56,6 +56,62 @@ static void fill_comp_msg(struct wcrypto_comp_ctx *ctx, @@ -116,5 +116,5 @@ index f898c1d..154db19 100644 } - -- -2.25.1 +2.31.1.windows.1 diff --git a/0087-uadk-v1-check-whether-the-data-address-pointer-is-no.patch b/0096-uadk-v1-check-whether-the-data-address-pointer-is-no.patch similarity index 98% rename from 0087-uadk-v1-check-whether-the-data-address-pointer-is-no.patch rename to 0096-uadk-v1-check-whether-the-data-address-pointer-is-no.patch index a5d6d22..7808895 100644 --- a/0087-uadk-v1-check-whether-the-data-address-pointer-is-no.patch +++ b/0096-uadk-v1-check-whether-the-data-address-pointer-is-no.patch @@ -1,7 +1,7 @@ -From f669f0bf233a1441fd98b4fc79400af2bbeae78f Mon Sep 17 00:00:00 2001 +From 79bd75212d39325f825549bb206992b912542a70 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Fri, 24 Nov 2023 11:57:05 +0800 -Subject: [PATCH 087/114] uadk/v1: check whether the data address pointer is +Subject: [PATCH 096/123] uadk/v1: check whether the data address pointer is not null The data address pointers were used without address verification, @@ -134,7 +134,7 @@ index 3e6fb3d..60a0f25 100644 } diff --git a/v1/wd_comp.c b/v1/wd_comp.c -index 154db19..3d2fcf1 100644 +index dd838eb..169f1b4 100644 --- a/v1/wd_comp.c +++ b/v1/wd_comp.c @@ -60,8 +60,8 @@ static int ctx_params_check(struct wd_queue *q, struct wcrypto_comp_ctx_setup *s @@ -405,5 +405,5 @@ index a8c6b15..bf17058 100644 #endif -- -2.25.1 +2.31.1.windows.1 diff --git a/0088-uadk-v1-remove-print-actions-after-wd_get_cookies.patch b/0097-uadk-v1-remove-print-actions-after-wd_get_cookies.patch similarity index 92% rename from 0088-uadk-v1-remove-print-actions-after-wd_get_cookies.patch rename to 0097-uadk-v1-remove-print-actions-after-wd_get_cookies.patch index 2e6b6b6..eea7d58 100644 --- a/0088-uadk-v1-remove-print-actions-after-wd_get_cookies.patch +++ b/0097-uadk-v1-remove-print-actions-after-wd_get_cookies.patch @@ -1,7 +1,7 @@ -From 80f2ff4c5181dac5fc5dff113d06c4429d3aa029 Mon Sep 17 00:00:00 2001 +From 4e4b64036f8001d1e40ea4fec4742a09d25b85ae Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 16:51:02 +0800 -Subject: [PATCH 088/114] uadk/v1: remove print actions after wd_get_cookies +Subject: [PATCH 097/123] uadk/v1: remove print actions after wd_get_cookies Print information after wd_get_cookies returning EBUSY can seriously affect performance,so remove it. @@ -62,5 +62,5 @@ index b617350..b8ea5ce 100644 for (i = 0; i < num; i++) { cookies[i]->tag.priv = opdata[i]->priv; -- -2.25.1 +2.31.1.windows.1 diff --git a/0089-uadk-fix-header-file-is-not-self-contained.patch b/0098-uadk-fix-header-file-is-not-self-contained.patch similarity index 89% rename from 0089-uadk-fix-header-file-is-not-self-contained.patch rename to 0098-uadk-fix-header-file-is-not-self-contained.patch index 1df7ea7..0e69cdb 100644 --- a/0089-uadk-fix-header-file-is-not-self-contained.patch +++ b/0098-uadk-fix-header-file-is-not-self-contained.patch @@ -1,7 +1,7 @@ -From 2edce8cc047c73341d5fde1ec6639e3a61681f64 Mon Sep 17 00:00:00 2001 +From c23fbffb2afe00b0d5c9842c88884d83b83629c0 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 16:54:46 +0800 -Subject: [PATCH 089/114] uadk: fix header file is not self contained +Subject: [PATCH 098/123] uadk: fix header file is not self contained Header files are not self contained, fix it. @@ -15,7 +15,7 @@ Signed-off-by: Wenkai Lin 5 files changed, 6 insertions(+) diff --git a/include/wd.h b/include/wd.h -index 0e67cad..6ee2ef5 100644 +index 0a654d6..80982b0 100644 --- a/include/wd.h +++ b/include/wd.h @@ -7,6 +7,7 @@ @@ -63,7 +63,7 @@ index a492d70..b145172 100644 #ifdef __cplusplus diff --git a/include/wd_util.h b/include/wd_util.h -index be9798c..78c5d23 100644 +index 0f35ccf..4536937 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -13,7 +13,9 @@ @@ -77,5 +77,5 @@ index be9798c..78c5d23 100644 #ifdef __cplusplus extern "C" { -- -2.25.1 +2.31.1.windows.1 diff --git a/0090-uadk-sec-modify-improper-comments.patch b/0099-uadk-sec-modify-improper-comments.patch similarity index 81% rename from 0090-uadk-sec-modify-improper-comments.patch rename to 0099-uadk-sec-modify-improper-comments.patch index 88c133c..cd4ee73 100644 --- a/0090-uadk-sec-modify-improper-comments.patch +++ b/0099-uadk-sec-modify-improper-comments.patch @@ -1,7 +1,7 @@ -From 5de69884dea416eea90b2f5a76ac1fcf1a70f8a9 Mon Sep 17 00:00:00 2001 +From 72e69f204e23ff415b76cc498349bdaef5c8a46a Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 17:00:48 +0800 -Subject: [PATCH 090/114] uadk\sec: modify improper comments. +Subject: [PATCH 099/123] uadk\sec: modify improper comments. Modify or delete improper comments in uadk/sec module. @@ -12,10 +12,10 @@ Signed-off-by: Qi Tao 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/wd_digest.c b/wd_digest.c -index 2307bf1..bc67878 100644 +index e523331..3cbb828 100644 --- a/wd_digest.c +++ b/wd_digest.c -@@ -131,7 +131,7 @@ int wd_digest_set_key(handle_t h_sess, const __u8 *key, __u32 key_len) +@@ -132,7 +132,7 @@ int wd_digest_set_key(handle_t h_sess, const __u8 *key, __u32 key_len) int ret; if (!key || !sess) { @@ -25,7 +25,7 @@ index 2307bf1..bc67878 100644 } diff --git a/wd_util.c b/wd_util.c -index a9640c3..d1d4037 100644 +index 989c99a..2d3cbbb 100644 --- a/wd_util.c +++ b/wd_util.c @@ -408,7 +408,6 @@ void wd_uninit_async_request_pool(struct wd_async_msg_pool *pool) @@ -45,5 +45,5 @@ index a9640c3..d1d4037 100644 { struct async_task_queue *task_queue; -- -2.25.1 +2.31.1.windows.1 diff --git a/0091-uadk-fixed-some-input-parameter-checking-issues.patch b/0100-uadk-fixed-some-input-parameter-checking-issues.patch similarity index 77% rename from 0091-uadk-fixed-some-input-parameter-checking-issues.patch rename to 0100-uadk-fixed-some-input-parameter-checking-issues.patch index e4a8568..2a38eda 100644 --- a/0091-uadk-fixed-some-input-parameter-checking-issues.patch +++ b/0100-uadk-fixed-some-input-parameter-checking-issues.patch @@ -1,7 +1,7 @@ -From 81d5593a3f9f6e5c763f81f6e7d393dc5efda961 Mon Sep 17 00:00:00 2001 +From 5a1b1dd52ce7cf0e5aaf40781d2b3820ca615834 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 17:02:26 +0800 -Subject: [PATCH 091/114] uadk: fixed some input parameter checking issues +Subject: [PATCH 100/123] uadk: fixed some input parameter checking issues Inside the asynchronous packet receiving interface of all submodules. When the number of expected received packets is 0. Failure to intercept @@ -23,10 +23,10 @@ Signed-off-by: Longfang Liu 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/wd_aead.c b/wd_aead.c -index 87d61c3..ff43086 100644 +index 20d1109..9b23411 100644 --- a/wd_aead.c +++ b/wd_aead.c -@@ -816,7 +816,7 @@ int wd_aead_poll_ctx(__u32 idx, __u32 expt, __u32 *count) +@@ -813,7 +813,7 @@ int wd_aead_poll_ctx(__u32 idx, __u32 expt, __u32 *count) __u32 tmp = expt; int ret; @@ -36,10 +36,10 @@ index 87d61c3..ff43086 100644 return -WD_EINVAL; } diff --git a/wd_cipher.c b/wd_cipher.c -index 58d34f7..0187c9c 100644 +index 76b9bad..029c854 100644 --- a/wd_cipher.c +++ b/wd_cipher.c -@@ -730,7 +730,7 @@ int wd_cipher_poll_ctx(__u32 idx, __u32 expt, __u32 *count) +@@ -732,7 +732,7 @@ int wd_cipher_poll_ctx(__u32 idx, __u32 expt, __u32 *count) __u32 tmp = expt; int ret; @@ -49,10 +49,10 @@ index 58d34f7..0187c9c 100644 return -WD_EINVAL; } diff --git a/wd_comp.c b/wd_comp.c -index 21c9928..57e8b8f 100644 +index b6fe85c..c2e393d 100644 --- a/wd_comp.c +++ b/wd_comp.c -@@ -340,8 +340,8 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count) +@@ -342,8 +342,8 @@ int wd_comp_poll_ctx(__u32 idx, __u32 expt, __u32 *count) __u32 tmp = expt; int ret; @@ -64,10 +64,10 @@ index 21c9928..57e8b8f 100644 } diff --git a/wd_dh.c b/wd_dh.c -index 40a52e5..dac55ca 100644 +index 157f7c6..6bfc0cc 100644 --- a/wd_dh.c +++ b/wd_dh.c -@@ -438,8 +438,8 @@ int wd_dh_poll_ctx(__u32 idx, __u32 expt, __u32 *count) +@@ -446,8 +446,8 @@ int wd_dh_poll_ctx(__u32 idx, __u32 expt, __u32 *count) __u32 tmp = expt; int ret; @@ -79,10 +79,10 @@ index 40a52e5..dac55ca 100644 } diff --git a/wd_digest.c b/wd_digest.c -index bc67878..1f2b3b2 100644 +index 3cbb828..7e09d96 100644 --- a/wd_digest.c +++ b/wd_digest.c -@@ -701,7 +701,7 @@ int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count) +@@ -698,7 +698,7 @@ int wd_digest_poll_ctx(__u32 idx, __u32 expt, __u32 *count) __u32 tmp = expt; int ret; @@ -92,10 +92,10 @@ index bc67878..1f2b3b2 100644 return -WD_EINVAL; } diff --git a/wd_ecc.c b/wd_ecc.c -index 4323e54..b5e7e36 100644 +index a1d4dae..3cdbfdf 100644 --- a/wd_ecc.c +++ b/wd_ecc.c -@@ -2272,8 +2272,8 @@ int wd_ecc_poll_ctx(__u32 idx, __u32 expt, __u32 *count) +@@ -2280,8 +2280,8 @@ int wd_ecc_poll_ctx(__u32 idx, __u32 expt, __u32 *count) __u32 tmp = expt; int ret; @@ -107,10 +107,10 @@ index 4323e54..b5e7e36 100644 } diff --git a/wd_rsa.c b/wd_rsa.c -index 1813676..b71540f 100644 +index b986855..1424f61 100644 --- a/wd_rsa.c +++ b/wd_rsa.c -@@ -495,8 +495,8 @@ int wd_rsa_poll_ctx(__u32 idx, __u32 expt, __u32 *count) +@@ -503,8 +503,8 @@ int wd_rsa_poll_ctx(__u32 idx, __u32 expt, __u32 *count) __u32 tmp = expt; int ret; @@ -122,5 +122,5 @@ index 1813676..b71540f 100644 } -- -2.25.1 +2.31.1.windows.1 diff --git a/0092-uadk-code-cleanup.patch b/0101-uadk-code-cleanup.patch similarity index 89% rename from 0092-uadk-code-cleanup.patch rename to 0101-uadk-code-cleanup.patch index 290490b..9a9fdbc 100644 --- a/0092-uadk-code-cleanup.patch +++ b/0101-uadk-code-cleanup.patch @@ -1,7 +1,7 @@ -From 7a129d1ee851524a6166341c492e874705540ca2 Mon Sep 17 00:00:00 2001 +From b580bdf42dc1a1a40815ee2af8d154e5855546df Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 17:05:32 +0800 -Subject: [PATCH 092/114] uadk: code cleanup +Subject: [PATCH 101/123] uadk: code cleanup Add the input pointer checking. @@ -17,7 +17,7 @@ Signed-off-by: Chenghai Huang 7 files changed, 62 insertions(+), 4 deletions(-) diff --git a/include/wd_util.h b/include/wd_util.h -index 78c5d23..3059ac1 100644 +index 4536937..5d397c1 100644 --- a/include/wd_util.h +++ b/include/wd_util.h @@ -235,6 +235,18 @@ void wd_put_msg_to_pool(struct wd_async_msg_pool *pool, int ctx_idx, @@ -40,7 +40,7 @@ index 78c5d23..3059ac1 100644 * wd_check_datalist() - Check the data list length * @head: Data list's head pointer. diff --git a/wd.c b/wd.c -index ddde38d..a6e207d 100644 +index e88c993..998c9be 100644 --- a/wd.c +++ b/wd.c @@ -756,7 +756,7 @@ struct uacce_dev *wd_find_dev_by_numa(struct uacce_dev_list *list, int numa_id) @@ -53,10 +53,10 @@ index ddde38d..a6e207d 100644 continue; } diff --git a/wd_aead.c b/wd_aead.c -index ff43086..6d49d76 100644 +index 9b23411..05f8883 100644 --- a/wd_aead.c +++ b/wd_aead.c -@@ -361,6 +361,11 @@ static int wd_aead_param_check(struct wd_aead_sess *sess, +@@ -362,6 +362,11 @@ static int wd_aead_param_check(struct wd_aead_sess *sess, return -WD_EINVAL; } @@ -68,7 +68,7 @@ index ff43086..6d49d76 100644 if (unlikely(sess->cmode == WD_CIPHER_CBC && req->in_bytes == 0)) { WD_ERR("aead input data length is zero!\n"); return -WD_EINVAL; -@@ -384,6 +389,12 @@ static int wd_aead_param_check(struct wd_aead_sess *sess, +@@ -385,6 +390,12 @@ static int wd_aead_param_check(struct wd_aead_sess *sess, return -WD_EINVAL; } @@ -82,10 +82,10 @@ index ff43086..6d49d76 100644 len = req->in_bytes + req->assoc_bytes; ret = wd_check_datalist(req->list_src, len); diff --git a/wd_cipher.c b/wd_cipher.c -index 0187c9c..47c0bf8 100644 +index 029c854..22fb2c7 100644 --- a/wd_cipher.c +++ b/wd_cipher.c -@@ -542,6 +542,11 @@ static int cipher_iv_len_check(struct wd_cipher_req *req, +@@ -544,6 +544,11 @@ static int cipher_iv_len_check(struct wd_cipher_req *req, if (sess->mode == WD_CIPHER_ECB) return 0; @@ -97,7 +97,7 @@ index 0187c9c..47c0bf8 100644 switch (sess->alg) { case WD_CIPHER_AES: case WD_CIPHER_SM4: -@@ -589,6 +594,12 @@ static int wd_cipher_check_params(handle_t h_sess, +@@ -591,6 +596,12 @@ static int wd_cipher_check_params(handle_t h_sess, return -WD_EINVAL; } @@ -111,10 +111,10 @@ index 0187c9c..47c0bf8 100644 ret = wd_check_datalist(req->list_src, req->in_bytes); if (unlikely(ret)) { diff --git a/wd_digest.c b/wd_digest.c -index 1f2b3b2..9008bcb 100644 +index 7e09d96..e119b42 100644 --- a/wd_digest.c +++ b/wd_digest.c -@@ -514,12 +514,18 @@ static int wd_digest_param_check(struct wd_digest_sess *sess, +@@ -511,12 +511,18 @@ static int wd_digest_param_check(struct wd_digest_sess *sess, return ret; if (unlikely(sess->alg == WD_DIGEST_AES_GMAC && @@ -174,7 +174,7 @@ index d1c829f..7aeea73 100644 /* Default async mode use ctx 0 */ loop_times--; diff --git a/wd_util.c b/wd_util.c -index d1d4037..10b0ab9 100644 +index 2d3cbbb..2892ee9 100644 --- a/wd_util.c +++ b/wd_util.c @@ -459,6 +459,14 @@ void wd_put_msg_to_pool(struct wd_async_msg_pool *pool, int ctx_idx, __u32 tag) @@ -193,5 +193,5 @@ index d1d4037..10b0ab9 100644 { struct wd_datalist *tmp = head; -- -2.25.1 +2.31.1.windows.1 diff --git a/0093-uadk-fix-sec-send-and-recv-check-failed.patch b/0102-uadk-fix-sec-send-and-recv-check-failed.patch similarity index 62% rename from 0093-uadk-fix-sec-send-and-recv-check-failed.patch rename to 0102-uadk-fix-sec-send-and-recv-check-failed.patch index b878772..ad8d660 100644 --- a/0093-uadk-fix-sec-send-and-recv-check-failed.patch +++ b/0102-uadk-fix-sec-send-and-recv-check-failed.patch @@ -1,103 +1,105 @@ -From e0ace2af02926648ec44070ac3b5e5328365f849 Mon Sep 17 00:00:00 2001 -From: Qi Tao -Date: Thu, 30 Nov 2023 17:08:58 +0800 -Subject: [PATCH 093/114] uadk: fix sec send and recv check failed +From b43227db361d5782077b05811d41ea02f6197fa0 Mon Sep 17 00:00:00 2001 +From: Wenkai Lin +Date: Sat, 9 Dec 2023 15:55:09 +0800 +Subject: [PATCH 102/123] uadk: fix sec send and recv check failed The send and recv pointers should be assigned at the beginning, not during wd initialization. -Signed-off-by: Wenkai Lin +Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com +drv/hisi_sec.c | 260 ++++++++++++++++++++++++++++--------------------- + 1 file changed, 149 insertions(+), 111 deletions(-) --- drv/hisi_sec.c | 260 ++++++++++++++++++++++++++++--------------------- 1 file changed, 149 insertions(+), 111 deletions(-) diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c -index 03e7037..9bf7e68 100644 +index 341e91a..747281a 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -539,12 +539,93 @@ static __u32 g_sec_hmac_full_len[WD_DIGEST_TYPE_MAX] = { - static int hisi_sec_init(struct wd_alg_driver *drv, void *conf); - static void hisi_sec_exit(struct wd_alg_driver *drv); + static int hisi_sec_init(void *conf, void *priv); + static void hisi_sec_exit(void *priv); -+static int hisi_sec_cipher_send(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_cipher_recv(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_cipher_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_cipher_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); ++static int hisi_sec_cipher_send(handle_t ctx, void *wd_msg); ++static int hisi_sec_cipher_recv(handle_t ctx, void *wd_msg); ++static int hisi_sec_cipher_send_v3(handle_t ctx, void *wd_msg); ++static int hisi_sec_cipher_recv_v3(handle_t ctx, void *wd_msg); + -+static int hisi_sec_digest_send(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_digest_recv(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_digest_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_digest_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); ++static int hisi_sec_digest_send(handle_t ctx, void *wd_msg); ++static int hisi_sec_digest_recv(handle_t ctx, void *wd_msg); ++static int hisi_sec_digest_send_v3(handle_t ctx, void *wd_msg); ++static int hisi_sec_digest_recv_v3(handle_t ctx, void *wd_msg); + -+static int hisi_sec_aead_send(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_aead_recv(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_aead_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); -+static int hisi_sec_aead_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg); ++static int hisi_sec_aead_send(handle_t ctx, void *wd_msg); ++static int hisi_sec_aead_recv(handle_t ctx, void *wd_msg); ++static int hisi_sec_aead_send_v3(handle_t ctx, void *wd_msg); ++static int hisi_sec_aead_recv_v3(handle_t ctx, void *wd_msg); + -+static int cipher_send(struct wd_alg_driver *drv, handle_t ctx, void *msg) ++static int cipher_send(handle_t ctx, void *msg) +{ + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; + struct hisi_qm_queue_info q_info = qp->q_info; + + if (q_info.hw_type == HISI_QM_API_VER2_BASE) -+ return hisi_sec_cipher_send(drv, ctx, msg); -+ return hisi_sec_cipher_send_v3(drv, ctx, msg); ++ return hisi_sec_cipher_send(ctx, msg); ++ return hisi_sec_cipher_send_v3(ctx, msg); +} + -+static int cipher_recv(struct wd_alg_driver *drv, handle_t ctx, void *msg) ++static int cipher_recv(handle_t ctx, void *msg) +{ + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; + struct hisi_qm_queue_info q_info = qp->q_info; + + if (q_info.hw_type == HISI_QM_API_VER2_BASE) -+ return hisi_sec_cipher_recv(drv, ctx, msg); -+ return hisi_sec_cipher_recv_v3(drv, ctx, msg); ++ return hisi_sec_cipher_recv(ctx, msg); ++ return hisi_sec_cipher_recv_v3(ctx, msg); +} + -+static int digest_send(struct wd_alg_driver *drv, handle_t ctx, void *msg) ++static int digest_send(handle_t ctx, void *msg) +{ + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; + struct hisi_qm_queue_info q_info = qp->q_info; + + if (q_info.hw_type == HISI_QM_API_VER2_BASE) -+ return hisi_sec_digest_send(drv, ctx, msg); -+ return hisi_sec_digest_send_v3(drv, ctx, msg); ++ return hisi_sec_digest_send(ctx, msg); ++ return hisi_sec_digest_send_v3(ctx, msg); +} + -+static int digest_recv(struct wd_alg_driver *drv, handle_t ctx, void *msg) ++static int digest_recv(handle_t ctx, void *msg) +{ + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; + struct hisi_qm_queue_info q_info = qp->q_info; + + if (q_info.hw_type == HISI_QM_API_VER2_BASE) -+ return hisi_sec_digest_recv(drv, ctx, msg); -+ return hisi_sec_digest_recv_v3(drv, ctx, msg); ++ return hisi_sec_digest_recv(ctx, msg); ++ return hisi_sec_digest_recv_v3(ctx, msg); +} + -+static int aead_send(struct wd_alg_driver *drv, handle_t ctx, void *msg) ++static int aead_send(handle_t ctx, void *msg) +{ + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; + struct hisi_qm_queue_info q_info = qp->q_info; + + if (q_info.hw_type == HISI_QM_API_VER2_BASE) -+ return hisi_sec_aead_send(drv, ctx, msg); -+ return hisi_sec_aead_send_v3(drv, ctx, msg); ++ return hisi_sec_aead_send(ctx, msg); ++ return hisi_sec_aead_send_v3(ctx, msg); +} + -+static int aead_recv(struct wd_alg_driver *drv, handle_t ctx, void *msg) ++static int aead_recv(handle_t ctx, void *msg) +{ + handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); + struct hisi_qp *qp = (struct hisi_qp *)h_qp; + struct hisi_qm_queue_info q_info = qp->q_info; + + if (q_info.hw_type == HISI_QM_API_VER2_BASE) -+ return hisi_sec_aead_recv(drv, ctx, msg); -+ return hisi_sec_aead_recv_v3(drv, ctx, msg); ++ return hisi_sec_aead_recv(ctx, msg); ++ return hisi_sec_aead_recv_v3(ctx, msg); +} + static int hisi_sec_get_usage(void *param) @@ -110,7 +112,7 @@ index 03e7037..9bf7e68 100644 {\ .drv_name = "hisi_sec2",\ .alg_name = (sec_alg_name),\ -@@ -555,57 +636,59 @@ static int hisi_sec_get_usage(void *param) +@@ -556,57 +637,59 @@ static int hisi_sec_get_usage(void *param) .fallback = 0,\ .init = hisi_sec_init,\ .exit = hisi_sec_exit,\ @@ -211,12 +213,12 @@ index 03e7037..9bf7e68 100644 }; static void dump_sec_msg(void *msg, const char *alg) -@@ -1092,10 +1175,10 @@ static int fill_cipher_bd2(struct wd_cipher_msg *msg, struct hisi_sec_sqe *sqe) +@@ -1093,10 +1176,10 @@ static int fill_cipher_bd2(struct wd_cipher_msg *msg, struct hisi_sec_sqe *sqe) return 0; } --int hisi_sec_cipher_send(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) -+static int hisi_sec_cipher_send(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_cipher_send(handle_t ctx, void *cipher_msg) ++static int hisi_sec_cipher_send(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_cipher_msg *msg = cipher_msg; @@ -224,12 +226,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe sqe; __u16 count = 0; int ret; -@@ -1137,10 +1220,10 @@ int hisi_sec_cipher_send(struct wd_alg_driver *drv, handle_t ctx, void *cipher_m +@@ -1138,10 +1221,10 @@ int hisi_sec_cipher_send(handle_t ctx, void *cipher_msg) return 0; } --int hisi_sec_cipher_recv(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) -+static int hisi_sec_cipher_recv(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_cipher_recv(handle_t ctx, void *cipher_msg) ++int hisi_sec_cipher_recv(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_cipher_msg *recv_msg = cipher_msg; @@ -237,12 +239,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe sqe; __u16 count = 0; int ret; -@@ -1295,10 +1378,10 @@ static int fill_cipher_bd3(struct wd_cipher_msg *msg, struct hisi_sec_sqe3 *sqe) +@@ -1296,10 +1379,10 @@ static int fill_cipher_bd3(struct wd_cipher_msg *msg, struct hisi_sec_sqe3 *sqe) return 0; } --int hisi_sec_cipher_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) -+static int hisi_sec_cipher_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_cipher_send_v3(handle_t ctx, void *cipher_msg) ++static int hisi_sec_cipher_send_v3(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_cipher_msg *msg = cipher_msg; @@ -250,12 +252,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe3 sqe; __u16 count = 0; int ret; -@@ -1385,10 +1468,10 @@ static void parse_cipher_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, +@@ -1386,10 +1469,10 @@ static void parse_cipher_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, dump_sec_msg(temp_msg, "cipher"); } --int hisi_sec_cipher_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *cipher_msg) -+static int hisi_sec_cipher_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_cipher_recv_v3(handle_t ctx, void *cipher_msg) ++int hisi_sec_cipher_recv_v3(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_cipher_msg *recv_msg = cipher_msg; @@ -263,12 +265,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe3 sqe; __u16 count = 0; int ret; -@@ -1658,10 +1741,10 @@ static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type) +@@ -1659,10 +1742,10 @@ static int digest_len_check(struct wd_digest_msg *msg, enum sec_bd_type type) return 0; } --int hisi_sec_digest_send(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) -+static int hisi_sec_digest_send(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_digest_send(handle_t ctx, void *digest_msg) ++static int hisi_sec_digest_send(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_digest_msg *msg = digest_msg; @@ -276,12 +278,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe sqe; __u16 count = 0; __u8 scene; -@@ -1725,10 +1808,10 @@ put_sgl: +@@ -1726,10 +1809,10 @@ put_sgl: return ret; } --int hisi_sec_digest_recv(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) -+static int hisi_sec_digest_recv(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_digest_recv(handle_t ctx, void *digest_msg) ++int hisi_sec_digest_recv(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_digest_msg *recv_msg = digest_msg; @@ -289,12 +291,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe sqe; __u16 count = 0; int ret; -@@ -1902,10 +1985,10 @@ static void fill_digest_v3_scene(struct hisi_sec_sqe3 *sqe, +@@ -1903,10 +1986,10 @@ static void fill_digest_v3_scene(struct hisi_sec_sqe3 *sqe, sqe->bd_param |= (__u16)(de | scene); } --int hisi_sec_digest_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) -+static int hisi_sec_digest_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_digest_send_v3(handle_t ctx, void *digest_msg) ++static int hisi_sec_digest_send_v3(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_digest_msg *msg = digest_msg; @@ -302,12 +304,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe3 sqe; __u16 count = 0; int ret; -@@ -2001,10 +2084,10 @@ static void parse_digest_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, +@@ -2002,10 +2085,10 @@ static void parse_digest_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, dump_sec_msg(temp_msg, "digest"); } --int hisi_sec_digest_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *digest_msg) -+static int hisi_sec_digest_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_digest_recv_v3(handle_t ctx, void *digest_msg) ++int hisi_sec_digest_recv_v3(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_digest_msg *recv_msg = digest_msg; @@ -315,12 +317,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe3 sqe; __u16 count = 0; int ret; -@@ -2473,10 +2556,10 @@ int aead_msg_state_check(struct wd_aead_msg *msg) +@@ -2474,10 +2557,10 @@ int aead_msg_state_check(struct wd_aead_msg *msg) return 0; } --int hisi_sec_aead_send(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) -+static int hisi_sec_aead_send(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_aead_send(handle_t ctx, void *aead_msg) ++static int hisi_sec_aead_send(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_aead_msg *msg = aead_msg; @@ -328,12 +330,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe sqe; __u16 count = 0; int ret; -@@ -2595,10 +2678,10 @@ static bool soft_compute_check(struct hisi_qp *qp, struct wd_aead_msg *msg) +@@ -2596,10 +2679,10 @@ static bool soft_compute_check(struct hisi_qp *qp, struct wd_aead_msg *msg) qp->q_info.qp_mode == CTX_MODE_SYNC; } --int hisi_sec_aead_recv(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) -+static int hisi_sec_aead_recv(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_aead_recv(handle_t ctx, void *aead_msg) ++int hisi_sec_aead_recv(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_aead_msg *recv_msg = aead_msg; @@ -341,12 +343,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe sqe; __u16 count = 0; int ret; -@@ -2857,10 +2940,10 @@ static int fill_aead_bd3(struct wd_aead_msg *msg, struct hisi_sec_sqe3 *sqe) +@@ -2858,10 +2941,10 @@ static int fill_aead_bd3(struct wd_aead_msg *msg, struct hisi_sec_sqe3 *sqe) return 0; } --int hisi_sec_aead_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) -+static int hisi_sec_aead_send_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_aead_send_v3(handle_t ctx, void *aead_msg) ++static int hisi_sec_aead_send_v3(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_aead_msg *msg = aead_msg; @@ -354,12 +356,12 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe3 sqe; __u16 count = 0; int ret; -@@ -2957,10 +3040,10 @@ static void parse_aead_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, +@@ -2958,10 +3041,10 @@ static void parse_aead_bd3(struct hisi_qp *qp, struct hisi_sec_sqe3 *sqe, dump_sec_msg(temp_msg, "aead"); } --int hisi_sec_aead_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *aead_msg) -+static int hisi_sec_aead_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *wd_msg) +-int hisi_sec_aead_recv_v3(handle_t ctx, void *aead_msg) ++int hisi_sec_aead_recv_v3(handle_t ctx, void *wd_msg) { handle_t h_qp = (handle_t)wd_ctx_get_priv(ctx); - struct wd_aead_msg *recv_msg = aead_msg; @@ -367,7 +369,7 @@ index 03e7037..9bf7e68 100644 struct hisi_sec_sqe3 sqe; __u16 count = 0; int ret; -@@ -2985,50 +3068,6 @@ int hisi_sec_aead_recv_v3(struct wd_alg_driver *drv, handle_t ctx, void *aead_ms +@@ -2986,50 +3069,6 @@ int hisi_sec_aead_recv_v3(handle_t ctx, void *aead_msg) return 0; } @@ -415,17 +417,17 @@ index 03e7037..9bf7e68 100644 - } -} - - static int hisi_sec_init(struct wd_alg_driver *drv, void *conf) + static int hisi_sec_init(void *conf, void *priv) { - struct hisi_sec_ctx *priv = (struct hisi_sec_ctx *)drv->priv; -@@ -3069,7 +3108,6 @@ static int hisi_sec_init(struct wd_alg_driver *drv, void *conf) + struct wd_ctx_config_internal *config = conf; +@@ -3061,7 +3100,6 @@ static int hisi_sec_init(void *conf, void *priv) config->ctxs[i].sqn = qm_priv.sqn; } - memcpy(&priv->config, config, sizeof(struct wd_ctx_config_internal)); + memcpy(&sec_ctx->config, config, sizeof(struct wd_ctx_config_internal)); - hisi_sec_driver_adapter((struct hisi_qp *)h_qp); - drv->priv = priv; return 0; + -- -2.25.1 +2.31.1.windows.1 diff --git a/0094-uadk-code-cleanup-for-error-codes-and-variable-type.patch b/0103-uadk-code-cleanup-for-error-codes-and-variable-type.patch similarity index 86% rename from 0094-uadk-code-cleanup-for-error-codes-and-variable-type.patch rename to 0103-uadk-code-cleanup-for-error-codes-and-variable-type.patch index 384ca9b..4bfcd90 100644 --- a/0094-uadk-code-cleanup-for-error-codes-and-variable-type.patch +++ b/0103-uadk-code-cleanup-for-error-codes-and-variable-type.patch @@ -1,7 +1,7 @@ -From 90511556722f51dcd6a6a4172943ee32e52db267 Mon Sep 17 00:00:00 2001 +From 7db9d07daf3dfa991f5665902f8d55a24785bfbb Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 17:12:17 +0800 -Subject: [PATCH 094/114] uadk: code cleanup for error codes and variable type +Subject: [PATCH 103/123] uadk: code cleanup for error codes and variable type Unify the use of error return name. Modify the variable type in hisi_sec to reduce variable conversion. @@ -13,7 +13,7 @@ Signed-off-by: Chenghai Huang 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c -index 9bf7e68..2f03d1f 100644 +index 747281a..14952e7 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -517,12 +517,12 @@ struct hisi_sec_sqe3 { @@ -31,7 +31,7 @@ index 9bf7e68..2f03d1f 100644 A_ALG_HMAC_SM3, A_ALG_HMAC_MD5, A_ALG_HMAC_SHA1, A_ALG_HMAC_SHA256, A_ALG_HMAC_SHA224, A_ALG_HMAC_SHA384, A_ALG_HMAC_SHA512, A_ALG_HMAC_SHA512_224, A_ALG_HMAC_SHA512_256, -@@ -1518,7 +1518,7 @@ static int fill_digest_bd2_alg(struct wd_digest_msg *msg, +@@ -1519,7 +1519,7 @@ static int fill_digest_bd2_alg(struct wd_digest_msg *msg, if (msg->mode == WD_DIGEST_NORMAL) sqe->type2.mac_key_alg |= @@ -40,7 +40,7 @@ index 9bf7e68..2f03d1f 100644 else if (msg->mode == WD_DIGEST_HMAC) { if (msg->key_bytes & WORD_ALIGNMENT_MASK) { WD_ERR("failed to check digest key_bytes, size = %u\n", -@@ -1530,7 +1530,7 @@ static int fill_digest_bd2_alg(struct wd_digest_msg *msg, +@@ -1531,7 +1531,7 @@ static int fill_digest_bd2_alg(struct wd_digest_msg *msg, sqe->type2.a_key_addr = (__u64)(uintptr_t)msg->key; sqe->type2.mac_key_alg |= @@ -49,7 +49,7 @@ index 9bf7e68..2f03d1f 100644 } else { WD_ERR("failed to check digest mode, mode = %u\n", msg->mode); return -WD_EINVAL; -@@ -1887,7 +1887,7 @@ static int fill_digest_bd3_alg(struct wd_digest_msg *msg, +@@ -1888,7 +1888,7 @@ static int fill_digest_bd3_alg(struct wd_digest_msg *msg, if (msg->mode == WD_DIGEST_NORMAL) { sqe->auth_mac_key |= @@ -58,7 +58,7 @@ index 9bf7e68..2f03d1f 100644 } else if (msg->mode == WD_DIGEST_HMAC) { ret = hmac_key_len_check(msg); if (ret) -@@ -1897,7 +1897,7 @@ static int fill_digest_bd3_alg(struct wd_digest_msg *msg, +@@ -1898,7 +1898,7 @@ static int fill_digest_bd3_alg(struct wd_digest_msg *msg, WORD_BYTES) << SEC_AKEY_OFFSET_V3; sqe->a_key_addr = (__u64)(uintptr_t)msg->key; sqe->auth_mac_key |= @@ -68,7 +68,7 @@ index 9bf7e68..2f03d1f 100644 if (msg->alg == WD_DIGEST_AES_GMAC) { sqe->auth_mac_key |= AI_GEN_IVIN_ADDR << SEC_AI_GEN_OFFSET_V3; diff --git a/wd.c b/wd.c -index a6e207d..be374f5 100644 +index 998c9be..2d9a42c 100644 --- a/wd.c +++ b/wd.c @@ -228,7 +228,7 @@ static int get_dev_info(struct uacce_dev *dev) @@ -90,5 +90,5 @@ index a6e207d..be374f5 100644 ret = get_int_attr(dev, "region_mmio_size", &value); -- -2.25.1 +2.31.1.windows.1 diff --git a/0095-uadk-sec-add-a-return-value-judgement.patch b/0104-uadk-sec-add-a-return-value-judgement.patch similarity index 72% rename from 0095-uadk-sec-add-a-return-value-judgement.patch rename to 0104-uadk-sec-add-a-return-value-judgement.patch index 337f6a1..498bc46 100644 --- a/0095-uadk-sec-add-a-return-value-judgement.patch +++ b/0104-uadk-sec-add-a-return-value-judgement.patch @@ -1,7 +1,7 @@ -From f118a291c4aacebf60c3c532d004581d125df6a1 Mon Sep 17 00:00:00 2001 +From 4ee1811e3dd7dc22946204f239448b901df075a7 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Thu, 30 Nov 2023 17:14:45 +0800 -Subject: [PATCH 095/114] uadk/sec: add a return value judgement +Subject: [PATCH 104/123] uadk/sec: add a return value judgement Add return value judgement of aead_get_aes_key_len(). @@ -11,10 +11,10 @@ Signed-off-by: Zhiqi Song 1 file changed, 4 insertions(+) diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c -index 2f03d1f..9102a27 100644 +index 14952e7..4421dfc 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c -@@ -2152,6 +2152,8 @@ static int fill_aead_bd2_alg(struct wd_aead_msg *msg, +@@ -2153,6 +2153,8 @@ static int fill_aead_bd2_alg(struct wd_aead_msg *msg, case WD_CIPHER_AES: sqe->type2.c_alg = C_ALG_AES; ret = aead_get_aes_key_len(msg, &c_key_len); @@ -23,7 +23,7 @@ index 2f03d1f..9102a27 100644 sqe->type2.icvw_kmode = (__u16)c_key_len << SEC_CKEY_OFFSET; break; default: -@@ -2721,6 +2723,8 @@ static int fill_aead_bd3_alg(struct wd_aead_msg *msg, +@@ -2722,6 +2724,8 @@ static int fill_aead_bd3_alg(struct wd_aead_msg *msg, case WD_CIPHER_AES: sqe->c_mode_alg |= C_ALG_AES << SEC_CALG_OFFSET_V3; ret = aead_get_aes_key_len(msg, &c_key_len); @@ -33,5 +33,5 @@ index 2f03d1f..9102a27 100644 break; default: -- -2.25.1 +2.31.1.windows.1 diff --git a/0096-uadk-Add-file-association.patch b/0105-uadk-Add-file-association.patch similarity index 85% rename from 0096-uadk-Add-file-association.patch rename to 0105-uadk-Add-file-association.patch index 0941076..d9194ac 100644 --- a/0096-uadk-Add-file-association.patch +++ b/0105-uadk-Add-file-association.patch @@ -1,7 +1,7 @@ -From 697b131a5a08586fb731c160c89c86e107f11984 Mon Sep 17 00:00:00 2001 +From 493f0bab40ff7bd083d2bfff1fcb78b411ffac6f Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:17:22 +0800 -Subject: [PATCH 096/114] uadk: Add file association +Subject: [PATCH 105/123] uadk: Add file association Add wd_comp file to zip. @@ -27,5 +27,5 @@ index 657ed20..e9ec47a 100644 libhisi_sec_la_LIBADD= -lwd -lwd_crypto libhisi_sec_la_LDFLAGS=$(UADK_VERSION) -- -2.25.1 +2.31.1.windows.1 diff --git a/0097-uadk-fix-the-failure-process-bug.patch b/0106-uadk-fix-the-failure-process-bug.patch similarity index 87% rename from 0097-uadk-fix-the-failure-process-bug.patch rename to 0106-uadk-fix-the-failure-process-bug.patch index 29d9467..6c39221 100644 --- a/0097-uadk-fix-the-failure-process-bug.patch +++ b/0106-uadk-fix-the-failure-process-bug.patch @@ -1,7 +1,7 @@ -From 044afdf1f90573c3a44187f7759461f496bf7bf8 Mon Sep 17 00:00:00 2001 +From 249ad7add2778b108c852faf3d65174518a44849 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:18:43 +0800 -Subject: [PATCH 097/114] uadk: fix the failure process bug +Subject: [PATCH 106/123] uadk: fix the failure process bug After a failure message is returned due to a calloc exception, the mp-ref count must be decreased by 1. Otherwise, an infinite @@ -35,5 +35,5 @@ index cb8c80b..ed107d1 100644 return (handle_t)(-WD_ENOMEM); } -- -2.25.1 +2.31.1.windows.1 diff --git a/0098-uadk-fix-the-failure-process-bug.patch b/0107-uadk-fix-the-failure-process-bug.patch similarity index 76% rename from 0098-uadk-fix-the-failure-process-bug.patch rename to 0107-uadk-fix-the-failure-process-bug.patch index bc08feb..32919ef 100644 --- a/0098-uadk-fix-the-failure-process-bug.patch +++ b/0107-uadk-fix-the-failure-process-bug.patch @@ -1,7 +1,7 @@ -From f7a2fb057185759708d8b9712608150c9dccafef Mon Sep 17 00:00:00 2001 +From bb600d5a9178ce32375edfce50a8a568a88d13a8 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:20:38 +0800 -Subject: [PATCH 098/114] uadk: fix the failure process bug +Subject: [PATCH 107/123] uadk: fix the failure process bug After the sem_post operation of full_sem fails, it need to restore empty_sem to ensure that resources are available. @@ -12,7 +12,7 @@ Signed-off-by: Chenghai Huang 1 file changed, 1 insertion(+) diff --git a/wd_util.c b/wd_util.c -index 10b0ab9..4867d63 100644 +index 2892ee9..24e1094 100644 --- a/wd_util.c +++ b/wd_util.c @@ -1398,6 +1398,7 @@ err_out: @@ -24,5 +24,5 @@ index 10b0ab9..4867d63 100644 return ret; } -- -2.25.1 +2.31.1.windows.1 diff --git a/0099-uadk-fix-the-failure-process-bug.patch b/0108-uadk-fix-the-failure-process-bug.patch similarity index 87% rename from 0099-uadk-fix-the-failure-process-bug.patch rename to 0108-uadk-fix-the-failure-process-bug.patch index decc55e..d110ec6 100644 --- a/0099-uadk-fix-the-failure-process-bug.patch +++ b/0108-uadk-fix-the-failure-process-bug.patch @@ -1,7 +1,7 @@ -From 9de8de67355430cfa9764109655af988cb7c031e Mon Sep 17 00:00:00 2001 +From 2343c310e30e6df6be3aa421c8f9e6307bc3b852 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:23:32 +0800 -Subject: [PATCH 099/114] uadk: fix the failure process+bug +Subject: [PATCH 108/123] uadk: fix the failure process+bug Assign numa_num to sched_ctx before err_out for wd_scheduling_rr_release release memoryc orrectly. @@ -32,5 +32,5 @@ index 7aeea73..419280e 100644 sched->sched_init = sched_table[sched_type].sched_init; -- -2.25.1 +2.31.1.windows.1 diff --git a/0100-uadk-bugfix.patch b/0109-uadk-bugfix.patch similarity index 80% rename from 0100-uadk-bugfix.patch rename to 0109-uadk-bugfix.patch index fdb868d..ad89532 100644 --- a/0100-uadk-bugfix.patch +++ b/0109-uadk-bugfix.patch @@ -1,7 +1,7 @@ -From bf5a2e34368228538436a3856fd69167a6897516 Mon Sep 17 00:00:00 2001 +From a815a003a4c679b8ce35ae6f97b8601da78dd811 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:25:47 +0800 -Subject: [PATCH 100/114] uadk: bugfix +Subject: [PATCH 109/123] uadk: bugfix Replace strncpy with memcpy to avoid compilation warnings. @@ -11,7 +11,7 @@ Signed-off-by: Chenghai Huang 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wd.c b/wd.c -index be374f5..b08abab 100644 +index 2d9a42c..abadcf9 100644 --- a/wd.c +++ b/wd.c @@ -426,7 +426,7 @@ handle_t wd_request_ctx(struct uacce_dev *dev) @@ -24,5 +24,5 @@ index be374f5..b08abab 100644 return (handle_t)ctx; -- -2.25.1 +2.31.1.windows.1 diff --git a/0101-uadk-v1-adapter-code-cleanup.patch b/0110-uadk-v1-adapter-code-cleanup.patch similarity index 87% rename from 0101-uadk-v1-adapter-code-cleanup.patch rename to 0110-uadk-v1-adapter-code-cleanup.patch index 2a2cc08..c97936a 100644 --- a/0101-uadk-v1-adapter-code-cleanup.patch +++ b/0110-uadk-v1-adapter-code-cleanup.patch @@ -1,7 +1,7 @@ -From 111d3b3688063ec0f40171f837f0f0bde68b7e25 Mon Sep 17 00:00:00 2001 +From c283c0d1b5a682e1658bb22c9f3d493fd5734eb5 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:29:22 +0800 -Subject: [PATCH 101/114] uadk v1: adapter code cleanup +Subject: [PATCH 110/123] uadk v1: adapter code cleanup Delete unnecessary processing. @@ -35,5 +35,5 @@ index 6b0b4d8..6e95562 100644 if (ret < 0) { drv_show_ss_slices(q); -- -2.25.1 +2.31.1.windows.1 diff --git a/0102-uadk-v1-fix-wd_rng-resource-release-bug.patch b/0111-uadk-v1-fix-wd_rng-resource-release-bug.patch similarity index 86% rename from 0102-uadk-v1-fix-wd_rng-resource-release-bug.patch rename to 0111-uadk-v1-fix-wd_rng-resource-release-bug.patch index 6477fbd..da25754 100644 --- a/0102-uadk-v1-fix-wd_rng-resource-release-bug.patch +++ b/0111-uadk-v1-fix-wd_rng-resource-release-bug.patch @@ -1,7 +1,7 @@ -From f99c4bfe4aec8110043bd88df0f52b47ed8e05e8 Mon Sep 17 00:00:00 2001 +From 229d6b81c9ac88bc3152bbdad07da247ff1261f2 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:30:23 +0800 -Subject: [PATCH 102/114] uadk v1: fix wd_rng resource release bug +Subject: [PATCH 111/123] uadk v1: fix wd_rng resource release bug Before wd_free_id and ctx_num are released, check whether ctx_num is less than or equal to 0 to @@ -36,5 +36,5 @@ index 927665f..24a4b7a 100644 free(ctx); -- -2.25.1 +2.31.1.windows.1 diff --git a/0103-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch b/0112-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch similarity index 97% rename from 0103-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch rename to 0112-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch index e598059..09661a3 100644 --- a/0103-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch +++ b/0112-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch @@ -1,7 +1,7 @@ -From 294719db475aeb6f13dbc8b364b6ce1e48846f40 Mon Sep 17 00:00:00 2001 +From 878a9677dfc6fbfbf8d01444efbce6860e11f0fd Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:33:19 +0800 -Subject: [PATCH 103/114] uadk v1: code cleanup for error codes and header +Subject: [PATCH 112/123] uadk v1: code cleanup for error codes and header files Unify the use of error return name. Adjusting the @@ -231,5 +231,5 @@ index 3839304..26e7af3 100644 { if (!log) { -- -2.25.1 +2.31.1.windows.1 diff --git a/0104-uadk-concentrate-the-same-definitions.patch b/0113-uadk-concentrate-the-same-definitions.patch similarity index 92% rename from 0104-uadk-concentrate-the-same-definitions.patch rename to 0113-uadk-concentrate-the-same-definitions.patch index 17a07cf..edbfbe3 100644 --- a/0104-uadk-concentrate-the-same-definitions.patch +++ b/0113-uadk-concentrate-the-same-definitions.patch @@ -1,7 +1,7 @@ -From 98c371e0c0ff955befb8a10a9b426bb5c0aea776 Mon Sep 17 00:00:00 2001 +From 310c4d1a49f1d1599dc5bd3046b064e2a5fccbb5 Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:35:02 +0800 -Subject: [PATCH 104/114] uadk: concentrate the same definitions +Subject: [PATCH 113/123] uadk: concentrate the same definitions The sec algorithm has multiple common header files, so they are centrally stored in wd_alg_common. @@ -18,7 +18,7 @@ Signed-off-by: Chenghai Huang 7 files changed, 15 insertions(+), 37 deletions(-) diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c -index 9102a27..5b114f6 100644 +index 4421dfc..08f91b6 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -63,13 +63,6 @@ @@ -35,7 +35,7 @@ index 9102a27..5b114f6 100644 #define DES3_BLOCK_SIZE 8 #define AES_BLOCK_SIZE 16 #define CTR_128BIT_COUNTER 16 -@@ -823,9 +816,9 @@ static void update_iv_sgl(struct wd_cipher_msg *msg) +@@ -824,9 +817,9 @@ static void update_iv_sgl(struct wd_cipher_msg *msg) static int get_3des_c_key_len(struct wd_cipher_msg *msg, __u8 *c_key_len) { @@ -97,7 +97,7 @@ index ad4d579..f0916c3 100644 * wd_digest_type - Algorithm type of digest * algorithm should be offered by struct wd_digest_arg diff --git a/wd_aead.c b/wd_aead.c -index 6d49d76..34a3b86 100644 +index 05f8883..abbdf8d 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -10,15 +10,6 @@ @@ -117,7 +117,7 @@ index 6d49d76..34a3b86 100644 #define WD_AEAD_CCM_GCM_MAX 16 diff --git a/wd_cipher.c b/wd_cipher.c -index 47c0bf8..f35ce6f 100644 +index 22fb2c7..eb10a5c 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -13,13 +13,6 @@ @@ -135,7 +135,7 @@ index 47c0bf8..f35ce6f 100644 #define DES_WEAK_KEY_NUM 16 diff --git a/wd_digest.c b/wd_digest.c -index 9008bcb..acf341a 100644 +index e119b42..8cd3ef2 100644 --- a/wd_digest.c +++ b/wd_digest.c @@ -10,16 +10,7 @@ @@ -156,5 +156,5 @@ index 9008bcb..acf341a 100644 static __u32 g_digest_mac_len[WD_DIGEST_TYPE_MAX] = { WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN, -- -2.25.1 +2.31.1.windows.1 diff --git a/0105-uadk-v1-optimize-the-function-length.patch b/0114-uadk-v1-optimize-the-function-length.patch similarity index 96% rename from 0105-uadk-v1-optimize-the-function-length.patch rename to 0114-uadk-v1-optimize-the-function-length.patch index 9832c32..13ddf72 100644 --- a/0105-uadk-v1-optimize-the-function-length.patch +++ b/0114-uadk-v1-optimize-the-function-length.patch @@ -1,7 +1,7 @@ -From 6ca1f2190a37490b5dc84f04f70cca945355da1e Mon Sep 17 00:00:00 2001 +From b489bf9429ece77fa0bef1616871d80072a50fae Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:36:12 +0800 -Subject: [PATCH 105/114] uadk v1: optimize the function length +Subject: [PATCH 114/123] uadk v1: optimize the function length The number of lines in the param_check function exceeds 50, so subfunctions are added for optimization. @@ -129,5 +129,5 @@ index b8ea5ce..df8a8af 100644 if (unlikely(tag && !tag[i])) { WD_ERR("invalid: tag[%u] is NULL!\n", i); -- -2.25.1 +2.31.1.windows.1 diff --git a/0106-uadk-v1-concentrate-the-same-definitions.patch b/0115-uadk-v1-concentrate-the-same-definitions.patch similarity index 97% rename from 0106-uadk-v1-concentrate-the-same-definitions.patch rename to 0115-uadk-v1-concentrate-the-same-definitions.patch index 7d15a3c..3ce9abe 100644 --- a/0106-uadk-v1-concentrate-the-same-definitions.patch +++ b/0115-uadk-v1-concentrate-the-same-definitions.patch @@ -1,7 +1,7 @@ -From 0580da2ecffbd20a392c987e28a0d164c6aa2b56 Mon Sep 17 00:00:00 2001 +From a470786b499641f10720dbcd3dbe257499d64d2d Mon Sep 17 00:00:00 2001 From: Qi Tao Date: Mon, 4 Dec 2023 17:37:24 +0800 -Subject: [PATCH 106/114] uadk v1: concentrate the same definitions +Subject: [PATCH 115/123] uadk v1: concentrate the same definitions The sec algorithm has multiple common header files, so they are centrally stored in wd_alg_common. @@ -155,5 +155,5 @@ index bf17058..9e5fa90 100644 #define X_DH_HW_KEY_SZ(hsz) ((hsz) * X_DH_HW_KEY_PARAM_NUM) #define SM2_KG_OUT_PARAMS_SZ(hsz) ((hsz) * SM2_KG_OUT_PARAM_NUM) -- -2.25.1 +2.31.1.windows.1 diff --git a/0116-uadk-v1-fix-security-view-issues-of-hpre.patch b/0116-uadk-v1-fix-security-view-issues-of-hpre.patch new file mode 100644 index 0000000..1840205 --- /dev/null +++ b/0116-uadk-v1-fix-security-view-issues-of-hpre.patch @@ -0,0 +1,165 @@ +From ff170d66d338d4131fd105704427a77d719659c0 Mon Sep 17 00:00:00 2001 +From: Zhiqi Song +Date: Thu, 7 Dec 2023 19:19:02 +0800 +Subject: [PATCH 116/123] uadk/v1: fix security view issues of hpre + +1. Add parameter check when fill rsa pubkey. +2. Modify addr seqence in DMA_ADDR(). +3. Modify redundant code. + +Signed-off-by: Zhiqi Song +--- + v1/drv/hisi_hpre_udrv.c | 22 +++++++++++++--------- + v1/wd_ecc.c | 11 ++++++++--- + v1/wd_rsa.c | 3 +++ + 3 files changed, 24 insertions(+), 12 deletions(-) + +diff --git a/v1/drv/hisi_hpre_udrv.c b/v1/drv/hisi_hpre_udrv.c +index 0d0c3b4..3f8029b 100644 +--- a/v1/drv/hisi_hpre_udrv.c ++++ b/v1/drv/hisi_hpre_udrv.c +@@ -40,7 +40,7 @@ + #define HPRE_SM2_ENC 0xE + #define HPRE_SM2_DEC 0xF + +-#define SM2_SQE_NUM 2 ++#define SM2_SQE_NUM 2 + + static bool is_hpre_bin_fmt(const char *data, int dsz, int bsz) + { +@@ -203,6 +203,11 @@ static int qm_fill_rsa_pubkey(struct wcrypto_rsa_pubkey *pubkey, void **data) + int ret; + + wcrypto_get_rsa_pubkey_params(pubkey, &wd_e, &wd_n); ++ if (unlikely(!wd_e || !wd_n)) { ++ WD_ERR("failed to get rsa pubkey params!\n"); ++ return -WD_EINVAL; ++ } ++ + ret = qm_crypto_bin_to_hpre_bin(wd_e->data, (const char *)wd_e->data, + wd_e->bsize, wd_e->dsize, "rsa pubkey e"); + if (unlikely(ret)) +@@ -330,7 +335,7 @@ static void rsa_key_unmap(struct wcrypto_rsa_msg *msg, struct wd_queue *q, + struct wcrypto_rsa_kg_out *key = (void *)msg->key; + uintptr_t phy; + +- phy = DMA_ADDR(hw_msg->low_key, hw_msg->hi_key); ++ phy = DMA_ADDR(hw_msg->hi_key, hw_msg->low_key); + phy -= (uintptr_t)va - (uintptr_t)key; + + drv_iova_unmap(q, msg->key, (void *)phy, size); +@@ -597,7 +602,7 @@ static int fill_dh_g_param(struct wd_queue *q, struct wcrypto_dh_msg *msg, + static void dh_g_unmap(struct wcrypto_dh_msg *msg, struct wd_queue *q, + struct hisi_hpre_sqe *hw_msg) + { +- uintptr_t phy = DMA_ADDR(hw_msg->low_in, hw_msg->hi_in); ++ uintptr_t phy = DMA_ADDR(hw_msg->hi_in, hw_msg->low_in); + if (phy) + drv_iova_unmap(q, msg->g, (void *)phy, msg->key_bytes); + } +@@ -605,7 +610,7 @@ static void dh_g_unmap(struct wcrypto_dh_msg *msg, struct wd_queue *q, + static void dh_xp_unmap(struct wcrypto_dh_msg *msg, struct wd_queue *q, + struct hisi_hpre_sqe *hw_msg) + { +- uintptr_t phy = DMA_ADDR(hw_msg->low_key, hw_msg->hi_key); ++ uintptr_t phy = DMA_ADDR(hw_msg->hi_key, hw_msg->low_key); + + drv_iova_unmap(q, msg->x_p, (void *)phy, GEN_PARAMS_SZ_UL(msg->key_bytes)); + } +@@ -1008,7 +1013,7 @@ static void ecc_key_unmap(struct wcrypto_ecc_msg *msg, struct wd_queue *q, + { + uintptr_t phy; + +- phy = DMA_ADDR(hw_msg->low_key, hw_msg->hi_key); ++ phy = DMA_ADDR(hw_msg->hi_key, hw_msg->low_key); + drv_iova_unmap(q, va, (void *)phy, size); + } + +@@ -1586,8 +1591,7 @@ static int ecc_verf_out_transfer(struct wcrypto_ecc_msg *msg, + { + __u32 result = hw_msg->low_out; + +- result >>= 1; +- result &= 1; ++ result = (result >> 1) & 1; + if (!result) + msg->result = WD_VERIFY_ERR; + +@@ -1667,7 +1671,7 @@ static int qm_fill_ecc_sqe_general(void *message, struct qm_queue_info *info, + hw_msg = (struct hisi_hpre_sqe *)sqe; + + memset(hw_msg, 0, sizeof(struct hisi_hpre_sqe)); +- hw_msg->task_len1 = msg->key_bytes / BYTE_BITS - 0x1; ++ hw_msg->task_len1 = ((msg->key_bytes) >> BYTE_BITS_SHIFT) - 0x1; + + /* prepare algorithm */ + ret = qm_ecc_prepare_alg(hw_msg, msg); +@@ -2327,7 +2331,7 @@ static int sm2_convert_enc_out(struct wcrypto_ecc_msg *src, + /* enc origin out data fmt: + * | x1y1(2*256bit) | x2y2(2*256bit) | other | + * final out data fmt: +- * | c1(2*256bit) | c2(plaintext size) | c3(256bit) | ++ * | c1(2*256bit) | c3(256bit) | c2(plaintext size) | + */ + x2y2.x.data = (void *)second->out; + x2y2.x.dsize = ksz; +diff --git a/v1/wd_ecc.c b/v1/wd_ecc.c +index 7650b2b..597926d 100644 +--- a/v1/wd_ecc.c ++++ b/v1/wd_ecc.c +@@ -428,7 +428,7 @@ static struct wcrypto_ecc_in *create_sm2_sign_in(struct wcrypto_ecc_ctx *ctx, + + hsz = get_hw_keysize(ctx->key_size); + len = sizeof(struct wcrypto_ecc_in) +- + ECC_SIGN_IN_PARAM_NUM * hsz + (__u64)m_len; ++ + ECC_SIGN_IN_PARAM_NUM * hsz + m_len; + in = br_alloc(br, len); + if (unlikely(!in)) { + WD_ERR("failed to br alloc, sz = %llu!\n", len); +@@ -1802,6 +1802,11 @@ static int generate_random(struct wcrypto_ecc_ctx *ctx, struct wd_dtb *k) + struct wcrypto_rand_mt *rand_mt = &ctx->setup.rand; + int ret; + ++ if (!rand_mt->cb) { ++ WD_ERR("failed to get rand cb!\n"); ++ return -WD_EINVAL; ++ } ++ + ret = rand_mt->cb(k->data, k->dsize, rand_mt->usr); + if (unlikely(ret)) + WD_ERR("failed to rand cb: ret = %d!\n", ret); +@@ -1932,7 +1937,7 @@ static struct wcrypto_ecc_in *new_sign_in(struct wcrypto_ecc_ctx *ctx, + return NULL; + + sin = &ecc_in->param.sin; +- if (!k && cx->setup.rand.cb) { ++ if (!k) { + ret = generate_random(cx, &sin->k); + if (unlikely(ret)) + goto release_in; +@@ -2018,7 +2023,7 @@ static struct wcrypto_ecc_in *create_sm2_verf_in(struct wcrypto_ecc_ctx *ctx, + + hsz = get_hw_keysize(ctx->key_size); + len = sizeof(struct wcrypto_ecc_in) + ECC_VERF_IN_PARAM_NUM * hsz + +- (__u64)m_len; ++ m_len; + in = br_alloc(br, len); + if (unlikely(!in)) { + WD_ERR("failed to br alloc, sz = %llu!\n", len); +diff --git a/v1/wd_rsa.c b/v1/wd_rsa.c +index 9e467d0..90c8f84 100644 +--- a/v1/wd_rsa.c ++++ b/v1/wd_rsa.c +@@ -798,6 +798,9 @@ static int rsa_prikey2_param_set(struct wcrypto_rsa_prikey2 *pkey2, + case WD_CRT_PRIKEY_Q: + ret = rsa_set_param(&pkey2->q, param); + break; ++ default: ++ ret = -WD_EINVAL; ++ break; + } + + return ret; +-- +2.31.1.windows.1 + diff --git a/0117-uadk-cleanup-issues-of-hpre.patch b/0117-uadk-cleanup-issues-of-hpre.patch new file mode 100644 index 0000000..f3c3cf3 --- /dev/null +++ b/0117-uadk-cleanup-issues-of-hpre.patch @@ -0,0 +1,635 @@ +From a3d3397b5b2c8fe8908519bc7626f5c5678df494 Mon Sep 17 00:00:00 2001 +From: Zhiqi Song +Date: Thu, 7 Dec 2023 19:19:03 +0800 +Subject: [PATCH 117/123] uadk: cleanup issues of hpre + +1. Remove redundant code. +2. Use safer and more efficient method to distinguish + algorithms. +3. Modify return value style. + +Signed-off-by: Zhiqi Song +--- + drv/hisi_hpre.c | 101 ++++++++++++++++++++++++++++-------------------- + wd_dh.c | 16 ++++---- + wd_ecc.c | 33 +++++++++------- + wd_rsa.c | 14 +++---- + 4 files changed, 93 insertions(+), 71 deletions(-) + +diff --git a/drv/hisi_hpre.c b/drv/hisi_hpre.c +index 2f8a5d6..53ebe52 100644 +--- a/drv/hisi_hpre.c ++++ b/drv/hisi_hpre.c +@@ -39,6 +39,8 @@ + #define GEN_PARAMS_SZ(key_size) ((key_size) << 1) + #define CRT_PARAM_SZ(key_size) ((key_size) >> 1) + ++#define WD_TRANS_FAIL 0 ++ + enum hpre_alg_type { + HPRE_ALG_NC_NCRT = 0x0, + HPRE_ALG_NC_CRT = 0x1, +@@ -64,6 +66,12 @@ enum hpre_alg_type { + HPRE_ALG_SM2_DEC = 0x15 + }; + ++enum hpre_alg_name { ++ WD_RSA, ++ WD_DH, ++ WD_ECC ++}; ++ + /* put vendor hardware message as a user interface is not suitable here */ + struct hisi_hpre_sqe { + __u32 alg : 5; +@@ -101,24 +109,34 @@ struct hisi_hpre_ctx { + struct wd_ctx_config_internal config; + }; + +-static void dump_hpre_msg(void *msg, const char *s) ++static void dump_hpre_msg(void *msg, int alg) + { + struct wd_rsa_msg *rsa_msg; + struct wd_ecc_msg *ecc_msg; + struct wd_dh_msg *dh_msg; + +- WD_ERR("dump %s alg message after a task error occurs.\n", s); +- +- if (!strcmp(s, "rsa")) { ++ switch (alg) { ++ case WD_RSA: + rsa_msg = (struct wd_rsa_msg *)msg; +- WD_ERR("key_bytes:%u key_type:%u\n", rsa_msg->key_bytes, rsa_msg->key_type); +- } else if (!strcmp(s, "ecc")) { +- ecc_msg = (struct wd_ecc_msg *)msg; +- WD_ERR("key_bytes:%u curve_id:%u\n", ecc_msg->key_bytes, ecc_msg->curve_id); +- } else if (!strcmp(s, "dh")) { ++ WD_ERR("dump RSA alg message after a task error occurs\n" ++ "key_bytes:%u key_type:%u\n", rsa_msg->key_bytes, ++ rsa_msg->key_type); ++ break; ++ case WD_DH: + dh_msg = (struct wd_dh_msg *)msg; +- WD_ERR("gbytes:%u key_bytes:%u is_g2:%u\n", dh_msg->gbytes, +- dh_msg->key_bytes, dh_msg->is_g2); ++ WD_ERR("dump DH alg message after a task error occurs\n" ++ "gbytes:%u key_bytes:%u is_g2:%u\n", dh_msg->gbytes, ++ dh_msg->key_bytes, dh_msg->is_g2); ++ break; ++ case WD_ECC: ++ ecc_msg = (struct wd_ecc_msg *)msg; ++ WD_ERR("dump ECC alg message after a task error occurs\n" ++ "key_bytes:%u curve_id:%u\n", ecc_msg->key_bytes, ++ ecc_msg->curve_id); ++ break; ++ default: ++ WD_ERR("invalid alg!\n"); ++ break; + } + } + +@@ -181,7 +199,7 @@ static int hpre_bin_to_crypto_bin(char *dst, const char *src, __u32 b_size, + + if (!dst || !src || !b_size) { + WD_ERR("invalid: %s trans to crypto bin parameters err!\n", p_name); +- return 0; ++ return WD_TRANS_FAIL; + } + + while (!src[j] && k < (b_size - 1)) +@@ -496,7 +514,7 @@ static int hpre_init_qm_priv(struct wd_ctx_config_internal *config, + config->ctxs[i].sqn = qm_priv->sqn; + } + +- return 0; ++ return WD_SUCCESS; + out: + for (j = 0; j < i; j++) { + h_qp = (handle_t)wd_ctx_get_priv(config->ctxs[j].ctx); +@@ -523,7 +541,7 @@ static int hpre_rsa_dh_init(void *conf, void *priv) + if (ret) + return ret; + +- return 0; ++ return WD_SUCCESS; + } + + static int hpre_ecc_init(void *conf, void *priv) +@@ -543,7 +561,7 @@ static int hpre_ecc_init(void *conf, void *priv) + if (ret) + return ret; + +- return 0; ++ return WD_SUCCESS; + } + + static void hpre_exit(void *priv) +@@ -655,9 +673,9 @@ static int rsa_recv(handle_t ctx, void *rsa_msg) + } + + if (unlikely(msg->result != WD_SUCCESS)) +- dump_hpre_msg(temp_msg, "rsa"); ++ dump_hpre_msg(temp_msg, WD_RSA); + +- return 0; ++ return WD_SUCCESS; + } + + static int fill_dh_xp_params(struct wd_dh_msg *msg, +@@ -798,9 +816,9 @@ static int dh_recv(handle_t ctx, void *dh_msg) + } + + if (unlikely(msg->result != WD_SUCCESS)) +- dump_hpre_msg(temp_msg, "dh"); ++ dump_hpre_msg(temp_msg, WD_DH); + +- return 0; ++ return WD_SUCCESS; + } + + static int ecc_prepare_alg(struct wd_ecc_msg *msg, +@@ -841,7 +859,7 @@ static int ecc_prepare_alg(struct wd_ecc_msg *msg, + return -WD_EINVAL; + } + +- return 0; ++ return WD_SUCCESS; + } + + static int trans_cv_param_to_hpre_bin(struct wd_dtb *p, struct wd_dtb *a, +@@ -976,7 +994,7 @@ static int ecc_prepare_prikey(struct wd_ecc_key *key, void **data, int id) + + *data = p->data; + +- return 0; ++ return WD_SUCCESS; + } + + static int trans_pub_to_hpre_bin(struct wd_ecc_point *pub) +@@ -1017,7 +1035,7 @@ static int ecc_prepare_pubkey(struct wd_ecc_key *key, void **data) + + *data = p->data; + +- return 0; ++ return WD_SUCCESS; + } + + static bool is_prikey_used(__u8 op_type) +@@ -1050,7 +1068,7 @@ static int ecc_prepare_key(struct wd_ecc_msg *msg, + hw_msg->low_key = LW_U32((uintptr_t)data); + hw_msg->hi_key = HI_U32((uintptr_t)data); + +- return 0; ++ return WD_SUCCESS; + } + + static void ecc_get_io_len(__u32 atype, __u32 hsz, size_t *ilen, +@@ -1146,7 +1164,7 @@ static int ecc_prepare_sign_in(struct wd_ecc_msg *msg, + + *data = e->data; + +- return 0; ++ return WD_SUCCESS; + } + + static int ecc_prepare_verf_in(struct wd_ecc_msg *msg, +@@ -1188,7 +1206,7 @@ static int ecc_prepare_verf_in(struct wd_ecc_msg *msg, + + *data = e->data; + +- return 0; ++ return WD_SUCCESS; + } + + static int sm2_prepare_enc_in(struct wd_ecc_msg *msg, +@@ -1211,7 +1229,7 @@ static int sm2_prepare_enc_in(struct wd_ecc_msg *msg, + hw_msg->sm2_mlen = ein->plaintext.dsize - 1; + *data = k->data; + +- return 0; ++ return WD_SUCCESS; + } + + static int sm2_prepare_dec_in(struct wd_ecc_msg *msg, +@@ -1235,7 +1253,7 @@ static int sm2_prepare_dec_in(struct wd_ecc_msg *msg, + hw_msg->sm2_mlen = din->c2.dsize - 1; + *data = c1->x.data; + +- return 0; ++ return WD_SUCCESS; + } + + static int ecc_prepare_dh_gen_in(struct wd_ecc_msg *msg, +@@ -1256,7 +1274,7 @@ static int ecc_prepare_dh_gen_in(struct wd_ecc_msg *msg, + + *data = in->x.data; + +- return 0; ++ return WD_SUCCESS; + } + + static int ecc_prepare_dh_compute_in(struct wd_ecc_msg *msg, +@@ -1278,7 +1296,7 @@ static int ecc_prepare_dh_compute_in(struct wd_ecc_msg *msg, + + *data = pbk->x.data; + +- return 0; ++ return WD_SUCCESS; + } + + static int u_is_in_p(struct wd_ecc_msg *msg) +@@ -1312,7 +1330,7 @@ static int u_is_in_p(struct wd_ecc_msg *msg) + return -WD_EINVAL; + } + +- return 0; ++ return WD_SUCCESS; + } + + static int ecc_prepare_in(struct wd_ecc_msg *msg, +@@ -1369,7 +1387,7 @@ static int ecc_prepare_dh_out(struct wd_ecc_out *out, void **data) + + *data = dh_out->x.data; + +- return 0; ++ return WD_SUCCESS; + } + + static int ecc_prepare_out(struct wd_ecc_msg *msg, void **data) +@@ -1437,13 +1455,14 @@ static int ecc_prepare_iot(struct wd_ecc_msg *msg, + return ret; + } + ++ /* op_type WD_ECDSA_VERIFY and WD_SM2_VERIFY do not need data */ + if (!data) +- return 0; ++ return WD_SUCCESS; + + hw_msg->low_out = LW_U32((uintptr_t)data); + hw_msg->hi_out = HI_U32((uintptr_t)data); + +- return 0; ++ return WD_SUCCESS; + } + + static __u32 get_hw_keysz(__u32 ksz) +@@ -1505,7 +1524,7 @@ static int set_param(struct wd_dtb *dst, const struct wd_dtb *src, + memset(dst->data, 0, dst->bsize); + memcpy(dst->data, src->data, src->dsize); + +- return 0; ++ return WD_SUCCESS; + } + + static int set_prikey(struct wd_ecc_prikey *prikey, +@@ -1571,7 +1590,6 @@ static struct wd_ecc_out *create_ecdh_out(struct wd_ecc_msg *msg) + dh_out->out.y.data = out->data; + dh_out->out.y.dsize = msg->key_bytes; + dh_out->out.y.bsize = hsz; +- out->size = data_sz; + + memcpy(out->data + data_sz, &msg, sizeof(void *)); + +@@ -1598,7 +1616,7 @@ static int init_req(struct wd_ecc_msg *dst, struct wd_ecc_msg *src, + else + dst->req.src = (void *)&pubkey->pub; + +- return 0; ++ return WD_SUCCESS; + } + + static struct wd_ecc_msg *create_req(struct wd_ecc_msg *src, __u8 req_idx) +@@ -1674,7 +1692,7 @@ static int split_req(struct wd_ecc_msg *src, struct wd_ecc_msg **dst) + return -WD_ENOMEM; + } + +- return 0; ++ return WD_SUCCESS; + } + + static int ecc_fill(struct wd_ecc_msg *msg, struct hisi_hpre_sqe *hw_msg) +@@ -1914,8 +1932,7 @@ static int ecc_verf_out_transfer(struct wd_ecc_msg *msg, + { + __u32 result = hw_msg->low_out; + +- result >>= 1; +- result &= 1; ++ result = (result >> 1) & 1; + if (!result) + msg->result = WD_VERIFY_ERR; + +@@ -2115,7 +2132,7 @@ static int is_equal(struct wd_dtb *src, struct wd_dtb *dst) + { + if (src->dsize == dst->dsize && + !memcmp(src->data, dst->data, src->dsize)) { +- return 0; ++ return WD_SUCCESS; + } + + return -WD_EINVAL; +@@ -2296,7 +2313,7 @@ static int ecc_sqe_parse(struct hisi_qp *qp, struct wd_ecc_msg *msg, + return ret; + + dump_err_msg: +- dump_hpre_msg(temp_msg, "ecc"); ++ dump_hpre_msg(temp_msg, WD_ECC); + + return ret; + } +@@ -2449,7 +2466,7 @@ static int ecc_recv(handle_t ctx, void *ecc_msg) + + static int hpre_get_usage(void *param) + { +- return 0; ++ return WD_SUCCESS; + } + + #define GEN_HPRE_ALG_DRIVER(hpre_alg_name) \ +diff --git a/wd_dh.c b/wd_dh.c +index 6bfc0cc..826f40b 100644 +--- a/wd_dh.c ++++ b/wd_dh.c +@@ -78,7 +78,7 @@ static int wd_dh_open_driver(void) + + wd_dh_setting.driver = driver; + +- return 0; ++ return WD_SUCCESS; + } + + static void wd_dh_clear_status(void) +@@ -116,7 +116,7 @@ static int wd_dh_common_init(struct wd_ctx_config *config, struct wd_sched *sche + if (ret) + goto out_clear_pool; + +- return 0; ++ return WD_SUCCESS; + + out_clear_pool: + wd_uninit_async_request_pool(&wd_dh_setting.pool); +@@ -143,7 +143,7 @@ static int wd_dh_common_uninit(void) + wd_dh_setting.driver, + &wd_dh_setting.priv); + +- return 0; ++ return WD_SUCCESS; + } + + int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched) +@@ -170,7 +170,7 @@ int wd_dh_init(struct wd_ctx_config *config, struct wd_sched *sched) + + wd_alg_set_init(&wd_dh_setting.status); + +- return 0; ++ return WD_SUCCESS; + + out_close_driver: + wd_dh_close_driver(); +@@ -270,7 +270,7 @@ int wd_dh_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_param + wd_alg_set_init(&wd_dh_setting.status); + wd_ctx_param_uninit(&dh_ctx_params); + +- return 0; ++ return WD_SUCCESS; + + out_params_uninit: + wd_ctx_param_uninit(&dh_ctx_params); +@@ -326,7 +326,7 @@ static int fill_dh_msg(struct wd_dh_msg *msg, struct wd_dh_req *req, + return -WD_EINVAL; + } + +- return 0; ++ return WD_SUCCESS; + } + + int wd_do_dh_sync(handle_t sess, struct wd_dh_req *req) +@@ -422,7 +422,7 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req) + if (ret) + goto fail_with_msg; + +- return 0; ++ return WD_SUCCESS; + + fail_with_msg: + wd_put_msg_to_pool(&wd_dh_setting.pool, idx, mid); +@@ -510,7 +510,7 @@ int wd_dh_get_mode(handle_t sess, __u8 *alg_mode) + + *alg_mode = ((struct wd_dh_sess *)sess)->setup.is_g2; + +- return 0; ++ return WD_SUCCESS; + } + + __u32 wd_dh_key_bits(handle_t sess) +diff --git a/wd_ecc.c b/wd_ecc.c +index 3cdbfdf..97c758c 100644 +--- a/wd_ecc.c ++++ b/wd_ecc.c +@@ -132,7 +132,7 @@ static int wd_ecc_open_driver(void) + + wd_ecc_setting.driver = driver; + +- return 0; ++ return WD_SUCCESS; + } + + static bool is_alg_support(const char *alg) +@@ -179,7 +179,7 @@ static int wd_ecc_common_init(struct wd_ctx_config *config, struct wd_sched *sch + if (ret) + goto out_clear_pool; + +- return 0; ++ return WD_SUCCESS; + + out_clear_pool: + wd_uninit_async_request_pool(&wd_ecc_setting.pool); +@@ -206,7 +206,7 @@ static int wd_ecc_common_uninit(void) + wd_ecc_setting.driver, + &wd_ecc_setting.priv); + +- return 0; ++ return WD_SUCCESS; + } + + int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched) +@@ -233,7 +233,7 @@ int wd_ecc_init(struct wd_ctx_config *config, struct wd_sched *sched) + + wd_alg_set_init(&wd_ecc_setting.status); + +- return 0; ++ return WD_SUCCESS; + + out_close_driver: + wd_ecc_close_driver(); +@@ -335,7 +335,7 @@ int wd_ecc_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_para + wd_alg_set_init(&wd_ecc_setting.status); + wd_ctx_param_uninit(&ecc_ctx_params); + +- return 0; ++ return WD_SUCCESS; + + out_params_uninit: + wd_ctx_param_uninit(&ecc_ctx_params); +@@ -827,7 +827,7 @@ static int set_param_single(struct wd_dtb *dst, const struct wd_dtb *src, + memset(dst->data, 0, dst->bsize); + memcpy(dst->data, src->data, src->dsize); + +- return 0; ++ return WD_SUCCESS; + } + + int wd_ecc_get_key_bits(handle_t sess) +@@ -905,7 +905,7 @@ static int set_curve_param(struct wd_ecc_key *key, + return -WD_EINVAL; + } + +- return 0; ++ return WD_SUCCESS; + } + + static const struct wd_ecc_curve_list *find_curve_list(__u32 id) +@@ -942,7 +942,7 @@ static int fill_param_by_id(struct wd_ecc_curve *c, + key_size = BITS_TO_BYTES(item->key_bits); + memcpy(c->p.data, item->data, CURVE_PARAM_NUM * key_size); + +- return 0; ++ return WD_SUCCESS; + } + + static void setup_curve_cfg(struct wd_ecc_sess_setup *setup) +@@ -1064,7 +1064,7 @@ static int create_sess_key(struct wd_ecc_sess_setup *setup, + goto free_d; + } + +- return 0; ++ return WD_SUCCESS; + + free_d: + release_ecc_d(sess); +@@ -1115,7 +1115,7 @@ static int setup_param_check(struct wd_ecc_sess_setup *setup) + return -WD_EINVAL; + } + +- return 0; ++ return WD_SUCCESS; + } + + static void del_sess_key(struct wd_ecc_sess *sess) +@@ -1627,7 +1627,7 @@ static int set_sign_in_param(struct wd_ecc_sign_in *sin, + return ret; + } + +- return 0; ++ return WD_SUCCESS; + } + + static int generate_random(struct wd_ecc_sess *sess, struct wd_dtb *k) +@@ -1635,6 +1635,11 @@ static int generate_random(struct wd_ecc_sess *sess, struct wd_dtb *k) + struct wd_rand_mt rand_t = sess->setup.rand; + int ret; + ++ if (!rand_t.cb) { ++ WD_ERR("failed to get rand cb!\n"); ++ return -WD_EINVAL; ++ } ++ + ret = rand_t.cb(k->data, k->dsize, rand_t.usr); + if (ret) + WD_ERR("failed to do rand cb, ret = %d!\n", ret); +@@ -1764,7 +1769,7 @@ static struct wd_ecc_in *new_sign_in(struct wd_ecc_sess *sess, + return NULL; + + sin = &ecc_in->param.sin; +- if (!k && sess_t->setup.rand.cb) { ++ if (!k) { + ret = generate_random(sess_t, &sin->k); + if (ret) + goto release_in; +@@ -1826,7 +1831,7 @@ static int set_verf_in_param(struct wd_ecc_verf_in *vin, + if (ret) + return ret; + +- return 0; ++ return WD_SUCCESS; + } + + static struct wd_ecc_in *create_sm2_verf_in(struct wd_ecc_sess *sess, +@@ -2258,7 +2263,7 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req) + if (ret) + goto fail_with_msg; + +- return 0; ++ return WD_SUCCESS; + + fail_with_msg: + wd_put_msg_to_pool(&wd_ecc_setting.pool, idx, mid); +diff --git a/wd_rsa.c b/wd_rsa.c +index 1424f61..e23e096 100644 +--- a/wd_rsa.c ++++ b/wd_rsa.c +@@ -117,7 +117,7 @@ static int wd_rsa_open_driver(void) + + wd_rsa_setting.driver = driver; + +- return 0; ++ return WD_SUCCESS; + } + + static void wd_rsa_clear_status(void) +@@ -154,7 +154,7 @@ static int wd_rsa_common_init(struct wd_ctx_config *config, struct wd_sched *sch + if (ret) + goto out_clear_pool; + +- return 0; ++ return WD_SUCCESS; + + out_clear_pool: + wd_uninit_async_request_pool(&wd_rsa_setting.pool); +@@ -181,7 +181,7 @@ static int wd_rsa_common_uninit(void) + wd_rsa_setting.driver, + &wd_rsa_setting.priv); + +- return 0; ++ return WD_SUCCESS; + } + + int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched) +@@ -208,7 +208,7 @@ int wd_rsa_init(struct wd_ctx_config *config, struct wd_sched *sched) + + wd_alg_set_init(&wd_rsa_setting.status); + +- return 0; ++ return WD_SUCCESS; + + out_close_driver: + wd_rsa_close_driver(); +@@ -308,7 +308,7 @@ int wd_rsa_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_para + wd_alg_set_init(&wd_rsa_setting.status); + wd_ctx_param_uninit(&rsa_ctx_params); + +- return 0; ++ return WD_SUCCESS; + + out_params_uninit: + wd_ctx_param_uninit(&rsa_ctx_params); +@@ -385,7 +385,7 @@ static int fill_rsa_msg(struct wd_rsa_msg *msg, struct wd_rsa_req *req, + + msg->key = key; + +- return 0; ++ return WD_SUCCESS; + } + + int wd_do_rsa_sync(handle_t h_sess, struct wd_rsa_req *req) +@@ -481,7 +481,7 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req) + if (ret) + goto fail_with_msg; + +- return 0; ++ return WD_SUCCESS; + + fail_with_msg: + wd_put_msg_to_pool(&wd_rsa_setting.pool, idx, mid); +-- +2.31.1.windows.1 + diff --git a/0118-uadk-v1-hpre-add-parameter-check-of-setup.patch b/0118-uadk-v1-hpre-add-parameter-check-of-setup.patch new file mode 100644 index 0000000..0a3ff7d --- /dev/null +++ b/0118-uadk-v1-hpre-add-parameter-check-of-setup.patch @@ -0,0 +1,104 @@ +From 42d99db17c805298d77b389fddd9d63018c60be2 Mon Sep 17 00:00:00 2001 +From: Zhiqi Song +Date: Thu, 7 Dec 2023 19:19:04 +0800 +Subject: [PATCH 118/123] uadk/v1/hpre: add parameter check of setup + +Add setup parameter check when create ctx, and +remove some redundant code. + +Signed-off-by: Zhiqi Song +--- + v1/drv/hisi_hpre_udrv.c | 9 ++++----- + v1/wd_dh.c | 3 ++- + v1/wd_ecc.c | 3 ++- + v1/wd_rsa.c | 3 ++- + 4 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/v1/drv/hisi_hpre_udrv.c b/v1/drv/hisi_hpre_udrv.c +index 3f8029b..de614f2 100644 +--- a/v1/drv/hisi_hpre_udrv.c ++++ b/v1/drv/hisi_hpre_udrv.c +@@ -301,7 +301,6 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, + if (hw_msg->alg == HPRE_ALG_KG_CRT) { + msg->out_bytes = CRT_GEN_PARAMS_SZ(kbytes); + *in_len = GEN_PARAMS_SZ_UL(kbytes); +- *out_len = msg->out_bytes; + wcrypto_get_rsa_kg_out_crt_params(key, &qinv, &dq, &dp); + ret = qm_tri_bin_transfer(&qinv, &dq, &dp, "rsa kg qinv&dp&dq"); + if (unlikely(ret)) +@@ -311,9 +310,7 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, + dq.dsize, dp.dsize); + } else if (hw_msg->alg == HPRE_ALG_KG_STD) { + msg->out_bytes = GEN_PARAMS_SZ(kbytes); +- *out_len = msg->out_bytes; + *in_len = GEN_PARAMS_SZ_UL(kbytes); +- + wcrypto_get_rsa_kg_out_params(key, &d, &n); + ret = qm_tri_bin_transfer(&d, &n, NULL, "rsa kg d & n"); + if (unlikely(ret)) +@@ -323,8 +320,10 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, + } else { + *in_len = kbytes; + msg->out_bytes = kbytes; +- *out_len = msg->out_bytes; + } ++ ++ *out_len = msg->out_bytes; ++ + return WD_SUCCESS; + } + +@@ -1922,7 +1921,7 @@ static int fill_sm2_enc_sqe(void *msg, struct qm_queue_info *info, __u16 idx) + } + + /* split message into two inner request msg +- * firest msg used to compute k * g ++ * first msg used to compute k * g + * second msg used to compute k * pb + */ + ret = split_req(info, req_src, req_dst); +diff --git a/v1/wd_dh.c b/v1/wd_dh.c +index 27bcb5a..0ccd7b3 100644 +--- a/v1/wd_dh.c ++++ b/v1/wd_dh.c +@@ -61,7 +61,8 @@ static int create_ctx_param_check(struct wd_queue *q, + return -WD_EINVAL; + } + +- if (!setup->br.alloc || !setup->br.free) { ++ if (!setup->br.alloc || !setup->br.free || ++ !setup->br.iova_map || !setup->br.iova_unmap) { + WD_ERR("create dh ctx user mm br err!\n"); + return -WD_EINVAL; + } +diff --git a/v1/wd_ecc.c b/v1/wd_ecc.c +index 597926d..02f63bf 100644 +--- a/v1/wd_ecc.c ++++ b/v1/wd_ecc.c +@@ -1011,7 +1011,8 @@ static int param_check(struct wd_queue *q, struct wcrypto_ecc_ctx_setup *setup) + return -WD_EINVAL; + } + +- if (unlikely(!setup->br.alloc || !setup->br.free)) { ++ if (unlikely(!setup->br.alloc || !setup->br.free || ++ !setup->br.iova_map || !setup->br.iova_unmap)) { + WD_ERR("user mm br error!\n"); + return -WD_EINVAL; + } +diff --git a/v1/wd_rsa.c b/v1/wd_rsa.c +index 90c8f84..5281b9b 100644 +--- a/v1/wd_rsa.c ++++ b/v1/wd_rsa.c +@@ -554,7 +554,8 @@ static int check_q_setup(struct wd_queue *q, struct wcrypto_rsa_ctx_setup *setup + return -WD_EINVAL; + } + +- if (!setup->br.alloc || !setup->br.free) { ++ if (!setup->br.alloc || !setup->br.free || ++ !setup->br.iova_map || !setup->br.iova_unmap) { + WD_ERR("create rsa ctx user mm br err!\n"); + return -WD_EINVAL; + } +-- +2.31.1.windows.1 + diff --git a/0119-uadk-ecc-fix-the-use-of-random-k-in-sm2-sign.patch b/0119-uadk-ecc-fix-the-use-of-random-k-in-sm2-sign.patch new file mode 100644 index 0000000..776bfda --- /dev/null +++ b/0119-uadk-ecc-fix-the-use-of-random-k-in-sm2-sign.patch @@ -0,0 +1,97 @@ +From 9212bec7dd58c8390f4a1b9345f64d112291a4d0 Mon Sep 17 00:00:00 2001 +From: Zhiqi Song +Date: Thu, 7 Dec 2023 19:19:05 +0800 +Subject: [PATCH 119/123] uadk/ecc: fix the use of random k in sm2 sign + +Fix the problem that can not get random k when do not set +the value or callback function. There are three ways to +use random k in sm2 sign, fix to support them all in v1 +and v2: + - If k is not set and cb has been set, use cb to generate + random k. + - If k is set or has been generated by cb, directly set k. + - If k and cb are not set, hw driver should config to + generate random k. + +Signed-off-by: Zhiqi Song +--- + v1/wd_ecc.c | 17 +++++++++-------- + wd_ecc.c | 15 +++++++++------ + 2 files changed, 18 insertions(+), 14 deletions(-) + +diff --git a/v1/wd_ecc.c b/v1/wd_ecc.c +index 02f63bf..3da55d2 100644 +--- a/v1/wd_ecc.c ++++ b/v1/wd_ecc.c +@@ -1803,11 +1803,6 @@ static int generate_random(struct wcrypto_ecc_ctx *ctx, struct wd_dtb *k) + struct wcrypto_rand_mt *rand_mt = &ctx->setup.rand; + int ret; + +- if (!rand_mt->cb) { +- WD_ERR("failed to get rand cb!\n"); +- return -WD_EINVAL; +- } +- + ret = rand_mt->cb(k->data, k->dsize, rand_mt->usr); + if (unlikely(ret)) + WD_ERR("failed to rand cb: ret = %d!\n", ret); +@@ -1938,14 +1933,20 @@ static struct wcrypto_ecc_in *new_sign_in(struct wcrypto_ecc_ctx *ctx, + return NULL; + + sin = &ecc_in->param.sin; +- if (!k) { ++ sin->k_set = 0; ++ sin->dgst_set = 0; ++ ++ /* ++ * If k is not set and cb has been set, use cb to generate random k. ++ * If k is set or has been generated by cb, directly set k. ++ * If k and cb are not set, hw driver should config to generate random k. ++ */ ++ if (!k && cx->setup.rand.cb) { + ret = generate_random(cx, &sin->k); + if (unlikely(ret)) + goto release_in; + } + +- sin->k_set = 0; +- sin->dgst_set = 0; + if (k || cx->setup.rand.cb) + sin->k_set = 1; + +diff --git a/wd_ecc.c b/wd_ecc.c +index 97c758c..710f1a0 100644 +--- a/wd_ecc.c ++++ b/wd_ecc.c +@@ -1635,11 +1635,6 @@ static int generate_random(struct wd_ecc_sess *sess, struct wd_dtb *k) + struct wd_rand_mt rand_t = sess->setup.rand; + int ret; + +- if (!rand_t.cb) { +- WD_ERR("failed to get rand cb!\n"); +- return -WD_EINVAL; +- } +- + ret = rand_t.cb(k->data, k->dsize, rand_t.usr); + if (ret) + WD_ERR("failed to do rand cb, ret = %d!\n", ret); +@@ -1769,7 +1764,15 @@ static struct wd_ecc_in *new_sign_in(struct wd_ecc_sess *sess, + return NULL; + + sin = &ecc_in->param.sin; +- if (!k) { ++ sin->k_set = 0; ++ sin->dgst_set = 0; ++ ++ /* ++ * If k is not set and cb has been set, use cb to generate random k. ++ * If k is set or has been generated by cb, directly set k. ++ * If k and cb are not set, hw driver should config to generate random k. ++ */ ++ if (!k && sess_t->setup.rand.cb) { + ret = generate_random(sess_t, &sin->k); + if (ret) + goto release_in; +-- +2.31.1.windows.1 + diff --git a/0120-uadk-v1-cleanup-common-part-code-style.patch b/0120-uadk-v1-cleanup-common-part-code-style.patch new file mode 100644 index 0000000..9b7decb --- /dev/null +++ b/0120-uadk-v1-cleanup-common-part-code-style.patch @@ -0,0 +1,219 @@ +From 25362ee741d1f304f9e5b45f47bf73bf46562a8d Mon Sep 17 00:00:00 2001 +From: Zhiqi Song +Date: Thu, 7 Dec 2023 19:19:06 +0800 +Subject: [PATCH 120/123] uadk/v1: cleanup common part code style + +Cleanup the following issues: +1. Add const to static variables that do not change. +2. Modify indentation and whitespace. +3. Put macro definitions at the beginning of the file. +4. Splitting judgment conditions to make it clearer. + +Signed-off-by: Zhiqi Song +--- + v1/drv/hisi_qm_udrv.c | 16 ++++++++-------- + v1/wd_adapter.c | 18 +++++++++--------- + v1/wd_bmm.c | 13 ++++++------- + v1/wd_sgl.c | 27 ++++++++++++++++++++++----- + 4 files changed, 45 insertions(+), 29 deletions(-) + +diff --git a/v1/drv/hisi_qm_udrv.c b/v1/drv/hisi_qm_udrv.c +index 0ca38d2..03a875b 100644 +--- a/v1/drv/hisi_qm_udrv.c ++++ b/v1/drv/hisi_qm_udrv.c +@@ -244,7 +244,7 @@ static int qm_set_queue_regions(struct wd_queue *q) + if (info->sq_base == MAP_FAILED) { + info->sq_base = NULL; + WD_ERR("mmap dus fail\n"); +- return -ENOMEM; ++ return -WD_ENOMEM; + } + + info->mmio_base = wd_drv_mmap_qfr(q, WD_UACCE_QFRT_MMIO, 0); +@@ -253,7 +253,7 @@ static int qm_set_queue_regions(struct wd_queue *q) + info->sq_base = NULL; + info->mmio_base = NULL; + WD_ERR("mmap mmio fail\n"); +- return -ENOMEM; ++ return -WD_ENOMEM; + } + + return 0; +@@ -439,7 +439,7 @@ static int qm_set_db_info(struct q_info *qinfo) + struct qm_queue_info *info = qinfo->priv; + + if (strstr(qinfo->hw_type, HISI_QM_API_VER2_BASE) || +- strstr(qinfo->hw_type, HISI_QM_API_VER3_BASE)) { ++ strstr(qinfo->hw_type, HISI_QM_API_VER3_BASE)) { + info->db = qm_db_v2; + info->doorbell_base = info->mmio_base + QM_V2_DOORBELL_OFFSET; + } else if (strstr(qinfo->hw_type, HISI_QM_API_VER_BASE)) { +@@ -447,7 +447,7 @@ static int qm_set_db_info(struct q_info *qinfo) + info->doorbell_base = info->mmio_base + QM_DOORBELL_OFFSET; + } else { + WD_ERR("hw version mismatch!\n"); +- return -EINVAL; ++ return -WD_EINVAL; + } + + return 0; +@@ -505,10 +505,10 @@ static int qm_set_queue_info(struct wd_queue *q) + + ret = qm_set_queue_regions(q); + if (ret) +- return -EINVAL; ++ return -WD_EINVAL; + if (!info->sqe_size) { + WD_ERR("sqe size =%d err!\n", info->sqe_size); +- ret = -EINVAL; ++ ret = -WD_EINVAL; + goto err_with_regions; + } + info->cq_base = (void *)((uintptr_t)info->sq_base + +@@ -520,7 +520,7 @@ static int qm_set_queue_info(struct wd_queue *q) + ret = mprotect(info->cq_base, psize, PROT_READ); + if (ret) { + WD_ERR("cqe mprotect set err!\n"); +- ret = -EINVAL; ++ ret = -WD_EINVAL; + goto err_with_regions; + } + +@@ -549,7 +549,7 @@ int qm_init_queue(struct wd_queue *q) + { + struct q_info *qinfo = q->qinfo; + struct qm_queue_info *info; +- int ret = -ENOMEM; ++ int ret = -WD_ENOMEM; + + info = calloc(1, sizeof(*info)); + if (!info) { +diff --git a/v1/wd_adapter.c b/v1/wd_adapter.c +index 6e95562..d574200 100644 +--- a/v1/wd_adapter.c ++++ b/v1/wd_adapter.c +@@ -28,7 +28,7 @@ + #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) + #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1) + +-static struct wd_drv_dio_if hw_dio_tbl[] = { { ++static const struct wd_drv_dio_if hw_dio_tbl[] = { { + .hw_type = "dummy_v1", + .open = dummy_set_queue_dio, + .close = dummy_unset_queue_dio, +@@ -155,13 +155,13 @@ void drv_free_slice(struct wd_queue *q) + struct q_info *qinfo = q->qinfo; + struct wd_ss_region *rgn; + +- while (true) { +- rgn = TAILQ_FIRST(&qinfo->ss_list); +- if (!rgn) +- break; +- TAILQ_REMOVE(&qinfo->ss_list, rgn, next); +- free(rgn); +- } ++ while (true) { ++ rgn = TAILQ_FIRST(&qinfo->ss_list); ++ if (!rgn) ++ break; ++ TAILQ_REMOVE(&qinfo->ss_list, rgn, next); ++ free(rgn); ++ } + } + + void drv_add_slice(struct wd_queue *q, struct wd_ss_region *rgn) +@@ -188,7 +188,7 @@ void drv_show_ss_slices(struct wd_queue *q) + int i = 0; + + TAILQ_FOREACH(rgn, qinfo->head, next) { +- WD_ERR("slice-%d:size=0x%lx\n", i, rgn->size); ++ WD_ERR("slice-%d:size = 0x%lx\n", i, rgn->size); + i++; + } + } +diff --git a/v1/wd_bmm.c b/v1/wd_bmm.c +index c98c487..cdf5f0b 100644 +--- a/v1/wd_bmm.c ++++ b/v1/wd_bmm.c +@@ -29,8 +29,12 @@ + #define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) + #define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a)-1) + +-#define TAG_FREE 0x12345678 /* block is free */ +-#define TAG_USED 0x87654321 /* block is busy */ ++#define TAG_FREE 0x12345678 /* block is free */ ++#define TAG_USED 0x87654321 /* block is busy */ ++#define MAX_ALIGN_SIZE 0x1000 /* 4KB */ ++#define MAX_BLOCK_SIZE 0x10000000 /* 256MB */ ++#define BLK_BALANCE_SZ 0x100000ul ++#define NUM_TIMES(x) (87 * (x) / 100) + + struct wd_blk_hd { + unsigned int blk_tag; +@@ -67,9 +71,6 @@ static struct wd_blk_hd *wd_blk_head(struct wd_blkpool *pool, void *blk) + + static int pool_params_check(struct wd_blkpool_setup *setup) + { +-#define MAX_ALIGN_SIZE 0x1000 /* 4KB */ +-#define MAX_BLOCK_SIZE 0x10000000 /* 256MB */ +- + if (!setup->block_num || !setup->block_size || + setup->block_size > MAX_BLOCK_SIZE) { + WD_ERR("Invalid block_size or block_num(%x, %u)!\n", +@@ -103,7 +104,6 @@ static int wd_pool_pre_layout(struct wd_queue *q, + if (!sp->br.alloc) + qinfo = q->qinfo; + +-#define BLK_BALANCE_SZ 0x100000ul + ret = pool_params_check(sp); + if (ret) + return ret; +@@ -171,7 +171,6 @@ static int wd_pool_init(struct wd_queue *q, struct wd_blkpool *p) + * if dma_num <= (1 / 1.15) * user's block_num, we think the pool + * is created with failure. + */ +-#define NUM_TIMES(x) (87 * (x) / 100) + if (dma_num <= NUM_TIMES(p->setup.block_num)) { + WD_ERR("dma_num = %u, not enough.\n", dma_num); + return -WD_EINVAL; +diff --git a/v1/wd_sgl.c b/v1/wd_sgl.c +index 97e4b73..cb3b8ee 100644 +--- a/v1/wd_sgl.c ++++ b/v1/wd_sgl.c +@@ -349,11 +349,28 @@ static int sgl_params_check(struct wd_sglpool_setup *setup) + struct wd_sglpool_setup *sp = setup; + __u32 buf_num_need; + +- if (!sp->buf_num || !sp->sgl_num || !sp->sge_num_in_sgl || +- !sp->buf_num_in_sgl || sp->buf_size < BUF_SIZE_MAX || +- sp->buf_num_in_sgl > sp->sge_num_in_sgl || +- sp->sgl_num > SGL_NUM_MAX || sp->sge_num_in_sgl > SGE_NUM_MAX) { +- WD_ERR("invalid size or num in sgl!\n"); ++ if (!sp->sgl_num || sp->sgl_num > SGL_NUM_MAX) { ++ WD_ERR("invalid sgl_num, %u!\n", sp->sgl_num); ++ return -WD_EINVAL; ++ } ++ ++ if (!sp->sge_num_in_sgl || sp->sge_num_in_sgl > SGE_NUM_MAX) { ++ WD_ERR("invlaid sge_num_in_sgl, %u\n!", sp->sge_num_in_sgl); ++ return -WD_EINVAL; ++ } ++ ++ if (!sp->buf_num) { ++ WD_ERR("invalid buf_num, %u!\n", sp->buf_num); ++ return -WD_EINVAL; ++ } ++ ++ if (sp->buf_size < BUF_SIZE_MAX) { ++ WD_ERR("invalid buf_size, %u!\n", sp->buf_size); ++ return -WD_EINVAL; ++ } ++ ++ if (!sp->buf_num_in_sgl || sp->buf_num_in_sgl > sp->sge_num_in_sgl) { ++ WD_ERR("invalid buf_num_in_sgl, %u!\n", sp->buf_num_in_sgl); + return -WD_EINVAL; + } + +-- +2.31.1.windows.1 + diff --git a/0121-uadk-fix-uninit-task-queue.patch b/0121-uadk-fix-uninit-task-queue.patch new file mode 100644 index 0000000..59b3f4d --- /dev/null +++ b/0121-uadk-fix-uninit-task-queue.patch @@ -0,0 +1,48 @@ +From 8c0420608a4655cdc519e91f1e126d567529eda3 Mon Sep 17 00:00:00 2001 +From: Zhiqi Song +Date: Sat, 9 Dec 2023 14:50:37 +0800 +Subject: [PATCH 121/123] uadk - fix uninit task queue + +Fix uninit wrong task queue on error branch. + +Singed-off-by: Zhiqi Song +--- + wd_util.c | 17 +++++++++++------ + 1 file changed, 11 insertions(+), 6 deletions(-) + +diff --git a/wd_util.c b/wd_util.c +index 24e1094..529c42e 100644 +--- a/wd_util.c ++++ b/wd_util.c +@@ -1570,17 +1570,22 @@ static int wd_init_async_polling_thread_per_numa(struct wd_env_config *config, + task_queue = queue_head; + for (i = 0; i < num; task_queue++, i++) { + ret = wd_init_one_task_queue(task_queue, alg_poll_ctx); +- if (ret) { +- for (j = 0; j < i; task_queue++, j++) +- wd_uninit_one_task_queue(task_queue); +- free(queue_head); +- return ret; +- } ++ if (ret) ++ goto uninit_queue; + } + + config_numa->async_task_queue_array = (void *)queue_head; + + return 0; ++ ++uninit_queue: ++ task_queue = queue_head; ++ for (j = 0; j < i; task_queue++, j++) ++ wd_uninit_one_task_queue(task_queue); ++ ++ free(queue_head); ++ ++ return ret; + } + + static void wd_uninit_async_polling_thread_per_numa(struct wd_env_config *cfg, +-- +2.31.1.windows.1 + diff --git a/0122-uadk-mempool-fix-pointer-check.patch b/0122-uadk-mempool-fix-pointer-check.patch new file mode 100644 index 0000000..2f86167 --- /dev/null +++ b/0122-uadk-mempool-fix-pointer-check.patch @@ -0,0 +1,29 @@ +From 9c41484e8dd458117f0b4330440183d2880a8c42 Mon Sep 17 00:00:00 2001 +From: Yang Shen +Date: Sat, 9 Dec 2023 16:13:48 +0800 +Subject: [PATCH 122/123] uadk: mempool - fix pointer check + +Add a check for map pointer. + +Signed-off-by: Yang Shen +--- + wd_mempool.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/wd_mempool.c b/wd_mempool.c +index ed107d1..5051300 100644 +--- a/wd_mempool.c ++++ b/wd_mempool.c +@@ -231,7 +231,8 @@ static struct bitmap *create_bitmap(int bits) + static void destroy_bitmap(struct bitmap *bm) + { + if (bm) { +- free(bm->map); ++ if (bm->map) ++ free(bm->map); + free(bm); + } + } +-- +2.31.1.windows.1 + diff --git a/0123-uadk-misc-cleanup.patch b/0123-uadk-misc-cleanup.patch new file mode 100644 index 0000000..41cb7c5 --- /dev/null +++ b/0123-uadk-misc-cleanup.patch @@ -0,0 +1,54 @@ +From 573c63b7793093adff971089524e78afcc225f91 Mon Sep 17 00:00:00 2001 +From: Yang Shen +Date: Sat, 9 Dec 2023 16:37:10 +0800 +Subject: [PATCH 123/123] uadk - misc cleanup + +Some cleanup. + +Signed-off-by: Yang Shen +--- + wd_dh.c | 3 ++- + wd_rsa.c | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/wd_dh.c b/wd_dh.c +index 826f40b..0a85543 100644 +--- a/wd_dh.c ++++ b/wd_dh.c +@@ -216,12 +216,13 @@ int wd_dh_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_param + + /* + * Driver lib file path could set by env param. +- * than open tham by wd_dlopen_drv() ++ * than open them by wd_dlopen_drv() + * default dir in the /root/lib/xxx.so and then dlopen + */ + wd_dh_setting.dlh_list = wd_dlopen_drv(NULL); + if (!wd_dh_setting.dlh_list) { + WD_ERR("failed to open driver lib files!\n"); ++ ret = -WD_EINVAL; + goto out_clear_init; + } + +diff --git a/wd_rsa.c b/wd_rsa.c +index e23e096..a94fd36 100644 +--- a/wd_rsa.c ++++ b/wd_rsa.c +@@ -254,12 +254,13 @@ int wd_rsa_init2_(char *alg, __u32 sched_type, int task_type, struct wd_ctx_para + + /* + * Driver lib file path could set by env param. +- * than open tham by wd_dlopen_drv() ++ * than open them by wd_dlopen_drv() + * default dir in the /root/lib/xxx.so and then dlopen + */ + wd_rsa_setting.dlh_list = wd_dlopen_drv(NULL); + if (!wd_rsa_setting.dlh_list) { + WD_ERR("failed to open driver lib files!\n"); ++ ret = -WD_EINVAL; + goto out_clear_init; + } + +-- +2.31.1.windows.1 + diff --git a/warpdrive.spec b/warpdrive.spec index f765707..ff054b4 100644 --- a/warpdrive.spec +++ b/warpdrive.spec @@ -1,7 +1,7 @@ Name: libwd Summary: User Space Accelerator Development Kit Version: 2.5.0 -Release: 6 +Release: 7 License: Apache-2.0 Source: %{name}-%{version}.tar.gz Vendor: Huawei Corporation @@ -100,35 +100,44 @@ Patch0082: 0082-uadk-wd_util-fix-a-theoretically-infinite-loop.patch Patch0083: 0083-uadk-wd-fix-fscanf-infinite-loop.patch Patch0084: 0084-uadk-zlibwrapper-fix-wrong-request-check.patch Patch0085: 0085-uadk-drv-hisi-fix-sgl-copy-offset-error.patch -Patch0086: 0086-uadk-v1-comp-add-comp-ctx-parameters-check.patch -Patch0087: 0087-uadk-v1-check-whether-the-data-address-pointer-is-no.patch -Patch0088: 0088-uadk-v1-remove-print-actions-after-wd_get_cookies.patch -Patch0089: 0089-uadk-fix-header-file-is-not-self-contained.patch -Patch0090: 0090-uadk-sec-modify-improper-comments.patch -Patch0091: 0091-uadk-fixed-some-input-parameter-checking-issues.patch -Patch0092: 0092-uadk-code-cleanup.patch -Patch0093: 0093-uadk-fix-sec-send-and-recv-check-failed.patch -Patch0094: 0094-uadk-code-cleanup-for-error-codes-and-variable-type.patch -Patch0095: 0095-uadk-sec-add-a-return-value-judgement.patch -Patch0096: 0096-uadk-Add-file-association.patch -Patch0097: 0097-uadk-fix-the-failure-process-bug.patch -Patch0098: 0098-uadk-fix-the-failure-process-bug.patch -Patch0099: 0099-uadk-fix-the-failure-process-bug.patch -Patch0100: 0100-uadk-bugfix.patch -Patch0101: 0101-uadk-v1-adapter-code-cleanup.patch -Patch0102: 0102-uadk-v1-fix-wd_rng-resource-release-bug.patch -Patch0103: 0103-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch -Patch0104: 0104-uadk-concentrate-the-same-definitions.patch -Patch0105: 0105-uadk-v1-optimize-the-function-length.patch -Patch0106: 0106-uadk-v1-concentrate-the-same-definitions.patch -Patch0107: 0107-v1-hpre-fix-key-transfer-error-issue.patch -Patch0108: 0108-uadk-hisi_hpre-fix-key-transfer-error-issue.patch -Patch0109: 0109-uadk-v1-remove-duplicate-header-files.patch -Patch0110: 0110-uadk-fix-error-writing-data-to-uninitialized-memory.patch -Patch0111: 0111-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch -Patch0112: 0112-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch -Patch0113: 0113-uadk-check-queue-status-before-sending-doorbells.patch -Patch0114: 0114-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch +Patch0086: 0086-uadk-zlibwrapper-fix-return-value-for-wd_zlib_uadk_i.patch +Patch0087: 0087-v1-hpre-fix-key-transfer-error-issue.patch +Patch0088: 0088-uadk-hisi_hpre-fix-key-transfer-error-issue.patch +Patch0089: 0089-uadk-v1-remove-duplicate-header-files.patch +Patch0090: 0090-uadk-fix-error-writing-data-to-uninitialized-memory.patch +Patch0091: 0091-uadk-drv-qm-fix-resource-leak-by-add-qp-info-clear-p.patch +Patch0092: 0092-uadk-v1-fix-error-writing-data-to-uninitialized-memo.patch +Patch0093: 0093-uadk-check-queue-status-before-sending-doorbells.patch +Patch0094: 0094-uadk-remove-drivers-alloc-and-free-resources.patch +Patch0095: 0095-uadk-v1-comp-add-comp-ctx-parameters-check.patch +Patch0096: 0096-uadk-v1-check-whether-the-data-address-pointer-is-no.patch +Patch0097: 0097-uadk-v1-remove-print-actions-after-wd_get_cookies.patch +Patch0098: 0098-uadk-fix-header-file-is-not-self-contained.patch +Patch0099: 0099-uadk-sec-modify-improper-comments.patch +Patch0100: 0100-uadk-fixed-some-input-parameter-checking-issues.patch +Patch0101: 0101-uadk-code-cleanup.patch +Patch0102: 0102-uadk-fix-sec-send-and-recv-check-failed.patch +Patch0103: 0103-uadk-code-cleanup-for-error-codes-and-variable-type.patch +Patch0104: 0104-uadk-sec-add-a-return-value-judgement.patch +Patch0105: 0105-uadk-Add-file-association.patch +Patch0106: 0106-uadk-fix-the-failure-process-bug.patch +Patch0107: 0107-uadk-fix-the-failure-process-bug.patch +Patch0108: 0108-uadk-fix-the-failure-process-bug.patch +Patch0109: 0109-uadk-bugfix.patch +Patch0110: 0110-uadk-v1-adapter-code-cleanup.patch +Patch0111: 0111-uadk-v1-fix-wd_rng-resource-release-bug.patch +Patch0112: 0112-uadk-v1-code-cleanup-for-error-codes-and-header-file.patch +Patch0113: 0113-uadk-concentrate-the-same-definitions.patch +Patch0114: 0114-uadk-v1-optimize-the-function-length.patch +Patch0115: 0115-uadk-v1-concentrate-the-same-definitions.patch +Patch0116: 0116-uadk-v1-fix-security-view-issues-of-hpre.patch +Patch0117: 0117-uadk-cleanup-issues-of-hpre.patch +Patch0118: 0118-uadk-v1-hpre-add-parameter-check-of-setup.patch +Patch0119: 0119-uadk-ecc-fix-the-use-of-random-k-in-sm2-sign.patch +Patch0120: 0120-uadk-v1-cleanup-common-part-code-style.patch +Patch0121: 0121-uadk-fix-uninit-task-queue.patch +Patch0122: 0122-uadk-mempool-fix-pointer-check.patch +Patch0123: 0123-uadk-misc-cleanup.patch %description This package contains the User Space Accelerator Library @@ -301,6 +310,9 @@ fi /sbin/ldconfig %changelog +* Sat Dec 09 2023 Yang Shen 2.5.0-7 +- libwd: update some patches + * Tue Dec 05 2023 JiangShui Yang 2.5.0-6 - libwd: update the source code