Use a C wrapper for trap() instead of checking and calling the DTrace trap
hook in assembly. Suggested by: kib Reviewed by: kib (original version) X-MFC-With: r268600
This commit is contained in:
parent
bef4f148b1
commit
5a5f9d21dd
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=268869
@ -228,24 +228,7 @@ alltraps_pushregs_no_rdi:
|
|||||||
.type calltrap,@function
|
.type calltrap,@function
|
||||||
calltrap:
|
calltrap:
|
||||||
movq %rsp,%rdi
|
movq %rsp,%rdi
|
||||||
#ifdef KDTRACE_HOOKS
|
call trap_check
|
||||||
/*
|
|
||||||
* Give DTrace a chance to vet this trap and skip the call to trap() if
|
|
||||||
* it turns out that it was caused by a DTrace probe.
|
|
||||||
*/
|
|
||||||
movq dtrace_trap_func,%rax
|
|
||||||
testq %rax,%rax
|
|
||||||
je skiphook
|
|
||||||
call *%rax
|
|
||||||
testq %rax,%rax
|
|
||||||
jne skiptrap
|
|
||||||
movq %rsp,%rdi
|
|
||||||
skiphook:
|
|
||||||
#endif
|
|
||||||
call trap
|
|
||||||
#ifdef KDTRACE_HOOKS
|
|
||||||
skiptrap:
|
|
||||||
#endif
|
|
||||||
MEXITCOUNT
|
MEXITCOUNT
|
||||||
jmp doreti /* Handle any pending ASTs */
|
jmp doreti /* Handle any pending ASTs */
|
||||||
|
|
||||||
|
@ -97,7 +97,8 @@ PMC_SOFT_DEFINE( , , page_fault, write);
|
|||||||
#include <sys/dtrace_bsd.h>
|
#include <sys/dtrace_bsd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void trap(struct trapframe *frame);
|
extern void __noinline trap(struct trapframe *frame);
|
||||||
|
extern void trap_check(struct trapframe *frame);
|
||||||
extern void syscall(struct trapframe *frame);
|
extern void syscall(struct trapframe *frame);
|
||||||
void dblfault_handler(struct trapframe *frame);
|
void dblfault_handler(struct trapframe *frame);
|
||||||
|
|
||||||
@ -604,6 +605,19 @@ trap(struct trapframe *frame)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure that we ignore any DTrace-induced faults. This function cannot
|
||||||
|
* be instrumented, so it cannot generate such faults itself.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
trap_check(struct trapframe *frame)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (dtrace_trap_func != NULL && (*dtrace_trap_func)(frame))
|
||||||
|
return;
|
||||||
|
trap(frame);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
trap_pfault(frame, usermode)
|
trap_pfault(frame, usermode)
|
||||||
struct trapframe *frame;
|
struct trapframe *frame;
|
||||||
|
@ -462,9 +462,7 @@ dtrace_gethrestime(void)
|
|||||||
return (current_time.tv_sec * 1000000000ULL + current_time.tv_nsec);
|
return (current_time.tv_sec * 1000000000ULL + current_time.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Function to handle DTrace traps during probes. See amd64/amd64/trap.c. */
|
||||||
* Function to handle DTrace traps during probes. See amd64/amd64/exception.S.
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
dtrace_trap(struct trapframe *frame)
|
dtrace_trap(struct trapframe *frame)
|
||||||
{
|
{
|
||||||
|
@ -232,13 +232,18 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
|
|||||||
int size;
|
int size;
|
||||||
u_int8_t *instr, *limit;
|
u_int8_t *instr, *limit;
|
||||||
|
|
||||||
if (strncmp(name, "dtrace_", 7) == 0 &&
|
if ((strncmp(name, "dtrace_", 7) == 0 &&
|
||||||
strncmp(name, "dtrace_safe_", 12) != 0) {
|
strncmp(name, "dtrace_safe_", 12) != 0) ||
|
||||||
|
strcmp(name, "trap_check") == 0) {
|
||||||
/*
|
/*
|
||||||
* Anything beginning with "dtrace_" may be called
|
* Anything beginning with "dtrace_" may be called
|
||||||
* from probe context unless it explicitly indicates
|
* from probe context unless it explicitly indicates
|
||||||
* that it won't be called from probe context by
|
* that it won't be called from probe context by
|
||||||
* using the prefix "dtrace_safe_".
|
* using the prefix "dtrace_safe_".
|
||||||
|
*
|
||||||
|
* Additionally, we avoid instrumenting trap_check() to avoid
|
||||||
|
* the possibility of generating a fault in probe context before
|
||||||
|
* DTrace's fault handler is called.
|
||||||
*/
|
*/
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user