test/crypto-perf: fix crash issue with asym perf test
Checks
Commit Message
From: Kiran Kumar K <kirankumark@marvell.com>
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 <kirankumark@marvell.com>
---
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(-)
Comments
> From: Kiran Kumar K <kirankumark@marvell.com>
>
> 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 <kirankumark@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
Applied to dpdk-next-crypto
Thanks.
@@ -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;
@@ -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;
}
@@ -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] = {
@@ -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