[PATCH v2 0/3] Switch get/put unaligned to use memcpy
From: Ian Rogers
Date: Tue Jun 17 2025 - 16:54:57 EST
The existing type punning approach with packed structs requires
-fno-strict-aliasing to be passed to the compiler for
correctness. This is true in the kernel tree but not in the tools
directory resulting in this suggested patch from Eric Biggers
<ebiggers@xxxxxxxxxx>:
https://lore.kernel.org/lkml/20250614044133.660848-2-ebiggers@xxxxxxxxxx/
Requiring -fno-strict-aliasing seems unfortunate and so this patch
makes the unaligned code work via memcpy for type punning rather than
the packed attribute.
v2: switch memcpy to __builtin_memcpy to avoid potential/disallowed
memcpy calls in vdso caused by -fno-builtin. Reported by
Christophe Leroy <christophe.leroy@xxxxxxxxxx>:
https://lore.kernel.org/lkml/c57de5bf-d55c-48c5-9dfa-e2fb844dafe9@xxxxxxxxxx/
Ian Rogers (3):
vdso: Switch get/put unaligned from packed struct to memcpy
tools headers: Update the linux/unaligned.h copy with the kernel
sources
tools headers: Remove unneeded ignoring of warnings in unaligned.h
include/vdso/unaligned.h | 48 ++++++++++++++++++++++++++++-----
tools/include/linux/unaligned.h | 4 ---
tools/include/vdso/unaligned.h | 48 ++++++++++++++++++++++++++++-----
3 files changed, 84 insertions(+), 16 deletions(-)
--
2.50.0.rc2.701.gf1e915cc24-goog