[PATCH V7 2/4] asm-generic/io.h: Add big-endian MMIO accessors
Guntupalli, Manikanta
manikanta.guntupalli at amd.com
Wed Sep 24 03:12:31 PDT 2025
[Public]
Hi,
> -----Original Message-----
> From: Arnd Bergmann <arnd at arndb.de>
> Sent: Wednesday, September 24, 2025 3:16 PM
> To: Guntupalli, Manikanta <manikanta.guntupalli at amd.com>; git (AMD-Xilinx)
> <git at amd.com>; Simek, Michal <michal.simek at amd.com>; Alexandre Belloni
> <alexandre.belloni at bootlin.com>; Frank Li <Frank.Li at nxp.com>; Rob Herring
> <robh at kernel.org>; krzk+dt at kernel.org; Conor Dooley <conor+dt at kernel.org>;
> Przemysław Gaj <pgaj at cadence.com>; Wolfram Sang <wsa+renesas at sang-
> engineering.com>; tommaso.merciai.xr at bp.renesas.com;
> quic_msavaliy at quicinc.com; S-k, Shyam-sundar <Shyam-sundar.S-k at amd.com>;
> Sakari Ailus <sakari.ailus at linux.intel.com>; 'billy_tsai at aspeedtech.com'
> <billy_tsai at aspeedtech.com>; Kees Cook <kees at kernel.org>; Gustavo A. R. Silva
> <gustavoars at kernel.org>; Jarkko Nikula <jarkko.nikula at linux.intel.com>; Jorge
> Marques <jorge.marques at analog.com>; linux-i3c at lists.infradead.org;
> devicetree at vger.kernel.org; linux-kernel at vger.kernel.org; Linux-Arch <linux-
> arch at vger.kernel.org>; linux-hardening at vger.kernel.org
> Cc: Pandey, Radhey Shyam <radhey.shyam.pandey at amd.com>; Goud, Srinivas
> <srinivas.goud at amd.com>; Datta, Shubhrajyoti <shubhrajyoti.datta at amd.com>;
> manion05gk at gmail.com
> Subject: Re: [PATCH V7 2/4] asm-generic/io.h: Add big-endian MMIO accessors
>
> On Wed, Sep 24, 2025, at 10:59, Guntupalli, Manikanta wrote:
> >> From: Arnd Bergmann <arnd at arndb.de>
> >> Sent: Wednesday, September 24, 2025 12:08 AM
> >> To: Guntupalli, Manikanta <manikanta.guntupalli at amd.com>; git
> >> (AMD-Xilinx)
> >
> > From both description and implementation, {read,write}{b,w,l,q}()
> > access little-endian memory and return the result in native endianness:
> ...
> > This works on little-endian CPUs, but on big-endian CPUs the
> > {read,write}{b,w,l,q}() helpers already return data in big-endian
> > format.
>
> > The extra byte swap in io{read,write}*be() therefore corrupts the
> > data, producing little-endian values when big-endian is expected.
>
> > The newly introduced {read,write}{w,l,q}_be() helpers directly access
> > big-endian IO memory and return results in native endianness, avoiding
> > this mismatch.
>
> No, in both your {read,write}{w,l,q}_be() and the existing io{read,write}*be() helpers,
> big-endian platforms end up with an even number of swaps
> (0 or 2), while little-endian platforms have exactly one swap.
>
> The only exception is your {read,write}s{w,l,q}_be() string helpers that are wrong
> because they have an extra swap and are broken on FIFO registers in little-endian
> kernels.
We have performed our validation on little-endian kernels, and in our testing, the helpers worked correctly without any issues.
Thanks,
Manikanta.
More information about the linux-i3c
mailing list