From patchwork Mon Oct 9 18:28:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115287 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2862755qgn; Mon, 9 Oct 2017 11:31:14 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDxF9dNd7iJqdZT/vmhz+R8AdWxWg5k9sxTaM3JarTi02GheFueNIDnITYbtEVh6MIsV/Jd X-Received: by 10.99.168.76 with SMTP id i12mr10001283pgp.427.1507573874442; Mon, 09 Oct 2017 11:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507573874; cv=none; d=google.com; s=arc-20160816; b=N7VMsGYLqJSLYJBpiKMLoqcDR7uhTSAFc+oL3FkO52es7XO5Qnn+Tl5x5rduGE3lPh hVpAS0nSkjrdcrCN+ogycvxNvKDvHRUYmV81Gme4c1YzrClNVd8ZlLOpDXMYhLfD7IbB t+G4q8X+4sI2u/jv4AJk4HOK/nrPk4dSPL9SEk5hZaKZ6+dD6EB3Fvc2QK+EFqrAIM9X OVtk2n1Jy4Wx0sHTjqbYkbTQDCECYgNKm9k2RZoaZRFoo5ejIM/Ul7eOrKcgu/nUdnnW QeJLI6qv0YqrtMQ6NDySsfOQseXax8LsLoAcSm+TiRTNn7Cr/55ZF8DqUeLo4syQgbYj Z7ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=n4OaV4mMAvopicOHTZe+woX0pVx25TZrcqkpkKMtFWs=; b=sc+Dt9btihHfC1lIYezgmFOIP23JC50SlyPPlQDmDD+psvlXkpDY0lEbRWgKsznkfr jqrPNiyS7enNfVRlR2Jg/kCVv8HzebZ/N2rioDPMe1f1g7j2ZCz9K2NlfZItBpvVsBwS 2YXGSVdRDEXFPlwGcqFYvJqQZG1WHT6LC37zZfyyL8XSAxZlZ6caaRCG2ZqMHRBMCNWl 0DbmVTYG5539fH0u+e0gMBR0hsaa9S5FYB1KAV/l+WaANt31h/p3YwJ/s8nnHXLhS5lR BsfSfmPq38JwEtjHq1pMDWWiOB41LR7wtmW3WxtLKJmIHZhK/DssyXthKz+TgeeO1nUg W/EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e72si7432058pfm.35.2017.10.09.11.31.14; Mon, 09 Oct 2017 11:31:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755396AbdJISbB (ORCPT + 26 others); Mon, 9 Oct 2017 14:31:01 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33828 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754216AbdJISa6 (ORCPT ); Mon, 9 Oct 2017 14:30:58 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 271DA165C; Mon, 9 Oct 2017 11:30:58 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 189EB3F483; Mon, 9 Oct 2017 11:30:56 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: Mark Rutland , Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras , Shuah Khan Subject: [PATCH 11/13] selftests/powerpc: kill off ACCESS_ONCE() Date: Mon, 9 Oct 2017 19:28:48 +0100 Message-Id: <1507573730-8083-12-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507573730-8083-1-git-send-email-mark.rutland@arm.com> References: <1507573730-8083-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For several reasons, it is desirable to use {READ,WRITE}_ONCE() in preference to ACCESS_ONCE(), and new code is expected to use one of the former. So far, there's been no reason to change most existing uses of ACCESS_ONCE(), as these aren't currently harmful. However, for some features it is necessary to instrument reads and writes separately, which is not possible with ACCESS_ONCE(). This distinction is critical to correct operation. The bulk of the kernel code can be transformed via Coccinelle to use {READ,WRITE}_ONCE(), though this only modifies users of ACCESS_ONCE(), and not the implementation itself. As such, it has the potential to break homebrew ACCESS_ONCE() macros seen in some user code in the kernel tree (e.g. the virtio code, as fixed in commit ea9156fb3b71d9f7). To avoid fragility if/when that transformation occurs, and to align with the preferred usage of {READ,WRITE}_ONCE(), this patch updates the DSCR selftest code to use READ_ONCE() rather than ACCESS_ONCE(). There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Benjamin Herrenschmidt Cc: Michael Ellerman Cc: Paul Mackerras Cc: Shuah Khan --- tools/testing/selftests/powerpc/dscr/dscr.h | 2 +- tools/testing/selftests/powerpc/dscr/dscr_default_test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 1.9.1 Acked-by: Michael Ellerman diff --git a/tools/testing/selftests/powerpc/dscr/dscr.h b/tools/testing/selftests/powerpc/dscr/dscr.h index 18ea223b..cdb840b 100644 --- a/tools/testing/selftests/powerpc/dscr/dscr.h +++ b/tools/testing/selftests/powerpc/dscr/dscr.h @@ -39,7 +39,7 @@ #define rmb() asm volatile("lwsync":::"memory") #define wmb() asm volatile("lwsync":::"memory") -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) +#define READ_ONCE(x) (*(volatile typeof(x) *)&(x)) /* Prilvilege state DSCR access */ inline unsigned long get_dscr(void) diff --git a/tools/testing/selftests/powerpc/dscr/dscr_default_test.c b/tools/testing/selftests/powerpc/dscr/dscr_default_test.c index df17c3b..9e1a37e 100644 --- a/tools/testing/selftests/powerpc/dscr/dscr_default_test.c +++ b/tools/testing/selftests/powerpc/dscr/dscr_default_test.c @@ -27,7 +27,7 @@ static void *do_test(void *in) unsigned long d, cur_dscr, cur_dscr_usr; unsigned long s1, s2; - s1 = ACCESS_ONCE(sequence); + s1 = READ_ONCE(sequence); if (s1 & 1) continue; rmb();