Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: przemyslaw.kitszel@intel.com
Cc: netdev@vger.kernel.org, kuba@kernel.org, jiri@resnulli.us,
	anthony.l.nguyen@intel.com, aleksandr.loktionov@intel.com,
	mschmidt@redhat.com, edumazet@kernel.org, horms@kernel.org,
	pabeni@redhat.com, davem@davemloft.net, corbet@lwn.net,
	skhan@linuxfoundation.org, rdunlap@infradead.org,
	andrew+netdev@lunn.ch, saeedm@nvidia.com, tariqt@nvidia.com,
	leon@kernel.org, mbloch@nvidia.com, jacob.e.keller@intel.com,
	jedrzej.jagielski@intel.com, anzaki@gmail.com,
	brett.creeley@amd.com, ohartoov@nvidia.com, poros@redhat.com,
	donald.hunter@gmail.com
Subject: Re: [PATCH net-next v7 15/15] ice: support up to 256 VF queues
Date: Tue, 24 Nov 2026 21:57:46 +0000	[thread overview]
Message-ID: <179555746609.3135.17615546634769705803@kernel.org> (raw)
In-Reply-To: <20261121230123.316391-16-przemyslaw.kitszel@intel.com>

Thank you for your contribution! Sashiko AI review found 8 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 2 · Low: 4

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] ice_init_vf_devlink()
  (drivers/net/ethernet/intel/ice/ice_vf_lib.c) asserts that…
- [High] ice_sriov_set_msix_vec_count() (sriov_vf_msix_count sysfs) reads
  and rebuilds the VF VSI without vf->cfg_lock.
- [Medium] ice: NULL pointer dereference on VF recovery after VSI rebuild
  failure
- [Medium] ice: sriov_vf_msix_count overridden by num_req_qs and not
  capped to LUT or 256
- [Low] ice_vf_max_contig_qs() returns 0 when either
  bitmap_alloc(GFP_KERNEL) fails: it jumps to `out` with max_tx and…
- [Low] ice_sriov_set_msix_vec_count() now has two capacity checks that
  measure different things.
- [Low] ice_vf_max_contig_qs() copies pf->avail_txqs/avail_rxqs under
  pf->avail_q_mutex, drops the mutex, and returns the longest free range…
- [Low] ice_init_vf_devlink() returns void and exits silently when
  devlink_alloc_drv() returns NULL or devl_nested_devlink_set() fails:…

--

ice: support up to 256 VF queues

This patch supports up to 256 queues per VF. A VF gets the bigger RSS
LUT it needs through a new per-VF devlink instance with an rss_lut
resource. It also hooks up the large-queue virtchnl opcodes, defers the
VF reset to the service task, and only grants queue requests that fit in
one contiguous free range of PF queues.

> diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
> index d7c4a65400083..24c521aaf3f3b 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sriov.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c

[ ... ]

> @@ -969,6 +991,12 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
>  		return 0;
>  	}
>  
> +	/* VSI rebuild takes one free range for all queues of the VF */
> +	if ((vf->num_req_qs ?: queues) > ice_vf_max_contig_qs(vf, vsi)) {
> +		ice_put_vf(vf);
> +		return -ENOSPC;
> +	}
> +
>  	prev_msix = vf->num_msix;
>  	prev_queues = vf->num_vf_qs;
>  

[Severity: Medium]
This check uses vf->num_req_qs ?: queues, but
ice_sriov_set_msix_vec_count() never updates vf->num_req_qs. On
rebuild, ice_vsi_set_num_qs() overwrites vf->num_vf_qs with
vf->num_req_qs whenever that is non-zero.

This patch adds two places that set num_req_qs without the admin or
the VF asking for it. ice_change_rss_lut() and ice_rebuild_rss_luts()
set vf->num_req_qs = max_qs when (vf->num_req_qs ?: vf->num_vf_qs) is
above the LUT limit.

Take a VF with a global LUT that got 64 queues through
sriov_vf_msix_count. After a PF reset, num_req_qs is latched at 16.
>From then on, a sriov_vf_msix_count write changes vf->num_msix and sets
vf->num_vf_qs = queues, but the VSI rebuild puts the queue count back
to 16. That also happens after the VF gets a bigger LUT again. The
-ENOSPC check here is done against that stale 16, not the count that
was written. vsi->req_txq/req_rxq do not help either, since they are
only read for ICE_VSI_PF.

