Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp971281ybl; Fri, 10 Jan 2020 09:46:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyUOtAqMve3mWVoL7b2QrRiAHxCFfS9Oeh00KlvN0lfP5uVXpZANrWF4WNZUNqBpFfGQsgV X-Received: by 2002:a05:6830:2102:: with SMTP id i2mr3496679otc.123.1578678391850; Fri, 10 Jan 2020 09:46:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578678391; cv=none; d=google.com; s=arc-20160816; b=y6IwF0suH3JJYObENiR3aggOUK8uGRu29OD7YA8b7pzeIuIduNdfBAVVIEeEHqDCMq ZIiZzh0TxuZyeU/ifW88sF/TEMyQWAOjps1W9xmcw6SUKPf14FPorbxsyyracULkThd3 T7QtHUDmjrMjQDEQWxPBsUWUpZtgN1FYLl80GtmhOrFCrls6ufsjngFW7F2mbfIS4yE3 5pKsp2kkgywM5MNIxz4SDF1rq62rPNlsJ7qROAOn1IbegivApePoyWAu4+TtigM5NMWS 1oZPN4O+K0NeK2UZTCHheJoMf1lHycpZYDKbyaaJSlzFg7ofingr03qus/NJPDBX5/9h CobA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ipilCwigcyALeFq5XcEmZLTrnvyABa9h5jQ7YmK0ryo=; b=Kg+o15l/bucylKwArIOGOzBrEbutBYIy810zrdxMl6i/vqmiq+Gm5Or6ignsQGx6PW 71iYc+IB3zTUeZEVRDzx6LrCSbr5OJy71cio3pXLnMBZVpk9zISVI8h6PrDm4AmnBHOD XAdikYN50/WHvslND67GzY+4vxB1NQgoJq9P3QgpDNzG4ObgyyoSKlGkVWrddgx+t4ee cIgRVddEJh3wguhrhA/vhGTHRyZCIeSSFEJsVm1N7NnIwOH3zkOiDCIBFFSL6APYLW6Z tOQWF45r1ExiDb+NSssndvfCrqk4sCyo6Vn2OxRcykVyZUNf7xBJXMWOD6bm50y5+kCC c/dA== 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 v21si1701312otj.282.2020.01.10.09.46.20; Fri, 10 Jan 2020 09:46:31 -0800 (PST) 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 S1728530AbgAJRpL (ORCPT + 99 others); Fri, 10 Jan 2020 12:45:11 -0500 Received: from foss.arm.com ([217.140.110.172]:49260 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727742AbgAJRpL (ORCPT ); Fri, 10 Jan 2020 12:45:11 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8806C30E; Fri, 10 Jan 2020 09:45:10 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 19AB03F6C4; Fri, 10 Jan 2020 09:45:08 -0800 (PST) Date: Fri, 10 Jan 2020 17:45:07 +0000 From: Mark Rutland To: Will Deacon Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@android.com, Michael Ellerman , Peter Zijlstra , Linus Torvalds , Segher Boessenkool , Christian Borntraeger , Luc Van Oostenryck , Arnd Bergmann Subject: Re: [RFC PATCH 8/8] arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release macros Message-ID: <20200110174506.GK33536@lakrids.cambridge.arm.com> References: <20200110165636.28035-1-will@kernel.org> <20200110165636.28035-9-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200110165636.28035-9-will@kernel.org> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 10, 2020 at 04:56:36PM +0000, Will Deacon wrote: > Passing volatile-qualified pointers to the arm64 implementations of the > load-acquire/store-release macros results in a re-load from the stack > and a bunch of associated stack-protector churn due to the temporary > result variable inheriting the volatile semantics thanks to the use of > 'typeof()'. > > Define these temporary variables using 'unqual_scalar_typeof' to drop > the volatile qualifier in the case that they are scalar types. > > Cc: Mark Rutland > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Arnd Bergmann > Signed-off-by: Will Deacon Based on my understanding of __unqual_scalar_typeof(), these changes look sound to me: Acked-by: Mark Rutland Mark. > --- > arch/arm64/include/asm/barrier.h | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h > index 7d9cc5ec4971..fb4c27506ef4 100644 > --- a/arch/arm64/include/asm/barrier.h > +++ b/arch/arm64/include/asm/barrier.h > @@ -76,8 +76,8 @@ static inline unsigned long array_index_mask_nospec(unsigned long idx, > #define __smp_store_release(p, v) \ > do { \ > typeof(p) __p = (p); \ > - union { typeof(*p) __val; char __c[1]; } __u = \ > - { .__val = (__force typeof(*p)) (v) }; \ > + union { __unqual_scalar_typeof(*p) __val; char __c[1]; } __u = \ > + { .__val = (__force __unqual_scalar_typeof(*p)) (v) }; \ > compiletime_assert_atomic_type(*p); \ > kasan_check_write(__p, sizeof(*p)); \ > switch (sizeof(*p)) { \ > @@ -110,7 +110,7 @@ do { \ > > #define __smp_load_acquire(p) \ > ({ \ > - union { typeof(*p) __val; char __c[1]; } __u; \ > + union { __unqual_scalar_typeof(*p) __val; char __c[1]; } __u; \ > typeof(p) __p = (p); \ > compiletime_assert_atomic_type(*p); \ > kasan_check_read(__p, sizeof(*p)); \ > @@ -136,33 +136,33 @@ do { \ > : "Q" (*__p) : "memory"); \ > break; \ > } \ > - __u.__val; \ > + (typeof(*p))__u.__val; \ > }) > > #define smp_cond_load_relaxed(ptr, cond_expr) \ > ({ \ > typeof(ptr) __PTR = (ptr); \ > - typeof(*ptr) VAL; \ > + __unqual_scalar_typeof(*ptr) VAL; \ > for (;;) { \ > VAL = READ_ONCE(*__PTR); \ > if (cond_expr) \ > break; \ > __cmpwait_relaxed(__PTR, VAL); \ > } \ > - VAL; \ > + (typeof(*ptr))VAL; \ > }) > > #define smp_cond_load_acquire(ptr, cond_expr) \ > ({ \ > typeof(ptr) __PTR = (ptr); \ > - typeof(*ptr) VAL; \ > + __unqual_scalar_typeof(*ptr) VAL; \ > for (;;) { \ > VAL = smp_load_acquire(__PTR); \ > if (cond_expr) \ > break; \ > __cmpwait_relaxed(__PTR, VAL); \ > } \ > - VAL; \ > + (typeof(*ptr))VAL; \ > }) > > #include > -- > 2.25.0.rc1.283.g88dfdc4193-goog >