freebsd-skq/sys/amd64
andrew 5e0e456d9f Add support for the Clang Coverage Sanitizer in the kernel (KCOV).
When building with KCOV enabled the compiler will insert function calls
to probes allowing us to trace the execution of the kernel from userspace.
These probes are on function entry (trace-pc) and on comparison operations
(trace-cmp).

Userspace can enable the use of these probes on a single kernel thread with
an ioctl interface. It can allocate space for the probe with KIOSETBUFSIZE,
then mmap the allocated buffer and enable tracing with KIOENABLE, with the
trace mode being passed in as the int argument. When complete KIODISABLE
is used to disable tracing.

The first item in the buffer is the number of trace event that have
happened. Userspace can write 0 to this to reset the tracing, and is
expected to do so on first use.

The format of the buffer depends on the trace mode. When in PC tracing just
the return address of the probe is stored. Under comparison tracing the
comparison type, the two arguments, and the return address are traced. The
former method uses on entry per trace event, while the later uses 4. As
such they are incompatible so only a single mode may be enabled.

KCOV is expected to help fuzzing the kernel, and while in development has
already found a number of issues. It is required for the syzkaller system
call fuzzer [1]. Other kernel fuzzers could also make use of it, either
with the current interface, or by extending it with new modes.

A man page is currently being worked on and is expected to be committed
soon, however having the code in the kernel now is useful for other
developers to use.

[1] https://github.com/google/syzkaller

Submitted by:	Mitchell Horne <mhorne063@gmail.com> (Earlier version)
Reviewed by:	kib
Testing by:	tuexen
Sponsored by:	DARPA, AFRL
Sponsored by:	The FreeBSD Foundation (Mitchell Horne)
Differential Revision:	https://reviews.freebsd.org/D14599
2019-01-12 11:21:28 +00:00
..
acpica Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
amd64 x86: Report per-cpu IPI TLB shootdown generation in ddb 'show pcpu' output. 2019-01-04 17:25:47 +00:00
cloudabi32 Use TO_PTR() to convert integers to pointers. 2017-11-26 14:45:56 +00:00
cloudabi64 Use TO_PTR() to convert integers to pointers. 2017-11-26 14:45:56 +00:00
conf Add support for the Clang Coverage Sanitizer in the kernel (KCOV). 2019-01-12 11:21:28 +00:00
ia32 Remove iBCS2, part2: general kernel 2018-12-19 21:57:58 +00:00
include Add a custom implementation of cpu_lock_delay() for x86. 2018-11-05 22:54:03 +00:00
linux Fix errno values returned from DUMMY_XATTR linuxulator calls 2019-01-11 07:58:25 +00:00
linux32 Fix errno values returned from DUMMY_XATTR linuxulator calls 2019-01-11 07:58:25 +00:00
pci Do not flush cache for PCIe config window. 2018-10-18 20:49:16 +00:00
sgx Rename assym.s to assym.inc 2018-03-20 17:58:51 +00:00
vmm Align IA32_ARCH_CAP MSR definitions and use with SDM rev. 068. 2018-11-16 21:27:11 +00:00
Makefile Bring the tags and links entries for amd64 up to date. 2015-10-27 22:59:24 +00:00