Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1313039ybl; Fri, 13 Dec 2019 13:08:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyUJtFaQAF5ZDuZ3QVB4tG5c81qtZrdjSkS3SCnAnTqP1xnPQEtW4ezypMSXbHMxkXYdr0h X-Received: by 2002:aca:fd58:: with SMTP id b85mr8171327oii.106.1576271305671; Fri, 13 Dec 2019 13:08:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576271305; cv=none; d=google.com; s=arc-20160816; b=l2AY2d/nLpsIqlTvWbCLwoR98kbpyJZ/1o1xGXCZ9i4c+tVv0XSOL4r8nuf422pmnM xcCxUz1CGmYVkvs2ED35jRyCRC+6alPTn1bJzga9TYIgVHVGEkeR8cI4I5534hEIScpP 1vxTLSvPlhejmuRrbVqg+6A0zWaXUfYyGEpG2Kli5ipT53T+FSqDPDvy6T+0OsCWq06h sktJs9jFLk/T4Zh4iBMdV76ddzpB+/Vtj3f6501haxU7vGXbFTq5Jr3AleU+IpBifel5 HH4vqCJ6wy0zRciefG3gpR6M8l7obYQONBw2c9/dB5vYTMO8Ow3BJhEiajidjFK69GHT usLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=LBm/+yp0Hy5uDzx3uor5KCoYjLM1dTHEAtQUfcSF1VU=; b=zN9RoUAQoEl2rN+2kwN9cF20KZzpjRoIOXkBxm8tBRLELBY7vpZnBdPGAZ76crZ2l8 0xHL5id/41gCJiq2HoSZ9WOcyqsxP/OgKKVM9F9BAMfolhTdo7wPSvaEA3E9X1aa1I3h YnbFc41X0XSvxeTJmwLHwzD+igCSwAYDyadqSBLt8mWAH9cPdf0ehuYd8000v1KnoaUm TRZQO6Cw7ayR+33TLX6u16LSutppLAEPsf+CjBqg4Y1H6RViKTwLol1iLLSHLf2gkd1T Lu6Shwivd0Lw8Wd1wKcSDS0zjHBQnfr+t28SMMsLHnC2ePNneVCTy0+WuA4UvrPx+9uw Od/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b="k23J/zLd"; 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 c131si5958769oib.267.2019.12.13.13.08.12; Fri, 13 Dec 2019 13:08:25 -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; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b="k23J/zLd"; 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 S1726911AbfLMVGz (ORCPT + 99 others); Fri, 13 Dec 2019 16:06:55 -0500 Received: from ozlabs.org ([203.11.71.1]:53267 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfLMVGz (ORCPT ); Fri, 13 Dec 2019 16:06:55 -0500 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 47ZNWw2BJjz9sP6; Sat, 14 Dec 2019 08:06:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1576271213; bh=MGInI7+F0s7HGbUV0Xqx0TPozxlo/Am/To6UDohXxq4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=k23J/zLdvtKqBunmy1ixSs+42bGbHDuGSQCB6Ke7L4Uq+z+ldveUzevFgLwdpKq0d mkr6DDnR7H0smvCQcN+BM6T37JbnmqHD4/L9a/NkSKrjRcYPT2yHYyhdPyiEXPyrMB Efjh7qR7zHjSZA5mgVn0XUYlFLdEhavQXa026DnFJi45/5Ez7taLlBYjyOaBMxyE/b 7GJ80E1SaCmTKU2aBFLDMNx1yGZX4v2RQz2d9xbDgYEA2gziROONKrvnz6W/pFOCgL jX4iWoccqf6+gYa3ICv0po4aLuXfa8qENKOix+W7EG9numuE+zbXEzjMmrCD9q6b2x GpuH9UJg8ssSA== From: Michael Ellerman To: Segher Boessenkool 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)) In-Reply-To: <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> <20191213135353.GN3152@gate.crashing.org> Date: Sat, 14 Dec 2019 08:06:49 +1100 Message-ID: <87mubwndee.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Segher Boessenkool writes: > 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. Argh, yuck. Thanks, I shouldn't try to read asm listings at 11pm. So that just confirms what Will was saying further up the thread about the volatile pointer, rather than READ_ONCE() per se. cheers