Re: [Regression] [PATCH v5 2/4] vdso: Switch get/put unaligned from packed struct to memcpy
From: Arnd Bergmann
Date: Tue Oct 20 2026 - 04:47:02 EST
On Tue, Oct 20, 2026, at 10:36, David Laight wrote:
>
> Historically it has definitely done that.
> And you can't 'cast away' the alignment implicit in a type.
> The alignment can get tracked into an inlined function.
> Plenty of crashes on sparc32 from that one.
>
> Any structure that might be misaligned in memory better be packed.
>
> But what is actually wrong with using byte access? eg:
> u32 get_le32(u8 *p) { return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; }
> On x86, arm64, ppc (etc) both gcc and clang generate a single memory read
> (byteswapped if necessary).
>
> https://godbolt.org/z/d33hvesr8
IIRC this is one of the versions we had in the past on some architectures,
but the packed struct version ended up being better in some cases and
never worse. It is possible that on new compilers are just as good with this
version, and if someone can show that being true I think we can do
that here as well.
Arnd