From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Arnd Bergmann <arnd@arndb.de>, Heiko Carstens <hca@linux.ibm.com>,
Danilo Krummrich <dakr@kernel.org>,
Gerd Bayer <gbayer@linux.ibm.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
driver-core@lists.linux.dev,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Sven Schnelle" <svens@linux.ibm.com>,
linux-s390@vger.kernel.org,
Linux-Arch <linux-arch@vger.kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
rust-for-linux@vger.kernel.org
Subject: Re: `io{re,un}map()` build error in s390 under `!CONFIG_HAS_IOMEM`
Date: Thu, 06 Aug 2026 15:25:50 +0200 [thread overview]
Message-ID: <2aaf01a4417cea313ce0cce7cfdbec65d350a41f.camel@linux.ibm.com> (raw)
In-Reply-To: <f2002ee7-00a4-4a3f-a516-409886b724ab@app.fastmail.com>
On Wed, 2026-08-05 at 17:56 +0200, Arnd Bergmann wrote:
> On Wed, Aug 5, 2026, at 17:36, Niklas Schnelle wrote:
> > On Tue, 2026-08-04 at 17:52 +0200, Arnd Bergmann wrote:
> > > On Tue, Aug 4, 2026, at 14:21, Niklas Schnelle wrote:
> > > - On PCI MMIO areas, memremap() and memremap_wt() should return a
> > > normal kernel pointer that can be dereferenced, e.g. for
> > > option ROM contents for a framebuffer console. This can't work
> > > on non-MIO guests but might work on MIO depending on which
> > > instructions are allowed those mappings (I can never quite
> > > remember how this part works on z, does this have to use
> > > pcistgi or does a normal aligned load/store work as well?).
> >
> > You still have to use pcistgi/pcilgi/pcistbi normal aligned
> > loads/stores will fail as the physical address is beyond the memory
> > limit. On the other hand the PCI instructions can't access normal
> > memory. So you when using memremap() you'd have to know which kind of
> > memory you're remapping and use the right accessors.
>
> Ok, so memremap() by definition cannot work on s390 for regular
> PCI devices, since you are not allowed to use readl() etc on a
> kernel pointer returned by memremap(), only on an __iomem
> token returned by ioremap().
>
> One important exception seems to be virtio_fs, which uses
> devm_memremap_pages() to map a virtio_shm_region, which in
> turn can come from a virtio-pci device but is backed by
> actual cached memory in the host instead of an emulated
> PCI memory BAR.
Interesting, do I see that right that devm_memremap_pages() and
memremap_pages() unlike plain memremap() does not utilize ioremap() and
thus isn't affected by our nopped ioreamp() when there is no-MIO?
>
> > > This would not help with either memremap() or the !CONFIG_HAS_MMIO
> > > issue though, right?
> >
> > I think it would help with memremap() because it would mean that when
> > used on normal memory and accessed with normal loads/stores memremap()
> > works and when used on PCI BAR / MIO addresses and accessed by I/O
> > accessors it would also work. So it should behave the same no matter if
> > memory-I/O is available.
>
> Have you come across any users of memremap() that pass the
> kernel address into readl()/writel() rather than accessing
> them as pointers? This would of course work on arm and x86,
> but is still a violation of the linux/io.h interface definition
> and causes a compile-time warning with sparse. If these exist,
> I think we just need to change them to ioremap().
>
> Arnd
No, I'm not aware of any users of memremap() that would then use
readl()/writel() and I agree they really should be using ioremap() and
the use case doesn't really make sense I was just thinking about what
would technically work with the prototype I have.
Thanks,
Niklas
next prev parent reply other threads:[~2026-08-06 13:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 18:09 `io{re,un}map()` build error in s390 under `!CONFIG_HAS_IOMEM` Miguel Ojeda
2026-08-03 19:56 ` Arnd Bergmann
2026-08-03 20:09 ` Danilo Krummrich
2026-08-04 7:13 ` Heiko Carstens
2026-08-04 10:36 ` Arnd Bergmann
2026-08-04 11:10 ` Danilo Krummrich
2026-08-04 12:02 ` Arnd Bergmann
2026-08-04 12:26 ` Gary Guo
2026-08-05 15:08 ` Danilo Krummrich
2026-08-04 12:21 ` Niklas Schnelle
2026-08-04 15:52 ` Arnd Bergmann
[not found] ` <94c3ebc645e80feae1044a57b8b5c82d4d4ff408.camel@linux.ibm.com>
2026-08-05 15:56 ` Arnd Bergmann
2026-08-06 13:25 ` Niklas Schnelle [this message]
2026-08-06 13:44 ` Arnd Bergmann
2026-08-06 15:21 ` Geert Uytterhoeven
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=2aaf01a4417cea313ce0cce7cfdbec65d350a41f.camel@linux.ibm.com \
--to=schnelle@linux.ibm.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=agordeev@linux.ibm.com \
--cc=aliceryhl@google.com \
--cc=arnd@arndb.de \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=borntraeger@linux.ibm.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gbayer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.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