Re: [PATCH] rwonce: fix crash by removing READ_ONCE() for unaligned read
From: Arnd Bergmann
Date: Thu Mar 27 2025 - 07:00:27 EST
On Thu, Mar 27, 2025, at 01:49, Linus Torvalds wrote:
> On Wed, 26 Mar 2025 at 15:54, Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>>
>> > Put another way: I wonder what other cases may lurk around this all...
>>
>> That change has caused only one issue that I know of, which was fixed by
>> commit d3f450533bbc ("efi: tpm: Avoid READ_ONCE() for accessing the
>> event log"). I have not seen any since then until this point and I do
>> daily boots of -next with LTO enabled on both of my arm64 test machines.
>
> Ahh, ok. That makes me happier.
I've sent a new v2 pull request now.
> I guess unaligned READ_ONCE() code really shouldn't exist in generic
> code anyway, since some architectures will fail any unaligned access.
Even if the unaligned READ_ONCE()/WRITE_ONCE() doesn't fail, it may
be surprising to callers when it is not atomic.
> But those architectures tend to not get a lot of testing (they are a
> dying breed - good riddance), so "shouldn't exist" doesn't necessarily
> equate to really not existing.
Unfortunately, they don't seem to quite die out just yet, as both
riscv and loongarch have gained support for CPUs without unaligned
access even though they started out requiring it:
https://lore.kernel.org/lkml/20231004151405.521596-1-cleger@xxxxxxxxxxxx/
https://lore.kernel.org/lkml/20230202084238.2408516-1-chenhuacai@xxxxxxxxxxx/
ARMv7 also has the annoying behavior of supporting unaligned word
access, but not unaligned multi-word load/store with ldrd/strd
on u64 variables.
Arnd