From 6d1ffb50fc321edd0c39c565c24fedc38699630c Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Sat, 30 Jul 2016 03:11:53 +0000 Subject: [PATCH] Include fasttrap handling for DATAMODEL_ILP32 when compiling for amd64. MFC after: 1 month --- .../opensolaris/uts/common/dtrace/fasttrap.c | 8 +++++ .../uts/intel/dtrace/fasttrap_isa.c | 29 ++++--------------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c index 51db19ba3c9c..4b739fdf7b3b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -930,6 +931,13 @@ fasttrap_tracepoint_enable(proc_t *p, fasttrap_probe_t *probe, uint_t index) ASSERT(0); } +#ifdef __FreeBSD__ + if (SV_PROC_FLAG(p, SV_LP64)) + p->p_model = DATAMODEL_LP64; + else + p->p_model = DATAMODEL_ILP32; +#endif + /* * If the ISA-dependent initialization goes to plan, go back to the * beginning and try to install this freshly made tracepoint. diff --git a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c index 5b3f485e1b50..7c82176888d3 100644 --- a/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c +++ b/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c @@ -43,11 +43,11 @@ #include #include #else -#include #include +#include #include #include -#include +#include #include #include #include @@ -283,12 +283,10 @@ fasttrap_anarg(struct reg *rp, int function_entry, int argno) DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT | CPU_DTRACE_BADADDR); } else { #endif -#ifdef __i386 - uint32_t *stack = (uint32_t *)rp->r_esp; + uint32_t *stack = (uint32_t *)rp->r_rsp; DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT); value = dtrace_fuword32(&stack[argno + shift]); DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT | CPU_DTRACE_BADADDR); -#endif #ifdef __amd64 } #endif @@ -716,7 +714,6 @@ fasttrap_fulword_noerr(const void *uaddr) } #endif -#ifdef __i386__ static uint32_t fasttrap_fuword32_noerr(const void *uaddr) { @@ -727,7 +724,6 @@ fasttrap_fuword32_noerr(const void *uaddr) return (0); } -#endif static void fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid, @@ -842,7 +838,6 @@ fasttrap_usdt_args64(fasttrap_probe_t *probe, struct reg *rp, int argc, } #endif -#ifdef __i386__ static void fasttrap_usdt_args32(fasttrap_probe_t *probe, struct reg *rp, int argc, uint32_t *argv) @@ -860,7 +855,6 @@ fasttrap_usdt_args32(fasttrap_probe_t *probe, struct reg *rp, int argc, argv[i] = 0; } } -#endif static int fasttrap_do_seg(fasttrap_tracepoint_t *tp, struct reg *rp, uintptr_t *addr) @@ -1094,7 +1088,6 @@ fasttrap_pid_probe(struct reg *rp) if (tp->ftt_ids != NULL) { fasttrap_id_t *id; -#ifdef __amd64 if (p->p_model == DATAMODEL_LP64) { for (id = tp->ftt_ids; id != NULL; id = id->fti_next) { fasttrap_probe_t *probe = id->fti_probe; @@ -1136,9 +1129,8 @@ fasttrap_pid_probe(struct reg *rp) } } } else { -#else /* __amd64 */ uintptr_t s0, s1, s2, s3, s4, s5; - uint32_t *stack = (uint32_t *)rp->r_esp; + uint32_t *stack = (uint32_t *)rp->r_rsp; /* * In 32-bit mode, all arguments are passed on the @@ -1191,10 +1183,7 @@ fasttrap_pid_probe(struct reg *rp) t[2], t[3], t[4]); } } -#endif /* __amd64 */ -#ifdef __amd64 } -#endif } /* @@ -1259,12 +1248,10 @@ fasttrap_pid_probe(struct reg *rp) addr = rp->r_rsp + sizeof (uintptr_t); } else { #endif -#ifdef __i386__ uint32_t dst32; - ret = dst32 = fasttrap_fuword32((void *)rp->r_esp); + ret = dst32 = fasttrap_fuword32((void *)rp->r_rsp); dst = dst32; - addr = rp->r_esp + sizeof (uint32_t); -#endif + addr = rp->r_rsp + sizeof (uint32_t); #ifdef __amd64 } #endif @@ -1409,10 +1396,8 @@ fasttrap_pid_probe(struct reg *rp) ret = fasttrap_sulword((void *)rp->r_rsp, rp->r_rbp); } else { #endif -#ifdef __i386__ rp->r_rsp -= sizeof (uint32_t); ret = fasttrap_suword32((void *)rp->r_rsp, rp->r_rbp); -#endif #ifdef __amd64 } #endif @@ -1732,7 +1717,6 @@ fasttrap_pid_probe(struct reg *rp) i += sizeof (uint64_t); } else { #endif -#ifdef __i386__ /* * Set up the jmp to the next instruction; note that * the size of the traced instruction cancels out. @@ -1741,7 +1725,6 @@ fasttrap_pid_probe(struct reg *rp) /* LINTED - alignment */ *(uint32_t *)&scratch[i] = pc - addr - 5; i += sizeof (uint32_t); -#endif #ifdef __amd64 } #endif