lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 4 Jun 2021 11:52:42 -0500
From:   Segher Boessenkool <segher@...nel.crashing.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Will Deacon <will@...nel.org>,
        "Paul E. McKenney" <paulmck@...nel.org>,
        Alan Stern <stern@...land.harvard.edu>,
        Andrea Parri <parri.andrea@...il.com>,
        Boqun Feng <boqun.feng@...il.com>,
        Nick Piggin <npiggin@...il.com>,
        David Howells <dhowells@...hat.com>,
        Jade Alglave <j.alglave@....ac.uk>,
        Luc Maranget <luc.maranget@...ia.fr>,
        Akira Yokosawa <akiyks@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-toolchains@...r.kernel.org,
        linux-arch <linux-arch@...r.kernel.org>
Subject: Re: [RFC] LKMM: Add volatile_if()

On Fri, Jun 04, 2021 at 06:37:22PM +0200, Peter Zijlstra wrote:
> On Fri, Jun 04, 2021 at 09:30:01AM -0700, Linus Torvalds wrote:
> > Why is "volatile_if()" not just
> > 
> >        #define barier_true() ({ barrier(); 1; })
> > 
> >        #define volatile_if(x) if ((x) && barrier_true())
> > 
> > because that should essentially cause the same thing - the compiler
> > should be *forced* to create one conditional branch (because "barrier"
> > is an asm that can't be done on the false side, so it can't do it with
> > arithmetic or other games), and after that we're done.
> > 
> > No need for per-architecture "asm goto" games. No new memory barriers.
> > No actual new code generation (except for the empty asm volatile that
> > is a barrier).
> 
> Because we weren't sure compilers weren't still allowed to optimize the
> branch away.

barrier_true is a volatile asm, so it should be executed on the real
machine exactly as often as on the abstract machine (and in order with
other side effects).  And the && short-circuits, so you will always have
the same effect as a branch.  But there of course is nothing that forces
there to be a branch (as a silly example, the compiler could convert
some control flow to go via computed return addresses).


Segher

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