PERFORCE change 206903 for review
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Sun Feb 26 07:26:43 UTC 2012
http://p4web.freebsd.org/@@206903?ac=10
Change 206903 by gonzo at gonzo_thinkpad on 2012/02/26 07:26:20
Initial code drop from my private git repo
Affected files ...
.. //depot/projects/dtrace-mips/Makefile.inc1#2 edit
.. //depot/projects/dtrace-mips/cddl/contrib/opensolaris/lib/libdtrace/mips/dt_isadep.c#1 add
.. //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c#2 edit
.. //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c#2 edit
.. //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h#2 edit
.. //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/output.c#2 edit
.. //depot/projects/dtrace-mips/cddl/lib/Makefile#2 edit
.. //depot/projects/dtrace-mips/cddl/lib/libdtrace/Makefile#2 edit
.. //depot/projects/dtrace-mips/cddl/usr.sbin/Makefile#2 edit
.. //depot/projects/dtrace-mips/contrib/gcc/config/mips/freebsd.h#2 edit
.. //depot/projects/dtrace-mips/lib/Makefile#2 edit
.. //depot/projects/dtrace-mips/lib/libelf/libelf_data.c#2 edit
.. //depot/projects/dtrace-mips/lib/libproc/proc_bkpt.c#2 edit
.. //depot/projects/dtrace-mips/lib/libproc/proc_regs.c#2 edit
.. //depot/projects/dtrace-mips/share/mk/bsd.cpu.mk#2 edit
.. //depot/projects/dtrace-mips/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c#2 edit
.. //depot/projects/dtrace-mips/sys/cddl/contrib/opensolaris/uts/mips/dtrace/fasttrap_isa.c#1 add
.. //depot/projects/dtrace-mips/sys/cddl/contrib/opensolaris/uts/mips/sys/fasttrap_isa.h#1 add
.. //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/dis_tables.c#1 add
.. //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/dis_tables.h#1 add
.. //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/dtrace_asm.S#1 add
.. //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/dtrace_isa.c#1 add
.. //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/dtrace_subr.c#1 add
.. //depot/projects/dtrace-mips/sys/cddl/dev/dtrace/mips/regset.h#1 add
.. //depot/projects/dtrace-mips/sys/cddl/dev/lockstat/lockstat.c#2 edit
.. //depot/projects/dtrace-mips/sys/cddl/dev/profile/profile.c#2 edit
.. //depot/projects/dtrace-mips/sys/conf/files.mips#2 edit
.. //depot/projects/dtrace-mips/sys/kern/init_main.c#2 edit
.. //depot/projects/dtrace-mips/sys/kern/link_elf.c#2 edit
.. //depot/projects/dtrace-mips/sys/mips/conf/CN5020#1 add
.. //depot/projects/dtrace-mips/sys/mips/conf/CN5020.hints#1 add
.. //depot/projects/dtrace-mips/sys/mips/include/db_machdep.h#2 edit
.. //depot/projects/dtrace-mips/sys/mips/include/trap.h#2 edit
.. //depot/projects/dtrace-mips/sys/mips/mips/backtrace.c#1 add
.. //depot/projects/dtrace-mips/sys/mips/mips/db_trace.c#2 edit
.. //depot/projects/dtrace-mips/sys/mips/mips/exception.S#2 edit
.. //depot/projects/dtrace-mips/sys/mips/mips/trap.c#2 edit
.. //depot/projects/dtrace-mips/sys/modules/cyclic/Makefile#2 edit
.. //depot/projects/dtrace-mips/sys/modules/dtrace/Makefile#2 edit
.. //depot/projects/dtrace-mips/sys/sys/elf_common.h#2 edit
Differences ...
==== //depot/projects/dtrace-mips/Makefile.inc1#2 (text+ko) ====
@@ -1054,9 +1054,7 @@
usr.bin/clang/clang-tblgen
.endif
-.if ${MK_CDDL} != "no" && \
- ${BOOTSTRAPPING} < 800038 && \
- !(${BOOTSTRAPPING} >= 700112 && ${BOOTSTRAPPING} < 799999)
+.if ${MK_CDDL} != "no"
_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
.endif
==== //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/ctf.c#2 (text+ko) ====
@@ -62,6 +62,18 @@
int ntholes; /* number of type holes */
};
+/*
+ * Macros to reverse byte order
+ */
+#define BSWAP_8(x) ((x) & 0xff)
+#define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
+#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
+
+#define SWAP_16(x) (x) = BSWAP_16(x)
+#define SWAP_32(x) (x) = BSWAP_32(x)
+
+static int needSwap;
+
/*PRINTFLIKE1*/
static void
parseterminate(const char *fmt, ...)
@@ -140,6 +152,11 @@
ctl.ctl_label = strtab_insert(&b->ctb_strtab, le->le_name);
ctl.ctl_typeidx = le->le_idx;
+ if (needSwap) {
+ SWAP_32(ctl.ctl_label);
+ SWAP_32(ctl.ctl_typeidx);
+ }
+
ctf_buf_write(b, &ctl, sizeof (ctl));
return (1);
@@ -152,6 +169,10 @@
ctf_buf_write(b, &id, sizeof (id));
+ if (needSwap) {
+ SWAP_16(id);
+ }
+
debug(3, "Wrote object %s (%d)\n", (idp ? idp->ii_name : "(null)"), id);
}
@@ -180,10 +201,21 @@
fdata[0] = CTF_TYPE_INFO(CTF_K_FUNCTION, 1, nargs);
fdata[1] = idp->ii_dtype->t_id;
+
+ if (needSwap) {
+ SWAP_16(fdata[0]);
+ SWAP_16(fdata[1]);
+ }
+
ctf_buf_write(b, fdata, sizeof (fdata));
for (i = 0; i < idp->ii_nargs; i++) {
id = idp->ii_args[i]->t_id;
+
+ if (needSwap) {
+ SWAP_16(id);
+ }
+
ctf_buf_write(b, &id, sizeof (id));
}
@@ -208,11 +240,25 @@
ctt->ctt_size = CTF_LSIZE_SENT;
ctt->ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size);
ctt->ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size);
+ if (needSwap) {
+ SWAP_32(ctt->ctt_name);
+ SWAP_16(ctt->ctt_info);
+ SWAP_16(ctt->ctt_size);
+ SWAP_32(ctt->ctt_lsizehi);
+ SWAP_32(ctt->ctt_lsizelo);
+ }
ctf_buf_write(b, ctt, sizeof (*ctt));
} else {
ctf_stype_t *cts = (ctf_stype_t *)ctt;
cts->ctt_size = (ushort_t)size;
+
+ if (needSwap) {
+ SWAP_32(cts->ctt_name);
+ SWAP_16(cts->ctt_info);
+ SWAP_16(cts->ctt_size);
+ }
+
ctf_buf_write(b, cts, sizeof (*cts));
}
}
@@ -222,6 +268,12 @@
{
ctf_stype_t *cts = (ctf_stype_t *)ctt;
+ if (needSwap) {
+ SWAP_32(cts->ctt_name);
+ SWAP_16(cts->ctt_info);
+ SWAP_16(cts->ctt_size);
+ }
+
ctf_buf_write(b, cts, sizeof (*cts));
}
@@ -296,6 +348,9 @@
encoding = ip->intr_fformat;
data = CTF_INT_DATA(encoding, ip->intr_offset, ip->intr_nbits);
+ if (needSwap) {
+ SWAP_32(data);
+ }
ctf_buf_write(b, &data, sizeof (data));
break;
@@ -312,6 +367,11 @@
cta.cta_contents = tp->t_ardef->ad_contents->t_id;
cta.cta_index = tp->t_ardef->ad_idxtype->t_id;
cta.cta_nelems = tp->t_ardef->ad_nelems;
+ if (needSwap) {
+ SWAP_16(cta.cta_contents);
+ SWAP_16(cta.cta_index);
+ SWAP_32(cta.cta_nelems);
+ }
ctf_buf_write(b, &cta, sizeof (cta));
break;
@@ -341,6 +401,11 @@
offset);
ctm.ctm_type = mp->ml_type->t_id;
ctm.ctm_offset = mp->ml_offset;
+ if (needSwap) {
+ SWAP_32(ctm.ctm_name);
+ SWAP_16(ctm.ctm_type);
+ SWAP_16(ctm.ctm_offset);
+ }
ctf_buf_write(b, &ctm, sizeof (ctm));
}
} else {
@@ -355,6 +420,14 @@
CTF_OFFSET_TO_LMEMHI(mp->ml_offset);
ctlm.ctlm_offsetlo =
CTF_OFFSET_TO_LMEMLO(mp->ml_offset);
+
+ if (needSwap) {
+ SWAP_32(ctlm.ctlm_name);
+ SWAP_16(ctlm.ctlm_type);
+ SWAP_32(ctlm.ctlm_offsethi);
+ SWAP_32(ctlm.ctlm_offsetlo);
+ }
+
ctf_buf_write(b, &ctlm, sizeof (ctlm));
}
}
@@ -377,6 +450,12 @@
offset = strtab_insert(&b->ctb_strtab, ep->el_name);
cte.cte_name = CTF_TYPE_NAME(CTF_STRTAB_0, offset);
cte.cte_value = ep->el_number;
+
+ if (needSwap) {
+ SWAP_32(cte.cte_name);
+ SWAP_32(cte.cte_value);
+ }
+
ctf_buf_write(b, &cte, sizeof (cte));
i--;
}
@@ -420,6 +499,11 @@
for (i = 0; i < (int) tp->t_fndef->fn_nargs; i++) {
id = tp->t_fndef->fn_args[i]->t_id;
+
+ if (needSwap) {
+ SWAP_16(id);
+ }
+
ctf_buf_write(b, &id, sizeof (id));
}
@@ -613,6 +697,9 @@
int i;
+ needSwap = do_compress & CTF_SWAP_BYTES;
+ do_compress &= ~CTF_SWAP_BYTES;
+
/*
* Prepare the header, and create the CTF output buffers. The data
* object section and function section are both lists of 2-byte
@@ -649,6 +736,18 @@
h.cth_stroff = ctf_buf_cur(buf);
h.cth_strlen = strtab_size(&buf->ctb_strtab);
+ if (needSwap) {
+ SWAP_16(h.cth_preamble.ctp_magic);
+ SWAP_32(h.cth_parlabel); /* ref to name of parent lbl uniq'd against */
+ SWAP_32(h.cth_parname); /* ref to basename of parent */
+ SWAP_32(h.cth_lbloff); /* offset of label section */
+ SWAP_32(h.cth_objtoff); /* offset of object section */
+ SWAP_32(h.cth_funcoff); /* offset of function section */
+ SWAP_32(h.cth_typeoff); /* offset of type section */
+ SWAP_32(h.cth_stroff); /* offset of string section */
+ SWAP_32(h.cth_strlen); /* length of string section in bytes */
+ }
+
/*
* We only do compression for ctfmerge, as ctfconvert is only
* supposed to be used on intermediary build objects. This is
==== //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c#2 (text+ko) ====
@@ -620,7 +620,7 @@
terminate("No CTF data found in source file %s\n", srcfile);
tmpname = mktmpname(destfile, ".ctf");
- write_ctf(srctd, destfile, tmpname, CTF_COMPRESS | keep_stabs);
+ write_ctf(srctd, destfile, tmpname, CTF_COMPRESS | CTF_SWAP_BYTES | keep_stabs);
if (rename(tmpname, destfile) != 0) {
terminate("Couldn't rename temp file %s to %s", tmpname,
destfile);
@@ -1015,7 +1015,7 @@
tmpname = mktmpname(outfile, ".ctf");
write_ctf(savetd, outfile, tmpname,
- CTF_COMPRESS | write_fuzzy_match | dynsym | keep_stabs);
+ CTF_COMPRESS | CTF_SWAP_BYTES | write_fuzzy_match | dynsym | keep_stabs);
if (rename(tmpname, outfile) != 0)
terminate("Couldn't rename output temp file %s", tmpname);
free(tmpname);
==== //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h#2 (text+ko) ====
@@ -391,6 +391,7 @@
#define CTF_USE_DYNSYM 0x2 /* use .dynsym not .symtab */
#define CTF_COMPRESS 0x4 /* compress CTF output */
#define CTF_KEEP_STABS 0x8 /* keep .stabs sections */
+#define CTF_SWAP_BYTES 0x10 /* target byte order is different from host */
void write_ctf(tdata_t *, const char *, const char *, int);
==== //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/output.c#2 (text+ko) ====
@@ -717,7 +717,7 @@
iiburst = sort_iidescs(elf, file, td, flags & CTF_FUZZY_MATCH,
flags & CTF_USE_DYNSYM);
- data = ctf_gen(iiburst, lenp, flags & CTF_COMPRESS);
+ data = ctf_gen(iiburst, lenp, flags & (CTF_COMPRESS | CTF_SWAP_BYTES));
iiburst_free(iiburst);
==== //depot/projects/dtrace-mips/cddl/lib/Makefile#2 (text+ko) ====
@@ -19,7 +19,7 @@
.endif
.endif
-.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
+.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "mips64eb"
_drti= drti
_libdtrace= libdtrace
.endif
==== //depot/projects/dtrace-mips/cddl/lib/libdtrace/Makefile#2 (text+ko) ====
@@ -70,6 +70,10 @@
.elif ${MACHINE_CPUARCH} == "sparc64"
CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/sparc
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/sparc
+.elif ${MACHINE_CPUARCH} == "mips"
+CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/mips
+.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libdtrace/mips
+.PATH: ${.CURDIR}/../../../sys/cddl/dev/dtrace/mips
.else
# temporary hack
CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel
==== //depot/projects/dtrace-mips/cddl/usr.sbin/Makefile#2 (text+ko) ====
@@ -13,6 +13,8 @@
.endif
.endif
+_dtrace= dtrace
+
.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
_dtrace= dtrace
_dtruss= dtruss
==== //depot/projects/dtrace-mips/contrib/gcc/config/mips/freebsd.h#2 (text+ko) ====
@@ -351,4 +351,5 @@
#endif
/************************[ Debugger stuff ]*********************************/
-
+#undef DBX_DEBUGGING_INFO
+#undef MIPS_DEBUGGING_INFO
==== //depot/projects/dtrace-mips/lib/Makefile#2 (text+ko) ====
@@ -179,7 +179,7 @@
_libypclnt= libypclnt
.endif
-.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "mips"
.if ${MK_NCP} != "no"
_libncp= libncp
.endif
==== //depot/projects/dtrace-mips/lib/libelf/libelf_data.c#2 (text+ko) ====
@@ -86,6 +86,8 @@
#endif
case SHT_MIPS_DWARF:
/* FALLTHROUGH */
+ case SHT_MIPS_OPTIONS:
+ /* FALLTHROUGH */
case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */
return (ELF_T_BYTE);
default:
==== //depot/projects/dtrace-mips/lib/libproc/proc_bkpt.c#2 (text+ko) ====
@@ -44,6 +44,9 @@
#if defined(__i386__) || defined(__amd64__)
#define BREAKPOINT_INSTR 0xcc /* int 0x3 */
#define BREAKPOINT_INSTR_SZ 1
+#elif defined(__mips__)
+#define BREAKPOINT_INSTR 0xd /* break */
+#define BREAKPOINT_INSTR_SZ 4
#else
#error "Add support for your architecture"
#endif
==== //depot/projects/dtrace-mips/lib/libproc/proc_regs.c#2 (text+ko) ====
@@ -58,6 +58,8 @@
*regvalue = regs.r_rip;
#elif defined(__i386__)
*regvalue = regs.r_eip;
+#elif defined(__mips__)
+ *regvalue = regs.r_regs[PC];
#endif
break;
case REG_SP:
@@ -65,6 +67,8 @@
*regvalue = regs.r_rsp;
#elif defined(__i386__)
*regvalue = regs.r_esp;
+#elif defined(__mips__)
+ *regvalue = regs.r_regs[SP];
#endif
break;
default:
@@ -93,6 +97,8 @@
regs.r_rip = regvalue;
#elif defined(__i386__)
regs.r_eip = regvalue;
+#elif defined(__mips__)
+ regs.r_regs[PC] = regvalue;
#endif
break;
case REG_SP:
@@ -100,6 +106,8 @@
regs.r_rsp = regvalue;
#elif defined(__i386__)
regs.r_esp = regvalue;
+#elif defined(__mips__)
+ regs.r_regs[PC] = regvalue;
#endif
break;
default:
==== //depot/projects/dtrace-mips/share/mk/bsd.cpu.mk#2 (text+ko) ====
@@ -211,6 +211,7 @@
.endif
.if ${MACHINE_CPUARCH} == "mips"
+AFLAGS += -EB -G0 -march=octeon -mabi=64
CFLAGS += -G0
.endif
==== //depot/projects/dtrace-mips/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c#2 (text+ko) ====
@@ -235,7 +235,7 @@
static struct mtx dtrace_unr_mtx;
MTX_SYSINIT(dtrace_unr_mtx, &dtrace_unr_mtx, "Unique resource identifier", MTX_DEF);
int dtrace_in_probe; /* non-zero if executing a probe */
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__i386__) || defined(__amd64__) || defined(__mips__)
uintptr_t dtrace_in_probe_addr; /* Address of invop when already in probe */
#endif
#endif
@@ -10659,7 +10659,7 @@
#else
int i;
-#if defined(__amd64__)
+#if defined(__amd64__) || defined(__mips__)
/*
* FreeBSD isn't good at limiting the amount of memory we
* ask to malloc, so let's place a limit here before trying
==== //depot/projects/dtrace-mips/sys/cddl/dev/lockstat/lockstat.c#2 (text+ko) ====
@@ -45,7 +45,7 @@
#include <sys/dtrace.h>
#include <sys/lockstat.h>
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__i386__) || defined(__amd64__) || defined(__mips__)
#define LOCKSTAT_AFRAMES 1
#else
#error "architecture not supported"
==== //depot/projects/dtrace-mips/sys/cddl/dev/profile/profile.c#2 (text+ko) ====
@@ -112,6 +112,10 @@
#endif
#endif
+#ifdef __mips
+#define PROF_ARTIFICIAL_FRAMES 3
+#endif
+
typedef struct profile_probe {
char prof_name[PROF_NAMELEN];
dtrace_id_t prof_id;
==== //depot/projects/dtrace-mips/sys/conf/files.mips#2 (text+ko) ====
@@ -44,6 +44,7 @@
mips/mips/pm_machdep.c standard
mips/mips/swtch.S standard
mips/mips/tlb.c standard
+mips/mips/backtrace.c standard
mips/mips/bus_space_generic.c standard
mips/mips/busdma_machdep.c standard
==== //depot/projects/dtrace-mips/sys/kern/init_main.c#2 (text+ko) ====
@@ -101,7 +101,7 @@
struct vmspace vmspace0;
struct proc *initproc;
-int boothowto = 0; /* initialized so that it can be patched */
+int boothowto = RB_SINGLE; /* initialized so that it can be patched */
SYSCTL_INT(_debug, OID_AUTO, boothowto, CTLFLAG_RD, &boothowto, 0,
"Boot control flags, passed from loader");
int bootverbose;
==== //depot/projects/dtrace-mips/sys/kern/link_elf.c#2 (text+ko) ====
@@ -307,7 +307,7 @@
if (modptr != NULL)
modname = (char *)preload_search_info(modptr, MODINFO_NAME);
if (modname == NULL)
- modname = "kernel";
+ modname = "/boot/kernel/kernel";
linker_kernel_file = linker_make_file(modname, &link_elf_class);
if (linker_kernel_file == NULL)
panic("%s: Can't create linker structures for kernel",
==== //depot/projects/dtrace-mips/sys/mips/include/db_machdep.h#2 (text+ko) ====
@@ -95,5 +95,6 @@
void stacktrace_subr(register_t pc, register_t sp, register_t ra, int (*)(const char *, ...));
int32_t kdbpeek(int *);
int64_t kdbpeekd(int *);
+int db_trace_location(register_t pc, register_t sp, register_t ra);
#endif /* !_MIPS_DB_MACHDEP_H_ */
==== //depot/projects/dtrace-mips/sys/mips/include/trap.h#2 (text+ko) ====
@@ -115,6 +115,7 @@
void MipsTLBMissException(void);
void MipsUserGenException(void);
void MipsUserIntr(void);
+uintptr_t MipsEmulateBranch(struct trapframe *, uintptr_t, int, uintptr_t);
register_t trap(struct trapframe *);
==== //depot/projects/dtrace-mips/sys/mips/mips/db_trace.c#2 (text+ko) ====
@@ -434,6 +434,15 @@
return (0);
}
+int
+db_trace_location(register_t pc, register_t sp, register_t ra)
+{
+ stacktrace_subr(pc, sp, ra,
+ (int (*) (const char *, ...))db_printf);
+
+ return (0);
+}
+
void
db_show_mdpcpu(struct pcpu *pc)
{
==== //depot/projects/dtrace-mips/sys/mips/mips/exception.S#2 (text+ko) ====
@@ -63,11 +63,33 @@
#include <machine/pte.h>
#include "opt_cputype.h"
+#include "opt_kdtrace.h"
#include "assym.s"
.set noreorder # Noreorder is default style!
+#ifdef KDTRACE_HOOKS
+/* XXX: mips64 */
+ .data
+ .globl dtrace_invop_jump_addr
+ .align 4
+ .type dtrace_invop_jump_addr, @object
+ .size dtrace_invop_jump_addr, 8
+dtrace_invop_jump_addr:
+ .word 0
+ .word 0
+ .globl dtrace_invop_calltrap_addr
+ .align 4
+ .type dtrace_invop_calltrap_addr, @object
+ .size dtrace_invop_calltrap_addr, 8
+dtrace_invop_calltrap_addr:
+ .word 0
+ .word 0
+#endif
+
+ .text
+
/*
* Reasonable limit
*/
@@ -979,16 +1001,19 @@
* the trapframe.
*/
SAVE_REG(k1, SP, sp)
+ move a3, k1
/*
* Squelch any more overflow checks by setting the stack base to 0.
*/
GET_CPU_PCPU(k1)
PTR_L k0, PC_CURTHREAD(k1)
+ PTR_L a2, TD_KSTACK(k0)
PTR_S zero, TD_KSTACK(k0)
move a1, a0
- PANIC("kernel stack overflow - trapframe at %p")
+ # PANIC("kernel stack overflow - trapframe at %p, td_kstack at %p, sp at %p")
+ jal kernel_stack_overflow
/*
* This nop is necessary so that the 'ra' remains within the bounds
==== //depot/projects/dtrace-mips/sys/mips/mips/trap.c#2 (text+ko) ====
@@ -44,6 +44,7 @@
#include "opt_ddb.h"
#include "opt_global.h"
#include "opt_ktrace.h"
+#include "opt_kdtrace.h"
#define NO_REG_DEFS 1 /* Prevent asm.h from including regdef.h */
#include <sys/param.h>
@@ -91,6 +92,33 @@
#include <sys/kdb.h>
#endif
+#ifdef KDTRACE_HOOKS
+#include <sys/dtrace_bsd.h>
+
+/*
+ * This is a hook which is initialised by the dtrace module
+ * to handle traps which might occur during DTrace probe
+ * execution.
+ */
+dtrace_trap_func_t dtrace_trap_func;
+
+dtrace_doubletrap_func_t dtrace_doubletrap_func;
+
+/*
+ * This is a hook which is initialised by the systrace module
+ * when it is loaded. This keeps the DTrace syscall provider
+ * implementation opaque.
+ */
+systrace_probe_func_t systrace_probe_func;
+
+/*
+ * These hooks are necessary for the pid, usdt and fasttrap providers.
+ */
+dtrace_fasttrap_probe_ptr_t dtrace_fasttrap_probe_ptr;
+dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr;
+dtrace_return_probe_ptr_t dtrace_return_probe_ptr;
+#endif
+
#ifdef TRAP_DEBUG
int trap_debug = 0;
SYSCTL_INT(_machdep, OID_AUTO, trap_debug, CTLFLAG_RW,
@@ -489,6 +517,46 @@
}
}
#endif
+
+#ifdef KDTRACE_HOOKS
+ /*
+ * A trap can occur while DTrace executes a probe. Before
+ * executing the probe, DTrace blocks re-scheduling and sets
+ * a flag in it's per-cpu flags to indicate that it doesn't
+ * want to fault. On returning from the probe, the no-fault
+ * flag is cleared and finally re-scheduling is enabled.
+ *
+ * If the DTrace kernel module has registered a trap handler,
+ * call it and if it returns non-zero, assume that it has
+ * handled the trap and modified the trap frame so that this
+ * function can return normally.
+ */
+#if 0
+ if (type == T_DTRACE_PROBE || type == T_DTRACE_RET ||
+ type == T_BPTFLT) {
+ struct reg regs;
+
+ fill_frame_regs(frame, ®s);
+ if (type == T_DTRACE_PROBE &&
+ dtrace_fasttrap_probe_ptr != NULL &&
+ dtrace_fasttrap_probe_ptr(®s) == 0)
+ goto out;
+ else if (type == T_BPTFLT &&
+ dtrace_pid_probe_ptr != NULL &&
+ dtrace_pid_probe_ptr(®s) == 0)
+ goto out;
+ else if (type == T_DTRACE_RET &&
+ dtrace_return_probe_ptr != NULL &&
+ dtrace_return_probe_ptr(®s) == 0)
+ goto out;
+ }
+#endif
+ if (!usermode) {
+ if (dtrace_trap_func != NULL && (*dtrace_trap_func)(trapframe, type))
+ return (trapframe->pc);
+ }
+#endif
+
switch (type) {
case T_MCHECK:
#ifdef DDB
@@ -593,6 +661,9 @@
PROC_LOCK(p);
--p->p_lock;
PROC_UNLOCK(p);
+ /*
+ * XXXDTRACE: add dtrace_doubletrap_func here?
+ */
#ifdef VMFAULT_TRACE
printf("vm_fault(%p (pmap %p), %p (%p), %x, %d) -> %x at pc %p\n",
map, &vm->vm_pmap, (void *)va, (void *)(intptr_t)trapframe->badvaddr,
@@ -1539,3 +1610,15 @@
}
return access_type;
}
+
+void kernel_stack_overflow(struct trapframe *frame);
+
+void
+kernel_stack_overflow(struct trapframe *frame)
+{
+ printf("pc = %#jx\n", (intmax_t)frame->pc);
+ printf("ra = %#jx\n", (intmax_t)frame->ra);
+ printf("badvaddr = %#jx\n", (intmax_t)frame->badvaddr);
+ db_trace_location(frame->pc, frame->sp, frame->ra);
+ panic("stack overflow: %p\n", frame);
+}
==== //depot/projects/dtrace-mips/sys/modules/cyclic/Makefile#2 (text+ko) ====
@@ -10,7 +10,7 @@
CFLAGS+= -I${.CURDIR}/../../cddl/compat/opensolaris \
-I${.CURDIR}/../../cddl/contrib/opensolaris/uts/common \
-I${.CURDIR}/../.. \
- -I${.CURDIR}/../../cddl/dev/cyclic/${MACHINE_CPUARCH:S/amd64/i386/}
+ -I${.CURDIR}/../../cddl/dev/cyclic/i386
CFLAGS+= -DDEBUG=1
==== //depot/projects/dtrace-mips/sys/modules/dtrace/Makefile#2 (text+ko) ====
@@ -9,14 +9,12 @@
dtrace \
dtraceall \
dtrace_test \
- lockstat \
- profile \
prototype \
sdt \
systrace
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
-SUBDIR+= fasttrap fbt systrace_linux32
+SUBDIR+= profile lockstat fasttrap fbt systrace_linux32
.endif
.if ${MACHINE_CPUARCH} == "amd64"
SUBDIR+= systrace_freebsd32
==== //depot/projects/dtrace-mips/sys/sys/elf_common.h#2 (text+ko) ====
@@ -296,6 +296,7 @@
#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */
#define SHT_LOPROC 0x70000000 /* reserved range for processor */
#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */
+#define SHT_MIPS_OPTIONS 0x7000000d
#define SHT_MIPS_DWARF 0x7000001e /* MIPS gcc uses MIPS_DWARF */
#define SHT_HIPROC 0x7fffffff /* specific section header types */
#define SHT_LOUSER 0x80000000 /* reserved range for application */
More information about the p4-projects
mailing list