um: Support kcov
authorVegard Nossum <vegard.nossum@oracle.com>
Sat, 21 May 2016 15:46:10 +0000 (17:46 +0200)
committerRichard Weinberger <richard@nod.at>
Wed, 3 Aug 2016 22:18:06 +0000 (00:18 +0200)
This adds support for kcov to UML.

There is a small problem where UML will randomly segfault during boot;
this is because current_thread_info() occasionally returns an invalid
(non-NULL) pointer and we try to dereference it in
__sanitizer_cov_trace_pc(). I consider this a bug in UML itself and this
patch merely exposes it.

[v2: disable instrumentation in UML-specific code]

Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Thomas Meyer <thomas@m3y3r.de>
Cc: user-mode-linux-devel <user-mode-linux-devel@lists.sourceforge.net>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/Kconfig.common
arch/um/kernel/Makefile
arch/um/os-Linux/Makefile
arch/x86/um/vdso/Makefile

index 08d931c98621c2c67d3d3136016cb537ee1e0832..f8530d866c9fb40aebff0d21b764cd3fdcc40a43 100644 (file)
@@ -1,6 +1,7 @@
 config UML
        bool
        default y
+       select ARCH_HAS_KCOV
        select HAVE_ARCH_AUDITSYSCALL
        select HAVE_ARCH_SECCOMP_FILTER
        select HAVE_UID16
index a6a5e42caaef539cb24da8e046bdc998ecbdf976..2f36d515762ecbcaf9507f00b08fa6b955b919f9 100644 (file)
@@ -3,6 +3,11 @@
 # Licensed under the GPL
 #
 
+# Don't instrument UML-specific code; without this, we may crash when
+# accessing the instrumentation buffer for the first time from the
+# kernel.
+KCOV_INSTRUMENT                := n
+
 CPPFLAGS_vmlinux.lds := -DSTART=$(LDS_START)           \
                         -DELF_ARCH=$(LDS_ELF_ARCH)     \
                         -DELF_FORMAT=$(LDS_ELF_FORMAT) \
index 08ff5094fcdd9c82897d32b1c877284803b497b2..ada473bf6f46e536048a8589f7af67edd6048f1a 100644 (file)
@@ -3,6 +3,9 @@
 # Licensed under the GPL
 #
 
+# Don't instrument UML-specific code
+KCOV_INSTRUMENT                := n
+
 obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
        registers.o sigio.o signal.o start_up.o time.o tty.o \
        umid.o user_syms.o util.o drivers/ skas/
index 6c803ca49b5d2e12f5fcd0541febe92fdccee15c..d72dec406ccbee1be87b64747d4d2aaaf13bc301 100644 (file)
@@ -2,6 +2,9 @@
 # Building vDSO images for x86.
 #
 
+# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
+KCOV_INSTRUMENT                := n
+
 VDSO64-y               := y
 
 vdso-install-$(VDSO64-y)       += vdso.so