dtrace_isa.c revision 8e50396accfa540cbe0b549256487d237e3d02f3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013, 2014 by Delphix. All rights reserved.
*/
#include <sys/dtrace_impl.h>
#include <sys/privregs.h>
#include <sys/sysmacros.h>
extern uintptr_t kernelbase;
int dtrace_ustackdepth_max = 2048;
void
{
int depth = 0;
else
aframes++;
while (depth < pcstack_limit) {
if (on_intr) {
/*
* Hop from interrupt stack to thread stack.
*/
on_intr = 0;
continue;
}
/*
* This is the last frame we can process; indicate
* that we should return after processing this frame.
*/
last = 1;
}
if (aframes > 0) {
/*
* We've just run out of artificial frames,
* and we have a valid caller -- fill it in
* now.
*/
}
} else {
if (depth < pcstack_limit)
}
if (last) {
while (depth < pcstack_limit)
return;
}
}
}
static int
{
int ret = 0;
ASSERT(dtrace_ustackdepth_max > 0);
if (p->p_model == DATAMODEL_NATIVE) {
} else {
}
while (pc != 0) {
/*
* We limit the number of times we can go around this
* loop to account for a circular stack.
*/
if (ret++ >= dtrace_ustackdepth_max) {
*flags |= CPU_DTRACE_BADSTACK;
break;
}
if (pcstack_limit <= 0)
break;
}
if (sp == 0)
break;
if (p->p_model == DATAMODEL_NATIVE) {
} else {
}
} else {
if (p->p_model == DATAMODEL_NATIVE) {
} else {
}
}
*flags |= CPU_DTRACE_BADSTACK;
break;
}
/*
* This is totally bogus: if we faulted, we're going to clear
* the fault and break. This is to deal with the apparently
* broken Java stacks on x86.
*/
if (*flags & CPU_DTRACE_FAULT) {
*flags &= ~CPU_DTRACE_FAULT;
break;
}
}
return (ret);
}
void
{
int n;
return;
if (pcstack_limit <= 0)
return;
/*
* If there's no user context we still need to zero the stack.
*/
goto zero;
if (pcstack_limit <= 0)
return;
if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
if (pcstack_limit <= 0)
return;
if (p->p_model == DATAMODEL_NATIVE)
else
}
ASSERT(n >= 0);
ASSERT(n <= pcstack_limit);
pcstack += n;
pcstack_limit -= n;
zero:
while (pcstack_limit-- > 0)
}
int
dtrace_getustackdepth(void)
{
int n = 0;
return (0);
return (-1);
if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
n++;
if (p->p_model == DATAMODEL_NATIVE)
else
}
return (n);
}
void
{
if (*flags & CPU_DTRACE_FAULT)
return;
if (pcstack_limit <= 0)
return;
/*
* If there's no user context we still need to zero the stack.
*/
goto zero;
if (pcstack_limit <= 0)
return;
if (p->p_model == DATAMODEL_NATIVE) {
} else {
}
if (DTRACE_CPUFLAG_ISSET(CPU_DTRACE_ENTRY)) {
*fpstack++ = 0;
if (pcstack_limit <= 0)
return;
if (p->p_model == DATAMODEL_NATIVE)
else
}
while (pc != 0) {
if (pcstack_limit <= 0)
break;
if (sp == 0)
break;
if (p->p_model == DATAMODEL_NATIVE) {
} else {
}
} else {
if (p->p_model == DATAMODEL_NATIVE) {
} else {
}
}
/*
* This is totally bogus: if we faulted, we're going to clear
* the fault and break. This is to deal with the apparently
* broken Java stacks on x86.
*/
if (*flags & CPU_DTRACE_FAULT) {
*flags &= ~CPU_DTRACE_FAULT;
break;
}
}
zero:
while (pcstack_limit-- > 0)
}
/*ARGSUSED*/
{
int i;
#if defined(__amd64)
/*
* A total of 6 arguments are passed via registers; any argument with
* index of 5 or lower is therefore in a register.
*/
int inreg = 5;
#endif
for (i = 1; i <= aframes; i++) {
#if !defined(__amd64)
/*
* If we pass through the invalid op handler, we will
* use the pointer that it passed to the stack as the
* second argument to dtrace_invop() as the pointer to
* the stack. When using this stack, we must step
* beyond the EIP that was pushed when the trap was
* taken -- hence the "+ 1" below.
*/
#else
/*
* In the case of amd64, we will use the pointer to the
* regs structure that was pushed when we took the
* trap. To get this structure, we must increment
* beyond the frame structure, the calling RIP, and
* padding stored in dtrace_invop(). If the argument
* that we're seeking is passed on the stack, we'll
* pull the true stack pointer out of the saved
* registers and decrement our argument by the number
* of arguments passed in registers; if the argument
* we're seeking is passed in regsiters, we can just
* load it directly.
*/
sizeof (uintptr_t) * 2);
} else {
}
#endif
goto load;
}
}
/*
* We know that we did not come through a trap to get into
* dtrace_probe() -- the provider simply called dtrace_probe()
* directly. As this is the case, we need to shift the argument
* that we're looking for: the probe ID is the first argument to
* dtrace_probe(), so the argument n will actually be found where
* one would expect to find argument (n + 1).
*/
arg++;
#if defined(__amd64)
/*
* This shouldn't happen. If the argument is passed in a
* register then it should have been, well, passed in a
* register...
*/
return (0);
}
#endif
load:
return (val);
}
/*ARGSUSED*/
int
{
int depth = 0;
int on_intr;
else
aframes++;
for (;;) {
depth++;
if (on_intr) {
/*
* Hop from interrupt stack to thread stack.
*/
on_intr = 0;
continue;
}
break;
}
}
return (0);
}
{
#if defined(__amd64)
int regmap[] = {
REG_GS, /* GS */
REG_FS, /* FS */
REG_ES, /* ES */
REG_DS, /* DS */
REG_RDI, /* EDI */
REG_RSI, /* ESI */
REG_RBP, /* EBP */
REG_RSP, /* ESP */
REG_RBX, /* EBX */
REG_RDX, /* EDX */
REG_RCX, /* ECX */
REG_RAX, /* EAX */
REG_TRAPNO, /* TRAPNO */
REG_ERR, /* ERR */
REG_RIP, /* EIP */
REG_CS, /* CS */
REG_RFL, /* EFL */
REG_RSP, /* UESP */
REG_SS /* SS */
};
return (0);
}
} else {
}
switch (reg) {
case REG_RDI:
case REG_RSI:
case REG_RDX:
case REG_RCX:
case REG_R8:
case REG_R9:
case REG_RAX:
case REG_RBX:
case REG_RBP:
case REG_R10:
case REG_R11:
case REG_R12:
case REG_R13:
case REG_R14:
case REG_R15:
case REG_DS:
case REG_ES:
case REG_FS:
case REG_GS:
case REG_TRAPNO:
case REG_ERR:
case REG_RIP:
case REG_CS:
case REG_SS:
case REG_RFL:
case REG_RSP:
default:
return (0);
}
#else
return (0);
}
#endif
}
static int
{
return (0);
}
return (1);
}
/*ARGSUSED*/
void
{
}
/*ARGSUSED*/
void
{
}
void
{
}
void
{
}
dtrace_fuword8(void *uaddr)
{
extern uint8_t dtrace_fuword8_nocheck(void *);
return (0);
}
return (dtrace_fuword8_nocheck(uaddr));
}
dtrace_fuword16(void *uaddr)
{
extern uint16_t dtrace_fuword16_nocheck(void *);
return (0);
}
return (dtrace_fuword16_nocheck(uaddr));
}
dtrace_fuword32(void *uaddr)
{
extern uint32_t dtrace_fuword32_nocheck(void *);
return (0);
}
return (dtrace_fuword32_nocheck(uaddr));
}
dtrace_fuword64(void *uaddr)
{
extern uint64_t dtrace_fuword64_nocheck(void *);
return (0);
}
return (dtrace_fuword64_nocheck(uaddr));
}