Skip to content

Commit

Permalink
um: Support kcov
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Richard Weinberger <[email protected]>
Cc: Thomas Meyer <[email protected]>
Cc: user-mode-linux-devel <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Signed-off-by: Vegard Nossum <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
vegard authored and richardweinberger committed Aug 3, 2016
1 parent 8e99bc7 commit 915eed2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/um/Kconfig.common
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions arch/um/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
3 changes: 3 additions & 0 deletions arch/um/os-Linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
3 changes: 3 additions & 0 deletions arch/x86/um/vdso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 915eed2

Please sign in to comment.