Re: [PATCH] coresight: etm4x: work around clang-12+ build failure
From: Arnd Bergmann <arnd@kernel.org>
Date: 2021-02-25 22:05:22
Also in:
lkml
On Thu, Feb 25, 2021 at 10:23 PM 'Nick Desaulniers' via Clang Built Linux [off-list ref] wrote:
On Thu, Feb 25, 2021 at 8:45 AM Mathieu Poirier [off-list ref] wrote:quoted
Good morning, On Thu, Feb 25, 2021 at 10:42:58AM +0100, Arnd Bergmann wrote:quoted
From: Arnd Bergmann <arnd@arndb.de> clang-12 fails to build the etm4x driver with -fsanitize=array-bounds:Is a sanitizer enabled, that would trap on OOB?quoted
quoted
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel