Skip to content

Commit

Permalink
acc/uadk: fix queue configuration parameter error
Browse files Browse the repository at this point in the history
When executing an asynchronous task, the scheduler may
incorrectly specify a synchronous queue.
This will cause an error in the queue configuration
parameters and result in a segment error.
In wd_get_msg_from_pool(), msg_num == 0 indicates that
the asynchronous task scheduler is executed but the
synchronous queue is specified.Therefore,
when msg_num == 0 is detected in this function,
the program needs to return an exception immediately
to avoid errors.

Signed-off-by: Qi Tao <[email protected]>
  • Loading branch information
Qi Tao authored and Liulongfang committed Sep 29, 2024
1 parent bdcebcd commit 05b1b0b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion wd_aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ int wd_do_aead_async(handle_t h_sess, struct wd_aead_req *req)
idx, (void **)&msg);
if (unlikely(msg_id < 0)) {
WD_ERR("failed to get msg from pool!\n");
return -WD_EBUSY;
return msg_id;
}

fill_request_msg(msg, req, sess);
Expand Down
4 changes: 2 additions & 2 deletions wd_agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,8 @@ static int wd_agg_async_job(struct wd_agg_sess *sess, struct wd_agg_req *req, bo
ctx = config->ctxs + idx;
msg_id = wd_get_msg_from_pool(&wd_agg_setting.pool, idx, (void **)&msg);
if (unlikely(msg_id < 0)) {
WD_ERR("busy, failed to get agg msg from pool!\n");
return -WD_EBUSY;
WD_ERR("failed to get agg msg from pool!\n");
return msg_id;
}

if (is_input)
Expand Down
4 changes: 2 additions & 2 deletions wd_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ int wd_do_cipher_async(handle_t h_sess, struct wd_cipher_req *req)
msg_id = wd_get_msg_from_pool(&wd_cipher_setting.pool, idx,
(void **)&msg);
if (unlikely(msg_id < 0)) {
WD_ERR("busy, failed to get msg from pool!\n");
return -WD_EBUSY;
WD_ERR("failed to get msg from pool!\n");
return msg_id;
}

fill_request_msg(msg, req, sess);
Expand Down
2 changes: 1 addition & 1 deletion wd_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ int wd_do_comp_async(handle_t h_sess, struct wd_comp_req *req)
tag = wd_get_msg_from_pool(&wd_comp_setting.pool, idx, (void **)&msg);
if (unlikely(tag < 0)) {
WD_ERR("failed to get msg from pool!\n");
return -WD_EBUSY;
return tag;
}
fill_comp_msg(sess, msg, req);
msg->tag = tag;
Expand Down
6 changes: 4 additions & 2 deletions wd_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,10 @@ int wd_do_dh_async(handle_t sess, struct wd_dh_req *req)
ctx = config->ctxs + idx;

mid = wd_get_msg_from_pool(&wd_dh_setting.pool, idx, (void **)&msg);
if (mid < 0)
return -WD_EBUSY;
if (unlikely(mid < 0)) {
WD_ERR("failed to get msg from pool!\n");
return mid;
}

ret = fill_dh_msg(msg, req, (struct wd_dh_sess *)sess);
if (ret)
Expand Down
4 changes: 2 additions & 2 deletions wd_digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ int wd_do_digest_async(handle_t h_sess, struct wd_digest_req *req)
msg_id = wd_get_msg_from_pool(&wd_digest_setting.pool, idx,
(void **)&msg);
if (unlikely(msg_id < 0)) {
WD_ERR("busy, failed to get msg from pool!\n");
return -WD_EBUSY;
WD_ERR("failed to get msg from pool!\n");
return msg_id;
}

fill_request_msg(msg, req, dsess);
Expand Down
6 changes: 4 additions & 2 deletions wd_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2268,8 +2268,10 @@ int wd_do_ecc_async(handle_t sess, struct wd_ecc_req *req)
ctx = config->ctxs + idx;

mid = wd_get_msg_from_pool(&wd_ecc_setting.pool, idx, (void **)&msg);
if (mid < 0)
return -WD_EBUSY;
if (unlikely(mid < 0)) {
WD_ERR("failed to get msg from pool!\n");
return mid;
}

ret = fill_ecc_msg(msg, req, (struct wd_ecc_sess *)sess);
if (ret)
Expand Down
6 changes: 4 additions & 2 deletions wd_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,10 @@ int wd_do_rsa_async(handle_t sess, struct wd_rsa_req *req)
ctx = config->ctxs + idx;

mid = wd_get_msg_from_pool(&wd_rsa_setting.pool, idx, (void **)&msg);
if (mid < 0)
return -WD_EBUSY;
if (unlikely(mid < 0)) {
WD_ERR("failed to get msg from pool!\n");
return mid;
}

ret = fill_rsa_msg(msg, req, (struct wd_rsa_sess *)sess);
if (ret)
Expand Down
4 changes: 4 additions & 0 deletions wd_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ int wd_get_msg_from_pool(struct wd_async_msg_pool *pool,
__u32 cnt = 0;
__u32 idx = p->tail;

/* Scheduler set a sync ctx */
if (!msg_num)
return -WD_EINVAL;

while (__atomic_test_and_set(&p->used[idx], __ATOMIC_ACQUIRE)) {
idx = (idx + 1) % msg_num;
cnt++;
Expand Down

0 comments on commit 05b1b0b

Please sign in to comment.