mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +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:
@@ -2,6 +2,7 @@
|
||||
#define _MSR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <kernel/kcov.h>
|
||||
|
||||
#define MSR_IA32APICBASE 0x1B
|
||||
#define MSR_PERF_FIXED_CTR2 0x30b
|
||||
@@ -20,13 +21,13 @@
|
||||
|
||||
#define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01
|
||||
|
||||
static inline uint64_t rdmsr(uint32_t which) {
|
||||
KCOV_DISABLED static inline uint64_t rdmsr(uint32_t which) {
|
||||
uint64_t low,high;
|
||||
asm volatile("rdmsr" : "=a"(low), "=d"(high) : "c"(which));
|
||||
return (high << 32) | low;
|
||||
}
|
||||
|
||||
static inline void wrmsr(uint32_t which, uint64_t value) {
|
||||
KCOV_DISABLED static inline void wrmsr(uint32_t which, uint64_t value) {
|
||||
uint32_t low = value & 0xFFFFFFFF;
|
||||
uint32_t high = (value >> 32) & 0xFFFFFFFF;
|
||||
asm volatile("wrmsr" : : "a"(low), "d"(high), "c"(which));
|
||||
|
||||
Reference in New Issue
Block a user