kcov: initial implementation

Implement a device (/dev/kcov) that exposes coverage info for the
kernel. This will be especially useful for coverage-based fuzzing (e.g.
syzkaller).

Exclude a lot of functions which would crash/otherwise interfere in the
coverage, including only processing coverage callbacks when not handling
an irq.
This commit is contained in:
Matheus
2026-10-06 11:05:58 -03:00
parent 111a8696d8
commit e4a4896b4b
14 changed files with 581 additions and 25 deletions
+4
View File
@@ -6,6 +6,7 @@
#include <kernel/abi.h>
#include <kernel/signal.h>
#include <kernel/event.h>
#include <kernel/kcov.h>
#define THREAD_FLAGS_QUEUED 1
#define THREAD_FLAGS_RUNNING 2
@@ -31,6 +32,9 @@ typedef struct thread_t {
struct cpu_t *cpu;
struct cpu_t *cputarget;
struct cpu_t *last_cpu;
#ifdef KCOV_ENABLED
kcov_t *kcov;
#endif
context_t context;
extracontext_t extracontext;
void *kernelstack;