From: Jacob Keller <jacob.e.keller@intel.com> mainline inclusion from mainline-v5.18-rc1 commit 7eb517e434c653a4afa16ec3d0a750c2f46b3560 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBP3Y9 CVE: CVE-2022-49722 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... ---------------------- The ice_reset_vf function takes a boolean parameter which indicates whether or not the reset is due to a VFLR event. This is somewhat confusing to read because readers must interpret what "true" and "false" mean when seeing a line of code like "ice_reset_vf(vf, false)". We will want to add another toggle to the ice_reset_vf in a following change. To avoid proliferating many arguments, convert this function to take flags instead. ICE_VF_RESET_VFLR will indicate if this is a VFLR reset. A value of 0 indicates no flags. One could argue that "ice_reset_vf(vf, 0)" is no more readable than "ice_reset_vf(vf, false)".. However, this type of flags interface is somewhat common and using 0 to mean "no flags" makes sense in this context. We could bother to add a define for "ICE_VF_RESET_PLAIN" or something similar, but this can be confusing since its not an actual bit flag. This paves the way to add another flag to the function in a following change. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Conflicts: drivers/net/ethernet/intel/ice/ice_main.c drivers/net/ethernet/intel/ice/ice_sriov.c drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h drivers/net/ethernet/intel/ice/ice_vf_lib.c drivers/net/ethernet/intel/ice/ice_vf_lib.h [Conflicts due to previous commits not merged.] Signed-off-by: Liu Chuang <liuchuang40@huawei.com> Signed-off-by: Xiaomeng Zhang <zhangxiaomeng13@huawei.com> --- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 15 +++++++++------ drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h | 9 +++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 4f6625308264..ffcb71ccf9ad 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -1609,7 +1609,7 @@ static void ice_handle_mdd_event(struct ice_pf *pf) */ ice_print_vf_rx_mdd_event(vf); mutex_lock(&pf->vf[i].cfg_lock); - ice_reset_vf(&pf->vf[i], false); + ice_reset_vf(&pf->vf[i], 0); mutex_unlock(&pf->vf[i].cfg_lock); } } diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c index f6ccc99fb2d7..05eab9ec4879 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -1264,13 +1264,16 @@ static bool ice_is_vf_disabled(struct ice_vf *vf) /** * ice_reset_vf - Reset a particular VF * @vf: pointer to the VF structure - * @is_vflr: true if VFLR was issued, false if not + * @flags: flags controlling behavior of the reset + * + * Flags: + * ICE_VF_RESET_VFLR - Indicates a reset is due to VFLR event * * Returns 0 if the VF is currently in reset, if the resets are disabled, or * if the VF resets successfully. Returns an error code if the VF fails to * rebuild. */ -int ice_reset_vf(struct ice_vf *vf, bool is_vflr) +int ice_reset_vf(struct ice_vf *vf, u32 flags) { struct ice_pf *pf = vf->pf; struct ice_vsi *vsi; @@ -1299,7 +1302,7 @@ int ice_reset_vf(struct ice_vf *vf, bool is_vflr) /* Set VF disable bit state here, before triggering reset */ set_bit(ICE_VF_STATE_DIS, vf->vf_states); - ice_trigger_vf_reset(vf, is_vflr, false); + ice_trigger_vf_reset(vf, flags & ICE_VF_RESET_VFLR, false); vsi = pf->vsi[vf->lan_vsi_idx]; @@ -1739,7 +1742,7 @@ void ice_process_vflr_event(struct ice_pf *pf) if (reg & BIT(bit_idx)) { /* GLGEN_VFLRSTAT bit will be cleared in ice_reset_vf */ mutex_lock(&vf->cfg_lock); - ice_reset_vf(vf, true); + ice_reset_vf(vf, ICE_VF_RESET_VFLR); mutex_unlock(&vf->cfg_lock); } } @@ -1752,7 +1755,7 @@ void ice_process_vflr_event(struct ice_pf *pf) static void ice_vc_reset_vf(struct ice_vf *vf) { ice_vc_notify_vf_reset(vf); - ice_reset_vf(vf, false); + ice_reset_vf(vf, 0); } /** @@ -2023,7 +2026,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) static void ice_vc_reset_vf_msg(struct ice_vf *vf) { if (test_bit(ICE_VF_STATE_INIT, vf->vf_states)) - ice_reset_vf(vf, false); + ice_reset_vf(vf, 0); } /** diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h index 86f82493841d..43e9e10d846e 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h @@ -104,6 +104,11 @@ struct ice_vf { struct ice_mdd_vf_events mdd_tx_events; }; +/* Flags for controlling behavior of ice_reset_vf */ +enum ice_vf_reset_flags { + ICE_VF_RESET_VFLR = BIT(0), /* Indicate a VFLR reset */ +}; + #ifdef CONFIG_PCI_IOV void ice_process_vflr_event(struct ice_pf *pf); int ice_sriov_configure(struct pci_dev *pdev, int num_vfs); @@ -116,7 +121,7 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event); void ice_vc_notify_link_state(struct ice_pf *pf); void ice_vc_notify_reset(struct ice_pf *pf); bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr); -int ice_reset_vf(struct ice_vf *vf, bool is_vflr); +int ice_reset_vf(struct ice_vf *vf, u32 flags); void ice_restore_all_vfs_msi_state(struct pci_dev *pdev); int @@ -160,7 +165,7 @@ ice_reset_all_vfs(struct ice_pf __always_unused *pf, } static inline int -ice_reset_vf(struct ice_vf __always_unused *vf, bool __always_unused is_vflr) +ice_reset_vf(struct ice_vf __always_unused *vf, u32__always_unused flags) { return 0; } -- 2.34.1