All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/4] Switch get/put unaligned to use memcpy
@ 2025-10-16 20:51 Ian Rogers
  2025-10-16 20:51 ` [PATCH v5 1/4] parisc: Inline a type punning version of get_unaligned_le32 Ian Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 37+ messages in thread
From: Ian Rogers @ 2025-10-16 20:51 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller, Andy Lutomirski,
	Thomas Gleixner, Vincenzo Frascino, Ian Rogers,
	Arnaldo Carvalho de Melo, linux-parisc, linux-kernel,
	Eric Biggers, Al Viro, Christophe Leroy, Jason A. Donenfeld

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 was not true in the
tools directory until this patch from Eric Biggers <ebiggers@google.com>:
https://lore.kernel.org/lkml/20250625202311.23244-2-ebiggers@kernel.org/

Requiring -fno-strict-aliasing seems unfortunate and so this patch
makes the unaligned code work via memcpy rather than type punning with
the packed attribute.

v5: add a patch to make parisc still use a punned version of
    get_unaligned_le32 for an unusual boot case they have. This is
    untested but suggested as necessary by:
    https://lore.kernel.org/lkml/202509051042.7KOze0fZ-lkp@intel.com/
    I wasn't clear if this work was picked up, but I don't see it in
    v6.18-rc1 and so I'm resending rebased as v5.

v4: switch the type/expression variable __get_unaligned_ctrl_type that
    is used by _Generic to be a pointer to avoid 0 vs NULL usage
    warnings - always use NULL and dereference the type. This should
    also hopefully address analysis bots complaints.

v3: switch to __unqual_scalar_typeof, reducing the code, and use an
    uninitialized variable rather than a cast of 0 to try to avoid a
    sparse warning about not using NULL. The code is trying to
    navigate a minefield of uninitialized and casting warnings,
    hopefully the best balance has been struck, but the code will fail
    for cases like:
    const void *val = get_unaligned((const void * const *)ptr);
    due to __unqual_scalar_typeof leaving the 2nd const of the cast in
    place. Thankfully no code does this - tested with an
    allyesconfig. Support would be achievable by using void* as a
    default case in __unqual_scalar_typeof, it just doesn't seem worth
    it for a fairly unusual const case.

v2: switch memcpy to __builtin_memcpy to avoid potential/disallowed
    memcpy calls in vdso caused by -fno-builtin. Reported by
    Christophe Leroy <christophe.leroy@csgroup.eu>:
    https://lore.kernel.org/lkml/c57de5bf-d55c-48c5-9dfa-e2fb844dafe9@csgroup.eu/

Ian Rogers (4):
  parisc: Inline a type punning version of get_unaligned_le32
  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

 arch/parisc/boot/compressed/misc.c   | 15 +++++++++-
 include/vdso/unaligned.h             | 41 ++++++++++++++++++++++++----
 tools/include/linux/compiler_types.h | 22 +++++++++++++++
 tools/include/linux/unaligned.h      |  4 ---
 tools/include/vdso/unaligned.h       | 41 ++++++++++++++++++++++++----
 5 files changed, 106 insertions(+), 17 deletions(-)

-- 
2.51.0.858.gf9c4a03a3a-goog


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2026-10-20 21:20 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 20:51 [PATCH v5 0/4] Switch get/put unaligned to use memcpy Ian Rogers
2025-10-16 20:51 ` [PATCH v5 1/4] parisc: Inline a type punning version of get_unaligned_le32 Ian Rogers
2026-01-13 13:47   ` [tip: timers/vdso] parisc: Inline a type punning version of get_unaligned_le32() tip-bot2 for Ian Rogers
2026-01-14  8:01   ` tip-bot2 for Ian Rogers
2025-10-16 20:51 ` [PATCH v5 2/4] vdso: Switch get/put unaligned from packed struct to memcpy Ian Rogers
2025-10-17 11:40   ` kernel test robot
2025-10-19 17:24   ` David Laight
2026-01-13 13:47   ` [tip: timers/vdso] vdso: Switch get/put_unaligned() from packed struct to memcpy() tip-bot2 for Ian Rogers
2026-01-14  8:01   ` tip-bot2 for Ian Rogers
2026-09-28 15:39   ` [Regression] [PATCH v5 2/4] vdso: Switch get/put unaligned from packed struct to memcpy Stefan Kerkmann
2026-09-28 15:58     ` Ian Rogers
2026-10-06 12:31     ` Marc Kleine-Budde
2026-10-07 10:59       ` Arnd Bergmann
2026-10-09 21:28         ` Ian Rogers
2026-10-10 10:26           ` Christophe Leroy (CS GROUP)
2026-10-10 12:20             ` Ian Rogers
2026-10-10 14:06           ` Arnd Bergmann
2026-10-10 15:04             ` Ian Rogers
2026-10-19 12:37               ` Marc Kleine-Budde
2026-10-19 15:10                 ` Ian Rogers
2026-10-19 16:27                   ` Arnd Bergmann
2026-10-19 17:04                     ` Ian Rogers
2026-10-19 21:00                       ` Arnd Bergmann
2026-10-19 21:14                         ` Ian Rogers
2026-10-19 22:05                           ` Arnd Bergmann
2026-10-20 16:21                             ` Ian Rogers
2026-10-20 19:27                               ` David Laight
2026-10-20 21:20                                 ` David Laight
2026-10-20  8:36                     ` David Laight
2026-10-20  8:41                       ` Arnd Bergmann
2026-10-20 10:01                         ` David Laight
2025-10-16 20:51 ` [PATCH v5 3/4] tools headers: Update the linux/unaligned.h copy with the kernel sources Ian Rogers
2026-01-13 13:47   ` [tip: timers/vdso] " tip-bot2 for Ian Rogers
2026-01-14  8:01   ` tip-bot2 for Ian Rogers
2025-10-16 20:51 ` [PATCH v5 4/4] tools headers: Remove unneeded ignoring of warnings in unaligned.h Ian Rogers
2026-01-13 13:47   ` [tip: timers/vdso] " tip-bot2 for Ian Rogers
2026-01-14  8:01   ` tip-bot2 for Ian Rogers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.