LKML Archive on
help / color / mirror / Atom feed
* [Question] Alignment requirement for readX() and writeX()
@ 2021-07-30 16:42 Boqun Feng
  2021-07-30 16:58 ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Boqun Feng @ 2021-07-30 16:42 UTC (permalink / raw)
  To: linux-arch, linux-kernel
  Cc: Miguel Ojeda, Wedson Almeida Filho, Gary Guo, Hector Martin,
	Arnd Bergmann, Linus Walleij


The background is that I'm reviewing Wedson's PR on IoMem for
Rust-for-Linux project:

readX() and writeX() are used to provide Rust code to read/write IO
memory. And I want to find whether we need to check the alignment of the
pointer. I wonder whether the addresses passed to readX() and writeX()
need to be aligned to the size of the accesses (e.g. the parameter of
readl() has to be a 4-byte aligned pointer).

The only related information I get so far is the following quote in

	On many platforms, I/O accesses must be aligned with respect to
	the access size; failure to do so will result in an exception or
	unpredictable results.

Does it mean all readX() and writeX() need to use aligned addresses?
Or the alignment requirement is arch-dependent, i.e. if the architecture
supports and has enabled misalignment load and store, no alignment
requirement on readX() and writeX(), otherwise still need to use aligned

I know different archs have their own alignment requirement on memory
accesses, just want to make sure the requirement of the readX() and
writeX() APIs.

Thanks a lot!


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-02  8:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 16:42 [Question] Alignment requirement for readX() and writeX() Boqun Feng
2021-07-30 16:58 ` Arnd Bergmann
2021-07-30 17:30   ` Boqun Feng
2021-07-30 20:24     ` Arnd Bergmann
2021-07-31  1:51       ` Boqun Feng
2021-08-02  8:37   ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).