diff options
author | anton <anton@cvs.openbsd.org> | 2020-08-01 08:40:21 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2020-08-01 08:40:21 +0000 |
commit | 305b18a7d9db2b0c1b1d16cfc7add1adbbbbe82d (patch) | |
tree | cd8070c731ede7d08850af72be49944b3d2a76e5 /share/man/man9 | |
parent | e4b9cd26ed4156efd50d5f75c946f074d205264c (diff) |
Add support for remote coverage to kcov. Remote coverage is collected
from threads other than the one currently having kcov enabled. A thread
with kcov enabled occasionally delegates work to another thread,
collecting coverage from such threads improves the ability of syzkaller
to correlate side effects in the kernel caused by issuing a syscall.
Remote coverage is divided into subsystems. The only supported subsystem
right now collects coverage from scheduled tasks and timeouts on behalf
of a kcov enabled thread. In order to make this work `struct task' and
`struct timeout' must be extended with a new field keeping track of the
process that scheduled the task/timeout. Both aforementioned structures
have therefore increased with the size of a pointer on all
architectures.
The kernel API is documented in a new kcov_remote_register(9) manual.
Remote coverage is also supported by kcov on NetBSD and Linux.
ok mpi@
Diffstat (limited to 'share/man/man9')
-rw-r--r-- | share/man/man9/Makefile | 6 | ||||
-rw-r--r-- | share/man/man9/kcov_remote_register.9 | 92 |
2 files changed, 95 insertions, 3 deletions
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 7b494dc20de..a04e8add7f5 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.305 2020/07/06 11:48:03 dlg Exp $ +# $OpenBSD: Makefile,v 1.306 2020/08/01 08:40:20 anton Exp $ # $NetBSD: Makefile,v 1.4 1996/01/09 03:23:01 thorpej Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -22,8 +22,8 @@ MAN= aml_evalnode.9 atomic_add_int.9 atomic_cas_uint.9 \ ifiq_input.9 ifq_enqueue.9 \ ifq_deq_begin.9 imax.9 iic.9 intro.9 inittodr.9 \ intr_barrier.9 intrmap_create.9 \ - KASSERT.9 km_alloc.9 knote.9 kstat_create.9 kstat_kv_init.9 \ - kthread.9 ktrace.9 \ + KASSERT.9 kcov_remote_register.9 km_alloc.9 knote.9 kstat_create.9 \ + kstat_kv_init.9 kthread.9 ktrace.9 \ lim_cur.9 loadfirmware.9 log.9 \ malloc.9 membar_sync.9 memcmp.9 mbuf.9 mbuf_tags.9 md5.9 mi_switch.9 \ microtime.9 ml_init.9 mq_init.9 mutex.9 \ diff --git a/share/man/man9/kcov_remote_register.9 b/share/man/man9/kcov_remote_register.9 new file mode 100644 index 00000000000..5186d72db1d --- /dev/null +++ b/share/man/man9/kcov_remote_register.9 @@ -0,0 +1,92 @@ +.\" $OpenBSD: kcov_remote_register.9,v 1.1 2020/08/01 08:40:20 anton Exp $ +.\" +.\" Copyright (c) 2020 Anton Lindqvist <anton@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: August 1 2020 $ +.Dt KCOV_REMOTE_REGISTER 9 +.Os +.Sh NAME +.Nm kcov_remote_register , +.Nm kcov_remote_unregister , +.Nm kcov_remote_enter , +.Nm kcov_remote_leave +.Nd Remote kernel code coverage collection interface +.Sh SYNOPSIS +.In sys/kcov.h +.Ft void +.Fn kcov_remote_register "int subsystem" "void *id" +.Ft void +.Fn kcov_remote_unregister "int subsystem" "void *id" +.Ft void +.Fn kcov_remote_enter "int subsystem" "void *id" +.Ft void +.Fn kcov_remote_leave "int subsystem" "void *id" +.Sh DESCRIPTION +These functions provide an interface to collect code coverage from various +kernel subsystems using +.Xr kcov 4 . +The +.Fa subsystem +must be one of the following: +.Bd -literal +#define KCOV_REMOTE_COMMON 0 +.Ed +.Pp +The +.Va id +must be an unique identifier for a resource tied to +.Va subsystem +that is known both by kernel and user space. +For instance, a network interface driver could form a subsystem using the +unique interface identifier as the +.Fa id . +.Pp +.Fn kcov_remote_register +registers a new instance of the given +.Fa subsystem . +Calling this function more than once with the same arguments is idempotent. +.Pp +.Fn kcov_remote_unregister +unregisters an existing instance of the given +.Fa subsystem , +if present. +If one or many threads are currently within a remote section, +.Fn kcov_remote_unregister +will sleep until all the sections has been left. +.Pp +.Fn kcov_remote_enter +enters a remote section. +If the current thread has +.Xr kcov 4 +enabled, code coverage will collected inside the remote section. +Remote sections may not be nested. +.Pp +.Fn kcov_remote_leave +leaves a remote section. +.Sh CONTEXT +.Fn kcov_remote_register , +.Fn kcov_remote_unregister , +.Fn kcov_remote_enter +and +.Fn kcov_remote_leave +can be called from process context. +.Sh CODE REFERENCES +These functions are implemented in +.Pa sys/dev/kcov.c . +.Sh SEE ALSO +.Xr kcov 4 +.Sh HISTORY +These functions first appeared in +.Ox 6.8 . |