When num_req_qs is 0, queues is capped neither by
ice_lut_type_to_qs_num(vsi->rss_lut_type) nor by ICE_MAX_QS_PER_VF.
VIRTCHNL_VF_LARGE_NUM_QPAIRS is now granted to any VF with a global
or PF LUT. So a VF with a 512 entry global LUT and sriov_vf_msix_count
set to 128 gets num_queue_pairs = 128 in the GET_VF_RESOURCES reply,
while its LUT spreads traffic over only 64 of them.

Above 256 queues it gets worse. ice_ena_vf_q_mappings() writes
max_txq - 1 into the 8-bit VFNUMQ fields of VPLAN_TX_QBASE and
VPLAN_RX_QBASE, so 257 queues wrap to a single queue in hardware. Queue
id 256 also passes ice_vc_isvalid_q_id(), which only checks against
vsi->alloc_txq. ice_vf_vsi_dis_single_txq() then indexes past the
ICE_MAX_QS_PER_VF sized vf->txq_ena bitmap.

Should the sysfs path set or clear vf->num_req_qs together with
vf->num_vf_qs? Should it also cap queues to the RSS LUT limit and to
ICE_MAX_QS_PER_VF, the way ice_vc_request_qs_msg() caps a VF request?

[Severity: High]
ice_sriov_set_msix_vec_count() does not take vf->cfg_lock. With this
patch, the VF devlink rss_lut setter can work on the same VF VSI at the
same time:

devlink resource set pci/<VF> path rss_lut ...
  ice_rss_lut_vf_size_set()        (VF devl lock + vf->cfg_lock)
    ice_rss_lut_set()
      ice_change_rss_lut()
        writes vsi->rss_table_size, rss_lut_type, rss_size,
        vf->num_req_qs
        ice_schedule_vf_reset()

service task
  ice_handle_deferred_vf_reset()
    ice_reset_vf()
      ice_vf_reconfig_vsi()
        ice_vsi_decfg() / ice_vsi_cfg()   (cfg_lock only)

sriov_vf_msix_count store
  ice_sriov_set_msix_vec_count()   (no cfg_lock)
    reads vf->num_req_qs
    ice_vf_max_contig_qs()         walks vsi->txq_map[] / rxq_map[]
    ice_vsi_rebuild()

The sysfs path only needs the VF to be unbound. The devlink setter only
needs ice_vf_is_ready(), and an unbound VF in INIT state passes that
check.

Can the two paths run decfg/cfg on the same VSI at once? Can
ice_vf_max_contig_qs() read vsi->txq_map[] while it is being freed or
reallocated?

ice_rebuild_rss_luts() also writes vf->num_req_qs and the VF VSI rss
fields while holding table_lock and rss_lut_lock, but not cfg_lock.

The missing cfg_lock in ice_sriov_set_msix_vec_count() predates this
patch, since ndo_set_vf_* resets can already race with it. This patch
adds a new concurrent writer and new unlocked reads on top of that.

[Severity: Low]
Earlier in ice_sriov_set_msix_vec_count() there is still the older
capacity check:

	if (queues > min(ice_get_avail_txq_count(pf),
			 ice_get_avail_rxq_count(pf)))
		return -EINVAL;

That check counts the VF's current queues as used, because they are
still set in pf->avail_txqs/avail_rxqs. It also tests queues, not
vf->num_req_qs ?: queues.

The new check counts the VF's own queues as free, as the
ice_vf_max_contig_qs() kernel-doc says. Will a write that would fit once
the VF's own queues are released be rejected early with -EINVAL? Will a
VF that really does not fit usually get -EINVAL rather than -ENOSPC?

The commit message says:

  A write to sriov_vf_msix_count fails with -ENOSPC when the VF would
  not fit.

That only holds when the older check passes first. Should the two
checks be reconciled?

> diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
> index 320b393ddaaf0..015b50c70bdcc 100644
> --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c

[ ... ]

