From: Arnd Bergmann <arnd@arndb.de>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Russell King - ARM Linux admin <linux@armlinux.org.uk>,
Mikael Pettersson <mikpelinux@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Nick Desaulniers <ndesaulniers@google.com>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Darren Hart <dvhart@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Dave Martin <Dave.Martin@arm.com>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/2] ARM: futex: make futex_detect_cmpxchg more reliable
Date: Mon, 11 Mar 2019 21:58:55 +0100 [thread overview]
Message-ID: <CAK8P3a2Rr1_+m245cBhS6EkKm9-ZgfVDNB0x-=RNJ3KrGEWBpQ@mail.gmail.com> (raw)
In-Reply-To: <CAKv+Gu__jgnm00ou+3FsqRBZWeDFy5Qi+1eiXeMKqc+hVSXomg@mail.gmail.com>
On Mon, Mar 11, 2019 at 5:36 PM Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
>
> On Mon, 11 Mar 2019 at 17:30, Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > On Mon, Mar 11, 2019 at 3:36 PM Ard Biesheuvel
> > <ard.biesheuvel@linaro.org> wrote:
> > > On Mon, 11 Mar 2019 at 15:34, Arnd Bergmann <arnd@arndb.de> wrote:
> > > > On Fri, Mar 8, 2019 at 12:56 PM Ard Biesheuvel
> > > > <ard.biesheuvel@linaro.org> wrote:
> > > > > On Fri, 8 Mar 2019 at 11:58, Russell King - ARM Linux admin <linux@armlinux.org.uk> wrote:
> > > > > > On Fri, Mar 08, 2019 at 11:45:21AM +0100, Ard Biesheuvel wrote:
> > > >
> > > > My first attempt (before finding the original patch from Mikael Pettersson)
> > > > was to change the probe to pass '1' as the value instead of '0', that
> > > > worked fine.
> > > >
> > >
> > > Which probe is that?
> >
> > diff --git a/kernel/futex.c b/kernel/futex.c
> > index c3b73b0311bc..19615ad3c4f7 100644
> > --- a/kernel/futex.c
> > +++ b/kernel/futex.c
> > @@ -3864,7 +3864,7 @@ static void __init futex_detect_cmpxchg(void)
> > * implementation, the non-functional ones will return
> > * -ENOSYS.
> > */
> > - if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
> > + if (cmpxchg_futex_value_locked(&curval, NULL, 1, 1) == -EFAULT)
> > futex_cmpxchg_enabled = 1;
> > #endif
> > }
> >
>
> Ah ok.
>
> That explains a lot.
>
> Can't we just return -EFAULT if uaddr is NULL? Or does that defeat this check?
I think that would work here, it would just create a tiny overhead
for each call to futex_atomic_cmpxchg_inatomic().
Semi-related side note:
After I looked at access_ok() for a bit too long, I tried replacing it with
#define access_ok(addr, size) \
(((u64)(uintptr_t)addr + (u64)(size_t)size) >=
current_thread_info()->addr_limit)
which interestingly seemed to improve the output with clang (it lets it
combine multiple access_ok() checks and schedule the instructions better,
compared to our inline asm implementation), but it unfortunately creates
horrible code with gcc.
Arnd
next prev parent reply other threads:[~2019-03-11 20:59 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 9:14 [PATCH 1/2] futex: mark futex_detect_cmpxchg() as 'noinline' Arnd Bergmann
2019-03-07 9:14 ` [PATCH 2/2] ARM: futex: make futex_detect_cmpxchg more reliable Arnd Bergmann
2019-03-07 19:39 ` Nick Desaulniers
2019-03-07 23:48 ` Russell King - ARM Linux admin
2019-03-08 0:04 ` Nick Desaulniers
2019-03-08 9:54 ` Russell King - ARM Linux admin
2019-03-08 8:57 ` Ard Biesheuvel
2019-03-08 9:53 ` Russell King - ARM Linux admin
2019-03-08 10:08 ` Ard Biesheuvel
2019-03-08 10:16 ` Ard Biesheuvel
2019-03-08 10:56 ` Russell King - ARM Linux admin
2019-03-08 10:34 ` Russell King - ARM Linux admin
2019-03-08 10:45 ` Ard Biesheuvel
2019-03-08 10:58 ` Russell King - ARM Linux admin
2019-03-08 11:55 ` Ard Biesheuvel
2019-03-11 14:34 ` Arnd Bergmann
2019-03-11 14:36 ` Ard Biesheuvel
2019-03-11 16:29 ` Arnd Bergmann
2019-03-11 16:36 ` Ard Biesheuvel
2019-03-11 20:58 ` Arnd Bergmann [this message]
2019-03-08 11:55 ` Dave Martin
2019-03-07 17:19 ` [PATCH 1/2] futex: mark futex_detect_cmpxchg() as 'noinline' Joe Perches
2019-03-07 17:25 ` Russell King - ARM Linux admin
2019-03-07 17:42 ` Joe Perches
2019-03-07 18:07 ` Russell King - ARM Linux admin
2019-03-07 18:12 ` Nick Desaulniers
2019-03-07 18:21 ` Nathan Chancellor
2019-03-07 22:24 ` Arnd Bergmann
2020-12-12 12:26 ` Marco Elver
2020-12-12 20:01 ` Thomas Gleixner
2020-12-14 10:22 ` Marco Elver
2020-12-14 13:15 ` Arnd Bergmann
2020-12-15 6:09 ` Guo Ren
2020-12-15 11:26 ` Arnd Bergmann
2020-12-15 19:38 ` Sam Ravnborg
2020-12-15 23:24 ` Arnd Bergmann
2020-12-17 15:32 ` Andreas Larsson
2020-12-17 16:43 ` Arnd Bergmann
2020-12-18 11:08 ` Andreas Larsson
2020-12-17 20:03 ` Sam Ravnborg
2020-12-16 10:07 ` David Laight
2020-12-16 11:40 ` Peter Zijlstra
2020-12-20 15:44 ` Guo Ren
2020-12-20 17:49 ` Arnd Bergmann
2020-12-21 2:58 ` Guo Ren
2021-07-22 20:05 ` Nathan Chancellor
2021-10-25 13:52 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK8P3a2Rr1_+m245cBhS6EkKm9-ZgfVDNB0x-=RNJ3KrGEWBpQ@mail.gmail.com' \
--to=arnd@arndb.de \
--cc=Dave.Martin@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=dvhart@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mikpelinux@gmail.com \
--cc=mingo@redhat.com \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).