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]
Message-ID: <YbIF02MADsQvPyHz@hirez.programming.kicks-ass.net>
Date:   Thu, 9 Dec 2021 14:34:11 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Mark Rutland <mark.rutland@....com>
Cc:     will@...nel.org, boqun.feng@...il.com,
        linux-kernel@...r.kernel.org, x86@...nel.org, elver@...gle.com,
        keescook@...omium.org, hch@...radead.org,
        torvalds@...ux-foundation.org, axboe@...nel.dk
Subject: Re: [RFC][PATCH 1/5] atomic: Introduce
 atomic_{inc,dec,dec_and_test}_ofl()

On Thu, Dec 09, 2021 at 12:42:47PM +0000, Mark Rutland wrote:
> On Wed, Dec 08, 2021 at 07:36:56PM +0100, Peter Zijlstra wrote:
> > In order to facilitate architecture support for refcount_t, introduce
> > a number of new atomic primitives that have a uaccess style exception
> > for overflow.
> > 
> > Notably:
> > 
> >   atomic_inc_ofl(v, Label) -- increment and goto Label when
> > 			      v is zero or negative.
> > 
> >   atomic_dec_ofl(v, Label) -- decrement and goto Label when
> > 			      the result is zero or negative
> > 
> >   atomic_dec_and_test_ofl(v, Label) -- decrement and return true when
> > 				       the result is zero and goto Label
> > 				       when the result is negative
> 
> Just to check, atomic_inc_ofl() tests the *old* value of `v`, and the other
> cases check the *new* value of `v`?
> 
> For clarity, in the descriptions it might be worth:
> 
>   s/v/the old value of v/
>   s/the result/the new value of v/
> 
> ... which I think makes that clearer.

Right, I'll clarify.

> > Since the GCC 'Labels as Values' extention doesn't allow having the
> > goto in an inline function, these new 'functions' must in fact be
> > implemented as macro magic.
> 
> Oh; fun... :(

Yeah, I tried all sorta things, it's all >.< close to working but then
GCC refuses to do the sensible thing.

> > This meant extending the atomic generation scripts to deal with
> > wrapping macros instead of inline functions. Since
> > xchg/cmpxchg/try_cmpxchg were already macro magic, there was existant
> > code for that. While extending/improving that a few latent
> > 'instrumentation' bugs were uncovered and 'accidentally' fixed.
> 
> I assume for non-RFC we can split that out into a preparatory patch. :)

Sure, I can split it in two; one add the infra and fix bugs and two
introduce the new ops.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