Re: [Regression] [PATCH v5 2/4] vdso: Switch get/put unaligned from packed struct to memcpy
From: David Laight
Date: Tue Oct 20 2026 - 17:20:49 EST
On Tue, 20 Oct 2026 20:27:44 +0100
David Laight <david.laight.linux@xxxxxxxxx> wrote:
> I suspect it happens less often with __packed.
> You can probably add volatile to stop the other merging.
>
> It really might be necessary to give up on the C versions and use asm()
> (at least for the unaligned access case).
This probably works for unaligned 64bit - and is much better than the code
the compiler generates:
unsigned long get_u64_le(void *s)
{
unsigned long p = (unsigned long)s;
unsigned int shift = 8 * (p & 7);
return *(unsigned long *)(p & ~7) >> shift |
*(unsigned long *)((p + 7) & ~7) << (-shift & 63);
}
For native BE the two shifts need swapping.
Not worth it for 32bit unless the alignment is known.
(And neither gcc nor clang do that for misaligned members in aligned struct.)
>
> David