Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: Support kcov

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>

authored by

Vegard Nossum and committed by
Richard Weinberger
915eed20 8e99bc70

+12
+1
arch/um/Kconfig.common
··· 1 1 config UML 2 2 bool 3 3 default y 4 + select ARCH_HAS_KCOV 4 5 select HAVE_ARCH_AUDITSYSCALL 5 6 select HAVE_ARCH_SECCOMP_FILTER 6 7 select HAVE_UID16
+5
arch/um/kernel/Makefile
··· 3 3 # Licensed under the GPL 4 4 # 5 5 6 + # Don't instrument UML-specific code; without this, we may crash when 7 + # accessing the instrumentation buffer for the first time from the 8 + # kernel. 9 + KCOV_INSTRUMENT := n 10 + 6 11 CPPFLAGS_vmlinux.lds := -DSTART=$(LDS_START) \ 7 12 -DELF_ARCH=$(LDS_ELF_ARCH) \ 8 13 -DELF_FORMAT=$(LDS_ELF_FORMAT) \
+3
arch/um/os-Linux/Makefile
··· 3 3 # Licensed under the GPL 4 4 # 5 5 6 + # Don't instrument UML-specific code 7 + KCOV_INSTRUMENT := n 8 + 6 9 obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ 7 10 registers.o sigio.o signal.o start_up.o time.o tty.o \ 8 11 umid.o user_syms.o util.o drivers/ skas/
+3
arch/x86/um/vdso/Makefile
··· 2 2 # Building vDSO images for x86. 3 3 # 4 4 5 + # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. 6 + KCOV_INSTRUMENT := n 7 + 5 8 VDSO64-y := y 6 9 7 10 vdso-install-$(VDSO64-y) += vdso.so