Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/dev/fbt/riscv/fbt_isa.c
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | case FBT_C_PATCHVAL: | ||||
break; | break; | ||||
case FBT_PATCHVAL: | case FBT_PATCHVAL: | ||||
*fbt->fbtp_patchpoint = val; | *fbt->fbtp_patchpoint = val; | ||||
fence_i(); | fence_i(); | ||||
break; | break; | ||||
}; | }; | ||||
} | } | ||||
static int | |||||
match_opcode(uint32_t insn, int match, int mask) | |||||
{ | |||||
if (((insn ^ match) & mask) == 0) | |||||
return (1); | |||||
return (0); | |||||
} | |||||
static int | |||||
check_c_ret(uint32_t **instr) | |||||
{ | |||||
uint16_t *instr1; | |||||
int i; | |||||
for (i = 0; i < 2; i++) { | |||||
instr1 = (uint16_t *)(*instr) + i; | |||||
if (match_opcode(*instr1, (MATCH_C_JR | (X_RA << RD_SHIFT)), | |||||
(MASK_C_JR | RD_MASK))) { | |||||
*instr = (uint32_t *)instr1; | |||||
return (1); | |||||
} | |||||
} | |||||
return (0); | |||||
} | |||||
static int | |||||
check_c_sdsp(uint32_t **instr) | |||||
{ | |||||
uint16_t *instr1; | |||||
int i; | |||||
for (i = 0; i < 2; i++) { | |||||
instr1 = (uint16_t *)(*instr) + i; | |||||
if (match_opcode(*instr1, (MATCH_C_SDSP | RS2_C_RA), | |||||
(MASK_C_SDSP | RS2_C_MASK))) { | |||||
*instr = (uint32_t *)instr1; | |||||
return (1); | |||||
} | |||||
} | |||||
return (0); | |||||
} | |||||
int | int | ||||
fbt_provide_module_function(linker_file_t lf, int symindx, | fbt_provide_module_function(linker_file_t lf, int symindx, | ||||
linker_symval_t *symval, void *opaque) | linker_symval_t *symval, void *opaque) | ||||
{ | { | ||||
fbt_probe_t *fbt, *retfbt; | fbt_probe_t *fbt, *retfbt; | ||||
uint32_t *instr, *limit; | uint32_t *instr, *limit; | ||||
const char *name; | const char *name; | ||||
char *modname; | char *modname; | ||||
Show All 21 Lines | if (strcmp(name, "do_trap_supervisor") == 0) | ||||
return (0); | return (0); | ||||
instr = (uint32_t *)(symval->value); | instr = (uint32_t *)(symval->value); | ||||
limit = (uint32_t *)(symval->value + symval->size); | limit = (uint32_t *)(symval->value + symval->size); | ||||
/* Look for sd operation */ | /* Look for sd operation */ | ||||
for (; instr < limit; instr++) { | for (; instr < limit; instr++) { | ||||
/* Look for a non-compressed store of ra to sp */ | /* Look for a non-compressed store of ra to sp */ | ||||
if (match_opcode(*instr, (MATCH_SD | RS2_RA | RS1_SP), | if (dtrace_instr_sdsp(&instr)) { | ||||
(MASK_SD | RS2_MASK | RS1_MASK))) { | |||||
rval = DTRACE_INVOP_SD; | rval = DTRACE_INVOP_SD; | ||||
patchval = FBT_PATCHVAL; | patchval = FBT_PATCHVAL; | ||||
break; | break; | ||||
} | } | ||||
/* Look for a 'C'-compressed store of ra to sp. */ | /* Look for a 'C'-compressed store of ra to sp. */ | ||||
if (check_c_sdsp(&instr)) { | if (dtrace_instr_c_sdsp(&instr)) { | ||||
rval = DTRACE_INVOP_C_SDSP; | rval = DTRACE_INVOP_C_SDSP; | ||||
patchval = FBT_C_PATCHVAL; | patchval = FBT_C_PATCHVAL; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (instr >= limit) | if (instr >= limit) | ||||
return (0); | return (0); | ||||
Show All 14 Lines | fbt_provide_module_function(linker_file_t lf, int symindx, | ||||
fbt_probetab[FBT_ADDR2NDX(instr)] = fbt; | fbt_probetab[FBT_ADDR2NDX(instr)] = fbt; | ||||
lf->fbt_nentries++; | lf->fbt_nentries++; | ||||
retfbt = NULL; | retfbt = NULL; | ||||
again: | again: | ||||
for (; instr < limit; instr++) { | for (; instr < limit; instr++) { | ||||
/* Look for non-compressed return */ | /* Look for non-compressed return */ | ||||
if (match_opcode(*instr, (MATCH_JALR | (X_RA << RS1_SHIFT)), | if (dtrace_instr_ret(&instr)) { | ||||
(MASK_JALR | RD_MASK | RS1_MASK | IMM_MASK))) { | |||||
rval = DTRACE_INVOP_RET; | rval = DTRACE_INVOP_RET; | ||||
patchval = FBT_PATCHVAL; | patchval = FBT_PATCHVAL; | ||||
break; | break; | ||||
} | } | ||||
/* Look for 'C'-compressed return */ | /* Look for 'C'-compressed return */ | ||||
if (check_c_ret(&instr)) { | if (dtrace_instr_c_ret(&instr)) { | ||||
rval = DTRACE_INVOP_C_RET; | rval = DTRACE_INVOP_C_RET; | ||||
patchval = FBT_C_PATCHVAL; | patchval = FBT_C_PATCHVAL; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (instr >= limit) | if (instr >= limit) | ||||
return (0); | return (0); | ||||
Show All 31 Lines |