Thread (12 messages) 12 messages, 3 authors, 2026-01-30

Re: [PATCH v2 1/3] arm64: Fix non-atomic __READ_ONCE() with CONFIG_LTO=y

From: Marco Elver <elver@google.com>
Date: 2026-01-29 01:33:18
Also in: lkml, llvm, stable

On Thu, 29 Jan 2026 at 02:21, Boqun Feng [off-list ref] wrote:
On Thu, Jan 29, 2026 at 01:52:32AM +0100, Marco Elver wrote:
quoted
The implementation of __READ_ONCE() under CONFIG_LTO=y incorrectly
qualified the fallback "once" access for types larger than 8 bytes,
which are not atomic but should still happen "once" and suppress common
compiler optimizations.

The cast `volatile typeof(__x)` applied the volatile qualifier to the
pointer type itself rather than the pointee. This created a volatile
pointer to a non-volatile type, which violated __READ_ONCE() semantics.

Fix this by casting to `volatile typeof(*__x) *`.
I guess a `volatile typeof(x) *` also works. Either way, good catch!
x might expand to some big expression, so better to refer to it only
once, and then use the same-typed *__x as a proxy. Semantically the
same, but compile-times ought to be better this way.
Reviewed-by: Boqun Feng <boqun@kernel.org>
Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help