Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_coverage.c
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
void | void | ||||
__sanitizer_cov_trace_pc(void) | __sanitizer_cov_trace_pc(void) | ||||
{ | { | ||||
cov_trace_pc_t trace_pc; | cov_trace_pc_t trace_pc; | ||||
trace_pc = (cov_trace_pc_t)atomic_load_ptr(&cov_trace_pc); | trace_pc = (cov_trace_pc_t)atomic_load_ptr(&cov_trace_pc); | ||||
if (trace_pc != NULL) | if (trace_pc != NULL) | ||||
trace_pc((uint64_t)__builtin_return_address(0)); | trace_pc((uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
/* | /* | ||||
* Comparison entry points. When the kernel performs a comparison | * Comparison entry points. When the kernel performs a comparison | ||||
* operation the compiler inserts a call to one of the following | * operation the compiler inserts a call to one of the following | ||||
* functions to record the operation. | * functions to record the operation. | ||||
*/ | */ | ||||
void | void | ||||
__sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) | __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(0), arg1, arg2, | trace_cmp(COV_CMP_SIZE(0), arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
void | void | ||||
__sanitizer_cov_trace_cmp2(uint16_t arg1, uint16_t arg2) | __sanitizer_cov_trace_cmp2(uint16_t arg1, uint16_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(1), arg1, arg2, | trace_cmp(COV_CMP_SIZE(1), arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
void | void | ||||
__sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) | __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(2), arg1, arg2, | trace_cmp(COV_CMP_SIZE(2), arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
void | void | ||||
__sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) | __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(3), arg1, arg2, | trace_cmp(COV_CMP_SIZE(3), arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
void | void | ||||
__sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) | __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(0) | COV_CMP_CONST, arg1, arg2, | trace_cmp(COV_CMP_SIZE(0) | COV_CMP_CONST, arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
void | void | ||||
__sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2) | __sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(1) | COV_CMP_CONST, arg1, arg2, | trace_cmp(COV_CMP_SIZE(1) | COV_CMP_CONST, arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
void | void | ||||
__sanitizer_cov_trace_const_cmp4(uint32_t arg1, uint32_t arg2) | __sanitizer_cov_trace_const_cmp4(uint32_t arg1, uint32_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(2) | COV_CMP_CONST, arg1, arg2, | trace_cmp(COV_CMP_SIZE(2) | COV_CMP_CONST, arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
void | void | ||||
__sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2) | __sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2) | ||||
{ | { | ||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp != NULL) | if (trace_cmp != NULL) | ||||
trace_cmp(COV_CMP_SIZE(3) | COV_CMP_CONST, arg1, arg2, | trace_cmp(COV_CMP_SIZE(3) | COV_CMP_CONST, arg1, arg2, | ||||
(uint64_t)__builtin_return_address(0)); | (uintptr_t)__builtin_return_address(0)); | ||||
} | } | ||||
/* | /* | ||||
* val is the switch operand | * val is the switch operand | ||||
* cases[0] is the number of case constants | * cases[0] is the number of case constants | ||||
* cases[1] is the size of val in bits | * cases[1] is the size of val in bits | ||||
* cases[2..n] are the case constants | * cases[2..n] are the case constants | ||||
*/ | */ | ||||
void | void | ||||
__sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) | __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) | ||||
{ | { | ||||
uint64_t i, count, ret, type; | uint64_t i, count, type; | ||||
uintptr_t ret; | |||||
cov_trace_cmp_t trace_cmp; | cov_trace_cmp_t trace_cmp; | ||||
trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | trace_cmp = (cov_trace_cmp_t)atomic_load_ptr(&cov_trace_cmp); | ||||
if (trace_cmp == NULL) | if (trace_cmp == NULL) | ||||
return; | return; | ||||
count = cases[0]; | count = cases[0]; | ||||
ret = (uint64_t)__builtin_return_address(0); | ret = (uintptr_t)__builtin_return_address(0); | ||||
switch (cases[1]) { | switch (cases[1]) { | ||||
case 8: | case 8: | ||||
type = COV_CMP_SIZE(0); | type = COV_CMP_SIZE(0); | ||||
break; | break; | ||||
case 16: | case 16: | ||||
type = COV_CMP_SIZE(1); | type = COV_CMP_SIZE(1); | ||||
break; | break; | ||||
Show All 16 Lines |