From 057fdedbff12445d4e26a16608f02c2de0faebed Mon Sep 17 00:00:00 2001 From: paul luse Date: Thu, 27 Jan 2022 13:36:51 +0000 Subject: [PATCH] idxd: zero out descriptor before use To avoid re-use of descriptors that may have fields set that are reserved by the one being used now. For example: If a batch desc is being built and was previously used by a copy we need to clear out the dst_addr field or things will explode as this is a reserved field for a batch. Signed-off-by: paul luse Change-Id: I6ba50b76589e38a276683291f5ec2970c80e8aa8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11308 Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/idxd/idxd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index 01035d029..d75281566 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -358,10 +358,14 @@ _idxd_prep_command(struct spdk_idxd_io_channel *chan, spdk_idxd_req_cb cb_fn, { struct idxd_hw_desc *desc; struct idxd_ops *op; + uint64_t comp_addr; if (!TAILQ_EMPTY(&chan->ops_pool)) { op = *_op = TAILQ_FIRST(&chan->ops_pool); desc = *_desc = op->desc; + comp_addr = desc->completion_addr; + memset(desc, 0, sizeof(*desc)); + desc->completion_addr = comp_addr; TAILQ_REMOVE(&chan->ops_pool, op, link); } else { /* The application needs to handle this, violation of flow control */ @@ -983,7 +987,6 @@ _idxd_submit_crc32c_single(struct spdk_idxd_io_channel *chan, uint32_t *crc_dst, /* Command specific. */ desc->opcode = IDXD_OPCODE_CRC32C_GEN; - desc->dst_addr = 0; /* Per spec, needs to be clear. */ desc->src_addr = src_addr; desc->flags &= IDXD_CLEAR_CRC_FLAGS; desc->crc32c.seed = seed; @@ -1042,7 +1045,6 @@ spdk_idxd_submit_crc32c(struct spdk_idxd_io_channel *chan, } desc->opcode = IDXD_OPCODE_CRC32C_GEN; - desc->dst_addr = 0; /* Per spec, needs to be clear. */ desc->src_addr = src_addr; if (i == 0) { desc->crc32c.seed = seed;