[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <77978246-11c0-4cea-8a22-26536a78eef1@app.fastmail.com>
Date: Wed, 24 Sep 2025 11:46:09 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Manikanta Guntupalli" <manikanta.guntupalli@....com>,
"git (AMD-Xilinx)" <git@....com>, "Michal Simek" <michal.simek@....com>,
"Alexandre Belloni" <alexandre.belloni@...tlin.com>,
"Frank Li" <Frank.Li@....com>, "Rob Herring" <robh@...nel.org>,
"krzk+dt@...nel.org" <krzk+dt@...nel.org>,
"Conor Dooley" <conor+dt@...nel.org>,
Przemysław Gaj <pgaj@...ence.com>,
"Wolfram Sang" <wsa+renesas@...g-engineering.com>,
"tommaso.merciai.xr@...renesas.com" <tommaso.merciai.xr@...renesas.com>,
"quic_msavaliy@...cinc.com" <quic_msavaliy@...cinc.com>, "S-k,
Shyam-sundar" <Shyam-sundar.S-k@....com>,
"Sakari Ailus" <sakari.ailus@...ux.intel.com>,
"'billy_tsai@...eedtech.com'" <billy_tsai@...eedtech.com>,
"Kees Cook" <kees@...nel.org>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
"Jarkko Nikula" <jarkko.nikula@...ux.intel.com>,
"Jorge Marques" <jorge.marques@...log.com>,
"linux-i3c@...ts.infradead.org" <linux-i3c@...ts.infradead.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Linux-Arch <linux-arch@...r.kernel.org>,
"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>
Cc: "Pandey, Radhey Shyam" <radhey.shyam.pandey@....com>,
"Goud, Srinivas" <srinivas.goud@....com>,
"Datta, Shubhrajyoti" <shubhrajyoti.datta@....com>,
"manion05gk@...il.com" <manion05gk@...il.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@...db.de>
>> Sent: Wednesday, September 24, 2025 12:08 AM
>> To: Guntupalli, Manikanta <manikanta.guntupalli@....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.
Arnd
Powered by blists - more mailing lists