On Wed, Mar 25, 2020 at 5:14 PM <glider@xxxxxxxxxx> wrote: > > Make KMSAN usable by adding the necessary Makefile bits. > > Signed-off-by: Alexander Potapenko <glider@xxxxxxxxxx> > To: Alexander Potapenko <glider@xxxxxxxxxx> > Cc: Jens Axboe <axboe@xxxxxxxxx> > Cc: Andy Lutomirski <luto@xxxxxxxxxx> > Cc: Vegard Nossum <vegard.nossum@xxxxxxxxxx> > Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> > Cc: Marco Elver <elver@xxxxxxxxxx> > Cc: Andrey Konovalov <andreyknvl@xxxxxxxxxx> > Cc: linux-mm@xxxxxxxxx > > --- > This patch was previously called "kmsan: Changing existing files to > enable KMSAN builds". Logically unrelated parts of it were split away. > > v4: > - split away changes to init/main.c as requested by Andrey Konovalov Hm, I've forgotten what exactly I asked here :( But right now this patch looks like parts of other patches. > > Change-Id: I37e0b7f2d2f2b0aeac5753ff9d6b411485fc374e > --- > Makefile | 3 ++- > mm/Makefile | 1 + > scripts/Makefile.lib | 6 ++++++ > 3 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index a532333b4cd02..da315f20618b3 100644 > --- a/Makefile > +++ b/Makefile > @@ -482,7 +482,7 @@ export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE > > export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS > export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE > -export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN CFLAGS_KCSAN > +export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN CFLAGS_KCSAN CFLAGS_KMSAN > export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE > export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE > export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL > @@ -901,6 +901,7 @@ KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) > endif > > include scripts/Makefile.kasan > +include scripts/Makefile.kmsan I think this change should go together with the addition of scripts/Makefile.kmsan. > include scripts/Makefile.extrawarn > include scripts/Makefile.ubsan > include scripts/Makefile.kcsan > diff --git a/mm/Makefile b/mm/Makefile > index fa91e963c2f9e..7b9bce9cc0afb 100644 > --- a/mm/Makefile > +++ b/mm/Makefile > @@ -81,6 +81,7 @@ obj-$(CONFIG_PAGE_POISONING) += page_poison.o > obj-$(CONFIG_SLAB) += slab.o > obj-$(CONFIG_SLUB) += slub.o > obj-$(CONFIG_KASAN) += kasan/ > +obj-$(CONFIG_KMSAN) += kmsan/ And this change should go together with the addition or enabling of CONFIG_KMSAN. > obj-$(CONFIG_FAILSLAB) += failslab.o > obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o > obj-$(CONFIG_MEMTEST) += memtest.o > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index b12dd5ba48960..e9a8c2671a4b3 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -137,6 +137,12 @@ _c_flags += $(if $(patsubst n%,, \ > $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) > endif > > +ifeq ($(CONFIG_KMSAN),y) > +_c_flags += $(if $(patsubst n%,, \ > + $(KMSAN_SANITIZE_$(basetarget).o)$(KMSAN_SANITIZE)y), \ > + $(CFLAGS_KMSAN)) > +endif > + And this looks like it deserves to be together with the definition of CFLAGS_KMSAN. > ifeq ($(CONFIG_UBSAN),y) > _c_flags += $(if $(patsubst n%,, \ > $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \ > -- > 2.25.1.696.g5e7596f4ac-goog >