[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191213135353.GN3152@gate.crashing.org>
Date: Fri, 13 Dec 2019 07:53:53 -0600
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Michael Ellerman <mpe@...erman.id.au>
Cc: Peter Zijlstra <peterz@...radead.org>,
Will Deacon <will@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>, dja@...ens.net,
linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
christophe.leroy@....fr, linux-arch@...r.kernel.org,
Mark Rutland <mark.rutland@....com>,
Arnd Bergmann <arnd@...db.de>,
Christian Borntraeger <borntraeger@...ibm.com>
Subject: Re: READ_ONCE() + STACKPROTECTOR_STRONG == :/ (was Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.5-2 tag (topic/kasan-bitops))
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 <ext4_resize_begin_generic+0xd0> 29 bne <ext4_resize_begin_ppc+0xd0>
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
Powered by blists - more mailing lists