mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
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:
@@ -57,6 +57,10 @@ thread_t *sched_newthread(void *ip, size_t kstacksize, int nice, proc_t *proc, v
|
||||
}
|
||||
|
||||
void sched_destroythread(thread_t *thread) {
|
||||
#ifdef KCOV_ENABLED
|
||||
if (thread->kcov)
|
||||
kcov_release(thread->kcov);
|
||||
#endif
|
||||
mm_unmap(thread->kernelstack, thread->kernelstacksize, 0);
|
||||
arch_extracontext_free(&thread->extracontext);
|
||||
slab_free(thread_cache, thread);
|
||||
@@ -101,6 +105,11 @@ __attribute__((noreturn)) void sched_threadexit() {
|
||||
PROC_RELEASE(proc);
|
||||
}
|
||||
|
||||
#ifdef KCOV_ENABLED
|
||||
if (current_thread()->kcov)
|
||||
kcov_set_mode(KCOV_MODE_DISABLED);
|
||||
#endif
|
||||
|
||||
interrupt_set(false);
|
||||
arch_context_saveandcall(threadexit_internal, current_cpu()->schedulerstack, NULL);
|
||||
__builtin_unreachable();
|
||||
|
||||
Reference in New Issue
Block a user