Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit bce9af1

Browse files
Marcin Szycikanguy11
authored andcommitted
ice: Fix increasing MSI-X on VF
Increasing MSI-X value on a VF leads to invalid memory operations. This is caused by not reallocating some arrays. Reproducer: modprobe ice echo 0 > /sys/bus/pci/devices/$PF_PCI/sriov_drivers_autoprobe echo 1 > /sys/bus/pci/devices/$PF_PCI/sriov_numvfs echo 17 > /sys/bus/pci/devices/$VF0_PCI/sriov_vf_msix_count Default MSI-X is 16, so 17 and above triggers this issue. KASAN reports: BUG: KASAN: slab-out-of-bounds in ice_vsi_alloc_ring_stats+0x38d/0x4b0 [ice] Read of size 8 at addr ffff8888b937d180 by task bash/28433 (...) Call Trace: (...) ? ice_vsi_alloc_ring_stats+0x38d/0x4b0 [ice] kasan_report+0xed/0x120 ? ice_vsi_alloc_ring_stats+0x38d/0x4b0 [ice] ice_vsi_alloc_ring_stats+0x38d/0x4b0 [ice] ice_vsi_cfg_def+0x3360/0x4770 [ice] ? mutex_unlock+0x83/0xd0 ? __pfx_ice_vsi_cfg_def+0x10/0x10 [ice] ? __pfx_ice_remove_vsi_lkup_fltr+0x10/0x10 [ice] ice_vsi_cfg+0x7f/0x3b0 [ice] ice_vf_reconfig_vsi+0x114/0x210 [ice] ice_sriov_set_msix_vec_count+0x3d0/0x960 [ice] sriov_vf_msix_count_store+0x21c/0x300 (...) Allocated by task 28201: (...) ice_vsi_cfg_def+0x1c8e/0x4770 [ice] ice_vsi_cfg+0x7f/0x3b0 [ice] ice_vsi_setup+0x179/0xa30 [ice] ice_sriov_configure+0xcaa/0x1520 [ice] sriov_numvfs_store+0x212/0x390 (...) To fix it, use ice_vsi_rebuild() instead of ice_vf_reconfig_vsi(). This causes the required arrays to be reallocated taking the new queue count into account (ice_vsi_realloc_stat_arrays()). Set req_txq and req_rxq before ice_vsi_rebuild(), so that realloc uses the newly set queue count. Additionally, ice_vsi_rebuild() does not remove VSI filters (ice_fltr_remove_all()), so ice_vf_init_host_cfg() is no longer necessary. Reported-by: Jacob Keller <[email protected]> Fixes: 2a2cb4c ("ice: replace ice_vf_recreate_vsi() with ice_vf_reconfig_vsi()") Reviewed-by: Michal Swiatkowski <[email protected]> Signed-off-by: Marcin Szycik <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent fbcb968 commit bce9af1

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

drivers/net/ethernet/intel/ice/ice_sriov.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,10 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
11211121
if (vf->first_vector_idx < 0)
11221122
goto unroll;
11231123

1124-
if (ice_vf_reconfig_vsi(vf) || ice_vf_init_host_cfg(vf, vsi)) {
1124+
vsi->req_txq = queues;
1125+
vsi->req_rxq = queues;
1126+
1127+
if (ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT)) {
11251128
/* Try to rebuild with previous values */
11261129
needs_rebuild = true;
11271130
goto unroll;
@@ -1150,8 +1153,10 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
11501153
}
11511154

11521155
if (needs_rebuild) {
1153-
ice_vf_reconfig_vsi(vf);
1154-
ice_vf_init_host_cfg(vf, vsi);
1156+
vsi->req_txq = prev_queues;
1157+
vsi->req_rxq = prev_queues;
1158+
1159+
ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT);
11551160
}
11561161

11571162
ice_ena_vf_mappings(vf);

drivers/net/ethernet/intel/ice/ice_vf_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static void ice_vf_pre_vsi_rebuild(struct ice_vf *vf)
256256
*
257257
* It brings the VSI down and then reconfigures it with the hardware.
258258
*/
259-
int ice_vf_reconfig_vsi(struct ice_vf *vf)
259+
static int ice_vf_reconfig_vsi(struct ice_vf *vf)
260260
{
261261
struct ice_vsi *vsi = ice_get_vf_vsi(vf);
262262
struct ice_pf *pf = vf->pf;

drivers/net/ethernet/intel/ice/ice_vf_lib_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#warning "Only include ice_vf_lib_private.h in CONFIG_PCI_IOV virtualization files"
2424
#endif
2525

26-
int ice_vf_reconfig_vsi(struct ice_vf *vf);
2726
void ice_initialize_vf_entry(struct ice_vf *vf);
2827
void ice_dis_vf_qs(struct ice_vf *vf);
2928
int ice_check_vf_init(struct ice_vf *vf);

0 commit comments

Comments
 (0)