Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3829348ybt; Tue, 30 Jun 2020 12:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfI8G0wINLi6oQelPzObZoCZLE7M9KbEtO6F/FdIwpSBWQTxgVIm6LO5EoX5OJtrmzU1FU X-Received: by 2002:a50:9f8c:: with SMTP id c12mr21479203edf.149.1593543180119; Tue, 30 Jun 2020 11:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593543180; cv=none; d=google.com; s=arc-20160816; b=y6Fa4tdSkFugUh+eUaLGQ7IM8/fbc94x4dVWRyU7tXwWRo5q1K6QkX4SrbEdqL7BJH Q5R+DpOQZe4fsJElyJ8A7paHRelDDPm5b9Xej5I5XQnyB+ijQ4Qs+b8nak1YrJfkeDug OvOmhduntjoT88s94OPIU3EuTAETkfQFyyd5IBN3jfc1v/QklveN8gACLzOp3HazW1IC Qc6bXO9+HRx51DubqEtWs/Nm2D5DG1HBcozknWgMWNhQrvkr7eEiBODjN3CxYawJapGB db8yjl4kusrutjR0VjpZ6BWSPZot2ObpZTVPmWx/P1nqKwN94+QCMFtfkn1AnQCHrJzF EslQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mzIa6MNdP/v5GqPqh+DGv5s7X5mgAeo9jnfQ4TJRnew=; b=Uq6gII5Qf8N4wssT6gegD6KJyp9Pt1b2t1zumiTPileGw/ODlrS/I3VsUDLDWg/9A5 q6U2BI3YHsphXRDc5dv3wBImG2JpvnzjtUE8LNJVldbMzPgshCq3Tfhl1iN1iRQdB8Yg j9YFAr+JYAVNSAtLp8uJIKendEam0QczSsmLacvkE/tNcgekdnJ8tFqMFoNqe4LfNghs Qnd74DhUnK+wCMClcqIlcGYhmLwXGViX0Ozqt3P/qUxes1MlZMG1fCcrPfXLq2W6O3hj CBZYZbb7uuty7TD5IYZz6bREcnCbV/uiT72bTbvc3/ULAbCm/c6V58xRTELlWdAg5gfe nr2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NSObXOKq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 d18si2148246ejt.487.2020.06.30.11.52.36; Tue, 30 Jun 2020 11:53:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=default header.b=NSObXOKq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S2390339AbgF3RiD (ORCPT + 99 others); Tue, 30 Jun 2020 13:38:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:50758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731150AbgF3RiC (ORCPT ); Tue, 30 Jun 2020 13:38:02 -0400 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 169692078D; Tue, 30 Jun 2020 17:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593538681; bh=pesny1RdH7DbGb79H7QfthXwHtI2vIe4lfYhnipzWT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NSObXOKqu4DQj3yJ/Fya2llNNcBmFi2aQ4hG3Eviqhclj+MeUmz+5cI5F3VnY54w/ DU6VQ9WPF9wMbLSnDQan0OVflp98HStaZgU3JeA8wiO47q1ZwVbBRwu6UF1at5VxEm 2M85sCNpJOz4yx/ilpz0JRysnZ/Ae1xykmJe1+dU= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: Will Deacon , Sami Tolvanen , Nick Desaulniers , Kees Cook , Marco Elver , "Paul E. McKenney" , Josh Triplett , Matt Turner , Ivan Kokshaysky , Richard Henderson , Peter Zijlstra , Alan Stern , "Michael S. Tsirkin" , Jason Wang , Arnd Bergmann , Boqun Feng , Catalin Marinas , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-alpha@vger.kernel.org, virtualization@lists.linux-foundation.org, kernel-team@android.com Subject: [PATCH 04/18] alpha: Override READ_ONCE() with barriered implementation Date: Tue, 30 Jun 2020 18:37:20 +0100 Message-Id: <20200630173734.14057-5-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630173734.14057-1-will@kernel.org> References: <20200630173734.14057-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rather then relying on the core code to use smp_read_barrier_depends() as part of the READ_ONCE() definition, instead override __READ_ONCE() in the Alpha code so that it is treated the same way as smp_load_acquire(). Acked-by: Paul E. McKenney Signed-off-by: Will Deacon --- arch/alpha/include/asm/barrier.h | 61 ++++---------------------------- arch/alpha/include/asm/rwonce.h | 19 ++++++++++ 2 files changed, 26 insertions(+), 54 deletions(-) create mode 100644 arch/alpha/include/asm/rwonce.h diff --git a/arch/alpha/include/asm/barrier.h b/arch/alpha/include/asm/barrier.h index 92ec486a4f9e..2ecd068d91d1 100644 --- a/arch/alpha/include/asm/barrier.h +++ b/arch/alpha/include/asm/barrier.h @@ -2,64 +2,17 @@ #ifndef __BARRIER_H #define __BARRIER_H -#include - #define mb() __asm__ __volatile__("mb": : :"memory") #define rmb() __asm__ __volatile__("mb": : :"memory") #define wmb() __asm__ __volatile__("wmb": : :"memory") -/** - * read_barrier_depends - Flush all pending reads that subsequents reads - * depend on. - * - * No data-dependent reads from memory-like regions are ever reordered - * over this barrier. All reads preceding this primitive are guaranteed - * to access memory (but not necessarily other CPUs' caches) before any - * reads following this primitive that depend on the data return by - * any of the preceding reads. This primitive is much lighter weight than - * rmb() on most CPUs, and is never heavier weight than is - * rmb(). - * - * These ordering constraints are respected by both the local CPU - * and the compiler. - * - * Ordering is not guaranteed by anything other than these primitives, - * not even by data dependencies. See the documentation for - * memory_barrier() for examples and URLs to more information. - * - * For example, the following code would force ordering (the initial - * value of "a" is zero, "b" is one, and "p" is "&a"): - * - * - * CPU 0 CPU 1 - * - * b = 2; - * memory_barrier(); - * p = &b; q = p; - * read_barrier_depends(); - * d = *q; - * - * - * because the read of "*q" depends on the read of "p" and these - * two reads are separated by a read_barrier_depends(). However, - * the following code, with the same initial values for "a" and "b": - * - * - * CPU 0 CPU 1 - * - * a = 2; - * memory_barrier(); - * b = 3; y = b; - * read_barrier_depends(); - * x = a; - * - * - * does not enforce ordering, since there is no data dependency between - * the read of "a" and the read of "b". Therefore, on some CPUs, such - * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() - * in cases like this where there are no data dependencies. - */ -#define read_barrier_depends() __asm__ __volatile__("mb": : :"memory") +#define __smp_load_acquire(p) \ +({ \ + __unqual_scalar_typeof(*p) ___p1 = \ + (*(volatile typeof(___p1) *)(p)); \ + compiletime_assert_atomic_type(*p); \ + ___p1; \ +}) #ifdef CONFIG_SMP #define __ASM_SMP_MB "\tmb\n" diff --git a/arch/alpha/include/asm/rwonce.h b/arch/alpha/include/asm/rwonce.h new file mode 100644 index 000000000000..83a92e49a615 --- /dev/null +++ b/arch/alpha/include/asm/rwonce.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2019 Google LLC. + */ +#ifndef __ASM_RWONCE_H +#define __ASM_RWONCE_H + +#include + +/* + * Alpha is apparently daft enough to reorder address-dependent loads + * on some CPU implementations. Knock some common sense into it with + * a memory barrier in READ_ONCE(). + */ +#define __READ_ONCE(x) __smp_load_acquire(&(x)) + +#include + +#endif /* __ASM_RWONCE_H */ -- 2.27.0.212.ge8ba1cc988-goog