mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: illusion.wang@nebula-matrix.com
Cc: dimon.zhao@nebula-matrix.com, alvin.wang@nebula-matrix.com,
	sam.chen@nebula-matrix.com, netdev@vger.kernel.org,
	kuba@kernel.org, andrew+netdev@lunn.ch, pabeni@redhat.com,
	edumazet@google.com, horms@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v34 net-next 6/8] net/nebula-matrix: dispatch: add mailbox RPCs for msix map, mailbox irq and vsi/eth id
Date: Mon, 16 Nov 2026 13:54:46 +0000	[thread overview]
Message-ID: <179483728648.3136.14599740534108145269@kernel.org> (raw)
In-Reply-To: <20261112094925.6098-7-illusion.wang@nebula-matrix.com>

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] The new NBL_CHAN_MSG_CONFIGURE_MSIX_MAP responder in
  nbl_disp_chan_cfg_msix_map_resp() (nbl_dispatch.c:286) passes a peer…

--

net/nebula-matrix: dispatch: add mailbox RPCs for msix map, mailbox irq and vsi/eth id

This patch adds request and response handlers for five dispatch
operations: cfg_msix_map, destroy_msix_map, set_mailbox_irq, get_vsi_id
and get_eth_id. A control PF calls the resource ops locally. A has_net PF
forwards them to the management PF over the mailbox channel, where the
new responders run them on the requester's behalf.

> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c b/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c
> index 966fee2dec8b0..cb68544e02723 100644
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_core/nbl_dispatch.c

[ ... ]

> @@ -25,6 +193,353 @@ static int nbl_disp_init_module(struct nbl_dispatch_mgt *disp_mgt)

[ ... ]

> +static void nbl_disp_chan_cfg_msix_map_resp(void *priv, u16 src_id, u16 msg_id,
> +					    void *data, u32 data_len)
> +{

[ ... ]

> +	if (rel_pf_id >= disp_mgt->common->max_pf) {
> +		err = -EPERM;
> +		goto ack_out;
> +	}
> +	if (data_len < sizeof(param)) {
> +		err = -EBADMSG;
> +		goto ack_out;
> +	}
> +	memcpy(&param, data, sizeof(param));
> +
> +	if (res_ops->cfg_msix_map) {
> +		/*
> +		 * The vector counts come from the peer PF.  A peer is
> +		 * trusted: hardware and firmware forbid PF passthrough to
> +		 * guests (see nbl_get_func_param()), so every peer runs this
> +		 * same host driver, and the resource layer bounds the counts
> +		 * by the global vector pool.  A peer asking for the whole
> +		 * pool can starve the others with -EAGAIN, but it cannot
> +		 * corrupt state.
> +		 */
> +		ret = res_ops->cfg_msix_map(p, src_id,
> +					    le16_to_cpu(param.num_net_msix),
> +					    le16_to_cpu(param.num_others_msix),
> +					    !!le16_to_cpu(param.msix_mask_en));

[Severity: Medium]
Can one sibling PF use this responder to drain the shared MSI-X vector
pools?

Before res_ops->cfg_msix_map() runs, the only checks are the rel_pf_id
range and data_len. So num_net_msix and num_others_msix reach
nbl_res_intr_cfg_msix_map() exactly as the peer sent them.

There is no per-function quota in nbl_res_intr_cfg_msix_map() either. Each
count is only capped at NBL_MSIX_MAP_TABLE_MAX_ENTRIES (1024), which is
the same size as the whole NBL_MAX_OTHER_INTERRUPT pool:

drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_interrupt.c:nbl_res_intr_cfg_msix_map() {
    ...
	for (; i < requested; i++) {
		intr_index =
			find_first_zero_bit(intr_mgt->intr_other_bmap,
					    NBL_MAX_OTHER_INTERRUPT);
		if (intr_index == NBL_MAX_OTHER_INTERRUPT) {
			dev_err(dev, "No free control interrupt vectors left\n");
			ret = -EAGAIN;
			goto release_vecs_unlock;
		}
    ...
}

The control PF already holds one vector, so a peer request for 1023
other vectors succeeds. After that, every sibling PF that configures its
map gets -EAGAIN from cfg_msix_map().

With the later "add common dev start/stop operation" patch, that error
makes nbl_dev_start() fail, so the sibling loses its mailbox interrupt
and its probe fails.

The net pool (NBL_MAX_NET_INTERRUPT, 4096) can be drained the same way by
four peers asking for 1024 net vectors each.

A peer can also send reconfiguration requests over and over. Each one
does a kcalloc() and a usleep_range()-based nbl_intr_quiesce_wait(), and
it still holds intr_mgt->lock during the wait.

The comment above trusts peers because "hardware and firmware forbid PF
passthrough to guests (see nbl_get_func_param())". However,
nbl_get_func_param() only selects the control PF:

drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c:nbl_get_func_param() {
    ...
	if ((PCI_FUNC(pdev->devfn) == 0) && !pdev->is_virtfn)
		param->caps.has_ctrl = 1;
}

No software check stops a sibling PF from being bound to another driver
or passed through. The in-tree driver only requests one non-net vector,
so this needs a misbehaving or out-of-tree peer driver. Whether such a
peer can exist depends on the hardware and firmware claim, which the code
does not show either way.

This is the first runtime path from a sibling PF into the control PF's
shared allocator. Would a fair-share cap here help, such as pool size
divided by max_pf, or one reserved other vector for each present PF?

> +		/* Forward the resource errno verbatim to the requester */
> +		if (ret)
> +			err = ret;
> +	} else {
> +		err = -EOPNOTSUPP;
> +	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112094925.6098-1-illusion.wang%40nebula-matrix.com

  reply	other threads:[~2026-11-16 13:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  9:49 [PATCH v34 net-next 0/8] nbl driver for Nebulamatrix NICs illusion.wang
2026-11-12  9:49 ` [PATCH v34 net-next 1/8] net/nebula-matrix: add channel layer illusion.wang
2026-11-12 12:01   ` Breno Leitao
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 2/8] net/nebula-matrix: add common resource implementation illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 3/8] net/nebula-matrix: add intr " illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 4/8] net/nebula-matrix: add chip-wide hardware init/deinit implementation illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 5/8] net/nebula-matrix: dispatch: add control-level routing core infrastructure illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 6/8] net/nebula-matrix: dispatch: add mailbox RPCs for msix map, mailbox irq and vsi/eth id illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko [this message]
2026-11-12  9:49 ` [PATCH v34 net-next 7/8] net/nebula-matrix: add common/ctrl dev init/remove operation illusion.wang
2026-11-16 13:54   ` netdev-bot+sashiko
2026-11-12  9:49 ` [PATCH v34 net-next 8/8] net/nebula-matrix: add common dev start/stop operation illusion.wang
2026-11-16 13:54   ` 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=179483728648.3136.14599740534108145269@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alvin.wang@nebula-matrix.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=dimon.zhao@nebula-matrix.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=illusion.wang@nebula-matrix.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sam.chen@nebula-matrix.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

all inboxes | Powered by JetHome®