[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAK8P3a2XD7yA7s4d1t1Ogy0vnX-YGYRaHkY9Civ0H4Z9VJ22Tw@mail.gmail.com>
Date: Thu, 25 Feb 2021 23:04:19 +0100
From: Arnd Bergmann <arnd@...nel.org>
To: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Mathieu Poirier <mathieu.poirier@...aro.org>,
Suzuki K Poulose <suzuki.poulose@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Nathan Chancellor <nathan@...nel.org>,
Arnd Bergmann <arnd@...db.de>,
Mike Leach <mike.leach@...aro.org>,
Leo Yan <leo.yan@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sai Prakash Ranjan <saiprakash.ranjan@...eaurora.org>,
coresight@...ts.linaro.org,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Bill Wendling <morbo@...gle.com>
Subject: Re: [PATCH] coresight: etm4x: work around clang-12+ build failure
On Thu, Feb 25, 2021 at 10:23 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@...glegroups.com> wrote:
>
> On Thu, Feb 25, 2021 at 8:45 AM Mathieu Poirier
> <mathieu.poirier@...aro.org> wrote:
> >
> > Good morning,
> >
> > On Thu, Feb 25, 2021 at 10:42:58AM +0100, Arnd Bergmann wrote:
> > > From: Arnd Bergmann <arnd@...db.de>
> > >
> > > clang-12 fails to build the etm4x driver with -fsanitize=array-bounds:
>
> Is a sanitizer enabled, that would trap on OOB?
>
> > >
> > > Link: https://github.com/ClangBuiltLinux/linux/issues/1310
As described over there, this happens only with the array-bounds
sanitizer.
Actually, looking at it again now, in the reduced test case, the inline
assembly is not even parsable, it only works because it never gets
emitted without -fsanitize=array-bounds, and the alternative
code path is used in
#define read_etm4x_sysreg_offset(offset, _64bit)
\
({
\
u64 __val;
\
\
if (__builtin_constant_p((offset)))
\
__val =
read_etm4x_sysreg_const_offset((offset)); \
else
\
__val = etm4x_sysreg_read((offset), true,
(_64bit)); \
__val;
\
})
read_etm4x_sysreg_const_offset() eventually turns into something
like
asm("msr_s " __stringify(offset));
so the offset has to be something that can be parsed by the
assembler. __builtin_constant_p() checks that it is a constant
value at compile-time, and in this case it can be because there
is a small upper bound and clang just unrolls the loop.
I don't think there is an alternative to __builtin_constant_p()
that can be used to decide if the argument is something that
can be used as a constant expression in an inline assembly.
Arnd
Powered by blists - more mailing lists