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 20536A0547; Fri, 29 Oct 2021 06:37:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1E7940688; Fri, 29 Oct 2021 06:37:12 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5726C40395 for ; Fri, 29 Oct 2021 06:37:11 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19T1jx9j025353; Thu, 28 Oct 2021 21:37:10 -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=et2js/iRTcjHuno76+grRmvN4KkPywM2wuzA+O6VP0iM4O+MlMMRzKgXqQaO/6XaV/Lj 9/fTm4mQhalV3LFDNaEr2jOCGZX91xM4dSMjMoav+S54SElb3jMJN7vuo+s+ShKE32KL lvtPzj1pJKUvt3w2h81YLQuOaTd828u3L9SxPhiEszGduRb3T2HRZDx7c8XsJUMHiGMs vOfUYQn2vvXBirsrVcVNYRBAxUDaEGPzeUOvrXeLMU3i7ZlwamcR9eQJnpI/EA7+Wf3d iDOtIUVTnqAH4h49GACt95YwvCN0txiwIJ9zDNI2WksgqaDrHwcSJWBi4QnfELcNF/c/ fQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3c07jrgh0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 28 Oct 2021 21:37:10 -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:37:08 -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:37:08 -0700 Received: from cavium-kiran.marvell.com (unknown [10.28.34.15]) by maili.marvell.com (Postfix) with ESMTP id 7C23F3F7079; Thu, 28 Oct 2021 21:37:07 -0700 (PDT) From: To: Declan Doherty , Ciara Power CC: , Kiran Kumar K Date: Fri, 29 Oct 2021 10:06:58 +0530 Message-ID: <20211029043658.3809156-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-ORIG-GUID: lcscACeXm8G-gYfgmvwZ8Xjfw3yoRwNt X-Proofpoint-GUID: lcscACeXm8G-gYfgmvwZ8Xjfw3yoRwNt 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-29_01,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