Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp868575ybl; Fri, 13 Dec 2019 05:57:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxP+gb8HqTIWvOo+p/MQ6Wd4RNWjqYSHajBQD6m6MJGRIHX28shewgXnvNHDI2cU3A8WuSR X-Received: by 2002:a05:6830:13d3:: with SMTP id e19mr14815045otq.135.1576245453725; Fri, 13 Dec 2019 05:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576245453; cv=none; d=google.com; s=arc-20160816; b=bPclmbcIjYHk8nhXNzWPggfbFPxj/5VdbISR4Hx66dBner25mRc5nPcaA6+UMOVejS wha52HhSGKJ4jzoXbDxLEV7DOmWnRYescMXO3XN50zIh0M1Eb6TvjQZhJrYG+DdCesrl 2zT31U6/pnYNatVvQ524Y5H9dcHLSBjpKu33fsq8jVjohQlUL62ahnYyoe9Q+reLv7yp u8aojiHUBgR7gntMtRu1sxTLM7QRUa9lPz+6N9gMs+XiVkRdSz9VoqsnNJ1yQ1DBIUtI WlPxZy6uv3I1pLkSZNORcsTXXsbQsFwr/l7uh2av2TO+CFG0ASPrc/+HT8jhjjdzoU8M llFQ== 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=g6psmOfcRudY6ZlOCLqUhLzInXJfanxJClS0yD1HYEU=; b=gVocHrm56mK4DOxKGs2zqK+xGttHTKP2trw3D06EMTVYwYvWzP5d5O3FNYEfkLI4yT of8GdtBA6jaboyGYm/2r3zq2LyqO3k1ECj/7pwc1LnneIujwR4k2JawAHyszK/VV6ZSP G3Q9/zyk6UrZujWfaJ8RPWOShxDMpIvb+AYJ3RM8rCnSNfEE1+kdyeTVYg5ueXEUHFX1 7sJLsC23CFYCKZTS5pFWoHFj8TJbZQC80BKfNM7LmUwAZ0H4bFdBpboI3GM21QnSGnwt foZP7/Gmhimrmb3/WZRbisogfRRqArR+FkFUHrFHfF5GIzTDJ+lFe7eh3uPAFYSYMZnL Tu4g== 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 m2si4858702otk.122.2019.12.13.05.57.22; Fri, 13 Dec 2019 05:57:33 -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 S1727669AbfLMN4c (ORCPT + 99 others); Fri, 13 Dec 2019 08:56:32 -0500 Received: from gate.crashing.org ([63.228.1.57]:56555 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbfLMN4c (ORCPT ); Fri, 13 Dec 2019 08:56:32 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id xBDDrto1009834; Fri, 13 Dec 2019 07:53:55 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id xBDDrrmP009833; Fri, 13 Dec 2019 07:53:53 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 13 Dec 2019 07:53:53 -0600 From: Segher Boessenkool To: Michael Ellerman Cc: Peter Zijlstra , Will Deacon , Linus Torvalds , dja@axtens.net, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, christophe.leroy@c-s.fr, linux-arch@vger.kernel.org, Mark Rutland , Arnd Bergmann , Christian Borntraeger Subject: Re: READ_ONCE() + STACKPROTECTOR_STRONG == :/ (was Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.5-2 tag (topic/kasan-bitops)) Message-ID: <20191213135353.GN3152@gate.crashing.org> References: <87blslei5o.fsf@mpe.ellerman.id.au> <20191206131650.GM2827@hirez.programming.kicks-ass.net> <875zimp0ay.fsf@mpe.ellerman.id.au> <20191212080105.GV2844@hirez.programming.kicks-ass.net> <20191212100756.GA11317@willie-the-truck> <20191212104610.GW2827@hirez.programming.kicks-ass.net> <87pngso2ck.fsf@mpe.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pngso2ck.fsf@mpe.ellerman.id.au> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On Fri, Dec 13, 2019 at 11:07:55PM +1100, Michael Ellerman wrote: > I tried this: > > > @@ -295,6 +296,23 @@ void __write_once_size(volatile void *p, void *res, int size) > > */ > > #define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0) > > > > +#else /* GCC_VERSION < 40800 */ > > + > > +#define READ_ONCE_NOCHECK(x) \ > > +({ \ > > + typeof(x) __x = *(volatile typeof(x))&(x); \ > > Didn't compile, needed: > > typeof(x) __x = *(volatile typeof(&x))&(x); \ > > > > + smp_read_barrier_depends(); \ > > + __x; > > +}) > > > And that works for me. No extra stack check stuff. > > I guess the question is does that version of READ_ONCE() implement the > read once semantics. Do we have a good way to test that? > > The only differences are because of the early return in the generic > test_and_set_bit_lock(): No, there is another difference: > 30 ld r10,560(r9) > 31 std r10,104(r1) > 32 ld r10,104(r1) > 33 andi. r10,r10,1 > 34 bne 29 bne The stack var is volatile, so it is read back immediately after writing it, here. This is a bad idea for performance, in general. Segher