linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Greg Hackmann <ghackmann@google.com>,
	Luis Lozano <llozano@google.com>,
	Michael Davidson <md@google.com>,
	Sami Tolvanen <samitolvanen@google.com>,
	Paul Lawrence <paullawrence@google.com>,
	Ingo Molnar <mingo@kernel.org>, Linux-MM <linux-mm@kvack.org>,
	kasan-dev <kasan-dev@googlegroups.com>,
	llvmlinux@lists.linuxfoundation.org, sil2review@lists.osadl.org,
	Manoj Gupta <manojgupta@chromium.org>,
	Stephen Hines <srhines@google.com>
Subject: Re: clang fails on linux-next since commit 8bf705d13039
Date: Mon, 19 Mar 2018 10:54:57 -0700	[thread overview]
Message-ID: <20180319175457.GC37438@google.com> (raw)
In-Reply-To: <CACT4Y+Z9xeWvu5XUy_qNTewihuCC1-2a0hZDuymU6PA_3NJ90Q@mail.gmail.com>

El Mon, Mar 19, 2018 at 06:39:32PM +0100 Dmitry Vyukov ha dit:

> On Mon, Mar 19, 2018 at 6:29 PM, Matthias Kaehlcke <mka@chromium.org> wrote:
> > El Mon, Mar 19, 2018 at 09:43:25AM +0300 Dmitry Vyukov ha dit:
> >
> >> On Sat, Mar 17, 2018 at 2:13 PM, Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
> >> > Hi Dmitry, hi Ingo,
> >> >
> >> > since commit 8bf705d13039 ("locking/atomic/x86: Switch atomic.h to use atomic-instrumented.h")
> >> > on linux-next (tested and bisected from tag next-20180316), compiling the
> >> > kernel with clang fails with:
> >> >
> >> > In file included from arch/x86/entry/vdso/vdso32/vclock_gettime.c:33:
> >> > In file included from arch/x86/entry/vdso/vdso32/../vclock_gettime.c:15:
> >> > In file included from ./arch/x86/include/asm/vgtod.h:6:
> >> > In file included from ./include/linux/clocksource.h:13:
> >> > In file included from ./include/linux/timex.h:56:
> >> > In file included from ./include/uapi/linux/timex.h:56:
> >> > In file included from ./include/linux/time.h:6:
> >> > In file included from ./include/linux/seqlock.h:36:
> >> > In file included from ./include/linux/spinlock.h:51:
> >> > In file included from ./include/linux/preempt.h:81:
> >> > In file included from ./arch/x86/include/asm/preempt.h:7:
> >> > In file included from ./include/linux/thread_info.h:38:
> >> > In file included from ./arch/x86/include/asm/thread_info.h:53:
> >> > In file included from ./arch/x86/include/asm/cpufeature.h:5:
> >> > In file included from ./arch/x86/include/asm/processor.h:21:
> >> > In file included from ./arch/x86/include/asm/msr.h:67:
> >> > In file included from ./arch/x86/include/asm/atomic.h:279:
> >> > ./include/asm-generic/atomic-instrumented.h:295:10: error: invalid output size for constraint '=a'
> >> >                 return arch_cmpxchg((u64 *)ptr, (u64)old, (u64)new);
> >> >                        ^
> >> > ./arch/x86/include/asm/cmpxchg.h:149:2: note: expanded from macro 'arch_cmpxchg'
> >> >         __cmpxchg(ptr, old, new, sizeof(*(ptr)))
> >> >         ^
> >> > ./arch/x86/include/asm/cmpxchg.h:134:2: note: expanded from macro '__cmpxchg'
> >> >         __raw_cmpxchg((ptr), (old), (new), (size), LOCK_PREFIX)
> >> >         ^
> >> > ./arch/x86/include/asm/cmpxchg.h:95:17: note: expanded from macro '__raw_cmpxchg'
> >> >                              : "=a" (__ret), "+m" (*__ptr)              \
> >> >                                      ^
> >> >
> >> > (... and some more similar and closely related errors)
> >>
> >>
> >> Thanks for reporting, Lukas.
> >>
> >> +more people who are more aware of the current state of clang for kernel.
> >>
> >> Are there are known issues in '=a' constraint handling between gcc and
> >> clang? Is there a recommended way to resolve them?
> >>
> >> Also, Lukas what's your version of clang? Potentially there are some
> >> fixes for kernel in the very latest versions of clang.
> >
> > My impression is that the problem only occurs in code built for
> > 32-bit (like arch/x86/entry/vdso/vdso32/*), where the use of a 64-bit
> > address with a '=a' constraint is indeed invalid. I think the 'root
> > cause' is that clang parses unreachable code before it discards it:
> >
> > static __always_inline unsigned long
> > cmpxchg_local_size(volatile void *ptr, unsigned long old, unsigned long new,
> >                    int size)
> > {
> >         ...
> >         switch (size) {
> >         ...
> >         case 8:
> >                 BUILD_BUG_ON(sizeof(unsigned long) != 8);
> >                 return arch_cmpxchg_local((u64 *)ptr, (u64)old, (u64)new);
> >         }
> >         ...
> > }
> >
> > For 32-bit builds size is 4 and the code in the 'offending' branch is
> > unreachable, however clang still parses it.
> >
> > d135b8b5060e ("arm64: uaccess: suppress spurious clang warning") fixes
> > a similar issue.
> 
> 
> Thanks!
> 
> Do I understand it correctly that this is being fixed in clang?

Personally I am not aware of any development on that side, however I'm
not an LLVM dev.

  reply	other threads:[~2018-03-19 17:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-17 11:13 Lukas Bulwahn
2018-03-19  6:43 ` Dmitry Vyukov
2018-03-19  7:15   ` Lukas Bulwahn
2018-03-19 17:24   ` Nick Desaulniers
2018-03-19 17:29   ` Matthias Kaehlcke
2018-03-19 17:39     ` Dmitry Vyukov
2018-03-19 17:54       ` Matthias Kaehlcke [this message]
2018-03-19 18:15         ` Dmitry Vyukov
2018-03-21 17:07           ` Nick Desaulniers
     [not found]     ` <99fbbbe3-df05-446b-9ce0-55787ea038f3@googlegroups.com>
2018-05-06 10:44       ` Dmitry Vyukov
2018-05-06 10:48         ` Sedat Dilek
2018-05-07  7:34           ` Dmitry Vyukov
2018-05-28 16:05             ` [llvmlinux] " Sedat Dilek
2018-05-29  6:49               ` Jan Beulich
2018-06-01 13:14                 ` Sedat Dilek
2018-07-29 18:12                 ` Sedat Dilek
2018-07-30  8:21                   ` Mark Rutland
2018-07-30  9:29                     ` Sedat Dilek
2018-06-09 15:17             ` Sedat Dilek

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=20180319175457.GC37438@google.com \
    --to=mka@chromium.org \
    --cc=dvyukov@google.com \
    --cc=ghackmann@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-mm@kvack.org \
    --cc=llozano@google.com \
    --cc=llvmlinux@lists.linuxfoundation.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=manojgupta@chromium.org \
    --cc=md@google.com \
    --cc=mingo@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=paullawrence@google.com \
    --cc=samitolvanen@google.com \
    --cc=sil2review@lists.osadl.org \
    --cc=srhines@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