From: sashiko-bot@kernel.org
To: "Greg Ungerer" <gerg@linux-m68k.org>
Cc: "Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
linux-can@vger.kernel.org, Frank.Li@kernel.org,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
imx@lists.linux.dev
Subject: Re: [PATCHv2 4/4] m68k: coldfire: fix non-standard readX()/writeX() functions
Date: Wed, 10 Jun 2026 14:27:24 +0000 [thread overview]
Message-ID: <20260610142725.031C31F0089A@smtp.kernel.org> (raw)
In-Reply-To: <20260609142139.1563360-6-gerg@linux-m68k.org>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [High] The transition to asm-generic readX()/writeX() changes the endianness of ColdFire internal IO accesses, breaking unpatched ColdFire drivers.
Pre-existing issues:
- [High] Undefined behavior when shifting 1 by 32 or more using `BIT(ch)` in `mcf_edma_tx_handler`.
- [High] The error interrupt handler incorrectly skips handling high channels and returns `IRQ_NONE` after servicing low channels.
--
commit 25193db3eba89f780b6dc534f2f72e16f3429571
Author: Greg Ungerer <gerg@linux-m68k.org>
m68k: coldfire: fix non-standard readX()/writeX() functions
Remove the local ColdFire definitions of readb()/readw()/readl() and
writeb()/writew()/writel() and use the asm-generic versions of them.
> diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
> index 4f0f34b06e37c..2f12f4ed0da54 100644
> --- a/arch/m68k/include/asm/io_no.h
> +++ b/arch/m68k/include/asm/io_no.h
[ ... ]
> -#define writel writel
> -static inline void writel(u32 value, volatile void __iomem *addr)
> -{
> - if (cf_internalio(addr))
> - __raw_writel(value, addr);
> - else
> - __raw_writel(swab32(value), addr);
> -}
[Severity: High]
Does replacing the local readX()/writeX() with the asm-generic versions
change the endianness of unpatched ColdFire drivers?
The old ColdFire implementation detected internal IO memory using
cf_internalio() and bypassed byte-swapping to provide native big-endian
access. The asm-generic accessors always assume little-endian devices and
perform byte-swapping.
Will unpatched drivers relying on readX()/writeX() for internal IO
(such as spi-coldfire-qspi.c, sdhci-esdhc-mcf.c, or fec_main.c) now read
and write byte-swapped values and malfunction?
[ ... ]
> diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
> index 9e1c6400c77be..4ed0ce644e37e 100644
> --- a/drivers/dma/mcf-edma-main.c
> +++ b/drivers/dma/mcf-edma-main.c
> @@ -21,9 +21,9 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
> unsigned int ch;
> u64 intmap;
>
> - intmap = ioread32(regs->inth);
> + intmap = ioread32be(regs->inth);
> intmap <<= 32;
> - intmap |= ioread32(regs->intl);
> + intmap |= ioread32be(regs->intl);
> if (!intmap)
> return IRQ_NONE;
[Severity: High]
This is a pre-existing issue, but does this shift invoke undefined behavior
for higher channels?
Looking at the loop immediately following this in mcf_edma_tx_handler():
for (ch = 0; ch < mcf_edma->n_chans; ch++) {
if (intmap & BIT(ch)) {
...
On a 32-bit architecture like m68k, BIT(ch) expands to a 32-bit unsigned
long. Since ch can be up to 64, shifting by 32 or more would be undefined,
potentially causing channels 32-63 to be improperly processed or missing
their interrupts entirely.
Should this use BIT_ULL(ch) when testing against the 64-bit intmap?
[ ... ]
> @@ -43,7 +43,7 @@ static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
> struct edma_regs *regs = &mcf_edma->regs;
> unsigned int err, ch;
>
> - err = ioread32(regs->errl);
> + err = ioread32be(regs->errl);
> if (!err)
> return IRQ_NONE;
[Severity: High]
This is a pre-existing issue, but does this early return incorrectly skip
handling high channels?
If regs->errl is zero, it returns IRQ_NONE immediately, ignoring any errors
in regs->errh. This could leave errors in higher channels uncleared.
[ ... ]
> @@ -55,7 +55,7 @@ static irqreturn_t mcf_edma_err_handler(int irq, void *dev_id)
> }
> }
>
> - err = ioread32(regs->errh);
> + err = ioread32be(regs->errh);
> if (!err)
> return IRQ_NONE;
[Severity: High]
This is a pre-existing issue, but does this return the wrong IRQ status if
low channel errors were already handled?
If errl was non-zero (so some errors were handled) but errh is zero,
returning IRQ_NONE here instead of IRQ_HANDLED might incorrectly signal
to the IRQ subsystem that the interrupt wasn't handled at all.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609142139.1563360-6-gerg@linux-m68k.org?part=1
prev parent reply other threads:[~2026-06-10 14:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 14:12 [PATCHv2 0/4] m68k: coldfire: fix non-standard readX()/writeX() functions Greg Ungerer
2026-06-09 14:12 ` [PATCHv2 1/4] net: fec: do not use readl()/writel() for ColdFire Greg Ungerer
2026-06-10 8:05 ` Andrew Lunn
2026-06-09 14:12 ` [PATCHv2 2/4] net: smc91x: do not use readw()/writew() on ColdFire platforms Greg Ungerer
2026-06-09 14:13 ` [PATCHv2 3/4] mmc: sdhci-esdhc-mcf: do not use readl()/writel() on ColdFire Greg Ungerer
2026-06-09 14:13 ` [PATCHv2 4/4] m68k: coldfire: fix non-standard readX()/writeX() functions Greg Ungerer
2026-06-09 15:26 ` Frank Li
2026-06-10 14:27 ` sashiko-bot [this message]
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=20260610142725.031C31F0089A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=gerg@linux-m68k.org \
--cc=imx@lists.linux.dev \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/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