Netdev List
 help / color / mirror / Atom feed
From: "Wei Fang (OSS)" <wei.fang@oss.nxp.com>
To: "sashiko-reviews@lists.linux.dev" <sashiko-reviews@lists.linux.dev>
Cc: "Frank.Li@kernel.org" <Frank.Li@kernel.org>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	Netdev <netdev@vger.kernel.org>
Subject: RE: [PATCH v3 net-next 07/15] net: enetc: add .ndo_set_vf_mac() to the enetc v4 driver
Date: Tue, 1 Sep 2026 06:59:28 +0000	[thread overview]
Message-ID: <GV2PR04MB117398E89D7F46740F76A8AD788A82@GV2PR04MB11739.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20260901032358.067311F000E9@smtp.kernel.org>

> Pre-existing issues:
> - [High] Asymmetrical MAC address register access between set and get
> functions for the PF (si == 0), causing the bootloader's MAC address to be
> ignored and overwritten.
> --
> 
> commit 7332ce3a436cebfb9b0a304898ec0b592d1b0ff9
> Author: Wei Fang <wei.fang@nxp.com>
> 
> net: enetc: add .ndo_set_vf_mac() to the enetc v4 driver
> 
> Add .ndo_set_vf_mac() to the enetc v4 driver to configure the MAC
> addresses of VFs.
> 
> > diff --git a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> > index 17fd9ee27942f..eeb70feeb7737 100644
> > --- a/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> > +++ b/drivers/net/ethernet/freescale/enetc/enetc4_pf.c
> > @@ -579,6 +579,7 @@ static const struct net_device_ops enetc4_ndev_ops
> = {
> >  	.ndo_hwtstamp_get	= enetc_hwtstamp_get,
> >  	.ndo_hwtstamp_set	= enetc_hwtstamp_set,
> >  	.ndo_set_vf_trust	= enetc_pf_set_vf_trust,
> > +	.ndo_set_vf_mac		= enetc_pf_set_vf_mac,
> >  };
> 
> [Severity: High]
> This is a pre-existing issue, but while reviewing the MAC address handling in
> this file, I noticed an asymmetrical register access between the set and get
> functions for the PF (when si == 0).
> 
> In enetc4_pf_get_si_primary_mac(), the code unconditionally reads from
> PSIPMAR0:
> 
>     upper = __raw_readl(hw->port + ENETC4_PSIPMAR0(si));
>     lower = __raw_readl(hw->port + ENETC4_PSIPMAR1(si));
> 
> However, the set function enetc4_pf_set_si_primary_mac() correctly writes
> to ENETC4_PMAR0 for si == 0.
> 
> Does this cause the PF (si == 0) to fail to read the primary MAC address
> configured by the bootloader or firmware during enetc4_pf_init()?
> 
> Since enetc_setup_mac_addresses() calls enetc_get_si_hw_addr(), wouldn't this
> read from the wrong register, assume no MAC is present, and generate a
> random
> MAC address that overwrites the bootloader's MAC address?
> 

This is a false positive. For the PF (SI 0), PSIPMAR0/1(0) are read only
registers, the MAC address of PF should be configured by PMAR0/1
registers. The values in PMAR0/1 are reflected in PSIPMAR0/1(0), so
the driver can get the MAC address from PSIPMAR0/1(0).


  parent reply	other threads:[~2026-09-01  6:59 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) [this message]
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
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=GV2PR04MB117398E89D7F46740F76A8AD788A82@GV2PR04MB11739.eurprd04.prod.outlook.com \
    --to=wei.fang@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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