From fce3e6018c0a9da80723a2503e1ebe8dd2dc3238 Mon Sep 17 00:00:00 2001 From: Zhou Wang Date: Thu, 11 Jul 2019 14:41:39 +0800 Subject: [PATCH] ACC: fix for qp full status check by qp->used driver inclusion category: bugfix bugzilla: NA CVE: NA fix for qp full status check by qp->used. Signed-off-by: Zhou Wang Signed-off-by: Hao Fang Signed-off-by: lingmingqiang Signed-off-by: Yang Yingliang --- drivers/crypto/hisilicon/qm.c | 10 +++------- drivers/crypto/hisilicon/qm.h | 1 - drivers/crypto/hisilicon/zip/zip_crypto.c | 2 -- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 36ea341aa5d5..6355e3880e6b 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -390,9 +390,6 @@ static void qm_sq_head_update(struct hisi_qp *qp) qp->qp_status.sq_head = 0; else qp->qp_status.sq_head++; - - if (unlikely(test_bit(QP_FULL, &qp->qp_status.flags))) - clear_bit(QP_FULL, &qp->qp_status.flags); } static void qm_cq_head_update(struct hisi_qp *qp) @@ -1041,7 +1038,7 @@ static void *qm_get_avail_sqe(struct hisi_qp *qp) struct hisi_qp_status *qp_status = &qp->qp_status; u16 sq_tail = qp_status->sq_tail; - if (unlikely(test_bit(QP_FULL, &qp->qp_status.flags))) + if (unlikely(atomic_read(&qp->qp_status.used) == QM_Q_DEPTH)) return NULL; return qp->sqe + sq_tail * qp->qm->sqe_size; @@ -1341,6 +1338,8 @@ EXPORT_SYMBOL_GPL(hisi_qm_stop_qp); * * This function will return -EBUSY if qp is currently full, and -EAGAIN * if qp related qm is resetting. + * + * Note: Do not support concurrent call of this function. */ int hisi_qp_send(struct hisi_qp *qp, const void *msg) { @@ -1362,10 +1361,7 @@ int hisi_qp_send(struct hisi_qp *qp, const void *msg) qm_db(qp->qm, qp->qp_id, QM_DOORBELL_CMD_SQ, sq_tail_next, 0); atomic_inc(&qp->qp_status.used); - qp_status->sq_tail = sq_tail_next; - if (qp_status->sq_tail == qp_status->sq_head) - set_bit(QP_FULL, &qp->qp_status.flags); return 0; } diff --git a/drivers/crypto/hisilicon/qm.h b/drivers/crypto/hisilicon/qm.h index 42f76dbb3b24..643eb3d91d3f 100644 --- a/drivers/crypto/hisilicon/qm.h +++ b/drivers/crypto/hisilicon/qm.h @@ -86,7 +86,6 @@ enum qm_state { enum qp_state { QP_STOP, - QP_FULL, }; enum qm_hw_ver { diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c index 797b97f8e0c4..f84b3b608a41 100644 --- a/drivers/crypto/hisilicon/zip/zip_crypto.c +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c @@ -244,8 +244,6 @@ static void hisi_zip_copy_data_from_buffer(struct hisi_zip_qp_ctx *qp_ctx, else qp->qp_status.sq_head++; - if (unlikely(test_bit(QP_FULL, &qp->qp_status.flags))) - clear_bit(QP_FULL, &qp->qp_status.flags); } static int hisi_zip_compress_data_output(struct hisi_zip_qp_ctx *qp_ctx, -- GitLab