History log of /src/sys/kern/subr_kcov.c |
Revision | | Date | Author | Comments |
1.18 |
| 26-Oct-2022 |
riastradh | kern/subr_kcov.c: We already get cold from sys/kernel.h.
|
1.17 |
| 06-Jul-2022 |
riastradh | uvm(9): fo_mmap caller guarantees positive size.
No functional change intended, just sprinkling assertions to make it clearer.
|
1.16 |
| 03-Jul-2020 |
maxv | Sync trace-pc and trace-cmp.
|
1.15 |
| 16-May-2020 |
hannken | Add __diagused, amd64 kernel ALL compiles again.
|
1.14 |
| 15-May-2020 |
maxv | Introduce kcov_silence_enter() and kcov_silence_leave(), to allow to temporarily disable KCOV on the current lwp. Should be used in the rare but problematic cases where extreme noise is introduced by an uninteresting subsystem.
Use this capability to silence KCOV during the LOCKDEBUG lookups. This divides the size of the KCOV output by more than two in my KCOV+vHCI tests.
|
1.13 |
| 15-May-2020 |
maxv | Introduce KCOV remote support. This allows to collect KCOV coverage on threads other than curlwp, which is useful when fuzzing components that defer processing, such as the network stack (partially runs in softints) and the USB stack (partially runs in uhub kthreads).
A subsystem that whishes to provide coverage for its threads creates a "mailbox" via kcov_remote_register() and gives it a (subsystem, id) identifier. There is one mailbox per "target lwp". The target lwp(s) must then call kcov_remote_enter() and kcov_remote_leave() with the identifier, to respectively enable and disable coverage within the thread.
On the userland side, the fuzzer has access to the mailboxes on the system with the KCOV_IOC_REMOTE_ATTACH and KCOV_IOC_REMOTE_DETACH ioctls. When attached to a mailbox with a given identifier, the KCOV_IOC_ENABLE, KCOV_IOC_DISABLE and mmap() operations will affect the mailbox.
As a demonstrator, the vHCI subsystem is changed to use KCOV mailboxes. When the vHCI bus attaches it creates as many mailboxes as it has USB ports, each mailbox being associated with a distinct port. Uhub is changed to enable KCOV coverage in usbd_new_device(). With that in place, all of the USB enumeration procedure can be traced with KCOV.
|
1.12 |
| 04-Apr-2020 |
maxv | Drop specificdata from KCOV, kMSan doesn't interact well with it. Also reduces the overhead.
|
1.11 |
| 07-Dec-2019 |
kamil | Revert the in_interrupt() change to use again the x86 specific code
This is prerequisite for kMSan and upcoming kernel changes.
Discussed with <maxv>
|
1.10 |
| 01-Dec-2019 |
kamil | Switch in_interrupt() in KCOV to cpu_intr_p()
This makes KCOV more MI friendly and removes x86-specific in_interrupt() implementation.
|
1.9 |
| 15-Nov-2019 |
maxv | Make kMSan compatible with KCOV. With kMSan we are forced to stay with the fsanitize flag on subr_kcov.c, which means that kMSan will instrument KCOV. We add a bunch of __nomsan attributes to reduce this instrumentation, but it does not remove it completely. That's fine.
|
1.8 |
| 26-May-2019 |
kamil | branches: 1.8.2; Drop no longer available macros KCOV_STORE() KCOV_LOAD() in kcov(4)
Recently KCOV_STORE() and KCOV_LOAD() were equivalent to x=y.
Obtained from <R3x>
|
1.7 |
| 07-Apr-2019 |
kamil | Switch kcov module class to MODULE_CLASS_MISC
MODULE_CLASS_ANY is not intended to be used by modules.
Noted by <pgoyette>
|
1.6 |
| 10-Mar-2019 |
kamil | Introduce enhancements to the kcov(4) code
Add new tests verifying dup2(2) scenarios: - kcov_dup2 - kcov_basic_dup2_pc - kcov_basic_dup2_cmp
The dup2(2) trick is used by syzkaller and assert that it works. All new tests pass.
While there add minor non-functional cleanup changes.
|
1.5 |
| 10-Mar-2019 |
kamil | Add support for trace type selection in kcov(4)
Allow to specify mode in KCOV_IOC_ENABLE synchronizing the functionality with Linux, FreeBSD and OpenBSD. As a NetBSD (and OpenBSD) specific of the ioctl(2) interface, the mode argument has to be specified as &value rather than value.
There are 3 modes available: 1. KCOV_MODE_NONE -- no trace specified, useful for testing purposes 2. KCOV_MODE_TRACE_PC -- trace the kernel program counter 3. KCOV_MODE_TRACE_CMP -- trace comparison instructions and switch statements
Adapt the ATF tests and documentation for new API.
The KCOV_MODE_TRACE_CMP mode is implemented but still awaits for the GCC 8.x upgrade or selection of Clang/LLVM as the kernel compiler.
Obtained from OpenBSD and adapted for NetBSD by myself.
|
1.4 |
| 10-Mar-2019 |
kamil | Add support for multiple threads in kcov(4)
Reuse the fd_clone() API to associate kcov descriptors (KD) with a file descriptor. Each fd (/dev/kcov) can be reused for a single LWP.
Add new ATF regression tests and cleanup existing code there. All tests pass.
Refresh the kcov(4) man page documentation.
Developed with help from <maxv>.
|
1.3 |
| 23-Feb-2019 |
kamil | Stop including <sys/atomic.h> in KCOV
This header is not needed.
Noted by <martin>
|
1.2 |
| 23-Feb-2019 |
kamil | Fix subr_kcov build on NetBSD/i386
Cast the pointer returned from __builtin_return_address() to intptr_t before converting it to uint64_t.
|
1.1 |
| 23-Feb-2019 |
kamil | Add KCOV - kernel code coverage tracing device
The KCOV driver implements collection of code coverage inside the kernel. It can be enabled on a per process basis from userland, allowing the kernel program counter to be collected during syscalls triggered by the same process.
The device is oriented towards kernel fuzzers, in particular syzkaller.
Currently the only supported coverage type is -fsanitize-coverage=trace-pc.
The KCOV driver was initially developed in Linux. A driver based on the same concept was then implemented in FreeBSD and OpenBSD.
Documentation is borrowed from OpenBSD and ATF tests from FreeBSD.
This patch has been prepared by Siddharth Muralee, improved by <maxv> and polished by myself before importing into the mainline tree.
All ATF tests pass.
|
1.8.2.3 |
| 13-Apr-2020 |
martin | Mostly merge changes from HEAD upto 20200411
|
1.8.2.2 |
| 10-Jun-2019 |
christos | Sync with HEAD
|
1.8.2.1 |
| 26-May-2019 |
christos | file subr_kcov.c was added on branch phil-wifi on 2019-06-10 22:09:03 +0000
|