Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Krzysztof Wilczyński" <kwilczynski@kernel.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH 2/2] PCI/sysfs: Fix read byte order in pci_read_legacy_io()
Date: Tue, 16 Jun 2026 16:36:41 +0000	[thread overview]
Message-ID: <20260616163641.8B87D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616163131.2763281-2-kwilczynski@kernel.org>

> pci_read_legacy_io() passes the sysfs buffer directly to pci_legacy_read():
> 
>   return pci_legacy_read(bus, off, (u32 *)buf, count);
> 
> The PowerPC implementation stores the result as a native-endian integer:
> 
>   *((u16 *)val) = in_le16(addr);
> 
> On big-endian PowerPC this stores the bytes in the wrong order, so
> a 2-byte read of a device register returns different bytes than two
> 1-byte reads at the same addresses.  The same applies to 4-byte
> reads.  On little-endian the native byte order already matches PCI
> I/O port byte order, so the conversion is a no-op.
> 
> Thus, let pci_legacy_read() store into a local u32 variable, then
> copy the I/O port value to the sysfs buffer using put_unaligned_le16()
> and put_unaligned_le32() for the 2 and 4 byte cases, converting from
> the native integer to little-endian byte order matching PCI I/O port
> space.
> 
> No changes are needed for the Alpha platform.
> 
> The legacy_io file is root-only and exists only on Alpha and PowerPC,
> the two architectures that define HAVE_PCI_LEGACY.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260616163131.2763281-1-kwilczynski@kernel.org?part=2


  reply	other threads:[~2026-06-16 16:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16 16:31 [PATCH 1/2] PCI/sysfs: Fix out-of-bounds read in pci_write_legacy_io() Krzysztof Wilczyński
2026-06-16 16:31 ` [PATCH 2/2] PCI/sysfs: Fix read byte order in pci_read_legacy_io() Krzysztof Wilczyński
2026-06-16 16:36   ` sashiko-bot [this message]
2026-06-16 16:42 ` [PATCH 1/2] PCI/sysfs: Fix out-of-bounds read in pci_write_legacy_io() sashiko-bot
2026-06-16 16:47   ` Krzysztof Wilczyński

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=20260616163641.8B87D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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