mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
e4a4896b4b
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.
37 lines
971 B
C
37 lines
971 B
C
#ifndef _MSR_H
|
|
#define _MSR_H
|
|
|
|
#include <stdint.h>
|
|
#include <kernel/kcov.h>
|
|
|
|
#define MSR_IA32APICBASE 0x1B
|
|
#define MSR_PERF_FIXED_CTR2 0x30b
|
|
#define MSR_PERF_FIXED_CTR_CTRL 0x38d
|
|
#define MSR_PERF_GLOBAL_STATUS 0x38e
|
|
#define MSR_PERF_GLOBAL_CTRL 0x38f
|
|
#define MSR_PERF_GLOBAL_OVF_CTRL 0x390
|
|
#define MSR_EFER 0xC0000080
|
|
#define MSR_STAR 0xC0000081
|
|
#define MSR_LSTAR 0xC0000082
|
|
#define MSR_CSTAR 0xC0000083
|
|
#define MSR_FMASK 0xC0000084
|
|
#define MSR_FSBASE 0xC0000100
|
|
#define MSR_GSBASE 0xC0000101
|
|
#define MSR_KERNELGSBASE 0xC0000102
|
|
|
|
#define MSR_KVM_SYSTEM_TIME_NEW 0x4b564d01
|
|
|
|
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;
|
|
}
|
|
|
|
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));
|
|
}
|
|
|
|
#endif
|