arch/m68k/include/asm/io_no.h | 9 --------- 1 file changed, 9 deletions(-)
Currently for 68000 readl() and friends are broken in that they
return the value from the bus as-is but should be reading a little
endian value and swapping it to big endian.
This was found using virtio-mmio on a 68000 virt machine. virtio-mmio
is little endian even if the emulated machine is big endian. This works
for MMU m68k because the io macros do what is expected there, but if
the kernel was built for nommu it breaks.
Potentially this will break some stuff for nommu non-CF m68k users
but since there are probably 2 or 3 of us in the world I think we
can work it out.
Suggested-by: Arnd Bergmann <arnd@kernel.org>
Link: https://lore.kernel.org/lkml/ada73dc9-edf5-458c-8849-9f9db23ff304@app.fastmail.com/
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
arch/m68k/include/asm/io_no.h | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h
index 516371d5587a..c39db8798ef2 100644
--- a/arch/m68k/include/asm/io_no.h
+++ b/arch/m68k/include/asm/io_no.h
@@ -96,15 +96,6 @@ static inline void writel(u32 value, volatile void __iomem *addr)
__raw_writel(swab32(value), addr);
}
-#else
-
-#define readb __raw_readb
-#define readw __raw_readw
-#define readl __raw_readl
-#define writeb __raw_writeb
-#define writew __raw_writew
-#define writel __raw_writel
-
#endif /* IOMEMBASE */
#if defined(CONFIG_PCI)
--
2.51.0
Hi Daniel, On 4/4/26 12:46, Daniel Palmer wrote: > Currently for 68000 readl() and friends are broken in that they > return the value from the bus as-is but should be reading a little > endian value and swapping it to big endian. > > This was found using virtio-mmio on a 68000 virt machine. virtio-mmio > is little endian even if the emulated machine is big endian. This works > for MMU m68k because the io macros do what is expected there, but if > the kernel was built for nommu it breaks. > > Potentially this will break some stuff for nommu non-CF m68k users > but since there are probably 2 or 3 of us in the world I think we > can work it out. > > Suggested-by: Arnd Bergmann <arnd@kernel.org> > Link: https://lore.kernel.org/lkml/ada73dc9-edf5-458c-8849-9f9db23ff304@app.fastmail.com/ > Signed-off-by: Daniel Palmer <daniel@0x0f.com> > --- > arch/m68k/include/asm/io_no.h | 9 --------- > 1 file changed, 9 deletions(-) > > diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h > index 516371d5587a..c39db8798ef2 100644 > --- a/arch/m68k/include/asm/io_no.h > +++ b/arch/m68k/include/asm/io_no.h > @@ -96,15 +96,6 @@ static inline void writel(u32 value, volatile void __iomem *addr) > __raw_writel(swab32(value), addr); > } > > -#else > - > -#define readb __raw_readb > -#define readw __raw_readw > -#define readl __raw_readl > -#define writeb __raw_writeb > -#define writew __raw_writew > -#define writel __raw_writel > - > #endif /* IOMEMBASE */ > > #if defined(CONFIG_PCI) This change, in this form at least, breaks most of the non-MMU ColdFire targets. Try compiling any of m5208evb, m5249evb, m5272c3, m5275evb, m5307c3 or m5407c3 defconfigs and you get build failures. Targets that do not have a PCI bus and so do not define IOMEMBASE will fail, which is most of them. Maybe something like this might be better. I think this ends up giving you the same result for 68000 nommu targets. diff --git a/arch/m68k/include/asm/io_no.h b/arch/m68k/include/asm/io_no.h index 516371d5587a..b335fd4a18e9 100644 --- a/arch/m68k/include/asm/io_no.h +++ b/arch/m68k/include/asm/io_no.h @@ -33,7 +33,6 @@ #include <asm/byteorder.h> #include <asm/coldfire.h> #include <asm/mcfsim.h> -#endif /* CONFIG_COLDFIRE */ #if defined(IOMEMBASE) /* @@ -126,6 +125,7 @@ static inline void writel(u32 value, volatile void __iomem *addr) #define PCI_IOBASE ((void __iomem *) PCI_IO_PA) #define PCI_SPACE_LIMIT PCI_IO_MASK #endif /* CONFIG_PCI */ +#endif /* CONFIG_COLDFIRE */ #include <asm/kmap.h> #include <asm/virtconvert.h> Regards Greg
Hi Greg, On Tue, 14 Apr 2026 at 21:18, Greg Ungerer <gerg@linux-m68k.org> wrote: > This change, in this form at least, breaks most of the non-MMU ColdFire targets. > Try compiling any of m5208evb, m5249evb, m5272c3, m5275evb, m5307c3 or > m5407c3 defconfigs and you get build failures. Targets that do not have > a PCI bus and so do not define IOMEMBASE will fail, which is most of them. Oof, that's the second time I broke coldfire this week (I broke it trying to make virtio work for m68k in u-boot too). Your patch works for my mc68000 virt and dragonball builds. I will build/boot test nommu CF in QEMU. Thanks, Daniel
On Sat, Apr 4, 2026, at 04:46, Daniel Palmer wrote:
> Currently for 68000 readl() and friends are broken in that they
> return the value from the bus as-is but should be reading a little
> endian value and swapping it to big endian.
>
> This was found using virtio-mmio on a 68000 virt machine. virtio-mmio
> is little endian even if the emulated machine is big endian. This works
> for MMU m68k because the io macros do what is expected there, but if
> the kernel was built for nommu it breaks.
>
> Potentially this will break some stuff for nommu non-CF m68k users
> but since there are probably 2 or 3 of us in the world I think we
> can work it out.
>
> Suggested-by: Arnd Bergmann <arnd@kernel.org>
> Link:
> https://lore.kernel.org/lkml/ada73dc9-edf5-458c-8849-9f9db23ff304@app.fastmail.com/
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
It looks like the non-swapping readl() on nommu-m68k predates
the git history, but apparently the coldfire version was fixed
in 4d5303787627 ("m68k: fix read/write multi-byte IO for PCI
on ColdFire") to behave like everything else, and dragonball
appears does not support ISA or PCI buses, so it never used
them.
Arnd
Hi Arnd,
On Mon, 13 Apr 2026 at 18:52, Arnd Bergmann <arnd@kernel.org> wrote:
> On Sat, Apr 4, 2026, at 04:46, Daniel Palmer wrote:
> > Currently for 68000 readl() and friends are broken in that they
> > return the value from the bus as-is but should be reading a little
> > endian value and swapping it to big endian.
> >
> > This was found using virtio-mmio on a 68000 virt machine. virtio-mmio
> > is little endian even if the emulated machine is big endian. This works
> > for MMU m68k because the io macros do what is expected there, but if
> > the kernel was built for nommu it breaks.
> >
> > Potentially this will break some stuff for nommu non-CF m68k users
> > but since there are probably 2 or 3 of us in the world I think we
> > can work it out.
> >
> > Suggested-by: Arnd Bergmann <arnd@kernel.org>
> > Link:
> > https://lore.kernel.org/lkml/ada73dc9-edf5-458c-8849-9f9db23ff304@app.fastmail.com/
> > Signed-off-by: Daniel Palmer <daniel@0x0f.com>
>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
>
> It looks like the non-swapping readl() on nommu-m68k predates
> the git history, but apparently the coldfire version was fixed
> in 4d5303787627 ("m68k: fix read/write multi-byte IO for PCI
> on ColdFire") to behave like everything else, and dragonball
> appears does not support ISA or PCI buses, so it never used
> them.
Correct. readl() and friends were introduced when it was deemed better
to use accessor functions instead of dereferencing volatile pointers
directly (which is what several m68k drivers are still doing), but
before it was decided that readl() is little endian for PCI everywhere
(there was no PCI on m68k at that point in time). And of course that
was long before the introduction of ioread32be()...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
© 2016 - 2026 Red Hat, Inc.