
From: Yu'an Wang <wangyuan46@huawei.com> hulk inclusion category: Bugfix bugzilla: NA CVE: NA When running the hpre kernel state task, a ras error occurred. After the driver actively called back the incomplete task to recycle the sqe resources, the hardware wrote back the sqe and caused the kernel calltrace. Signed-off-by: Yu'an Wang <wangyuan46@huawei.com> Signed-off-by: Hui Tang <tanghui20@huawei.com> Reviewed-by: Zibo Xu <xuzaibo@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/crypto/hisilicon/hpre/hpre.h | 1 + drivers/crypto/hisilicon/hpre/hpre_crypto.c | 10 +++++++++- drivers/crypto/hisilicon/hpre/hpre_main.c | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre.h b/drivers/crypto/hisilicon/hpre/hpre.h index 203eb2ac1e67d..14d60b48afc1f 100644 --- a/drivers/crypto/hisilicon/hpre/hpre.h +++ b/drivers/crypto/hisilicon/hpre/hpre.h @@ -32,6 +32,7 @@ enum hpre_dfx_dbgfs_file { HPRE_SEND_BUSY_CNT, HPRE_OVER_THRHLD_CNT, HPRE_OVERTIME_THRHLD, + HPRE_INVALID_REQ_CNT, HPRE_DFX_FILE_NUM }; diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index b68b30c886adb..5031d64789e68 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -414,9 +414,17 @@ static void hpre_rsa_cb(struct hpre_ctx *ctx, void *resp) static void hpre_alg_cb(struct hisi_qp *qp, void *resp) { struct hpre_ctx *ctx = qp->qp_ctx; + struct hpre_dfx *dfx = ctx->hpre->debug.dfx; struct hpre_sqe *sqe = resp; + struct hpre_asym_request *req = ctx->req_list[le16_to_cpu(sqe->tag)]; + + + if (unlikely(!req)) { + atomic64_inc(&dfx[HPRE_INVALID_REQ_CNT].value); + return; + } - ctx->req_list[le16_to_cpu(sqe->tag)]->cb(ctx, resp); + req->cb(ctx, resp); } static int hpre_ctx_init(struct hpre_ctx *ctx) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 22f623945b0b0..6c5dc53c92fa6 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -178,7 +178,8 @@ static const char *hpre_dfx_files[HPRE_DFX_FILE_NUM] = { "send_fail_cnt", "send_busy_cnt", "over_thrhld_cnt", - "overtime_thrhld" + "overtime_thrhld", + "invalid_req_cnt" }; #ifdef CONFIG_CRYPTO_QM_UACCE -- 2.25.1