From: Wei Fang <wei.fang@nxp.com>
To: "netdev-bot+sashiko@kernel.org" <netdev-bot+sashiko@kernel.org>,
"Wei Fang (OSS)" <wei.fang@oss.nxp.com>
Cc: Claudiu Manoil <claudiu.manoil@nxp.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Clark Wang <xiaoning.wang@nxp.com>,
"andrew@lunn.ch" <andrew@lunn.ch>,
"olteanv@gmail.com" <olteanv@gmail.com>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v3 net-next 11/15] net: enetc: restore VF MAC promiscuous mode after FLR for ENETC v4
Date: Fri, 4 Sep 2026 08:40:54 +0000 [thread overview]
Message-ID: <GV2PR04MB11739045BEEE7C80FD95E119988B52@GV2PR04MB11739.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <178847906763.4131868.15039580023572972267@kernel.org>
> > static void enetc_msg_task(struct work_struct *work)
> > {
> > struct enetc_si *si = container_of(work, struct enetc_si, msg_task);
> > @@ -602,6 +642,8 @@ static void enetc_msg_task(struct work_struct *work)
> > u32 mr_status, mr_mask;
> > int i;
> >
> > + enetc_vf_flr_handler(pf);
> > +
>
> [Severity: Medium]
> How long can the SI stay in the hardware promiscuous state before this
> restore runs?
>
> The hardware puts the SI into UC/MC promiscuous mode at the instant of the
> FLR, but the policy is only re-applied from the work item:
>
> enetc_msg_psi_msix() {
> enetc_disable_psiier_interrupts(pf);
> schedule_work(&si->msg_task);
>
> return IRQ_HANDLED;
> }
>
> enetc_msg_task() -> enetc_vf_flr_handler() -> pf->ops->vf_flr_handler()
> -> enetc4_pf_vf_flr_handler()
>
> Since the guest owning the VF triggers the FLR itself (vfio-pci reset, or a
> driver bind path reaching pcie_flr()), it knows exactly when that window
> opens and only needs to re-arm an Rx BD ring to receive frames destined for
> other SIs until enetc4_pf_vf_flr_handler() clears the bits in PSIPMMR.
>
> The scan also happens once, at the top of enetc_msg_task():
>
> enetc_vf_flr_handler(pf);
>
> mr_mask = ENETC_PSIMR_MASK(pf->num_vfs);
>
> and enetc_vf_flr_handler() takes a single PSIIDR snapshot with an early
> return:
>
> flr_status = enetc_rd(hw, ENETC_PSIIDR) & flr_mask;
> if (!flr_status)
> return;
>
> If an FLR lands while msg_task is already part-way through the VF message
> loop, is the restore then delayed until the whole in-flight batch finishes
> and the re-queued work runs? The FLR bits are not re-checked before
> enetc_enable_psiier_interrupts(pf) at the end of the work item.
>
> Would it be feasible to clear PSIPMMR[SIn_MAC_UP]/[SIn_MAC_MP] directly in
> enetc_msg_psi_msix() for the VFs whose FLR bits are set, and leave the full
> policy re-apply in the work item? As written the handler sleeps on
> vf_state->lock and pf->msg_lock, so it cannot run from the hardirq.
>
I don't think this window is worth fixing - the risk is very low and the proposed
change adds complexity for little gain.
First, the exposure is theoretical rather than practically useful. A VF FLR resets
the entire VF function, not just PSIPMMR - the Rx BD rings, SI enable state and
DMA configuration are all reset too. So immediately after the FLR the VF has no
armed Rx ring and cannot receive any frame, promiscuous or not. Before it can
capture anything it must first re-initialize and re-arm an Rx ring, which is not
instantaneous. The promiscuous state is only the reset default and is corrected
by the PF asynchronously; there is no guarantee the VF can bring up a ring and
line it up with that short window to actually sniff another SI's traffic. It cannot
reliably exploit the timing.
Second, under normal conditions the detect-to-restore latency is very short
(interrupt latency plus a workqueue wakeup).
Third, moving the promiscuous-mode clear into enetc_msg_psi_msix() would
not give a real guarantee anyway: the guest owns the FLR trigger, so it can simply
issue another FLR before the workqueue runs and return the SI to the reset-default
promiscuous state. So the hardirq clear does not close the window in any
meaningful sense.
Finally, it would add real complexity. enetc4_pf_vf_flr_handler() accesses
PSIPMMR under vf_state->lock and pf->msg_lock, which are mutexes and
cannot be taken in hardirq context. Doing the clear in the ISR would require
converting the PSIPMMR synchronization to an irq-safe spinlock, which touches
every path that writes PSIPMMR (set_rx_mode, the promisc message handler,
trust-off, clear_vf_config). That is a non-trivial change to the locking model for
a window that is not practically exploitable.
So I'd keep the current design: clear/re-apply the policy from the work item.
No change needed.
next prev parent reply other threads:[~2026-09-04 8:40 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 2:54 [PATCH v3 net-next 00/15] net: enetc: SR-IOV improvements and ENETC v4 VF support wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 01/15] net: enetc: add trusted " wei.fang
[not found] ` <20260901032358.B913A1F00A3D@smtp.kernel.org>
2026-09-01 6:13 ` Wei Fang (OSS)
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 6:29 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 02/15] net: enetc: move msg_task and msg_int_name to struct enetc_si wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 03/15] net: enetc: add link status message support to PF driver wei.fang
2026-08-31 12:00 ` Andrew Lunn
2026-09-01 2:31 ` Wei Fang
2026-09-01 3:05 ` Andrew Lunn
2026-09-01 3:40 ` Wei Fang
[not found] ` <20260901032359.788A11F00A3E@smtp.kernel.org>
2026-09-01 6:46 ` Wei Fang (OSS)
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 7:16 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 04/15] net: enetc: add link speed " wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 7:52 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 05/15] net: enetc: use enetc_set_si_hw_addr() to set VF MAC address wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 06/15] net: enetc: relocate enetc_pf_set_vf_mac() for common PF support wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 07/15] net: enetc: add .ndo_set_vf_mac() to the enetc v4 driver wei.fang
[not found] ` <20260901032358.067311F000E9@smtp.kernel.org>
2026-09-01 6:59 ` Wei Fang (OSS)
2026-08-31 2:54 ` [PATCH v3 net-next 08/15] net: enetc: move mac_filter from struct enetc_pf to struct enetc_si wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 09/15] net: enetc: add MAC address filtering support for VFs of ENETC v4 wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-08-31 2:54 ` [PATCH v3 net-next 10/15] net: enetc: simplify and rename PSIIER enable/disable helpers wei.fang
2026-08-31 2:54 ` [PATCH v3 net-next 11/15] net: enetc: restore VF MAC promiscuous mode after FLR for ENETC v4 wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 8:40 ` Wei Fang [this message]
2026-08-31 2:54 ` [PATCH v3 net-next 12/15] net: enetc: add VF support for i.MX94 and i.MX95 wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 9:05 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 13/15] net: enetc: implement ndo_set_rx_mode_async for ENETC v4 VF wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 9:53 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 14/15] net: enetc: add PSI-to-VSI link status notification support for VF wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-04 10:47 ` Wei Fang
2026-08-31 2:54 ` [PATCH v3 net-next 15/15] net: enetc: add ndo_get_vf_config() support wei.fang
2026-09-03 23:44 ` netdev-bot+sashiko
2026-09-03 2:56 ` [PATCH v3 net-next 00/15] net: enetc: SR-IOV improvements and ENETC v4 VF support Jakub Kicinski
2026-09-03 3:24 ` Wei Fang (OSS)
2026-09-03 23:22 ` Jakub Kicinski
2026-09-04 2:02 ` Wei Fang
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=GV2PR04MB11739045BEEE7C80FD95E119988B52@GV2PR04MB11739.eurprd04.prod.outlook.com \
--to=wei.fang@nxp.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@oss.nxp.com \
--cc=xiaoning.wang@nxp.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