From patchwork Fri May 14 10:00:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 438827 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp190819jam; Fri, 14 May 2021 03:02:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxDFSY+D9DFRriZyRb/NILOfHRbx8OqZzK2qxM6O6kaaBbRoiIQv/2OCBzNTCEDib4fCc5 X-Received: by 2002:a17:906:dd2:: with SMTP id p18mr48261320eji.513.1620986533819; Fri, 14 May 2021 03:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620986533; cv=none; d=google.com; s=arc-20160816; b=05dukE9vwEPTC7OJmMPSLXVYk2fne3EfQT41yu1k81uWFKWeIkKPC5PqaXL9oeX/XO L30NBpVZWvxLf2CefiON9t7QEX79g//h/jtG6/00b+eLsugyXGfxDRDldvZ5dvdYX2Is 5P2UCqlnfkB42/viH/Ov4yupyecKBzFSi1sk6PCEkeTMwSPqjSDdmKOLwx6EK3Ih0wDB zhauGMfkEYV6R0vGLssvtFFS4F6PUb4WNQluwwhAuIykqK83YMd5veb3MSqb3gsZ3m5C t0OLWlm/+M7Q9Atorx3gjAxkgzOmDrrwIq7X/3So8Z2Pf+a63qU1kFcXozs48h4/4/5h yBiQ== 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=wQ1du5lXC0ZDOffqaeRItw48MYNwT8vkPo0Sp8/gzR4=; b=e2pE0YnnhA5C/pbDx+M5bu2lFc+9bO/fjWMm35euZpFnVMp8FotD7zMZj6BexDltDc fSDSfJbwt6cvL9hVxE6ooWJGYNqOeXxYkb3gzEqjQbzLibE1mFCKtnKntcpWOJmq9KDk INqeL++VzoOoDLGI5QeldhRmLkj3QdZYVibPA78gKDmIJjcJvEdA5plTUTDgQ93H0rWs YPbfE17b6gjH1LOhX3enYqWcyrQ0n6wFVfzbxpfe4i8mKBJZsxJ+u+WVOBk7KBhtJLln KRU+bLonEXTaTGNBctsoC7UXWBUx0V7IG7kFgJR4biRPWHe7AM5iMp0BPkJlwWIcBeW3 bKUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iCIXGblw; 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 s13si6098803edr.479.2021.05.14.03.02.13; Fri, 14 May 2021 03:02: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=iCIXGblw; 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 S232078AbhENKDS (ORCPT + 3 others); Fri, 14 May 2021 06:03:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:58672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbhENKDR (ORCPT ); Fri, 14 May 2021 06:03:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CB4D2613BC; Fri, 14 May 2021 10:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620986526; bh=GrjPHc36lucdUSuooC9aqhL2Od7+jfK0fPUigqnZcVA=; h=From:To:Cc:Subject:Date:From; b=iCIXGblwqBis0HCCaKglHVxXgHdjY+ZnJUEpxhS25qd0YTOmPIMwFqlt0gAwqFaCn H6TYlYBWCxImWVPxQaXnme+hpROYqMTCLF2Ei6uKrfHadRhs+ayz5bA3lk5FtTeO/J kbiLtSut3lU229IM7sF582cRjJivSN3xcEhAoo9aZUac6zWidfJ8NHVAJjY3Rp7yEE dYKIekHBKs/JVyWBTb6nx0reJMz2nGFhAf8LBgLNfsP72b9qNOGH6t05d70F9GjPY+ 8sZc7aQR/6sMfmjSb+dYlYAWu/wuLtjPqPhcgnm4RJEAMEiB7smvyJnpuMYADmfYdd sGrgg1bm/9cMA== 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: [PATCH v2 00/13] Unify asm/unaligned.h around struct helper Date: Fri, 14 May 2021 12:00:48 +0200 Message-Id: <20210514100106.3404011-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 included this version in the asm-generic tree for 5.14 already, addressing the few issues that were pointed out in the RFC. If there are any remaining problems, I hope those can be addressed as follow-up patches. 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: https://lore.kernel.org/lkml/20210507220813.365382-14-arnd@kernel.org/ Link: git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git unaligned-rework-v2 Arnd Bergmann (13): 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: uaccess: 1-byte access is always aligned 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/uaccess.h | 4 +- include/asm-generic/unaligned.h | 141 +++++++++++--- 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 +- 31 files changed, 131 insertions(+), 1002 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 -- 2.29.2 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