From patchwork Tue Jun 30 17:37:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 11634435 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 344CA60D for ; Tue, 30 Jun 2020 17:39:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EB9220775 for ; Tue, 30 Jun 2020 17:39:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="e4BDCEd+"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="AqXudRS2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EB9220775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=2TvnlgeFgBMBAmq8+Y7FMhyK4dfzwD8AS48l4JM8UT4=; b=e4BDCEd+WlmmJhqrL3nvKqQI4s gncajfHLIgtCJHERoHIU0uwa4jt4B10y/wIXJUV1ofxiiUY4bVXSpO/v+K8kN79bhPoEGe2SLaJ3g 3lzjU0L/3QdipRRRMe2RQdA2GLEsx1lpH4JMx0SlK5Q1Xn0dlT/UYfwm8t6R4B0QEIi3r4PjPKB/b vFfQW0WPloW1Xz5yYaZsTZCU3yrTp8ByydkFPW3uZTcSZ4Hb6EBBc7nakMkAe4KE434HGs0pT32BT HCPIhtDKr8iALAVagYgGSgrtPsnQBJbNQMWgmieH0mzA379UtPPYhNKRS6CLd20TJ2ZL9OpFw+tZl Wu8Rja2w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqKCb-00010M-S4; Tue, 30 Jun 2020 17:37:49 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqKCY-0000zD-Fv for linux-arm-kernel@lists.infradead.org; Tue, 30 Jun 2020 17:37:47 +0000 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 597B12074D; Tue, 30 Jun 2020 17:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593538664; bh=BMss0eeOZQ/28jUy+KXQgifB64KSIn2xeTaQWoECZYE=; h=From:To:Cc:Subject:Date:From; b=AqXudRS2IFQSmR095JSkiCVCg7d0rvO8gF5dggEqpqfvtLr+TnFF8Zq9y58q7Nt8/ FyBqGoB5igPpGU1/B0Se1v1lIcbT1t/APM7/Bfyll5L/vs1bJUt6h5cw9M609GojH4 J7m46uvZbLWpzhvJD9KijCZehuzUtjsH/aueBXIk= From: Will Deacon To: linux-kernel@vger.kernel.org Subject: [PATCH 00/18] Allow architectures to override __READ_ONCE() Date: Tue, 30 Jun 2020 18:37:16 +0100 Message-Id: <20200630173734.14057-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200630_133746_659885_35E13417 X-CRM114-Status: GOOD ( 19.06 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "Michael S. Tsirkin" , Peter Zijlstra , Catalin Marinas , Jason Wang , virtualization@lists.linux-foundation.org, Will Deacon , Arnd Bergmann , Alan Stern , Sami Tolvanen , Matt Turner , kernel-team@android.com, Marco Elver , Kees Cook , "Paul E. McKenney" , Boqun Feng , Josh Triplett , Ivan Kokshaysky , linux-arm-kernel@lists.infradead.org, Richard Henderson , Nick Desaulniers , linux-alpha@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Hi everyone, This is the long-awaited version two of the patches I previously posted in November last year: https://lore.kernel.org/lkml/20191108170120.22331-1-will@kernel.org/ I ended up parking the series while the READ_ONCE() implementation was being overhauled, but with that merged during the recent merge window and LTO patches being posted again [1], it was time for a refresh. The patches allow architectures to provide their own implementation of __READ_ONCE(). This serves two main purposes: 1. It finally allows us to remove [smp_]read_barrier_depends() from the Linux memory model and make it an implementation detail of the Alpha back-end. 2. It allows arm64 to upgrade __READ_ONCE() to have RCpc acquire semantics when compiling with LTO, since this may enable compiler optimisations that break dependency ordering and therefore we require fencing to ensure ordering within the CPU. Both of these are implemented by this series. I've kept Paul's acks from v1 since, although the series has changed somewhat, the patches with his Ack have not changed materially in my opinion. I will drop them if anybody objects. In terms of merging this, my preference would be a stable branch in the arm64 tree, which others can pull in as they need it. Cheers, Will [1] https://lore.kernel.org/r/20200624203200.78870-1-samitolvanen@google.com Cc: Sami Tolvanen Cc: Nick Desaulniers Cc: Kees Cook Cc: Marco Elver Cc: "Paul E. McKenney" Cc: Josh Triplett Cc: Matt Turner Cc: Ivan Kokshaysky Cc: Richard Henderson Cc: Peter Zijlstra Cc: Alan Stern Cc: "Michael S. Tsirkin" Cc: Jason Wang Cc: Arnd Bergmann Cc: Boqun Feng Cc: Catalin Marinas Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org> Cc: linux-alpha@vger.kernel.org Cc: virtualization@lists.linux-foundation.org Cc: kernel-team@android.com --->8 SeongJae Park (1): Documentation/barriers/kokr: Remove references to [smp_]read_barrier_depends() Will Deacon (17): tools: bpf: Use local copy of headers including uapi/linux/filter.h compiler.h: Split {READ,WRITE}_ONCE definitions out into rwonce.h asm/rwonce: Allow __READ_ONCE to be overridden by the architecture alpha: Override READ_ONCE() with barriered implementation asm/rwonce: Remove smp_read_barrier_depends() invocation vhost: Remove redundant use of read_barrier_depends() barrier alpha: Replace smp_read_barrier_depends() usage with smp_[r]mb() locking/barriers: Remove definitions for [smp_]read_barrier_depends() Documentation/barriers: Remove references to [smp_]read_barrier_depends() tools/memory-model: Remove smp_read_barrier_depends() from informal doc include/linux: Remove smp_read_barrier_depends() from comments checkpatch: Remove checks relating to [smp_]read_barrier_depends() arm64: Reduce the number of header files pulled into vmlinux.lds.S arm64: alternatives: Split up alternative.h arm64: cpufeatures: Add capability for LDAPR instruction arm64: alternatives: Remove READ_ONCE() usage during patch operation arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y .../RCU/Design/Requirements/Requirements.rst | 2 +- Documentation/memory-barriers.txt | 156 +--------- .../translations/ko_KR/memory-barriers.txt | 146 +-------- arch/alpha/include/asm/atomic.h | 16 +- arch/alpha/include/asm/barrier.h | 61 +--- arch/alpha/include/asm/pgtable.h | 10 +- arch/alpha/include/asm/rwonce.h | 19 ++ arch/arm64/Kconfig | 3 + arch/arm64/include/asm/alternative-macros.h | 276 ++++++++++++++++++ arch/arm64/include/asm/alternative.h | 267 +---------------- arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/insn.h | 3 +- arch/arm64/include/asm/kernel-pgtable.h | 2 +- arch/arm64/include/asm/memory.h | 11 +- arch/arm64/include/asm/rwonce.h | 63 ++++ arch/arm64/include/asm/uaccess.h | 1 + arch/arm64/kernel/alternative.c | 7 +- arch/arm64/kernel/cpufeature.c | 10 + arch/arm64/kernel/entry.S | 1 + arch/arm64/kernel/vdso/Makefile | 2 +- arch/arm64/kernel/vdso32/Makefile | 2 +- arch/arm64/kernel/vmlinux.lds.S | 1 - arch/arm64/kvm/hyp-init.S | 1 + drivers/vhost/vhost.c | 5 - include/asm-generic/Kbuild | 1 + include/asm-generic/barrier.h | 17 -- include/asm-generic/rwonce.h | 82 ++++++ include/linux/compiler.h | 83 +----- include/linux/percpu-refcount.h | 2 +- include/linux/ptr_ring.h | 2 +- mm/memory.c | 2 +- scripts/checkpatch.pl | 9 +- tools/bpf/Makefile | 3 +- tools/include/uapi/linux/filter.h | 90 ++++++ .../Documentation/explanation.txt | 26 +- 35 files changed, 617 insertions(+), 768 deletions(-) create mode 100644 arch/alpha/include/asm/rwonce.h create mode 100644 arch/arm64/include/asm/alternative-macros.h create mode 100644 arch/arm64/include/asm/rwonce.h create mode 100644 include/asm-generic/rwonce.h create mode 100644 tools/include/uapi/linux/filter.h