> @@ -1450,3 +1474,52 @@ void ice_vf_update_mac_lldp_num(struct ice_vf *vf, struct ice_vsi *vsi,
>  	if (was_ena != is_ena)
>  		ice_vsi_cfg_sw_lldp(vsi, false, is_ena);
>  }
> +
> +void ice_init_vf_devlink(struct ice_vf *vf)
> +{
> +	struct devlink *pf_devlink = priv_to_devlink(vf->pf);
> +	static const struct devlink_ops noop = {};
> +	struct devlink *devlink;
> +	int err;
> +
> +	lockdep_assert_held(&vf->pf->vfs.table_lock);
> +
> +	/* no VF pci_dev when the VFs were not scanned, e.g. on s390 */
> +	if (!vf->vfdev)
> +		return;
> +
> +	devlink = devlink_alloc_drv(&noop, 0, &vf->vfdev->dev,
> +				    ice_pf_to_dev(vf->pf)->driver);
> +	if (!devlink)
> +		return;
> +
> +	scoped_guard(devl, pf_devlink)
> +		err = devl_nested_devlink_set(pf_devlink, devlink);

[Severity: High]
Can this deadlock against ice_tear_down_devlink_rate_tree()?

ice_start_vfs() calls ice_init_vf_devlink() for every VF while
ice_ena_vfs() holds pf->vfs.table_lock. That gives the order
table_lock -> PF devl.

ice_tear_down_devlink_rate_tree() in devlink/devlink.c takes the locks
the other way round:

	devl_lock(devlink);
	mutex_lock(&pf->vfs.table_lock);

It is reached from ice_pf_dcb_cfg() (dcbnl setets/setpfc/setapp, DCB
rebuild, LLDP MIB change handling). It is also reached from
ice_setup_tc_mqprio_qdisc() in channel mode.

CPU0                              CPU1
sriov_numvfs store                dcbnl setets / LLDP MIB change
ice_ena_vfs()                     ice_pf_dcb_cfg()
  lock table_lock                   ice_tear_down_devlink_rate_tree()
  ice_start_vfs()                     devl_lock(pf devlink)
    ice_init_vf_devlink()             lock table_lock  <- waits
      devl lock(pf devlink) <- waits

Before this patch, the table_lock -> PF devl order only showed up in
switchdev mode, through ice_eswitch_attach_vf()/ice_eswitch_detach_vf()
under table_lock. Now it also happens in the default legacy mode.

> +	if (err) {
> +		devlink_free(devlink);
> +		return;
> +	}

[Severity: Low]
When devlink_alloc_drv() returns NULL or devl_nested_devlink_set()
fails, ice_init_vf_devlink() returns without logging anything.

The VF devlink instance is the only way to give a VF a bigger RSS LUT.
Would a dev_warn() on these paths help explain why "devlink resource set
pci/<VF BDF> path rss_lut ..." is not available for that VF?

> +
> +	vf->devlink = devlink;
> +	scoped_guard(devl, devlink) {
> +		ice_devlink_vf_resources_register(vf);
> +		devl_register(devlink);
> +	}
> +}

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
> index e8635236cb6c1..1afb7a2946fe9 100644
> --- a/drivers/net/ethernet/intel/ice/virt/queues.c
> +++ b/drivers/net/ethernet/intel/ice/virt/queues.c
> @@ -986,6 +986,48 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)

[ ... ]

