Up to [cvs.NetBSD.org] / src / tests / modules
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
Sync with HEAD
file t_kcov.c was added on branch phil-wifi on 2019-06-10 22:10:08 +0000
Drop no longer needed macros KCOV_STORE() KCOV_LOAD() in kcov(4) Corrently KCOV_STORE() and KCOV_LOAD() are equivalent to x=y. Obtained from <R3x>
Fix flaky check for the /dev/kcov device in t_kcov Add a top-level check for the KCOV device, instead of deferring it ot each thread. The thread-based solution was flaky. PR kern/54064 by Andreas Gustafsson
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.
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.
Fix bug in kcov_multiple_threads in t_kcov Spawn the expected number of threads rather than hardcoding one value for all tests.
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>.
Fix build of t_kcov Correct the syntax that used to work in earlier uncommitted version.
Add KCOV_LOAD() and KCOV_STORE() - new helper macros New macros prefer 64-bit atomic operations whenever accessible. As a fallback they use volatile move operations that are not known to have negative effect in KCOV even if interrupted in the middle of operation. Enable kcov_basic and kcov_thread tests on targets without __HAVE_ATOMIC64_OPS.
Fix build of kcov tests on CPUs without 64-bit atomics Restrict the 64-bit atomics to ports defining __HAVE_ATOMIC64_OPS. Using 64-bit atomics is still good for i586 fuzzing, but the tests are build for earlier CPUs. This makes this code to be disabled in i386 builds. There is a similar situation with few other ports that offer 64-bit atomics in certain CPU models and ABIs.
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.