#include <sys/dtrace_ptss.h>
#include <kern/debug.h>
+#include <machine/pal_routines.h>
+
/* Solaris proc_t is the struct. Darwin's proc_t is a pointer to it. */
#define proc_t struct proc /* Steer clear of the Darwin typedef for proc_t */
*
* REG_RAX -> EAX
* REG_RCX -> ECX
- * ...
+ * REG_RDX -> EDX
+ * REG_RBX -> EBX
+ * REG_RSP -> UESP
+ * REG_RBP -> EBP
+ * REG_RSI -> ESI
* REG_RDI -> EDI
*
* The fasttrap_getreg function knows how to make the correct transformation.
*/
-#if __sol64 || defined(__APPLE__)
static const uint8_t regmap[16] = {
REG_RAX, REG_RCX, REG_RDX, REG_RBX, REG_RSP, REG_RBP, REG_RSI, REG_RDI,
REG_R8, REG_R9, REG_R10, REG_R11, REG_R12, REG_R13, REG_R14, REG_R15,
};
-#else
-static const uint8_t regmap[8] = {
- EAX, ECX, EDX, EBX, UESP, EBP, ESI, EDI
-};
-#endif
static user_addr_t fasttrap_getreg(x86_saved_state_t *, uint_t);
break;
}
-#if __sol64 || defined(__APPLE__)
/*
* Identify the REX prefix on 64-bit processes.
*/
if (p_model == DATAMODEL_LP64 && (instr[start] & 0xf0) == 0x40)
rex = instr[start++];
-#endif
/*
* Now that we're pretty sure that the instruction is okay, copy the
* modes, there is a 32-bit operand.
*/
if (mod == 0 && rm == 5) {
-#if __sol64 || defined(__APPLE__)
if (p_model == DATAMODEL_LP64)
tp->ftt_base = REG_RIP;
else
-#endif
tp->ftt_base = FASTTRAP_NOREG;
sz = 4;
} else {
break;
case FASTTRAP_NOP:
-#if __sol64 || defined(__APPLE__)
ASSERT(p_model == DATAMODEL_LP64 || rex == 0);
/*
* (e.g. xchgl %r8d, %eax or xcghq %r8, %rax).
*/
if (FASTTRAP_REX_B(rex) == 0)
-#endif
tp->ftt_type = FASTTRAP_T_NOP;
break;
}
}
-#if __sol64 || defined(__APPLE__)
if (p_model == DATAMODEL_LP64 && tp->ftt_type == FASTTRAP_T_COMMON) {
/*
* If the process is 64-bit and the instruction type is still
}
}
}
-#endif
return (0);
}
* parent. We know that there's only one thread of control in such a
* process: this one.
*/
- /*
- * APPLE NOTE: Terry says: "You need to hold the process locks (currently: kernel funnel) for this traversal"
- * FIXME: How do we assert this?
- */
- while (p->p_lflag & P_LINVFORK)
- p = p->p_pptr;
+ if (p->p_lflag & P_LINVFORK) {
+ proc_list_lock();
+ while (p->p_lflag & P_LINVFORK)
+ p = p->p_pptr;
+ proc_list_unlock();
+ }
pid = p->p_pid;
pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
* parent. We know that there's only one thread of control in such a
* process: this one.
*/
- /*
- * APPLE NOTE: Terry says: "You need to hold the process locks (currently: kernel funnel) for this traversal"
- * FIXME: How do we assert this?
- */
- while (p->p_lflag & P_LINVFORK)
- p = p->p_pptr;
+ if (p->p_lflag & P_LINVFORK) {
+ proc_list_lock();
+ while (p->p_lflag & P_LINVFORK)
+ p = p->p_pptr;
+ proc_list_unlock();
+ }
pid = p->p_pid;
pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
* parent. We know that there's only one thread of control in such a
* process: this one.
*/
- /*
- * APPLE NOTE: Terry says: "You need to hold the process locks (currently: kernel funnel) for this traversal"
- * How do we assert this?
- */
- while (p->p_lflag & P_LINVFORK) {
+ proc_list_lock();
+ while (p->p_lflag & P_LINVFORK)
p = p->p_pptr;
- }
+ proc_list_unlock();
/*
* We set rp->r_pc to the address of the traced instruction so
return (0);
}
-
uint64_t
fasttrap_pid_getarg(void *arg, dtrace_id_t id, void *parg, int argno,
int aframes)
{
+ pal_register_cache_state(current_thread(), VALID);
#pragma unused(arg, id, parg, aframes)
return (fasttrap_anarg((x86_saved_state_t *)find_user_regs(current_thread()), 1, argno));
}
fasttrap_usdt_getarg(void *arg, dtrace_id_t id, void *parg, int argno,
int aframes)
{
+ pal_register_cache_state(current_thread(), VALID);
#pragma unused(arg, id, parg, aframes)
return (fasttrap_anarg((x86_saved_state_t *)find_user_regs(current_thread()), 0, argno));
}