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.
quoted hunk ↗ jump to hunk
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?
quoted hunk ↗ jump to hunk
+
/**
* 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