* [PATCH net 0/3] ice, devlink: fixes needed for XLVF
@ 2026-12-02 12:48 Przemek Kitszel
2026-12-02 12:48 ` [PATCH net 1/3] ice: move only the valid VF queues on LAG reclaim and reset rebuild Przemek Kitszel
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Przemek Kitszel @ 2026-12-02 12:48 UTC (permalink / raw)
To: netdev, pabeni, willemb, donald.hunter, jiri
Cc: intel-wired-lan, anthony.l.nguyen, davem, edumazet, kuba, horms,
andrew+netdev, Petr Oros, Przemek Kitszel
These are fixes for problems that are already there upstream, found
while working on the XLVF series for ice and iavf (more than 16 queue
pairs for a VF) [1]. XLVF builds on top of them, so I'm sending them
for net first.
Patch 1 fixes the queue count passed to the FW when ice moves VF queues
between ports of a bond: only the queues with a valid TEID are filled
in, but the command got the number of all of them. Reported by Sashiko
on XLVF v7.
Patch 2 takes vf->cfg_lock while ice changes the MSI-X vector count of
a VF, which could race with a VF reset started by the PF and oops.
Reported by Petr on XLVF v7, XLVF also extends this path.
Patch 3 makes the devlink dev messages fit any number of nested devlink
instances. ice already nests one for each subfunction in the devlink of
its PF, and XLVF will nest the VF devlinks there too.
Known, not addressed here, as XLVF does not depend on them: the MSI-X
change remaps the vectors of the other inactive VFs without their
vf->cfg_lock, and its fallback to the old vector count, after a failed
VSI rebuild, can fail too.
[1] https://lore.kernel.org/netdev/20261121230123.316391-1-przemyslaw.kitszel@intel.com
Przemek Kitszel (3):
ice: move only the valid VF queues on LAG reclaim and reset rebuild
ice: lock VF config while changing its MSI-X vector count
devlink: make room for many nested instances in a dev message
Documentation/netlink/specs/devlink.yaml | 1 +
net/devlink/devl_internal.h | 2 +
net/devlink/netlink_gen.h | 1 +
drivers/net/ethernet/intel/ice/ice_lag.c | 4 +-
drivers/net/ethernet/intel/ice/ice_sriov.c | 7 ++++
net/devlink/core.c | 13 ++++++
net/devlink/dev.c | 48 +++++++++++++++++++---
net/devlink/netlink.c | 14 ++++++-
net/devlink/netlink_gen.c | 1 +
9 files changed, 82 insertions(+), 9 deletions(-)
--
2.51.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net 1/3] ice: move only the valid VF queues on LAG reclaim and reset rebuild
2026-12-02 12:48 [PATCH net 0/3] ice, devlink: fixes needed for XLVF Przemek Kitszel
@ 2026-12-02 12:48 ` Przemek Kitszel
2026-12-02 12:48 ` [PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count Przemek Kitszel
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Przemek Kitszel @ 2026-12-02 12:48 UTC (permalink / raw)
To: netdev, pabeni, willemb, donald.hunter, jiri
Cc: intel-wired-lan, anthony.l.nguyen, davem, edumazet, kuba, horms,
andrew+netdev, Petr Oros, Przemek Kitszel, Sashiko
ice_lag_reclaim_vf_tc() and ice_lag_move_vf_nodes_tc_sync() pass the
number of queue contexts to ice_aq_cfg_lan_txq(), but ice_lag_qbuf_recfg()
fills the buffer only with the queues that have a valid TEID and queue
handle, fewer when a VF uses fewer queues than it has. The command then
also gets the zeroed entries from the end of the buffer, which are not
queues of that VF. Pass the count of valid queues returned by
ice_lag_qbuf_recfg(), as ice_lag_move_vf_node_tc() already does.
Fixes: 1e0f9881ef79 ("ice: Flesh out implementation of support for SRIOV on bonded interface")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/netdev/179555745171.3135.7481127088391251734@kernel.org
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
drivers/net/ethernet/intel/ice/ice_lag.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c b/drivers/net/ethernet/intel/ice/ice_lag.c
index 08a17ded0ad5..ceac5e7ded2a 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.c
+++ b/drivers/net/ethernet/intel/ice/ice_lag.c
@@ -1277,7 +1277,7 @@ ice_lag_reclaim_vf_tc(struct ice_lag *lag, struct ice_hw *src_hw, u16 vsi_num,
goto reclaim_none;
}
- if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, numq,
+ if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, valq,
src_hw->port_info->lport, hw->port_info->lport,
ICE_AQC_Q_CFG_TC_CHNG, NULL)) {
dev_warn(dev, "Failure to configure queues for LAG failover\n");
@@ -2495,7 +2495,7 @@ ice_lag_move_vf_nodes_tc_sync(struct ice_lag *lag, struct ice_hw *dest_hw,
goto sync_none;
}
- if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, numq, hw->port_info->lport,
+ if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, valq, hw->port_info->lport,
dest_hw->port_info->lport,
ICE_AQC_Q_CFG_TC_CHNG, NULL)) {
dev_warn(dev, "Failure to configure queues for LAG reset rebuild\n");
--
2.51.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count
2026-12-02 12:48 [PATCH net 0/3] ice, devlink: fixes needed for XLVF Przemek Kitszel
2026-12-02 12:48 ` [PATCH net 1/3] ice: move only the valid VF queues on LAG reclaim and reset rebuild Przemek Kitszel
@ 2026-12-02 12:48 ` Przemek Kitszel
2026-12-03 13:31 ` netdev-bot+sashiko
2026-12-02 12:48 ` [PATCH net 3/3] devlink: make room for many nested instances in a dev message Przemek Kitszel
2026-12-02 12:54 ` [PATCH net 0/3] ice, devlink: fixes needed for XLVF netdev-bot+sinfo
3 siblings, 1 reply; 7+ messages in thread
From: Przemek Kitszel @ 2026-12-02 12:48 UTC (permalink / raw)
To: netdev, pabeni, willemb, donald.hunter, jiri
Cc: intel-wired-lan, anthony.l.nguyen, davem, edumazet, kuba, horms,
andrew+netdev, Petr Oros, Przemek Kitszel
ice_sriov_set_msix_vec_count() rebuilds the VF VSI and rewrites the VF
queue and interrupt mappings without vf->cfg_lock. The PCI core only
makes sure that no driver is bound to the VF, the PF can still reset the
VF at the same time, e.g. from ndo_set_vf_mac() or ndo_set_vf_vlan().
Such a reset rebuilds the same VSI under vf->cfg_lock, and one rebuild
frees the VSI arrays that the other one still uses. Reproducer, with one
VF that has no driver bound:
while :; do
ip link set $PF vf 0 mac 02:00:00:00:02:01
ip link set $PF vf 0 mac 02:00:00:00:02:02
done &
while :; do
echo 33 > /sys/bus/pci/devices/$VF/sriov_vf_msix_count
echo 17 > /sys/bus/pci/devices/$VF/sriov_vf_msix_count
done
The first MAC change already oopses, with RTNL held:
BUG: kernel NULL pointer dereference, address: 0000000000000000
RIP: 0010:ice_free_q_vector+0x16/0x140 [ice]
Call Trace:
ice_vsi_free_q_vectors+0x20/0x40 [ice]
ice_vsi_decfg+0x59/0xc0 [ice]
ice_reset_vf+0x38f/0x5a0 [ice]
__ice_set_vf_mac+0x10a/0x160 [ice]
do_setvfinfo+0x5d/0x450
do_setlink.constprop.0+0x57f/0xd20
rtnl_newlink+0x4a4/0x9b0
Take vf->cfg_lock for the whole change, like the other paths that
reconfigure a VF do. It nests in the device locks of the PF and the VF,
which the PCI core holds here; the reset paths take vf->cfg_lock without
any device lock.
Fixes: 05c16687e0cc ("ice: set MSI-X vector count on VF")
Reported-by: Petr Oros <poros@redhat.com>
Closes: https://lore.kernel.org/netdev/20261126094321.40071-1-poros@redhat.com
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
drivers/net/ethernet/intel/ice/ice_sriov.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index c49f48b5ae38..5916cf7bf914 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -957,14 +957,18 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
if (!vf)
return -ENOENT;
+ mutex_lock(&vf->cfg_lock);
+
vsi = ice_get_vf_vsi(vf);
if (!vsi) {
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return -ENOENT;
}
/* No need to rebuild if we're setting to the same value */
if (msix_vec_count == vf->num_msix) {
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return 0;
}
@@ -998,6 +1002,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
vf->vf_id, vf->num_msix, vf->num_vf_qs);
ice_ena_vf_mappings(vf);
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return 0;
@@ -1012,6 +1017,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
vf->first_vector_idx = ice_virt_get_irqs(pf, vf->num_msix);
if (vf->first_vector_idx < 0) {
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return -EINVAL;
}
@@ -1024,6 +1030,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
}
ice_ena_vf_mappings(vf);
+ mutex_unlock(&vf->cfg_lock);
ice_put_vf(vf);
return -EINVAL;
--
2.51.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net 3/3] devlink: make room for many nested instances in a dev message
2026-12-02 12:48 [PATCH net 0/3] ice, devlink: fixes needed for XLVF Przemek Kitszel
2026-12-02 12:48 ` [PATCH net 1/3] ice: move only the valid VF queues on LAG reclaim and reset rebuild Przemek Kitszel
2026-12-02 12:48 ` [PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count Przemek Kitszel
@ 2026-12-02 12:48 ` Przemek Kitszel
2026-12-03 13:31 ` netdev-bot+sashiko
2026-12-02 12:54 ` [PATCH net 0/3] ice, devlink: fixes needed for XLVF netdev-bot+sinfo
3 siblings, 1 reply; 7+ messages in thread
From: Przemek Kitszel @ 2026-12-02 12:48 UTC (permalink / raw)
To: netdev, pabeni, willemb, donald.hunter, jiri
Cc: intel-wired-lan, anthony.l.nguyen, davem, edumazet, kuba, horms,
andrew+netdev, Petr Oros, Przemek Kitszel
A DEVLINK_CMD_GET reply, and a DEVLINK_CMD_NEW/DEL notification, carry
the handle of every devlink instance nested in the described one. Each
handle takes about 40 bytes, 8 more with a netns id, so
NLMSG_DEFAULT_SIZE, below a page, fits only ~80 of them. Then the reply
fails with -EMSGSIZE, and the notification is dropped. A dump skb of
NLMSG_GOODSIZE has the same limit, and there it is silent: an instance
that does not fit in an empty skb ends the dump, so it and all the
instances after it are missing from the output.
ice nests the devlink of each subfunction in the devlink of its PF, and
their number is limited only by the HW resources. In a separate series,
I plan to nest there also the devlinks of up to 256 VFs.
Add the size of the nested handles to NLMSG_DEFAULT_SIZE for the reply
and the notification. For the dump, start with min_dump_alloc set to the
biggest needed size among the instances, and raise it when an instance
does not fit, so the next dump skb has room for it. Count the dump size
from 512 bytes, not from NLMSG_DEFAULT_SIZE, as the rest of the message
takes ~300 bytes: a dump skb over a page is truncated by readers with a
page-sized buffer, like iproute2 (ENOSPC). When an instance still does
not fit in an empty skb, e.g. as it got more nested instances during the
dump, fail the dump with -EMSGSIZE instead of ending it. Do that for all
devlink dumps.
Fixes: f43e3be662e6 ("ice: allocate devlink for subfunction")
Reported-by: Petr Oros <poros@redhat.com>
Closes: https://lore.kernel.org/netdev/20261126094321.40071-1-poros@redhat.com
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
Documentation/netlink/specs/devlink.yaml | 1 +
net/devlink/devl_internal.h | 2 +
net/devlink/netlink_gen.h | 1 +
net/devlink/core.c | 13 +++++++
net/devlink/dev.c | 48 +++++++++++++++++++++---
net/devlink/netlink.c | 14 ++++++-
net/devlink/netlink_gen.c | 1 +
7 files changed, 73 insertions(+), 7 deletions(-)
diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml
index 4706de628392..5ff809eb6d44 100644
--- a/Documentation/netlink/specs/devlink.yaml
+++ b/Documentation/netlink/specs/devlink.yaml
@@ -1486,6 +1486,7 @@ operations:
- dev-stats
- nested-devlink
dump:
+ pre: devlink-nl-get-pre-dumpit
reply: *get-reply
-
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index 798e707002b9..ba3798fee416 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -149,6 +149,7 @@ void devlink_rel_nested_in_notify(struct devlink *devlink);
int devlink_rel_devlink_handle_put(struct sk_buff *msg, struct devlink *devlink,
u32 rel_index, int attrtype,
bool *msg_updated);
+size_t devlink_rel_devlink_handle_size(u32 rel_index);
/* Netlink */
struct devlink_nl_ctx {
@@ -231,6 +232,7 @@ static inline int devlink_nl_put_u64(struct sk_buff *msg, int attrtype, u64 val)
int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
struct devlink *devlink, int attrtype);
+size_t devlink_nl_nested_handle_size(struct devlink *devlink);
int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info);
static inline bool devlink_nl_notify_need(struct devlink *devlink)
diff --git a/net/devlink/netlink_gen.h b/net/devlink/netlink_gen.h
index 99ccacc693b7..9f0b1d653961 100644
--- a/net/devlink/netlink_gen.h
+++ b/net/devlink/netlink_gen.h
@@ -43,6 +43,7 @@ void
devlink_nl_post_doit_parent_dev_optional(const struct genl_split_ops *ops,
struct sk_buff *skb,
struct genl_info *info);
+int devlink_nl_get_pre_dumpit(struct netlink_callback *cb);
int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
diff --git a/net/devlink/core.c b/net/devlink/core.c
index 9b844e0c1bd2..b565db8ec793 100644
--- a/net/devlink/core.c
+++ b/net/devlink/core.c
@@ -252,6 +252,19 @@ int devlink_rel_devlink_handle_put(struct sk_buff *msg, struct devlink *devlink,
return err;
}
+size_t devlink_rel_devlink_handle_size(u32 rel_index)
+{
+ struct devlink *rel_devlink;
+ size_t size;
+
+ rel_devlink = devlink_rel_devlink_get(rel_index);
+ if (!rel_devlink)
+ return 0;
+ size = devlink_nl_nested_handle_size(rel_devlink);
+ devlink_put(rel_devlink);
+ return size;
+}
+
void *devlink_priv(struct devlink *devlink)
{
return &devlink->priv;
diff --git a/net/devlink/dev.c b/net/devlink/dev.c
index b7e5aebf13be..07fad82d9e1c 100644
--- a/net/devlink/dev.c
+++ b/net/devlink/dev.c
@@ -156,6 +156,21 @@ static int devlink_nl_nested_fill(struct sk_buff *msg, struct devlink *devlink)
return 0;
}
+static size_t devlink_nl_dev_msg_size(struct devlink *devlink, size_t size)
+{
+ unsigned long rel_index;
+ void *unused;
+
+ xa_for_each(&devlink->nested_rels, rel_index, unused)
+ size += devlink_rel_devlink_handle_size(rel_index);
+ return size;
+}
+
+static size_t devlink_nl_dev_dump_size(struct devlink *devlink)
+{
+ return devlink_nl_dev_msg_size(devlink, 512);
+}
+
static int devlink_nl_fill(struct sk_buff *msg, struct devlink *devlink,
enum devlink_command cmd, u32 portid,
u32 seq, int flags)
@@ -207,7 +222,8 @@ static void devlink_notify(struct devlink *devlink, enum devlink_command cmd)
if (!devlink_nl_notify_need(devlink))
return;
- msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ msg = nlmsg_new(devlink_nl_dev_msg_size(devlink, NLMSG_DEFAULT_SIZE),
+ GFP_KERNEL);
if (!msg)
return;
@@ -226,7 +242,8 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
struct sk_buff *msg;
int err;
- msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ msg = nlmsg_new(devlink_nl_dev_msg_size(devlink, NLMSG_DEFAULT_SIZE),
+ GFP_KERNEL);
if (!msg)
return -ENOMEM;
@@ -240,13 +257,34 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg, info);
}
+int devlink_nl_get_pre_dumpit(struct netlink_callback *cb)
+{
+ struct net *net = sock_net(cb->skb->sk);
+ struct devlink *devlink;
+ unsigned long index;
+
+ /* no instance lock, the size is only a hint for the first dump skb */
+ devlinks_xa_for_each_registered_get(net, index, devlink) {
+ cb->min_dump_alloc = max(cb->min_dump_alloc,
+ devlink_nl_dev_dump_size(devlink));
+ devlink_put(devlink);
+ }
+ return 0;
+}
+
static int
devlink_nl_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
struct netlink_callback *cb, int flags)
{
- return devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW,
- NETLINK_CB(cb->skb).portid,
- cb->nlh->nlmsg_seq, flags);
+ int err;
+
+ err = devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW,
+ NETLINK_CB(cb->skb).portid,
+ cb->nlh->nlmsg_seq, flags);
+ if (err == -EMSGSIZE)
+ cb->min_dump_alloc = max(cb->min_dump_alloc,
+ devlink_nl_dev_dump_size(devlink));
+ return err;
}
int devlink_nl_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c
index a8eda727bff1..57d2ee4d73d0 100644
--- a/net/devlink/netlink.c
+++ b/net/devlink/netlink.c
@@ -172,6 +172,16 @@ int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
return -EMSGSIZE;
}
+/* upper bound of what devlink_nl_put_nested_handle() puts */
+size_t devlink_nl_nested_handle_size(struct devlink *devlink)
+{
+ return nla_total_size(0) +
+ nla_total_size(strlen(devlink_bus_name(devlink)) + 1) +
+ nla_total_size(strlen(devlink_dev_name(devlink)) + 1) +
+ nla_total_size(sizeof(u64)) + /* DEVLINK_ATTR_INDEX */
+ nla_total_size(sizeof(s32)); /* DEVLINK_ATTR_NETNS_ID */
+}
+
int devlink_nl_msg_reply_and_new(struct sk_buff **msg, struct genl_info *info)
{
int err;
@@ -402,7 +412,7 @@ static int devlink_nl_inst_single_dumpit(struct sk_buff *msg,
devl_unlock(devlink);
devlink_put(devlink);
- if (err != -EMSGSIZE)
+ if (err != -EMSGSIZE || !msg->len)
return err;
return msg->len;
}
@@ -438,7 +448,7 @@ static int devlink_nl_inst_iter_dumpit(struct sk_buff *msg,
state->port_ctx.index_valid = false;
}
- if (err != -EMSGSIZE)
+ if (err != -EMSGSIZE || !msg->len)
return err;
return msg->len;
}
diff --git a/net/devlink/netlink_gen.c b/net/devlink/netlink_gen.c
index 9e1b4c081a7b..296d6d6e4111 100644
--- a/net/devlink/netlink_gen.c
+++ b/net/devlink/netlink_gen.c
@@ -714,6 +714,7 @@ const struct genl_split_ops devlink_nl_ops[75] = {
{
.cmd = DEVLINK_CMD_GET,
.validate = GENL_DONT_VALIDATE_DUMP,
+ .start = devlink_nl_get_pre_dumpit,
.dumpit = devlink_nl_get_dumpit,
.flags = GENL_CMD_CAP_DUMP,
},
--
2.51.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net 0/3] ice, devlink: fixes needed for XLVF
2026-12-02 12:48 [PATCH net 0/3] ice, devlink: fixes needed for XLVF Przemek Kitszel
` (2 preceding siblings ...)
2026-12-02 12:48 ` [PATCH net 3/3] devlink: make room for many nested instances in a dev message Przemek Kitszel
@ 2026-12-02 12:54 ` netdev-bot+sinfo
3 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-12-02 12:54 UTC (permalink / raw)
To: Przemek Kitszel
Cc: netdev, pabeni, willemb, donald.hunter, jiri, intel-wired-lan,
anthony.l.nguyen, davem, edumazet, kuba, horms, andrew+netdev,
Petr Oros
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count
2026-12-02 12:48 ` [PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count Przemek Kitszel
@ 2026-12-03 13:31 ` netdev-bot+sashiko
0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 13:31 UTC (permalink / raw)
To: przemyslaw.kitszel
Cc: netdev, pabeni, willemb, donald.hunter, jiri, intel-wired-lan,
anthony.l.nguyen, davem, edumazet, kuba, horms, andrew+netdev,
poros
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 (2) · Medium: 0 · Low: 0
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] The patch serializes ice_sriov_set_msix_vec_count() against
resets of the target VF only.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it is a memory
corruption bug on the same function's error path.
- [High] This problem wasn't introduced by this patch, but it is a NULL-
pointer oops on the error path the patch now wraps in cfg_lock.
--
ice: lock VF config while changing its MSI-X vector count
This patch holds vf->cfg_lock for the whole of
ice_sriov_set_msix_vec_count(). That serializes the VF VSI rebuild and
the rewrite of its queue and interrupt mappings against PF-initiated
resets of the same VF, such as ndo_set_vf_mac(). It fixes a NULL pointer
dereference in ice_free_q_vector() that shows up when the MSI-X count and
the VF MAC are changed at the same time.
Closes: https://lore.kernel.org/netdev/20261126094321.40071-1-poros@redhat.com
> diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
> index c49f48b5ae38c..5916cf7bf914e 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sriov.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
> @@ -957,14 +957,18 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
> if (!vf)
> return -ENOENT;
>
> + mutex_lock(&vf->cfg_lock);
> +
[Severity: High]
This serializes against resets of the target VF. Does it leave the same
race open for every other VF?
With only vf->cfg_lock held, ice_sriov_set_msix_vec_count() then calls
ice_sriov_remap_vectors(pf, vf->vf_id). That function reconfigures every
other VF that does not have ICE_VF_STATE_ACTIVE set:
ice_sriov_remap_vectors() {
ice_for_each_vf(pf, bkt, tmp_vf) {
...
ice_dis_vf_mappings(tmp_vf);
ice_virt_free_irqs(pf, tmp_vf->first_vector_idx,
tmp_vf->num_msix);
...
}
for (int i = 0; i < to_remap; i++) {
...
tmp_vf->first_vector_idx =
ice_virt_get_irqs(pf, tmp_vf->num_msix);
...
ice_ena_vf_mappings(tmp_vf);
...
}
}
None of this holds tmp_vf->cfg_lock. The ice_for_each_vf() walk also
does not hold pf->vfs.table_lock, which ice_for_each_vf() documents as
required.
Meanwhile the PF can reset that other VF under its own cfg_lock, for
example with "ip link set $PF vf 1 mac ...":
__ice_set_vf_mac()
ice_reset_vf()
ice_vf_reconfig_vsi()
ice_vsi_decfg()
ice_vsi_free_arrays()
devm_kfree(dev, vsi->txq_map);
vsi->txq_map = NULL;
Can the remap path then reach
ice_ena_vf_mappings(tmp_vf)->ice_ena_vf_q_mappings() and dereference a
NULL or freed vsi->txq_map[0]?
The window looks wide. ice_fltr_remove_all() and ice_vsi_cfg() both issue
AdminQ commands before the arrays are allocated again.
The ICE_VF_STATE_ACTIVE filter also does not seem to exclude VFs that are
in the middle of a reset. ice_trigger_vf_reset() clears the bit at the
start of every reset:
clear_bit(ICE_VF_STATE_ACTIVE, vf->vf_states);
So the remap can also pick up a VF that has a driver bound, while that VF
is being reset.
Separately, the remap rewrites tmp_vf->first_vector_idx while the reset
path's ice_sriov_post_vsi_rebuild()->ice_ena_vf_mappings() programs
VPINT_ALLOC and GLINT_VECT2FUNC from that same field. Could the HW vector
routing end up disagreeing with the irq bitmap?
Here the PCI core holds only device_lock() of the PF and of the target
VF. The reset of the other VF holds rtnl, that VF's cfg_lock and
pf->lag_mutex. The two paths share no lock.
Would it make sense to also take the cfg_lock of each remapped VF? Taking
table_lock and then cfg_lock would match the order used in
ice_reset_all_vfs() and ice_free_vfs(). The other option is to not touch
other VFs here at all.
[ ... ]
> @@ -1012,6 +1017,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
>
> vf->first_vector_idx = ice_virt_get_irqs(pf, vf->num_msix);
> if (vf->first_vector_idx < 0) {
> + mutex_unlock(&vf->cfg_lock);
> ice_put_vf(vf);
> return -EINVAL;
> }
[Severity: High]
This is a pre-existing issue and was not introduced by this patch. What
state is the VF left in when this fallback ice_virt_get_irqs() fails?
The function returns -EINVAL and leaves things as follows:
- vf->first_vector_idx is -ENOENT
- VPINT_ALLOC and VPINT_ALLOC_PCI are cleared
- GLINT_VECT2FUNC has been handed back to the PF
- the VSI is still configured
This fallback can fail fairly easily. The old range was freed by
ice_virt_free_irqs() before the remap, and after that either of these can
happen:
- ice_sriov_remap_vectors() refits the other inactive VFs first-fit, and
one of them moves into the freed region.
- The new range from the first ice_virt_get_irqs(pf, vf->num_msix) lands
on top of the old region. When ice_vsi_rebuild() fails, that range
leaks, because the unroll path overwrites first_vector_idx without
calling ice_virt_free_irqs().
ice_sriov_remap_vectors() has the same unchecked pattern. It stores a
possibly negative ice_virt_get_irqs() result in tmp_vf->first_vector_idx
and then calls ice_ena_vf_mappings(tmp_vf) right away.
>From then on the negative index is used without checks:
- ice_ena_vf_msix_mappings() and ice_dis_vf_mappings() do
wr32(hw, GLINT_VECT2FUNC(v), reg) for negative v.
- ice_free_vf_res() writes GLINT_DYN_CTL(i) for negative i.
The next MSI-X change, or ice_free_vfs(), then calls:
void ice_virt_free_irqs(struct ice_pf *pf, u32 index, u32 irqs)
{
bitmap_clear(pf->virt_irq_tracker.bm, index - pf->virt_irq_tracker.base,
irqs);
}
Here index is (u32)-ENOENT. Does bitmap_clear() then write far outside
pf->virt_irq_tracker.bm?
> @@ -1024,6 +1030,7 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
> }
>
> ice_ena_vf_mappings(vf);
> + mutex_unlock(&vf->cfg_lock);
> ice_put_vf(vf);
>
> return -EINVAL;
[Severity: High]
This is also a pre-existing issue that was not introduced by this patch.
Is it safe to call ice_ena_vf_mappings() here when the fallback
ice_vsi_rebuild() just above it may have failed?
The unroll path ignores the return value of that rebuild:
if (needs_rebuild) {
vsi->req_txq = prev_queues;
vsi->req_rxq = prev_queues;
ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT);
}
ice_vsi_rebuild() always runs ice_vsi_decfg() first. That frees the
q_vectors, the rings and txq_map/rxq_map.
If ice_vsi_cfg_def() then fails, its unwind ends in ice_vsi_free_arrays(),
which sets txq_map/rxq_map to NULL. If the coalesce allocation fails
instead, ice_vsi_decfg() runs a second time.
In either case, ice_ena_vf_mappings() programs VPINT_ALLOC and
GLINT_VECT2FUNC for a VF that has no q_vectors. ice_ena_vf_q_mappings()
then writes VPLAN_TXQ_MAPENA and dereferences:
reg = FIELD_PREP(VPLAN_TX_QBASE_VFFIRSTQ_M, vsi->txq_map[0]) |
Can this oops on a NULL vsi->txq_map?
This path only runs after the first rebuild has already failed
(needs_rebuild == true). That usually means queues or memory have run
out, so a second failure seems plausible.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202124956.18277-1-przemyslaw.kitszel%40intel.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net 3/3] devlink: make room for many nested instances in a dev message
2026-12-02 12:48 ` [PATCH net 3/3] devlink: make room for many nested instances in a dev message Przemek Kitszel
@ 2026-12-03 13:31 ` netdev-bot+sashiko
0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-12-03 13:31 UTC (permalink / raw)
To: przemyslaw.kitszel
Cc: netdev, pabeni, willemb, donald.hunter, jiri, intel-wired-lan,
anthony.l.nguyen, davem, edumazet, kuba, horms, andrew+netdev,
poros
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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] In `devlink_nl_get_pre_dumpit()` (net/devlink/dev.c),
`cb->min_dump_alloc` is set to the largest size estimate of any…
--
devlink: make room for many nested instances in a dev message
This commit sizes the DEVLINK_CMD_GET doit reply and the NEW/DEL
notification so they include the handles of all nested devlink instances.
For the dump, it adds a start callback that sets min_dump_alloc to the
largest estimated message size among the instances. It also makes devlink
dumps fail with -EMSGSIZE when an instance does not fit in an empty skb.
Closes: https://lore.kernel.org/netdev/20261126094321.40071-1-poros@redhat.com
> diff --git a/net/devlink/dev.c b/net/devlink/dev.c
> index b7e5aebf13be5..07fad82d9e1c1 100644
> --- a/net/devlink/dev.c
> +++ b/net/devlink/dev.c
> @@ -156,6 +156,21 @@ static int devlink_nl_nested_fill(struct sk_buff *msg, struct devlink *devlink)
> return 0;
> }
>
> +static size_t devlink_nl_dev_msg_size(struct devlink *devlink, size_t size)
> +{
> + unsigned long rel_index;
> + void *unused;
> +
> + xa_for_each(&devlink->nested_rels, rel_index, unused)
> + size += devlink_rel_devlink_handle_size(rel_index);
> + return size;
> +}
> +
> +static size_t devlink_nl_dev_dump_size(struct devlink *devlink)
> +{
> + return devlink_nl_dev_msg_size(devlink, 512);
> +}
> +
[ ... ]
> @@ -240,13 +257,34 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
> return genlmsg_reply(msg, info);
> }
>
> +int devlink_nl_get_pre_dumpit(struct netlink_callback *cb)
> +{
> + struct net *net = sock_net(cb->skb->sk);
> + struct devlink *devlink;
> + unsigned long index;
> +
> + /* no instance lock, the size is only a hint for the first dump skb */
> + devlinks_xa_for_each_registered_get(net, index, devlink) {
> + cb->min_dump_alloc = max(cb->min_dump_alloc,
> + devlink_nl_dev_dump_size(devlink));
> + devlink_put(devlink);
> + }
> + return 0;
> +}
[Severity: Medium]
Can this make "devlink dev show" fail for readers with a page-sized
buffer, in setups where it worked before this patch?
min_dump_alloc ends up as the largest estimate over all instances in the
netns. netlink_dump() then uses it for every skb of the dump, not only the
first one:
net/netlink/af_netlink.c:netlink_dump() {
...
alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);
max_recvmsg_len = READ_ONCE(nlk->max_recvmsg_len);
if (alloc_min_size < max_recvmsg_len) {
alloc_size = max_recvmsg_len;
...
if (!skb) {
alloc_size = alloc_min_size;
...
skb_reserve(skb, skb_tailroom(skb) - alloc_size);
...
}
So once one instance's estimate goes over 4096, every dump skb is sized
above a page. Each skb is packed with as many messages as fit, including
skbs that only carry small instances with no nested devlinks.
The estimate is also noticeably higher than what actually gets put. The
512 byte base in devlink_nl_dev_dump_size() is about 240 bytes more than
the rest of the message (~270 bytes).
devlink_nl_nested_handle_size() always counts a u64 DEVLINK_ATTR_INDEX and
DEVLINK_ATTR_NETNS_ID. The put side looks like this:
net/devlink/devl_internal.h:devlink_nl_put_handle() {
...
if (nla_put_uint(msg, DEVLINK_ATTR_INDEX, devlink->index))
return -EMSGSIZE;
...
}
devlink->index is a u32, so it gets a 4 byte payload.
devlink_nl_put_nested_handle() only adds the netns id when the netns
differs. That is about 12 bytes of slack per same-netns handle.
As a rough example, take an ice PF with about 70 SF devlinks ("auxiliary"
and "ice.sf.N", about 44 bytes per handle). Its real message is about
272 + 44 * 70 = 3350 bytes, which even fit the old NLMSG_DEFAULT_SIZE
buffer. Its estimate is about 512 + 56 * 70 = 4430 bytes.
The SF instances are in the same netns, at about 250 bytes per message. So
about 17 of them get packed into one 4430 byte skb, and iproute2 gets
ENOSPC on the first recv. Before the patch, alloc_size was max_recvmsg_len
(4096) and every message fit.
Would it make sense to raise min_dump_alloc only for the skb that needs
it? Or could the estimate be tightened so it does not cross a page when
the real message does not?
For the larger counts this patch targets (more than ~80 SFs, and later
256 VFs), the devlink_nl_get_doit() reply is now delivered, but it is
larger than a page. So iproute2 gets ENOSPC instead of EMSGSIZE.
The dump also now fails outright. Before, it listed the instances that
come before the large one.
Given the Closes: tag, should the commit message say that iproute2 still
can't show these setups?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202124956.18277-1-przemyslaw.kitszel%40intel.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-12-03 13:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:48 [PATCH net 0/3] ice, devlink: fixes needed for XLVF Przemek Kitszel
2026-12-02 12:48 ` [PATCH net 1/3] ice: move only the valid VF queues on LAG reclaim and reset rebuild Przemek Kitszel
2026-12-02 12:48 ` [PATCH net 2/3] ice: lock VF config while changing its MSI-X vector count Przemek Kitszel
2026-12-03 13:31 ` netdev-bot+sashiko
2026-12-02 12:48 ` [PATCH net 3/3] devlink: make room for many nested instances in a dev message Przemek Kitszel
2026-12-03 13:31 ` netdev-bot+sashiko
2026-12-02 12:54 ` [PATCH net 0/3] ice, devlink: fixes needed for XLVF netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox