Re: [PATCH] arm64: Enable KCSAN

Kefeng Wang
2021-11-26T12:04:38Z

On 2021/11/26 18:39, Marco Elver wrote:
> On Fri, Nov 26, 2021 at 04:00PM +0800, Kefeng Wang wrote:
>> This patch enables KCSAN for arm64, with updates to build rules
>> to not use KCSAN for several incompatible compilation units.
>>
>> Tested selftest and kcsan_test, and all passed.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Nice! Although I think Mark (Cc'd) also had been working on this and
> probably knows what, if anything, is still missing.
>
> For one, have you tested gcc 11? To make it work with gcc 11, my
> preferred solution is that you simply squash this:
I only have gcc10,  will try gcc 11.
>
> ---
>
> diff --git a/kernel/kcsan/Makefile b/kernel/kcsan/Makefile
> index c2bb07f5bcc7..d7d0b51b79f5 100644
> --- a/kernel/kcsan/Makefile
> +++ b/kernel/kcsan/Makefile
> @@ -8,6 +8,7 @@ CFLAGS_REMOVE_debugfs.o = $(CC_FLAGS_FTRACE)
> CFLAGS_REMOVE_report.o = $(CC_FLAGS_FTRACE)
>
> CFLAGS_core.o := $(call cc-option,-fno-conserve-stack) \
> + $(call cc-option,-mno-outline-atomics) \
> -fno-stack-protector -DDISABLE_BRANCH_PROFILING
>
> obj-y := core.o debugfs.o report.o
>
> ---
>
> [ I have changes to kernel/kcsan/Makefile that I expect to land in -next
> soon'ish, the above is small enough that git can auto-merge. ]
>
> gcc somehow made outline-atomics the default (unlike clang), which will
> cause linker errors for kernel/kcsan/core.o. While the support for
> builtin atomics shouldn't be required on arm64, I want it to be
> (compile-)testable on all architectures. Although there's an exception
> that certain compiler instrumentation actually require working builtin
> atomics support, specifically GCOV_KERNEL.
Thanks for your infos, I will try to test it.
> Thanks,
> -- Marco
>
>