From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D0BAA0547; Fri, 29 Oct 2021 06:33:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9FBEB40688; Fri, 29 Oct 2021 06:33:53 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id B1A0240395 for ; Fri, 29 Oct 2021 06:33:51 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19T0Z8tH020112; Thu, 28 Oct 2021 21:33:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=G01+X2/0epLciy4VwODVnAEz3uSEHY6RmlAtFvlzjCg=; b=cVeBIVoXhfe2pPUsbkaGfnPoTPY0Q3b3YEYau00dDwgCAIl1EENH4SZsewJe3/o0OBZd S4KRHTuEhEc1z0LFDBDNqWyUcIi7zd/AefNRB1QNBSOPpQxjE9FwcK2zDSO7bLLZ3JVh LMXgLx36wvQmEnIdYossO+/50MIAKbEqJoX8av+L88i6I49KbF0O1CnrZXVrZKEQrpNW 8tul7tEZw+e8jQWfxdlTEBQsNLJ77RlcQroZsH0Hbl5EsFHb8zwLMNMBTqw900veLVEX Uhjp4kIqDkM6e1KVT9kOirSIb36aGfMuW2A5oMtGNBQiU6YFg1E510UEfMqRpPIKy6t3 bw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3c06hugqdf-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 28 Oct 2021 21:33:50 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 28 Oct 2021 21:33:48 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 28 Oct 2021 21:33:48 -0700 Received: from cavium-kiran.marvell.com (unknown [10.28.34.15]) by maili.marvell.com (Postfix) with ESMTP id B8F4B3F7079; Thu, 28 Oct 2021 21:33:46 -0700 (PDT) From: To: Declan Doherty , Ciara Power CC: , Kiran Kumar K Date: Fri, 29 Oct 2021 10:03:40 +0530 Message-ID: <20211029043341.3807559-1-kirankumark@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: NSOPnaHGwB_r_SL0OCb4vLkvcTwqpiV1 X-Proofpoint-ORIG-GUID: NSOPnaHGwB_r_SL0OCb4vLkvcTwqpiV1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-28_06,2021-10-26_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH] test/crypto-perf: fix crash issue with asym perf test X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kiran Kumar K While populating the crypto ops in case of asymmetric, result is being allocated from stack. This is causing crash in the application. And operation type is also not being initialized properly. Adding a fix by allocating the result from global memory and initialized the operation memory properly. Fixes: ba588ce3f9339 ("test/crypto-perf: test asymmetric crypto throughput") Signed-off-by: Kiran Kumar K --- app/test-crypto-perf/cperf_ops.c | 5 ++--- app/test-crypto-perf/cperf_test_common.c | 18 +++++++++++++++++- app/test-crypto-perf/cperf_test_vectors.c | 2 ++ app/test-crypto-perf/cperf_test_vectors.h | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c index 263841c339..d975ae1ab8 100644 --- a/app/test-crypto-perf/cperf_ops.c +++ b/app/test-crypto-perf/cperf_ops.c @@ -21,7 +21,6 @@ cperf_set_ops_asym(struct rte_crypto_op **ops, uint64_t *tsc_start __rte_unused) { uint16_t i; - uint8_t result[sizeof(perf_mod_p)] = { 0 }; struct rte_cryptodev_asym_session *asym_sess = (void *)sess; for (i = 0; i < nb_ops; i++) { @@ -30,8 +29,8 @@ cperf_set_ops_asym(struct rte_crypto_op **ops, ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; asym_op->modex.base.data = perf_base; asym_op->modex.base.length = sizeof(perf_base); - asym_op->modex.result.data = result; - asym_op->modex.result.length = sizeof(result); + asym_op->modex.result.data = perf_mod_result; + asym_op->modex.result.length = sizeof(perf_mod_result); rte_crypto_op_attach_asym_session(ops[i], asym_sess); } return 0; diff --git a/app/test-crypto-perf/cperf_test_common.c b/app/test-crypto-perf/cperf_test_common.c index 89f13fdebd..97a1ea47ad 100644 --- a/app/test-crypto-perf/cperf_test_common.c +++ b/app/test-crypto-perf/cperf_test_common.c @@ -82,6 +82,20 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp, m->next = NULL; } +static void +mempool_asym_obj_init(struct rte_mempool *mp, __rte_unused void *opaque_arg, + void *obj, __rte_unused unsigned int i) +{ + struct rte_crypto_op *op = obj; + + /* Set crypto operation */ + op->type = RTE_CRYPTO_OP_TYPE_ASYMMETRIC; + op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; + op->sess_type = RTE_CRYPTO_OP_WITH_SESSION; + op->phys_addr = rte_mem_virt2iova(obj); + op->mempool = mp; +} + static void mempool_obj_init(struct rte_mempool *mp, void *opaque_arg, @@ -146,13 +160,15 @@ cperf_alloc_common_memory(const struct cperf_options *options, rte_socket_id()); *pool = rte_crypto_op_pool_create( pool_name, RTE_CRYPTO_OP_TYPE_ASYMMETRIC, - options->pool_sz, 0, 0, rte_socket_id()); + options->pool_sz, RTE_MEMPOOL_CACHE_MAX_SIZE, 0, + rte_socket_id()); if (*pool == NULL) { RTE_LOG(ERR, USER1, "Cannot allocate mempool for device %u\n", dev_id); return -1; } + rte_mempool_obj_iter(*pool, mempool_asym_obj_init, NULL); return 0; } diff --git a/app/test-crypto-perf/cperf_test_vectors.c b/app/test-crypto-perf/cperf_test_vectors.c index e578ec1434..dafcfc0c6c 100644 --- a/app/test-crypto-perf/cperf_test_vectors.c +++ b/app/test-crypto-perf/cperf_test_vectors.c @@ -34,6 +34,8 @@ uint8_t perf_mod_p[129] = { 0x55 }; +uint8_t perf_mod_result[sizeof(perf_mod_p)]; + uint8_t perf_mod_e[3] = {0x01, 0x00, 0x01}; uint8_t plaintext[2048] = { diff --git a/app/test-crypto-perf/cperf_test_vectors.h b/app/test-crypto-perf/cperf_test_vectors.h index 92818c22b7..70f2839cd6 100644 --- a/app/test-crypto-perf/cperf_test_vectors.h +++ b/app/test-crypto-perf/cperf_test_vectors.h @@ -93,5 +93,6 @@ extern uint8_t digest[2048]; extern uint8_t perf_base[20]; extern uint8_t perf_mod_p[129]; extern uint8_t perf_mod_e[3]; +extern uint8_t perf_mod_result[sizeof(perf_mod_p)]; #endif -- 2.25.1