Skip to content

Commit

Permalink
Added check for cfg_cu payload_size to be within MAX_CQ_SLOT_SIZE in …
Browse files Browse the repository at this point in the history
…xocl_kds.c (#7552)

* Added check for cfg_cu payload_size to be within MAX_CQ_SLOT_SIZE

Signed-off-by: Jeff Lin <[email protected]>

* Added additional check for payload_size if it exceeds MAX_CQ_SLOT_SIZE before doubling and error out if it is exceeded.

Signed-off-by: Jeff Lin <[email protected]>

---------

Signed-off-by: Jeff Lin <[email protected]>
Co-authored-by: Jeff Lin <[email protected]>
(cherry picked from commit 4e2b68f)
  • Loading branch information
jeffli-xilinx authored and Jeff Lin committed Jun 6, 2023
1 parent e3c5acf commit edaeed5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/runtime_src/core/pcie/driver/linux/xocl/userpf/xocl_kds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1941,6 +1941,10 @@ xocl_kds_xgq_cfg_cus(struct xocl_dev *xdev, xuid_t *xclbin_id, struct xrt_cu_inf
if (cu_info[i].num_args)
max_off_arg_size = cu_info[i].args[max_off_idx].size;
cfg_cu->payload_size = max_off + max_off_arg_size + sizeof(struct xgq_cmd_sq_hdr);
if(cfg_cu->payload_size > MAX_CQ_SLOT_SIZE) {
userpf_err(xdev, "CU Argument Size %x > MAX_CQ_SLOT_SIZE!", cfg_cu->payload_size);
return -ENOMEM;
}
/*
* Times 2 to make sure XGQ slot size is bigger than the size of
* key-value pair commands, eg. ERT_START_KEY_VAL.
Expand All @@ -1950,6 +1954,10 @@ xocl_kds_xgq_cfg_cus(struct xocl_dev *xdev, xuid_t *xclbin_id, struct xrt_cu_inf
* approach.
*/
cfg_cu->payload_size = cfg_cu->payload_size * 2;
if(cfg_cu->payload_size > MAX_CQ_SLOT_SIZE) {
userpf_err(xdev, "CU Argument Size for Key-Valye Pair of %x > MAX_CQ_SLOT_SIZE, setting it to MAX_CQ_SLOT_SIZE! Key-Value pair will not be supported!", cfg_cu->payload_size);
cfg_cu->payload_size = MAX_CQ_SLOT_SIZE;
}

scnprintf(cfg_cu->name, sizeof(cfg_cu->name), "%s:%s",
cu_info[i].kname, cu_info[i].iname);
Expand Down

0 comments on commit edaeed5

Please sign in to comment.