From patchwork Fri May 7 22:07:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 432146 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp702783jao; Fri, 7 May 2021 15:09:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/OGltRFpo5eFtm+Hq2CT4Q/ggRr80GEvIETh0N8mFrKA6VPGndcTy+oMATFF/nt+l4gqe X-Received: by 2002:aa7:d513:: with SMTP id y19mr13854792edq.9.1620425353304; Fri, 07 May 2021 15:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620425353; cv=none; d=google.com; s=arc-20160816; b=C4uFkMUlVKzqOmyO/MZS6PFA0QbNQ7sShG8WKnE2anpX0gleQJaHIo5NXd3+z7nQxJ 16ytBlT4aomrQ0HgDIPB+7pBOQGnTU6hmwcHIfHASyXJzHobmWjVcWpc3Ne0bbo/V6+S faS48aa1MTfaSiTNNCwNgAJDD2QvNk5uapI7XJLAnOfFF4kIeRX/q2rSyLU7KCb66ItY 4DV6C8Ceh2pWYNsSYT/oktRi6sgtBeue5bTgrscIwqh/doHumE2ml+Mnadm+uvZLyYFv Dq9DAM50ajpCNxGczsvId2z5AjoeWShw3m5hEixqLW9UYlPNizMCmqsGXqpRQO7eLZsJ zHzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DLFkeFWqqnqMGk6E8NQ//pG5LCohNbcK3u44FxpBHow=; b=G3B8xpebB16QjYsGZSSRwMdyAdE7VKz+SV+SL0KpgD7+fe7Gr7JRQEycE6nQ8fOgl6 aL4vns6mjmw/6WXIeFe5ADKqjlWAR47Ru38+7avoo4obJ8AQM5yZliROa1LW1HA4OLIm T0wtpoI6OaXq0gpi6C4+apCV0Ijl/qGkw2rJFQRq7OjCJrlC4PqPoaTu5WgW7hSNgAQm JUJjymbDdvCd/naqPadMJ6EGWWRLPUjGaRiYX29zcZRguOMEQWRNM+JQvILJlmIstH9C AGgYRK4BFAYSZf6KYOiuZZrKox47K7ZR0REIKIAbPkbLfCFjUD74NxnkZ45kaky46fk7 /avA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GZ13BdKp; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk3si5971765edb.73.2021.05.07.15.09.13; Fri, 07 May 2021 15:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GZ13BdKp; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbhEGWKF (ORCPT + 3 others); Fri, 7 May 2021 18:10:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbhEGWKE (ORCPT ); Fri, 7 May 2021 18:10:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA33B60BD3; Fri, 7 May 2021 22:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620425342; bh=pLN/AlAGxiGZnqtkHzoskF1g1y+Og1zx70nNd/gvob8=; h=From:To:Cc:Subject:Date:From; b=GZ13BdKpryifxhRwUeXYiDxMV+BWySTA7GY7/CWwvuCWkusUFDxkw2jKiOlfzjbCr So4fZaGkAyPTwA8Q1TjLVhcTwgJc8xvHUXFTKFHcbAkEIqYdWcKh0axCM+T92qoOrQ bkgNUSiGEeKqAdmwuN3qiVKoII2y7FbwOUX6mX301a6kiRL+VhsHKLQbMnh2CNRIHJ HKxjre312EfivKKOz+Q2DN/Jdax+mgS6zOKiXtE7A5jQN2E+WeTOOh+m15wqAaIqSp vmCijYogutqPzDP5KIogDPopYspUOizf4eB1toyhkfcE7uWw2BB6nwUsTEL9hofb0l fr7hse6Wb3kJA== From: Arnd Bergmann To: linux-arch@vger.kernel.org Cc: Linus Torvalds , Vineet Gupta , Arnd Bergmann , Amitkumar Karwar , Benjamin Herrenschmidt , Borislav Petkov , Eric Dumazet , Florian Fainelli , Ganapathi Bhat , Geert Uytterhoeven , "H. Peter Anvin" , Ingo Molnar , Jakub Kicinski , James Morris , Jens Axboe , John Johansen , Jonas Bonn , Kalle Valo , Michael Ellerman , Paul Mackerras , Rich Felker , "Richard Russon (FlatCap)" , Russell King , "Serge E. Hallyn" , Sharvari Harisangam , Stafford Horne , Stefan Kristiansson , Thomas Gleixner , Vladimir Oltean , Xinming Hu , Yoshinori Sato , x86@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-crypto@vger.kernel.org, openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, linux-block@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [RFC 0/12] Unify asm/unaligned.h around struct helper Date: Sat, 8 May 2021 00:07:45 +0200 Message-Id: <20210507220813.365382-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Arnd Bergmann 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@synopsys.com/ 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 Cc: Arnd Bergmann Cc: Benjamin Herrenschmidt Cc: Borislav Petkov Cc: Eric Dumazet Cc: Florian Fainelli Cc: Ganapathi Bhat Cc: Geert Uytterhoeven Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jakub Kicinski Cc: James Morris Cc: Jens Axboe Cc: John Johansen Cc: Jonas Bonn Cc: Kalle Valo Cc: Michael Ellerman Cc: Paul Mackerras Cc: Rich Felker Cc: "Richard Russon (FlatCap)" Cc: Russell King Cc: "Serge E. Hallyn" Cc: Sharvari Harisangam Cc: Stafford Horne Cc: Stefan Kristiansson Cc: Thomas Gleixner Cc: Vladimir Oltean Cc: Xinming Hu Cc: Yoshinori Sato Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-m68k@lists.linux-m68k.org Cc: linux-crypto@vger.kernel.org Cc: openrisc@lists.librecores.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-sh@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linux-ntfs-dev@lists.sourceforge.net Cc: linux-block@vger.kernel.org Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-security-module@vger.kernel.org -- 2.29.2