From: Arnd Bergmann <arnd@xxxxxxxx> The get_unaligned()/put_unaligned() helpers are traditionally architecture specific, with the two main variants being the "access-ok.h" version that assumes unaligned pointer accesses always work on a particular architecture, and the "le-struct.h" version that casts the data to a byte aligned type before dereferencing, for architectures that cannot always do unaligned accesses in hardware. Based on the discussion linked below, it appears that the access-ok version is not realiable on any architecture, but the struct version probably has no downsides. This series changes the code to use the same implementation on all architectures, addressing the few exceptions separately. I've pushed the patches to the asm-generic git tree for testing. Arnd Link: https://lore.kernel.org/lkml/75d07691-1e4f-741f-9852-38c0b4f520bc@xxxxxxxxxxxx/ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100363 Link: git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git unaligned-rework Arnd Bergmann (12): asm-generic: use asm-generic/unaligned.h for most architectures openrisc: always use unaligned-struct header sh: remove unaligned access for sh4a m68k: select CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS powerpc: use linux/unaligned/le_struct.h on LE power7 asm-generic: unaligned: remove byteshift helpers asm-generic: unaligned always use struct helpers partitions: msdos: fix one-byte get_unaligned() apparmor: use get_unaligned() only for multi-byte words mwifiex: re-fix for unaligned accesses netpoll: avoid put_unaligned() on single character asm-generic: simplify asm/unaligned.h arch/alpha/include/asm/unaligned.h | 12 -- arch/arm/include/asm/unaligned.h | 27 --- arch/ia64/include/asm/unaligned.h | 12 -- arch/m68k/Kconfig | 1 + arch/m68k/include/asm/unaligned.h | 26 --- arch/microblaze/include/asm/unaligned.h | 27 --- arch/mips/crypto/crc32-mips.c | 2 +- arch/openrisc/include/asm/unaligned.h | 47 ----- arch/parisc/include/asm/unaligned.h | 6 +- arch/powerpc/include/asm/unaligned.h | 22 --- arch/sh/include/asm/unaligned-sh4a.h | 199 -------------------- arch/sh/include/asm/unaligned.h | 13 -- arch/sparc/include/asm/unaligned.h | 11 -- arch/x86/include/asm/unaligned.h | 15 -- arch/xtensa/include/asm/unaligned.h | 29 --- block/partitions/ldm.h | 2 +- block/partitions/msdos.c | 2 +- drivers/net/wireless/marvell/mwifiex/pcie.c | 10 +- include/asm-generic/unaligned.h | 149 ++++++++++++--- include/linux/unaligned/access_ok.h | 68 ------- include/linux/unaligned/be_byteshift.h | 71 ------- include/linux/unaligned/be_memmove.h | 37 ---- include/linux/unaligned/be_struct.h | 37 ---- include/linux/unaligned/generic.h | 115 ----------- include/linux/unaligned/le_byteshift.h | 71 ------- include/linux/unaligned/le_memmove.h | 37 ---- include/linux/unaligned/le_struct.h | 37 ---- include/linux/unaligned/memmove.h | 46 ----- net/core/netpoll.c | 4 +- security/apparmor/policy_unpack.c | 2 +- 30 files changed, 137 insertions(+), 1000 deletions(-) delete mode 100644 arch/alpha/include/asm/unaligned.h delete mode 100644 arch/arm/include/asm/unaligned.h delete mode 100644 arch/ia64/include/asm/unaligned.h delete mode 100644 arch/m68k/include/asm/unaligned.h delete mode 100644 arch/microblaze/include/asm/unaligned.h delete mode 100644 arch/openrisc/include/asm/unaligned.h delete mode 100644 arch/powerpc/include/asm/unaligned.h delete mode 100644 arch/sh/include/asm/unaligned-sh4a.h delete mode 100644 arch/sh/include/asm/unaligned.h delete mode 100644 arch/sparc/include/asm/unaligned.h delete mode 100644 arch/x86/include/asm/unaligned.h delete mode 100644 arch/xtensa/include/asm/unaligned.h delete mode 100644 include/linux/unaligned/access_ok.h delete mode 100644 include/linux/unaligned/be_byteshift.h delete mode 100644 include/linux/unaligned/be_memmove.h delete mode 100644 include/linux/unaligned/be_struct.h delete mode 100644 include/linux/unaligned/generic.h delete mode 100644 include/linux/unaligned/le_byteshift.h delete mode 100644 include/linux/unaligned/le_memmove.h delete mode 100644 include/linux/unaligned/le_struct.h delete mode 100644 include/linux/unaligned/memmove.h Cc: Amitkumar Karwar <amitkarwar@xxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> Cc: Borislav Petkov <bp@xxxxxxxxx> Cc: Eric Dumazet <edumazet@xxxxxxxxxx> Cc: Florian Fainelli <f.fainelli@xxxxxxxxx> Cc: Ganapathi Bhat <ganapathi017@xxxxxxxxx> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Jakub Kicinski <kuba@xxxxxxxxxx> Cc: James Morris <jmorris@xxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: John Johansen <john.johansen@xxxxxxxxxxxxx> Cc: Jonas Bonn <jonas@xxxxxxxxxxxx> Cc: Kalle Valo <kvalo@xxxxxxxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxx> Cc: Rich Felker <dalias@xxxxxxxx> Cc: "Richard Russon (FlatCap)" <ldm@xxxxxxxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: "Serge E. Hallyn" <serge@xxxxxxxxxx> Cc: Sharvari Harisangam <sharvari.harisangam@xxxxxxx> Cc: Stafford Horne <shorne@xxxxxxxxx> Cc: Stefan Kristiansson <stefan.kristiansson@xxxxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Vladimir Oltean <vladimir.oltean@xxxxxxx> Cc: Xinming Hu <huxinming820@xxxxxxxxx> Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx> Cc: x86@xxxxxxxxxx Cc: linux-kernel@xxxxxxxxxxxxxxx Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx Cc: linux-m68k@xxxxxxxxxxxxxxxxxxxx Cc: linux-crypto@xxxxxxxxxxxxxxx Cc: openrisc@xxxxxxxxxxxxxxxxxxxx Cc: linuxppc-dev@xxxxxxxxxxxxxxxx Cc: linux-sh@xxxxxxxxxxxxxxx Cc: sparclinux@xxxxxxxxxxxxxxx Cc: linux-ntfs-dev@xxxxxxxxxxxxxxxxxxxxx Cc: linux-block@xxxxxxxxxxxxxxx Cc: linux-wireless@xxxxxxxxxxxxxxx Cc: netdev@xxxxxxxxxxxxxxx Cc: linux-arch@xxxxxxxxxxxxxxx Cc: linux-security-module@xxxxxxxxxxxxxxx -- 2.29.2