Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wei Fang" <wei.fang@nxp.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v2 net-next 01/12] net: enetc: use enetc_set_si_hw_addr() for setting MAC address
Date: Sat, 30 May 2026 00:46:29 +0000	[thread overview]
Message-ID: <20260530004629.7C1B11F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260522092438.1264020-2-wei.fang@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Hardware registers for MAC address configuration are accessed using `__raw_readl` and `__raw_writel` without endianness conversions, causing incorrect MAC addresses on Big Endian systems.
--

commit 9950ab386f64a0d2f5b71b2003e9ca960d52dddd
Author: Wei Fang <wei.fang@nxp.com>
net: enetc: use enetc_set_si_hw_addr() for setting MAC address

This commit replaces enetc_pf_set_primary_mac_addr() with the generic
enetc_set_si_hw_addr() function to prepare for moving MAC address setting
logic to the common driver for reuse.

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
> index 76263b8566bb3..c30b5f71efd5e 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
[ ... ]
> @@ -7,13 +7,13 @@
>  
>  #include "enetc_pf_common.h"
>  
> -static void enetc_set_si_hw_addr(struct enetc_pf *pf, int si,
> -				 const u8 *mac_addr)
> +void enetc_set_si_hw_addr(struct enetc_pf *pf, int si, const u8 *mac_addr)
>  {
>  	struct enetc_hw *hw = &pf->si->hw;
>  
>  	pf->ops->set_si_primary_mac(hw, si, mac_addr);

[Severity: High]
This is a pre-existing issue, but does the underlying MAC address
configuration code have an endianness bug on Big Endian systems?

Hardware registers for MAC address configuration are accessed using
__raw_readl() and __raw_writel() without endianness conversions.

The code uses get_unaligned_le32() to read the first 4 bytes of the MAC
address into a host-endian u32. For a MAC address starting with 12:34:56:78,
on a Big Endian CPU this creates the u32 value 0x78563412.

It then uses __raw_writel() to write this u32 to the PCIe memory-mapped
register. __raw_writel() performs a raw host-endian memory store without any
byte swapping. On a Big Endian CPU, 0x78563412 is stored in memory as the
byte sequence 0x78, 0x56, 0x34, 0x12.

Since the PCIe controller interprets the MMIO space as Little Endian, it
reads those bytes back as 0x12345678, completely reversing the MAC address
bytes. Could this break network configuration and communication on Big Endian
systems?

The rest of the driver correctly uses iowrite32() and ioread32()
(via enetc_wr() and enetc_rd()), which handle the host-to-LE conversion
properly.

>  }
> +EXPORT_SYMBOL_GPL(enetc_set_si_hw_addr);
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522092438.1264020-1-wei.fang@nxp.com?part=1

  reply	other threads:[~2026-05-30  0:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  9:24 [PATCH v2 net-next 00/12] net: enetc: Prepare for ENETC v4 VF support Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 01/12] net: enetc: use enetc_set_si_hw_addr() for setting MAC address Wei Fang
2026-05-30  0:46   ` sashiko-bot [this message]
2026-05-22  9:24 ` [PATCH v2 net-next 02/12] net: enetc: move VF message handlers to enetc_msg.c Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 03/12] net: enetc: relocate SR-IOV configuration helper for common PF support Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 04/12] net: enetc: integrate enetc_msg.c into enetc-pf-common driver Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 05/12] net: enetc: use read_poll_timeout() for VF mailbox polling Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 06/12] net: enetc: convert mailbox messages to new formats Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 07/12] net: enetc: add VF-PF messaging support for IP minor revision query Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 08/12] net: enetc: align v1 CBDR API with v4 for VF driver sharing Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 09/12] net: enetc: add CBDR setup/teardown hooks to enetc_si_ops for VF support Wei Fang
2026-05-30  0:46   ` sashiko-bot
2026-05-22  9:24 ` [PATCH v2 net-next 10/12] net: enetc: add generic helper to initialize SR-IOV resources Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 11/12] net: enetc: use MADDR_TYPE for MAC filter array size Wei Fang
2026-05-22  9:24 ` [PATCH v2 net-next 12/12] net: enetc: dynamically allocate rxmsg based on VF count Wei Fang
2026-05-25  2:36   ` Wei Fang
2026-05-30  0:46   ` sashiko-bot
2026-05-26 11:30 ` [PATCH v2 net-next 00/12] net: enetc: Prepare for ENETC v4 VF support patchwork-bot+netdevbpf

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=20260530004629.7C1B11F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wei.fang@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