On 05/08/2018 08:20 PM, Andrey Konovalov wrote: > diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan > index 69552a39951d..47023daf5606 100644 > --- a/scripts/Makefile.kasan > +++ b/scripts/Makefile.kasan > @@ -1,5 +1,5 @@ > # SPDX-License-Identifier: GPL-2.0 > -ifdef CONFIG_KASAN > +ifdef CONFIG_KASAN_GENERIC > ifdef CONFIG_KASAN_INLINE > call_threshold := 10000 > else > @@ -45,3 +45,28 @@ endif > CFLAGS_KASAN_NOSANITIZE := -fno-builtin > > endif > + > +ifdef CONFIG_KASAN_HW > + > +ifdef CONFIG_KASAN_INLINE > + instrumentation_flags := -mllvm -hwasan-mapping-offset=$(KASAN_SHADOW_OFFSET) > +else > + instrumentation_flags := -mllvm -hwasan-instrument-with-calls=1 > +endif > + > +CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-hwaddress > + > +ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),) > + ifneq ($(CONFIG_COMPILE_TEST),y) > + $(warning Cannot use CONFIG_KASAN_HW: \ > + -fsanitize=hwaddress is not supported by compiler) > + endif > +else > + CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-hwaddress \ > + -mllvm -hwasan-instrument-stack=0 \ > + $(instrumentation_flags)) > +endif So this code does the following: 1) Warn if compiler doesn't support -fsanitize=kernel-hwaddress 2) Compile the kernel with all necessary set of the '-fsanitize=kernel-hwaddress -mllvm -hwasan-*' flags if compiler supports all of them. 3) Compile the kernel with empty CFLAGS_KASAN without a warning if compiler supports 'fsanitize=kernel-hwaddress', but doesn't support the rest '-mllvm -hwasan-*' flags. The last one is just nonsense. > + > +CFLAGS_KASAN_NOSANITIZE := -fno-builtin > + Does it really has to declared twice?