Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: przemyslaw.kitszel@intel.com
Cc: kuba@kernel.org, netdev@vger.kernel.org,
	aleksandr.loktionov@intel.com, andrew+netdev@lunn.ch,
	anthony.l.nguyen@intel.com, anzaki@gmail.com,
	brett.creeley@amd.com, corbet@lwn.net, davem@davemloft.net,
	edumazet@kernel.org, horms@kernel.org, jacob.e.keller@intel.com,
	jedrzej.jagielski@intel.com, jiri@resnulli.us, leon@kernel.org,
	mbloch@nvidia.com, mschmidt@redhat.com, ohartoov@nvidia.com,
	pabeni@redhat.com, poros@redhat.com, rdunlap@infradead.org,
	saeedm@nvidia.com, skhan@linuxfoundation.org, tariqt@nvidia.com
Subject: Re: [net-next v6 09/15] iavf: increase max number of queues to 256
Date: Thu, 19 Nov 2026 06:44:58 +0000	[thread overview]
Message-ID: <179507069863.3136.4636322783372070178@kernel.org> (raw)
In-Reply-To: <20261117094913.100756-10-przemyslaw.kitszel@intel.com>

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

Critical: 0 · High: 0 · Medium: 1 · Low: 1

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).

- [Medium] The patch turns q_vector->ring_mask into a fixed 256-bit
  bitmap (DECLARE_BITMAP(ring_mask, IAVF_MAX_REQ_QUEUES)).
- [Low] The new helper iavf_itrn_reg() (iavf_main.c:423) picks the ITR
  register bank per vector index: IAVF_VFINT_ITRN1 (base 0x2800, 0x40…

--

iavf: increase max number of queues to 256

This patch raises the iavf queue limit from 16 to 256. It turns
q_vector->ring_mask into a 256-bit bitmap and allocates the netdev with
256 Tx/Rx queues. Queue vectors are capped at 64, and the ITR of vectors
16..63 is programmed through a new IAVF_VFINT_ITRN_64 register bank.

> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 822d6e692d495..db769eead68f3 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -419,6 +419,15 @@ static irqreturn_t iavf_msix_clean_rings(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> +/* VFINT_ITRN1 fits 16 vectors only, VFINT_ITRN_64 aliases it for up to 64 */
> +static u32 iavf_itrn_reg(enum iavf_dyn_idx_t itr_idx, u16 reg_idx)
> +{
> +	if (reg_idx < 16)
> +		return IAVF_VFINT_ITRN1(itr_idx, reg_idx);
> +
> +	return IAVF_VFINT_ITRN_64(itr_idx, reg_idx);
> +}

[Severity: Low]
Is the aliasing in this comment documented anywhere? When a VF has more
than 16 queue vectors, iavf_itrn_reg() programs vectors 0..15 through
the 0x2800 bank and vectors 16..63 through the 0x2C00 bank.

idpf_lan_vf_regs.h describes the same VF register space. There, the two
banks are alternatives chosen by the VF's vector mode:

/* For VF with 16 vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing
 * is 0x40 and base register offset is 0x00002800
 */
...
/* For VF with 64 vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing
 * is 0x100 and base register offset is 0x00002C00
 */

Suppose a VF in 64-vector mode does not decode the 0x2800 bank. Then the
first ITR writes for vectors 0..15 in iavf_map_vector_to_rxq() and
iavf_map_vector_to_txq() are lost. Both functions still set current_itr
to target_itr afterwards.

With static ITR (adaptive turned off with ethtool -C),
iavf_update_enable_itr() only rewrites ITR when target_itr !=
current_itr. Would those vectors then stay at the hardware reset
moderation value?

Using IAVF_VFINT_ITRN_64 for every vector whenever the VF has more than
16 vectors would not depend on the aliasing. Would that be safer?

> +
>  /**
>   * iavf_map_vector_to_rxq - associate irqs with rx queues
>   * @adapter: board private structure
> @@ -439,8 +448,8 @@ iavf_map_vector_to_rxq(struct iavf_adapter *adapter, int v_idx, int r_idx)
>  	q_vector->rx.count++;
>  	q_vector->rx.next_update = jiffies + 1;
>  	q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting);
> -	q_vector->ring_mask |= BIT(r_idx);
> -	wr32(hw, IAVF_VFINT_ITRN1(IAVF_RX_ITR, q_vector->reg_idx),
> +	set_bit(r_idx, q_vector->ring_mask);

[Severity: Medium]
Can r_idx reach 256 here? ring_mask is now
DECLARE_BITMAP(ring_mask, IAVF_MAX_REQ_QUEUES). iavf_map_rings_to_vectors()
calls this for every ridx up to num_active_queues - 1, and nothing checks
r_idx against IAVF_MAX_REQ_QUEUES.

The only clamp is in iavf_validate_num_queues(). It checks only
vf_res->num_queue_pairs, and it rewrites vsi_res[i].num_queue_pairs only
inside that branch:

	if (adapter->vf_res->num_queue_pairs > IAVF_MAX_REQ_QUEUES) {
		...
		for (i = 0; i < adapter->vf_res->num_vsis; i++) {
			vsi_res = &adapter->vf_res->vsi_res[i];
			vsi_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES;
		}
	}

The queue count, however, comes from vsi_res->num_queue_pairs (a u16).
In iavf_alloc_queues():

		num_active_queues = min_t(int,
					  adapter->vsi_res->num_queue_pairs,
					  (int)(num_online_cpus()));

and in iavf_set_channels():

	if (num_req == 0 || num_req > adapter->vsi_res->num_queue_pairs)
		return -EINVAL;

Take a PF that reports vf_res->num_queue_pairs <= 256 but
vsi_res->num_queue_pairs > 256. num_active_queues can then go above 256,
either on a guest with more than 256 vCPUs or after
"ethtool -L combined N" once the PF grants N.

If so, set_bit() writes past ring_mask. Small overruns hit the q_vector
fields that follow it (itr_countdown, num_ringpairs, v_idx, reg_idx,
name). Larger r_idx values land past the end of the q_vectors array.
Before this patch, the same input only reached "|= BIT(r_idx)" on a
u32. That shift is undefined, but it stays inside the field.

The in-tree ice PF reports the same value for both counts. Hitting this
needs a buggy or malicious PF, which is the case the driver's own
comment in iavf_validate_num_queues() is meant to guard against.

The final iavf_validate_num_queues() at the end of the series has the
same structure; only the threshold depends on LARGE_NUM_QPAIRS_SUPPORT.

Should iavf_validate_num_queues() clamp vsi_res[i].num_queue_pairs on
its own terms? Or should r_idx be bounded before the set_bit()?

>  	     q_vector->rx.current_itr >> 1);
>  	q_vector->rx.current_itr = q_vector->rx.target_itr;
>  }

[ ... ]

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

  reply	other threads:[~2026-11-19  6:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:44 [net-next v6 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 01/15] devlink, mlx5: add init/fini ops for shared devlink Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 02/15] ice: use shared devlink to store ice_adapters instead of custom xarray Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 03/15] ice: add VF queue ena/dis helper functions Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
2026-11-19  6:44   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 06/15] ice: bump to 256qs for VF Przemek Kitszel
2026-11-19  6:44   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 07/15] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
2026-11-19  6:44   ` netdev-bot+sashiko [this message]
2026-11-17  9:44 ` [net-next v6 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 12/15] devlink: give user option to allocate resources Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 14/15] devlink: add devlink_alloc_drv() Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 15/15] ice: support up to 256 VF queues Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko

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=179507069863.3136.4636322783372070178@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=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