linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Ilie Halip <ilie.halip@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: objtool warning "uses BP as a scratch register" with clang-9
Date: Wed, 28 Aug 2019 17:28:50 +0200	[thread overview]
Message-ID: <CAK8P3a2ATzqRSqVeeKNswLU74+bjvwK_GmG0=jbMymVaSp2ysw@mail.gmail.com> (raw)
In-Reply-To: <20190828152226.r6pl64ij5kol6d4p@treble>

On Wed, Aug 28, 2019 at 5:22 PM Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Wed, Aug 28, 2019 at 05:13:59PM +0200, Arnd Bergmann wrote:
> > On Wed, Aug 28, 2019 at 11:00 AM Arnd Bergmann <arnd@arndb.de> wrote:
> > > On Tue, Aug 27, 2019 at 11:22 PM 'Nick Desaulniers' via Clang Built Linux <clang-built-linux@googlegroups.com> wrote:
> > I figured this one out as well:
> >
> > > http://paste.ubuntu.com/p/XjdDsypRxX/
> > > 0x5BA1B7A1:arch/x86/ia32/ia32_signal.o: warning: objtool:
> > > ia32_setup_rt_frame()+0x238: call to memset() with UACCESS enabled
> > > 0x5BA1B7A1:arch/x86/kernel/signal.o: warning: objtool:
> > > __setup_rt_frame()+0x5b8: call to memset() with UACCESS enabled
> >
> > When CONFIG_KASAN is set, clang decides to use memset() to set
> > the first two struct members in this function:
> >
> >  static inline void sas_ss_reset(struct task_struct *p)
> >  {
> >         p->sas_ss_sp = 0;
> >         p->sas_ss_size = 0;
> >         p->sas_ss_flags = SS_DISABLE;
> >  }
> >
> > and that is called from save_altstack_ex(). Adding a barrier() after
> > the sas_ss_sp() works around the issue, but is certainly not the
> > best solution. Any other ideas?
>
> Wow, is the compiler allowed to insert memset calls like that?  Seems a
> bit overbearing, at least in a kernel context.  I don't recall GCC ever
> doing it.

Yes, it's free to assume that any standard library function behaves
as defined, so it can and will turn struct assignments into memcpy
or back, or replace string operations with others depending on what
seems better for optimization.

clang is more aggressive than gcc here, and this has caused some
other problems in the past, but it's usually harmless.

In theory, we could pass -ffreestanding to tell the compiler
not to make assumptions about standard library function behavior,
but that turns off all kinds of useful optimizations. The problem
is really that the kernel is neither exactly hosted nor freestanding.

       Arnd

  reply	other threads:[~2019-08-28 15:29 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 12:30 objtool warning "uses BP as a scratch register" with clang-9 Arnd Bergmann
2019-08-27 14:51 ` Josh Poimboeuf
2019-08-27 14:59   ` Ilie Halip
2019-08-27 19:00     ` Arnd Bergmann
2019-08-27 19:22       ` Josh Poimboeuf
2019-08-27 19:47         ` Arnd Bergmann
2019-08-27 21:21           ` Nick Desaulniers
2019-08-28  9:00             ` Arnd Bergmann
2019-08-28 14:06               ` Arnd Bergmann
2019-08-28 14:51               ` Josh Poimboeuf
2019-08-28 15:29                 ` Arnd Bergmann
2019-08-28 17:57                   ` Josh Poimboeuf
2019-08-28 19:41                     ` Arnd Bergmann
2019-08-28 15:13               ` Arnd Bergmann
2019-08-28 15:22                 ` Josh Poimboeuf
2019-08-28 15:28                   ` Arnd Bergmann [this message]
2019-08-28 15:40                     ` Arnd Bergmann
2019-08-29 23:24                       ` Josh Poimboeuf
2019-08-30 10:44                         ` Arnd Bergmann
2019-08-30 15:14                           ` Josh Poimboeuf
2019-08-30 15:58                             ` Arnd Bergmann
2019-08-30 16:12                               ` David Laight
2019-08-30 16:03                             ` Linus Torvalds
2019-08-29 17:34                     ` Josh Poimboeuf
2019-08-29 18:30                       ` Linus Torvalds
2019-08-29 20:21                         ` Arnd Bergmann
2019-08-29 22:26                           ` Linus Torvalds
2019-08-30 15:02                             ` Josh Poimboeuf
2019-08-30 15:39                               ` David Laight
2019-08-30 15:48                               ` Linus Torvalds
2019-08-30 15:55                                 ` David Laight
2019-08-30 16:01                                   ` Linus Torvalds
2019-08-30 16:42                                     ` David Laight
2019-08-30 16:49                                 ` Josh Poimboeuf
2019-09-02  9:02                                   ` David Laight
2019-09-04 11:53                         ` Geert Uytterhoeven
2019-08-28 22:13         ` Nick Desaulniers
2019-08-29  0:28           ` Josh Poimboeuf

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='CAK8P3a2ATzqRSqVeeKNswLU74+bjvwK_GmG0=jbMymVaSp2ysw@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=ilie.halip@gmail.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    /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).