diff --git a/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c b/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c index 7a968c9c2ecc..56772b99b878 100644 --- a/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c +++ b/external/cddl/osnet/dev/dtrace/aarch64/dtrace_subr.c @@ -292,7 +292,7 @@ dtrace_invop_start(struct trapframe *frame) sp += (offs); break; default: - break; + __unreachable(); } /* Update the stack pointer and program counter to continue */ diff --git a/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c b/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c index 123290616ec5..54f851925f04 100644 --- a/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c +++ b/external/cddl/osnet/dev/fbt/aarch64/fbt_isa.c @@ -36,6 +36,9 @@ #include #include #include + +#include + #include #include @@ -67,6 +70,7 @@ fbt_invop(uintptr_t addr, struct trapframe *frame, uintptr_t rval) frame->tf_regs.r_reg[3], frame->tf_regs.r_reg[4]); cpu->cpu_dtrace_caller = 0; + KASSERT(fbt->fbtp_savedval != 0); return (fbt->fbtp_savedval); } } @@ -78,8 +82,9 @@ void fbt_patch_tracepoint(fbt_probe_t *fbt, fbt_patchval_t val) { - *fbt->fbtp_patchpoint = val; - cpu_icache_sync_range((vm_offset_t)fbt->fbtp_patchpoint, 4); + db_write_bytes((db_addr_t)fbt->fbtp_patchpoint, sizeof(val), + (const void *)&val); + cpu_icache_sync_range((vm_offset_t)fbt->fbtp_patchpoint, sizeof(val)); } #if defined(__FreeBSD__) @@ -138,6 +143,7 @@ fbt_provide_module_cb(const char *name, int symindx, void *value, if (instr >= limit) return (0); + KASSERT(*instr != 0); #ifdef __FreeBSD__ fbt = malloc(sizeof (fbt_probe_t), M_FBT, M_WAITOK | M_ZERO); @@ -157,7 +163,6 @@ fbt_provide_module_cb(const char *name, int symindx, void *value, #endif fbt->fbtp_savedval = *instr; fbt->fbtp_patchval = FBT_PATCHVAL; - fbt->fbtp_rval = DTRACE_INVOP_PUSHM; fbt->fbtp_symindx = symindx; fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)]; @@ -188,6 +193,7 @@ again: if (instr >= limit) return (0); + KASSERT(*instr != 0); /* * We have a winner! @@ -215,13 +221,10 @@ again: #ifdef __NetBSD__ fbt->fbtp_ctl = mod; #endif - fbt->fbtp_symindx = symindx; - if ((*instr & B_MASK) == B_INSTR) - fbt->fbtp_rval = DTRACE_INVOP_B; - else - fbt->fbtp_rval = DTRACE_INVOP_RET; fbt->fbtp_savedval = *instr; fbt->fbtp_patchval = FBT_PATCHVAL; + fbt->fbtp_symindx = symindx; + fbt->fbtp_hashnext = fbt_probetab[FBT_ADDR2NDX(instr)]; fbt_probetab[FBT_ADDR2NDX(instr)] = fbt; diff --git a/sys/arch/aarch64/aarch64/vectors.S b/sys/arch/aarch64/aarch64/vectors.S index de3c6654f126..d91e61b23132 100644 --- a/sys/arch/aarch64/aarch64/vectors.S +++ b/sys/arch/aarch64/aarch64/vectors.S @@ -3,6 +3,18 @@ #include #include "assym.h" #include "opt_ddb.h" +#include "opt_dtrace.h" + +#ifdef KDTRACE_HOOKS +/* + * dtrace needs to emulate stp x29,x30,[sp,#-FRAMESIZE], and + * FRAMESIZE can be as large as 512, so create a 512-byte buffer + * between the interrupted code's frame and our struct trapframe. + */ +#define TRAP_FRAMESIZE (TF_SIZE + 512) +#else +#define TRAP_FRAMESIZE TF_SIZE +#endif /* * vector_entry macro must be small enough to fit 0x80 bytes! @@ -11,7 +23,7 @@ .align 7 /* aligned 0x80 */ .if \el == 1 - sub sp, sp, #TF_SIZE /* need to allocate stack on el1 */ + sub sp, sp, #TRAP_FRAMESIZE /* need to allocate stack on el1 */ .endif stp x0, x1, [sp, #TF_X0] @@ -35,7 +47,7 @@ .if \el == 0 mrs x20, sp_el0 .else - add x20, sp, #TF_SIZE /* sp is already adjusted */ + add x20, sp, #TRAP_FRAMESIZE /* sp is already adjusted */ .endif mrs x21, elr_el1