Commit 057fdedb authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

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: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: I6ba50b76589e38a276683291f5ec2970c80e8aa8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11308


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 08f9b401
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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;