> +int ice_vf_max_contig_qs(struct ice_vf *vf, struct ice_vsi *vsi)
> +{
> +	struct ice_pf *pf = vf->pf;
> +	unsigned long *txqs, *rxqs;
> +	int max_tx = 0, max_rx = 0;
> +	int b, e;
> +
> +	txqs = bitmap_alloc(pf->max_pf_txqs, GFP_KERNEL);
> +	rxqs = bitmap_alloc(pf->max_pf_rxqs, GFP_KERNEL);
> +	if (!txqs || !rxqs)
> +		goto out;
> +
> +	scoped_guard(mutex, &pf->avail_q_mutex) {
> +		bitmap_copy(txqs, pf->avail_txqs, pf->max_pf_txqs);
> +		bitmap_copy(rxqs, pf->avail_rxqs, pf->max_pf_rxqs);
> +	}

[Severity: Low]
The snapshot is taken under avail_q_mutex, but the result is used after
the mutex is dropped.

ice_vc_request_qs_msg() then sets vf->num_req_qs and calls
ice_reset_vf(). The real allocation happens later, in
ice_vsi_get_qs()->__ice_vsi_get_qs(), under avail_q_mutex again.

A PF VSI rebuild (ethtool -L, XDP rings, ADQ channel VSIs) or another
sriov_vf_msix_count write can take queues in between. In that case
__ice_vsi_get_qs_contig() fails, and this fallback runs:

	ret = __ice_vsi_get_qs_contig(qs_cfg);
	if (ret && qs_cfg->q_count <= qs_cfg->scatter_count) {
		qs_cfg->mapping_mode = ICE_VSI_MAP_SCATTER;

ice_ena_vf_q_mappings() does not program scatter mode for VFs. Larger
counts make the rebuild fail and leave the VF disabled.

Doesn't that make the guarantee in the commit message ("granted only
when the VF fits in one free range of PF queues") best effort only?

> +	for (int i = 0; i < vsi->alloc_txq; i++)
> +		clear_bit(vsi->txq_map[i], txqs);
> +	for (int i = 0; i < vsi->alloc_rxq; i++)
> +		clear_bit(vsi->rxq_map[i], rxqs);
> +
> +	for_each_clear_bitrange(b, e, txqs, pf->max_pf_txqs)
> +		max_tx = max(max_tx, e - b);
> +	for_each_clear_bitrange(b, e, rxqs, pf->max_pf_rxqs)
> +		max_rx = max(max_rx, e - b);
> +out:
> +	bitmap_free(txqs);
> +	bitmap_free(rxqs);
> +
> +	return min(max_tx, max_rx);
> +}

[Severity: Medium]
When ice_vf_rebuild_vsi() fails here, the VF VSI is left half torn
down. ice_vsi_rebuild() runs ice_vsi_decfg() before ice_vsi_cfg_def(),
and both ice_vsi_decfg() and the ice_vsi_cfg_def() unwind call
ice_vsi_free_arrays(). That leaves vsi->txq_map, vsi->rxq_map,
vsi->tx_rings, vsi->rx_rings and vsi->q_vectors NULL, while
vsi->alloc_txq, alloc_rxq, num_txq and num_rxq keep their old values.

This patch sets ICE_VF_STATE_DIS while preparing for the PF reset, and
clears it again here so that a VFLR can reset the VF. With the bit
clear, ice_is_vf_disabled() is false, and a VFLR from the guest runs
the full reset on that VSI:

ice_process_vflr_event()
  ice_reset_vf(vf, ICE_VF_RESET_VFLR | ICE_VF_RESET_LOCK)
    ice_dis_vf_qs()
      ice_vsi_stop_all_rx_rings()    reads vsi->rxq_map[i]
    ice_reset_interrupts()           reads vsi->txq_map[i], rxq_map[i]
    ice_vf_reconfig_vsi()
      ice_vsi_decfg()                second decfg
      ice_vsi_cfg()                  with ICE_VSI_FLAG_NO_INIT

Isn't that a NULL pointer dereference in the first two steps?

Even if those were guarded, the second ice_vsi_decfg() still runs
ice_vsi_put_qs() on the NULL maps and drops vsi->agg_node->num_vsis
again. ice_vsi_cfg() with ICE_VSI_FLAG_NO_INIT then ends in
ice_update_vsi() for a VSI that firmware lost on the PF reset. That VSI
was never added back with ICE_VSI_FLAG_INIT. So the VFLR does not seem
able to recover the VF.

The new ice_vf_max_contig_qs() has the same problem. A
sriov_vf_msix_count write for this VF walks vsi->txq_map[] and
vsi->rxq_map[] up to alloc_txq and alloc_rxq without a NULL check.

Should the VSI be put into a consistent state before the bit is
cleared? Or should ice_reset_vf() notice a VF whose VSI rebuild failed
and do a full rebuild with ICE_VSI_FLAG_INIT instead?

[Severity: Low]
When either bitmap_alloc() fails, this returns 0. Callers cannot tell
that apart from "no free contiguous range".

ice_sriov_set_msix_vec_count() then returns -ENOSPC instead of -ENOMEM.

ice_vc_request_qs_msg() sets max_allowed_vf_queues to 0. It then logs
"only 0 are free in one range" and replies to the VF with
num_queue_pairs = 0.

Should the allocation failure be reported separately, for example as a
negative errno?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

  reply	other threads:[~2026-11-24 21:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 01/15] iavf: keep RSS config across resets Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 02/15] ice: prepare RSS LUT config for runtime LUT changes Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 03/15] ice: add VF queue ena/dis helper functions Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 06/15] ice: bump to 256qs for VF Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 07/15] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 12/15] devlink: add cmode to resources Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 14/15] devlink: add devlink_alloc_drv() Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 15/15] ice: support up to 256 VF queues Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko [this message]
2026-11-23  8:53 ` [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Matthieu Baerts
2026-11-23 15:03   ` Przemek Kitszel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179555746609.3135.17615546634769705803@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=anzaki@gmail.com \
    --cc=brett.creeley@amd.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jedrzej.jagielski@intel.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=mschmidt@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=ohartoov@nvidia.com \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=saeedm@nvidia.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox