Skip to content

Commit d9d6a9a

Browse files
bcreeley13Jeff Kirsher
authored andcommitted
i40e: Fix virtchnl_queue_select bitmap validation
Currently in i40e_vc_disable_queues_msg() we are incorrectly validating the virtchnl queue select bitmaps. The virtchnl_queue_select rx_queues and tx_queue bitmap is being compared against ICE_MAX_VF_QUEUES, but the problem is that these bitmaps can have a value greater than I40E_MAX_VF_QUEUES. Fix this by comparing the bitmaps against BIT(I40E_MAX_VF_QUEUES). Also, add the function i40e_vc_validate_vqs_bitmaps() that checks to see if both virtchnl_queue_select bitmaps are empty along with checking that the bitmaps only have valid bits set. This function can then be used in both the queue enable and disable flows. Suggested-by: Arkady Gilinksky <[email protected]> Signed-off-by: Brett Creeley <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 9546a0b commit d9d6a9a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,6 +2321,22 @@ static int i40e_ctrl_vf_rx_rings(struct i40e_vsi *vsi, unsigned long q_map,
23212321
return ret;
23222322
}
23232323

2324+
/**
2325+
* i40e_vc_validate_vqs_bitmaps - validate Rx/Tx queue bitmaps from VIRTHCHNL
2326+
* @vqs: virtchnl_queue_select structure containing bitmaps to validate
2327+
*
2328+
* Returns true if validation was successful, else false.
2329+
*/
2330+
static bool i40e_vc_validate_vqs_bitmaps(struct virtchnl_queue_select *vqs)
2331+
{
2332+
if ((!vqs->rx_queues && !vqs->tx_queues) ||
2333+
vqs->rx_queues >= BIT(I40E_MAX_VF_QUEUES) ||
2334+
vqs->tx_queues >= BIT(I40E_MAX_VF_QUEUES))
2335+
return false;
2336+
2337+
return true;
2338+
}
2339+
23242340
/**
23252341
* i40e_vc_enable_queues_msg
23262342
* @vf: pointer to the VF info
@@ -2346,7 +2362,7 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg)
23462362
goto error_param;
23472363
}
23482364

2349-
if ((0 == vqs->rx_queues) && (0 == vqs->tx_queues)) {
2365+
if (i40e_vc_validate_vqs_bitmaps(vqs)) {
23502366
aq_ret = I40E_ERR_PARAM;
23512367
goto error_param;
23522368
}
@@ -2408,9 +2424,7 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg)
24082424
goto error_param;
24092425
}
24102426

2411-
if ((vqs->rx_queues == 0 && vqs->tx_queues == 0) ||
2412-
vqs->rx_queues > I40E_MAX_VF_QUEUES ||
2413-
vqs->tx_queues > I40E_MAX_VF_QUEUES) {
2427+
if (i40e_vc_validate_vqs_bitmaps(vqs)) {
24142428
aq_ret = I40E_ERR_PARAM;
24152429
goto error_param;
24162430
}

0 commit comments

Comments
 (0)