Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp716766ybz; Wed, 15 Apr 2020 17:23:22 -0700 (PDT) X-Google-Smtp-Source: APiQypKuCD/cNLNEv1xssMGxzsqtWRZIDjb6VrxheFmoa/h8qtoL/iU39bep4xq7krdGqcJJUBzT X-Received: by 2002:a17:907:2098:: with SMTP id pv24mr7434461ejb.22.1586996602760; Wed, 15 Apr 2020 17:23:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586996602; cv=none; d=google.com; s=arc-20160816; b=LNczGQvlphcj/YEpaYxqDQuFiKmxwsAaDFuDXSazlDx4d2f8lqNBHpBWXQU842aNdO nnpxBRdhjINKqfVtNiFIjn7rDScX20IJqV39mukCpN6/4cAFVZvqcbDPMnYuSwvBYp6e +J/VItga+baUo9RUMAbXa0c4UN6XXtahXtzP7MA0tcJP5J49xgE3C2GoMr/jigbbZ+z1 Sz3AbXKAXHoNkdnBRt6rpGCp9QiFugYRzAEiuvrIQr8sFLVnkieYjXAzOtgXw2vlcR0N Y22KJSG0sjiEFwF+Yv/8U4l9ua1coT/TJ0KHzXGb9G9c7OQekVV2xQWzLpIqDXbXtRUA SSAA== 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=zjY/p9SeE6zgwGwqBoWqrzVF3Nv4illY3VvwiCEDDSU=; b=sMco6FsNY8YHDuiz+tlcwFJdIex7T01Hdj3eWRG5XBTb0WlT8vZRG8O7j/nk+i/lFY HVuhb+av4D6CfT7IECfaN06m1z/yFcte8SZouSvc5UazJXwOn4jlK/iQsb23YlfY8GUx lLCZyUuLhvRNG3gsvBrT8M/t6f+iA9P+GhdFs2/H1gvrf1m6B6lhwdMacyQBObzD7Fhl jk5kRIcPmwzh0npQZPPMSAB+pQshdRafnyXTIAhivxMyltDbjvv97YOOa4qjbTr7bvQD We50H1pwvnHvntFoV0hctkCuabF2oxbXGVoAK1Vei7D1gaHx8YfKbkfo3BK7yKPVvirh r1hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SE9Pquuu; 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 me19si3657975ejb.140.2020.04.15.17.22.59; Wed, 15 Apr 2020 17:23:22 -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=SE9Pquuu; 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 S1416226AbgDOQxk (ORCPT + 99 others); Wed, 15 Apr 2020 12:53:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:55272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410528AbgDOQxS (ORCPT ); Wed, 15 Apr 2020 12:53:18 -0400 Received: from localhost.localdomain (unknown [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 C2A3120857; Wed, 15 Apr 2020 16:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586969597; bh=6+cVZvFe+Uym0xrElz7C/4vR93gGyN1gMpIswPuFVnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SE9PquuuBTmR04wuDLyo5nSr9MAJ5x7c1pqliNSLKUkYNGD7UFxL9GETbO2tCT9v1 c5jJe/q88bOJUarvHRLI+cvNA3CAwTjwt8O0hN8zxExpFtqt6NcylZ8iDfleTYNUOK KI2cgFJB/OFJGgIkG61C8n4WgyiMxe9XeVtgxSO4= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, kernel-team@android.com, Will Deacon , Michael Ellerman , Peter Zijlstra , Linus Torvalds , Segher Boessenkool , Christian Borntraeger , Luc Van Oostenryck , Arnd Bergmann , Peter Oberparleiter , Masahiro Yamada , Nick Desaulniers , Mark Rutland Subject: [PATCH v3 10/12] arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release macros Date: Wed, 15 Apr 2020 17:52:16 +0100 Message-Id: <20200415165218.20251-11-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200415165218.20251-1-will@kernel.org> References: <20200415165218.20251-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 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: Linus Torvalds Cc: Peter Zijlstra Cc: Arnd Bergmann Acked-by: Mark Rutland Signed-off-by: Will Deacon --- 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.26.0.110.g2183baf09c-goog