xref: /onnv-gate/usr/src/cmd/mdb/i86pc/modules/unix/unix.c (revision 9489:7aad39a516b4)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
53446Smrj  * Common Development and Distribution License (the "License").
63446Smrj  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*9489SJoe.Bonasera@sun.com  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <mdb/mdb_modapi.h>
270Sstevel@tonic-gate #include <mdb/mdb_ctf.h>
280Sstevel@tonic-gate #include <sys/cpuvar.h>
290Sstevel@tonic-gate #include <sys/systm.h>
300Sstevel@tonic-gate #include <sys/traptrace.h>
313446Smrj #include <sys/x_call.h>
32*9489SJoe.Bonasera@sun.com #include <sys/xc_levels.h>
330Sstevel@tonic-gate #include <sys/avintr.h>
340Sstevel@tonic-gate #include <sys/systm.h>
350Sstevel@tonic-gate #include <sys/trap.h>
360Sstevel@tonic-gate #include <sys/mutex.h>
370Sstevel@tonic-gate #include <sys/mutex_impl.h>
380Sstevel@tonic-gate #include "i86mmu.h"
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #define	TT_HDLR_WIDTH	17
410Sstevel@tonic-gate 
420Sstevel@tonic-gate static int
430Sstevel@tonic-gate ttrace_ttr_size_check(void)
440Sstevel@tonic-gate {
450Sstevel@tonic-gate 	mdb_ctf_id_t ttrtid;
460Sstevel@tonic-gate 	ssize_t ttr_size;
470Sstevel@tonic-gate 
480Sstevel@tonic-gate 	if (mdb_ctf_lookup_by_name("trap_trace_rec_t", &ttrtid) != 0 ||
490Sstevel@tonic-gate 	    mdb_ctf_type_resolve(ttrtid, &ttrtid) != 0) {
500Sstevel@tonic-gate 		mdb_warn("failed to determine size of trap_trace_rec_t; "
510Sstevel@tonic-gate 		    "non-TRAPTRACE kernel?\n");
520Sstevel@tonic-gate 		return (0);
530Sstevel@tonic-gate 	}
540Sstevel@tonic-gate 
550Sstevel@tonic-gate 	if ((ttr_size = mdb_ctf_type_size(ttrtid)) !=
560Sstevel@tonic-gate 	    sizeof (trap_trace_rec_t)) {
570Sstevel@tonic-gate 		/*
580Sstevel@tonic-gate 		 * On Intel machines, this will happen when TTR_STACK_DEPTH
590Sstevel@tonic-gate 		 * is changed.  This code could be smarter, and could
600Sstevel@tonic-gate 		 * dynamically adapt to different depths, but not until a
610Sstevel@tonic-gate 		 * need for such adaptation is demonstrated.
620Sstevel@tonic-gate 		 */
630Sstevel@tonic-gate 		mdb_warn("size of trap_trace_rec_t (%d bytes) doesn't "
640Sstevel@tonic-gate 		    "match expected %d\n", ttr_size, sizeof (trap_trace_rec_t));
650Sstevel@tonic-gate 		return (0);
660Sstevel@tonic-gate 	}
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	return (1);
690Sstevel@tonic-gate }
700Sstevel@tonic-gate 
710Sstevel@tonic-gate int
720Sstevel@tonic-gate ttrace_walk_init(mdb_walk_state_t *wsp)
730Sstevel@tonic-gate {
740Sstevel@tonic-gate 	trap_trace_ctl_t *ttcp;
750Sstevel@tonic-gate 	size_t ttc_size = sizeof (trap_trace_ctl_t) * NCPU;
760Sstevel@tonic-gate 	int i;
770Sstevel@tonic-gate 
780Sstevel@tonic-gate 	if (!ttrace_ttr_size_check())
790Sstevel@tonic-gate 		return (WALK_ERR);
800Sstevel@tonic-gate 
810Sstevel@tonic-gate 	ttcp = mdb_zalloc(ttc_size, UM_SLEEP);
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 	if (wsp->walk_addr != NULL) {
840Sstevel@tonic-gate 		mdb_warn("ttrace only supports global walks\n");
850Sstevel@tonic-gate 		return (WALK_ERR);
860Sstevel@tonic-gate 	}
870Sstevel@tonic-gate 
880Sstevel@tonic-gate 	if (mdb_readsym(ttcp, ttc_size, "trap_trace_ctl") == -1) {
890Sstevel@tonic-gate 		mdb_warn("symbol 'trap_trace_ctl' not found; "
900Sstevel@tonic-gate 		    "non-TRAPTRACE kernel?\n");
910Sstevel@tonic-gate 		mdb_free(ttcp, ttc_size);
920Sstevel@tonic-gate 		return (WALK_ERR);
930Sstevel@tonic-gate 	}
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 	/*
960Sstevel@tonic-gate 	 * We'll poach the ttc_current pointer (which isn't used for
970Sstevel@tonic-gate 	 * anything) to store a pointer to our current TRAPTRACE record.
980Sstevel@tonic-gate 	 * This allows us to only keep the array of trap_trace_ctl structures
990Sstevel@tonic-gate 	 * as our walker state (ttc_current may be the only kernel data
1000Sstevel@tonic-gate 	 * structure member added exclusively to make writing the mdb walker
1010Sstevel@tonic-gate 	 * a little easier).
1020Sstevel@tonic-gate 	 */
1030Sstevel@tonic-gate 	for (i = 0; i < NCPU; i++) {
1040Sstevel@tonic-gate 		trap_trace_ctl_t *ttc = &ttcp[i];
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate 		if (ttc->ttc_first == NULL)
1070Sstevel@tonic-gate 			continue;
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate 		/*
1100Sstevel@tonic-gate 		 * Assign ttc_current to be the last completed record.
1110Sstevel@tonic-gate 		 * Note that the error checking (i.e. in the ttc_next ==
1120Sstevel@tonic-gate 		 * ttc_first case) is performed in the step function.
1130Sstevel@tonic-gate 		 */
1140Sstevel@tonic-gate 		ttc->ttc_current = ttc->ttc_next - sizeof (trap_trace_rec_t);
1150Sstevel@tonic-gate 	}
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate 	wsp->walk_data = ttcp;
1180Sstevel@tonic-gate 	return (WALK_NEXT);
1190Sstevel@tonic-gate }
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate int
1220Sstevel@tonic-gate ttrace_walk_step(mdb_walk_state_t *wsp)
1230Sstevel@tonic-gate {
1240Sstevel@tonic-gate 	trap_trace_ctl_t *ttcp = wsp->walk_data, *ttc, *latest_ttc;
1250Sstevel@tonic-gate 	trap_trace_rec_t rec;
1260Sstevel@tonic-gate 	int rval, i, recsize = sizeof (trap_trace_rec_t);
1270Sstevel@tonic-gate 	hrtime_t latest = 0;
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate 	/*
1300Sstevel@tonic-gate 	 * Loop through the CPUs, looking for the latest trap trace record
1310Sstevel@tonic-gate 	 * (we want to walk through the trap trace records in reverse
1320Sstevel@tonic-gate 	 * chronological order).
1330Sstevel@tonic-gate 	 */
1340Sstevel@tonic-gate 	for (i = 0; i < NCPU; i++) {
1350Sstevel@tonic-gate 		ttc = &ttcp[i];
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 		if (ttc->ttc_current == NULL)
1380Sstevel@tonic-gate 			continue;
1390Sstevel@tonic-gate 
1400Sstevel@tonic-gate 		if (ttc->ttc_current < ttc->ttc_first)
1410Sstevel@tonic-gate 			ttc->ttc_current = ttc->ttc_limit - recsize;
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 		if (mdb_vread(&rec, sizeof (rec), ttc->ttc_current) == -1) {
1440Sstevel@tonic-gate 			mdb_warn("couldn't read rec at %p", ttc->ttc_current);
1450Sstevel@tonic-gate 			return (WALK_ERR);
1460Sstevel@tonic-gate 		}
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate 		if (rec.ttr_stamp > latest) {
1490Sstevel@tonic-gate 			latest = rec.ttr_stamp;
1500Sstevel@tonic-gate 			latest_ttc = ttc;
1510Sstevel@tonic-gate 		}
1520Sstevel@tonic-gate 	}
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 	if (latest == 0)
1550Sstevel@tonic-gate 		return (WALK_DONE);
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate 	ttc = latest_ttc;
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate 	if (mdb_vread(&rec, sizeof (rec), ttc->ttc_current) == -1) {
1600Sstevel@tonic-gate 		mdb_warn("couldn't read rec at %p", ttc->ttc_current);
1610Sstevel@tonic-gate 		return (WALK_ERR);
1620Sstevel@tonic-gate 	}
1630Sstevel@tonic-gate 
1640Sstevel@tonic-gate 	rval = wsp->walk_callback(ttc->ttc_current, &rec, wsp->walk_cbdata);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate 	if (ttc->ttc_current == ttc->ttc_next)
1670Sstevel@tonic-gate 		ttc->ttc_current = NULL;
1680Sstevel@tonic-gate 	else
1690Sstevel@tonic-gate 		ttc->ttc_current -= sizeof (trap_trace_rec_t);
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate 	return (rval);
1720Sstevel@tonic-gate }
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate void
1750Sstevel@tonic-gate ttrace_walk_fini(mdb_walk_state_t *wsp)
1760Sstevel@tonic-gate {
1770Sstevel@tonic-gate 	mdb_free(wsp->walk_data, sizeof (trap_trace_ctl_t) * NCPU);
1780Sstevel@tonic-gate }
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate static int
1810Sstevel@tonic-gate ttrace_syscall(trap_trace_rec_t *rec)
1820Sstevel@tonic-gate {
1830Sstevel@tonic-gate 	GElf_Sym sym;
1840Sstevel@tonic-gate 	int sysnum = rec->ttr_sysnum;
1850Sstevel@tonic-gate 	uintptr_t addr;
1860Sstevel@tonic-gate 	struct sysent sys;
1870Sstevel@tonic-gate 
1883446Smrj 	mdb_printf("%-3x", sysnum);
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate 	if (rec->ttr_sysnum > NSYSCALL) {
1913446Smrj 		mdb_printf(" %-*d", TT_HDLR_WIDTH, rec->ttr_sysnum);
1920Sstevel@tonic-gate 		return (0);
1930Sstevel@tonic-gate 	}
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate 	if (mdb_lookup_by_name("sysent", &sym) == -1) {
1960Sstevel@tonic-gate 		mdb_warn("\ncouldn't find 'sysent'");
1970Sstevel@tonic-gate 		return (-1);
1980Sstevel@tonic-gate 	}
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate 	addr = (uintptr_t)sym.st_value + sysnum * sizeof (struct sysent);
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate 	if (addr >= (uintptr_t)sym.st_value + sym.st_size) {
2030Sstevel@tonic-gate 		mdb_warn("\nsysnum %d out-of-range\n", sysnum);
2040Sstevel@tonic-gate 		return (-1);
2050Sstevel@tonic-gate 	}
2060Sstevel@tonic-gate 
2070Sstevel@tonic-gate 	if (mdb_vread(&sys, sizeof (sys), addr) == -1) {
2080Sstevel@tonic-gate 		mdb_warn("\nfailed to read sysent at %p", addr);
2090Sstevel@tonic-gate 		return (-1);
2100Sstevel@tonic-gate 	}
2110Sstevel@tonic-gate 
2123446Smrj 	mdb_printf(" %-*a", TT_HDLR_WIDTH, sys.sy_callc);
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate 	return (0);
2150Sstevel@tonic-gate }
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate static int
2180Sstevel@tonic-gate ttrace_interrupt(trap_trace_rec_t *rec)
2190Sstevel@tonic-gate {
2200Sstevel@tonic-gate 	GElf_Sym sym;
2210Sstevel@tonic-gate 	uintptr_t addr;
2220Sstevel@tonic-gate 	struct av_head hd;
2230Sstevel@tonic-gate 	struct autovec av;
2240Sstevel@tonic-gate 
2253446Smrj 	switch (rec->ttr_regs.r_trapno) {
2263446Smrj 	case T_SOFTINT:
2273446Smrj 		mdb_printf("%-3s %-*s", "-", TT_HDLR_WIDTH, "(fakesoftint)");
2280Sstevel@tonic-gate 		return (0);
2293446Smrj 	default:
2303446Smrj 		break;
2310Sstevel@tonic-gate 	}
2320Sstevel@tonic-gate 
2333446Smrj 	mdb_printf("%-3x ", rec->ttr_vector);
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate 	if (mdb_lookup_by_name("autovect", &sym) == -1) {
2360Sstevel@tonic-gate 		mdb_warn("\ncouldn't find 'autovect'");
2370Sstevel@tonic-gate 		return (-1);
2380Sstevel@tonic-gate 	}
2390Sstevel@tonic-gate 
2400Sstevel@tonic-gate 	addr = (uintptr_t)sym.st_value +
2410Sstevel@tonic-gate 	    rec->ttr_vector * sizeof (struct av_head);
2420Sstevel@tonic-gate 
2430Sstevel@tonic-gate 	if (addr >= (uintptr_t)sym.st_value + sym.st_size) {
2440Sstevel@tonic-gate 		mdb_warn("\nav_head for vec %x is corrupt\n", rec->ttr_vector);
2450Sstevel@tonic-gate 		return (-1);
2460Sstevel@tonic-gate 	}
2470Sstevel@tonic-gate 
2480Sstevel@tonic-gate 	if (mdb_vread(&hd, sizeof (hd), addr) == -1) {
2490Sstevel@tonic-gate 		mdb_warn("\ncouldn't read av_head for vec %x", rec->ttr_vector);
2500Sstevel@tonic-gate 		return (-1);
2510Sstevel@tonic-gate 	}
2520Sstevel@tonic-gate 
2530Sstevel@tonic-gate 	if (hd.avh_link == NULL) {
2543446Smrj 		if (rec->ttr_ipl == XC_CPUPOKE_PIL)
2553446Smrj 			mdb_printf("%-*s", TT_HDLR_WIDTH, "(cpupoke)");
2563446Smrj 		else
2573446Smrj 			mdb_printf("%-*s", TT_HDLR_WIDTH, "(spurious)");
2580Sstevel@tonic-gate 	} else {
2590Sstevel@tonic-gate 		if (mdb_vread(&av, sizeof (av), (uintptr_t)hd.avh_link) == -1) {
2600Sstevel@tonic-gate 			mdb_warn("couldn't read autovec at %p",
2610Sstevel@tonic-gate 			    (uintptr_t)hd.avh_link);
2620Sstevel@tonic-gate 		}
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate 		mdb_printf("%-*a", TT_HDLR_WIDTH, av.av_vector);
2650Sstevel@tonic-gate 	}
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 	return (0);
2680Sstevel@tonic-gate }
2690Sstevel@tonic-gate 
2700Sstevel@tonic-gate static struct {
2710Sstevel@tonic-gate 	int tt_trapno;
2720Sstevel@tonic-gate 	char *tt_name;
2730Sstevel@tonic-gate } ttrace_traps[] = {
2740Sstevel@tonic-gate 	{ T_ZERODIV,	"divide-error" },
2750Sstevel@tonic-gate 	{ T_SGLSTP,	"debug-exception" },
2760Sstevel@tonic-gate 	{ T_NMIFLT,	"nmi-interrupt" },
2770Sstevel@tonic-gate 	{ T_BPTFLT,	"breakpoint" },
2780Sstevel@tonic-gate 	{ T_OVFLW,	"into-overflow" },
2790Sstevel@tonic-gate 	{ T_BOUNDFLT,	"bound-exceeded" },
2800Sstevel@tonic-gate 	{ T_ILLINST,	"invalid-opcode" },
2810Sstevel@tonic-gate 	{ T_NOEXTFLT,	"device-not-avail" },
2820Sstevel@tonic-gate 	{ T_DBLFLT,	"double-fault" },
2830Sstevel@tonic-gate 	{ T_EXTOVRFLT,	"segment-overrun" },
2840Sstevel@tonic-gate 	{ T_TSSFLT,	"invalid-tss" },
2850Sstevel@tonic-gate 	{ T_SEGFLT,	"segment-not-pres" },
2860Sstevel@tonic-gate 	{ T_STKFLT,	"stack-fault" },
2870Sstevel@tonic-gate 	{ T_GPFLT,	"general-protectn" },
2880Sstevel@tonic-gate 	{ T_PGFLT,	"page-fault" },
2890Sstevel@tonic-gate 	{ T_EXTERRFLT,	"error-fault" },
2900Sstevel@tonic-gate 	{ T_ALIGNMENT,	"alignment-check" },
2910Sstevel@tonic-gate 	{ T_MCE,	"machine-check" },
2920Sstevel@tonic-gate 	{ T_SIMDFPE,	"sse-exception" },
2933446Smrj 
2943446Smrj 	{ T_DBGENTR,	"debug-enter" },
2953446Smrj 	{ T_FASTTRAP,	"fasttrap-0xd2" },
2963446Smrj 	{ T_SYSCALLINT,	"syscall-0x91" },
2973446Smrj 	{ T_DTRACE_RET,	"dtrace-ret" },
2983446Smrj 	{ T_SOFTINT,	"softint" },
2993446Smrj 	{ T_INTERRUPT,	"interrupt" },
3003446Smrj 	{ T_FAULT,	"fault" },
3013446Smrj 	{ T_AST,	"ast" },
3023446Smrj 	{ T_SYSCALL,	"syscall" },
3033446Smrj 
3040Sstevel@tonic-gate 	{ 0,		NULL }
3050Sstevel@tonic-gate };
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate static int
3080Sstevel@tonic-gate ttrace_trap(trap_trace_rec_t *rec)
3090Sstevel@tonic-gate {
3100Sstevel@tonic-gate 	int i;
3110Sstevel@tonic-gate 
3123446Smrj 	if (rec->ttr_regs.r_trapno == T_AST)
3133446Smrj 		mdb_printf("%-3s ", "-");
3143446Smrj 	else
3153446Smrj 		mdb_printf("%-3x ", rec->ttr_regs.r_trapno);
3160Sstevel@tonic-gate 
3170Sstevel@tonic-gate 	for (i = 0; ttrace_traps[i].tt_name != NULL; i++) {
3180Sstevel@tonic-gate 		if (rec->ttr_regs.r_trapno == ttrace_traps[i].tt_trapno)
3190Sstevel@tonic-gate 			break;
3200Sstevel@tonic-gate 	}
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate 	if (ttrace_traps[i].tt_name == NULL)
3230Sstevel@tonic-gate 		mdb_printf("%-*s", TT_HDLR_WIDTH, "(unknown)");
3240Sstevel@tonic-gate 	else
3250Sstevel@tonic-gate 		mdb_printf("%-*s", TT_HDLR_WIDTH, ttrace_traps[i].tt_name);
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate 	return (0);
3280Sstevel@tonic-gate }
3290Sstevel@tonic-gate 
3303446Smrj static void
3313446Smrj ttrace_intr_detail(trap_trace_rec_t *rec)
3323446Smrj {
3333446Smrj 	mdb_printf("\tirq %x ipl %d oldpri %d basepri %d\n", rec->ttr_vector,
3343446Smrj 	    rec->ttr_ipl, rec->ttr_pri, rec->ttr_spl);
3353446Smrj }
3363446Smrj 
3373446Smrj static struct {
3380Sstevel@tonic-gate 	uchar_t t_marker;
3390Sstevel@tonic-gate 	char *t_name;
3400Sstevel@tonic-gate 	int (*t_hdlr)(trap_trace_rec_t *);
3410Sstevel@tonic-gate } ttrace_hdlr[] = {
3420Sstevel@tonic-gate 	{ TT_SYSCALL, "sysc", ttrace_syscall },
3430Sstevel@tonic-gate 	{ TT_SYSENTER, "syse", ttrace_syscall },
3440Sstevel@tonic-gate 	{ TT_SYSC, "asys", ttrace_syscall },
3450Sstevel@tonic-gate 	{ TT_SYSC64, "sc64", ttrace_syscall },
3460Sstevel@tonic-gate 	{ TT_INTERRUPT, "intr", ttrace_interrupt },
3470Sstevel@tonic-gate 	{ TT_TRAP, "trap", ttrace_trap },
3483446Smrj 	{ TT_EVENT, "evnt", ttrace_trap },
3490Sstevel@tonic-gate 	{ 0, NULL, NULL }
3500Sstevel@tonic-gate };
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate typedef struct ttrace_dcmd {
3530Sstevel@tonic-gate 	processorid_t ttd_cpu;
3540Sstevel@tonic-gate 	uint_t ttd_extended;
3550Sstevel@tonic-gate 	trap_trace_ctl_t ttd_ttc[NCPU];
3560Sstevel@tonic-gate } ttrace_dcmd_t;
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate #if defined(__amd64)
3590Sstevel@tonic-gate 
3600Sstevel@tonic-gate #define	DUMP(reg) #reg, regs->r_##reg
3610Sstevel@tonic-gate #define	THREEREGS	"         %3s: %16lx %3s: %16lx %3s: %16lx\n"
3620Sstevel@tonic-gate 
3630Sstevel@tonic-gate static void
3640Sstevel@tonic-gate ttrace_dumpregs(trap_trace_rec_t *rec)
3650Sstevel@tonic-gate {
3660Sstevel@tonic-gate 	struct regs *regs = &rec->ttr_regs;
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate 	mdb_printf(THREEREGS, DUMP(rdi), DUMP(rsi), DUMP(rdx));
3690Sstevel@tonic-gate 	mdb_printf(THREEREGS, DUMP(rcx), DUMP(r8), DUMP(r9));
3700Sstevel@tonic-gate 	mdb_printf(THREEREGS, DUMP(rax), DUMP(rbx), DUMP(rbp));
3710Sstevel@tonic-gate 	mdb_printf(THREEREGS, DUMP(r10), DUMP(r11), DUMP(r12));
3720Sstevel@tonic-gate 	mdb_printf(THREEREGS, DUMP(r13), DUMP(r14), DUMP(r15));
3733446Smrj 	mdb_printf(THREEREGS, DUMP(ds), DUMP(es), DUMP(fs));
3743446Smrj 	mdb_printf(THREEREGS, DUMP(gs), "trp", regs->r_trapno, DUMP(err));
3753446Smrj 	mdb_printf(THREEREGS, DUMP(rip), DUMP(cs), DUMP(rfl));
3763446Smrj 	mdb_printf(THREEREGS, DUMP(rsp), DUMP(ss), "cr2", rec->ttr_cr2);
3770Sstevel@tonic-gate 	mdb_printf("\n");
3780Sstevel@tonic-gate }
3790Sstevel@tonic-gate 
3800Sstevel@tonic-gate #else
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate #define	DUMP(reg) #reg, regs->r_##reg
3830Sstevel@tonic-gate #define	FOURREGS	"         %3s: %08x %3s: %08x %3s: %08x %3s: %08x\n"
3840Sstevel@tonic-gate 
3850Sstevel@tonic-gate static void
3860Sstevel@tonic-gate ttrace_dumpregs(trap_trace_rec_t *rec)
3870Sstevel@tonic-gate {
3880Sstevel@tonic-gate 	struct regs *regs = &rec->ttr_regs;
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate 	mdb_printf(FOURREGS, DUMP(gs), DUMP(fs), DUMP(es), DUMP(ds));
3910Sstevel@tonic-gate 	mdb_printf(FOURREGS, DUMP(edi), DUMP(esi), DUMP(ebp), DUMP(esp));
3920Sstevel@tonic-gate 	mdb_printf(FOURREGS, DUMP(ebx), DUMP(edx), DUMP(ecx), DUMP(eax));
3930Sstevel@tonic-gate 	mdb_printf(FOURREGS, "trp", regs->r_trapno, DUMP(err),
3940Sstevel@tonic-gate 	    DUMP(pc), DUMP(cs));
3950Sstevel@tonic-gate 	mdb_printf(FOURREGS, DUMP(efl), "usp", regs->r_uesp, DUMP(ss),
3960Sstevel@tonic-gate 	    "cr2", rec->ttr_cr2);
3970Sstevel@tonic-gate 	mdb_printf("\n");
3980Sstevel@tonic-gate }
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate #endif	/* __amd64 */
4010Sstevel@tonic-gate 
4020Sstevel@tonic-gate int
4030Sstevel@tonic-gate ttrace_walk(uintptr_t addr, trap_trace_rec_t *rec, ttrace_dcmd_t *dcmd)
4040Sstevel@tonic-gate {
4050Sstevel@tonic-gate 	struct regs *regs = &rec->ttr_regs;
4060Sstevel@tonic-gate 	processorid_t cpu = -1, i;
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate 	for (i = 0; i < NCPU; i++) {
4090Sstevel@tonic-gate 		if (addr >= dcmd->ttd_ttc[i].ttc_first &&
4100Sstevel@tonic-gate 		    addr < dcmd->ttd_ttc[i].ttc_limit) {
4110Sstevel@tonic-gate 			cpu = i;
4120Sstevel@tonic-gate 			break;
4130Sstevel@tonic-gate 		}
4140Sstevel@tonic-gate 	}
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate 	if (cpu == -1) {
4170Sstevel@tonic-gate 		mdb_warn("couldn't find %p in any trap trace ctl\n", addr);
4180Sstevel@tonic-gate 		return (WALK_ERR);
4190Sstevel@tonic-gate 	}
4200Sstevel@tonic-gate 
4210Sstevel@tonic-gate 	if (dcmd->ttd_cpu != -1 && cpu != dcmd->ttd_cpu)
4220Sstevel@tonic-gate 		return (WALK_NEXT);
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate 	mdb_printf("%3d %15llx ", cpu, rec->ttr_stamp);
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate 	for (i = 0; ttrace_hdlr[i].t_hdlr != NULL; i++) {
4270Sstevel@tonic-gate 		if (rec->ttr_marker != ttrace_hdlr[i].t_marker)
4280Sstevel@tonic-gate 			continue;
4290Sstevel@tonic-gate 		mdb_printf("%4s ", ttrace_hdlr[i].t_name);
4300Sstevel@tonic-gate 		if (ttrace_hdlr[i].t_hdlr(rec) == -1)
4310Sstevel@tonic-gate 			return (WALK_ERR);
4320Sstevel@tonic-gate 	}
4330Sstevel@tonic-gate 
4343446Smrj 	mdb_printf(" %a\n", regs->r_pc);
4350Sstevel@tonic-gate 
4360Sstevel@tonic-gate 	if (dcmd->ttd_extended == FALSE)
4370Sstevel@tonic-gate 		return (WALK_NEXT);
4380Sstevel@tonic-gate 
439*9489SJoe.Bonasera@sun.com 	if (rec->ttr_marker == TT_INTERRUPT)
4403446Smrj 		ttrace_intr_detail(rec);
4413446Smrj 	else
4423446Smrj 		ttrace_dumpregs(rec);
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate 	if (rec->ttr_sdepth > 0) {
4450Sstevel@tonic-gate 		for (i = 0; i < rec->ttr_sdepth; i++) {
4460Sstevel@tonic-gate 			if (i >= TTR_STACK_DEPTH) {
4470Sstevel@tonic-gate 				mdb_printf("%17s*** invalid ttr_sdepth (is %d, "
4480Sstevel@tonic-gate 				    "should be <= %d)\n", " ", rec->ttr_sdepth,
4490Sstevel@tonic-gate 				    TTR_STACK_DEPTH);
4500Sstevel@tonic-gate 				break;
4510Sstevel@tonic-gate 			}
4520Sstevel@tonic-gate 
4530Sstevel@tonic-gate 			mdb_printf("%17s %a()\n", " ", rec->ttr_stack[i]);
4540Sstevel@tonic-gate 		}
4550Sstevel@tonic-gate 		mdb_printf("\n");
4560Sstevel@tonic-gate 	}
4570Sstevel@tonic-gate 
4580Sstevel@tonic-gate 	return (WALK_NEXT);
4590Sstevel@tonic-gate }
4600Sstevel@tonic-gate 
4610Sstevel@tonic-gate int
4620Sstevel@tonic-gate ttrace(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
4630Sstevel@tonic-gate {
4640Sstevel@tonic-gate 	ttrace_dcmd_t dcmd;
4650Sstevel@tonic-gate 	trap_trace_ctl_t *ttc = dcmd.ttd_ttc;
4660Sstevel@tonic-gate 	trap_trace_rec_t rec;
4670Sstevel@tonic-gate 	size_t ttc_size = sizeof (trap_trace_ctl_t) * NCPU;
4680Sstevel@tonic-gate 
4690Sstevel@tonic-gate 	if (!ttrace_ttr_size_check())
4700Sstevel@tonic-gate 		return (WALK_ERR);
4710Sstevel@tonic-gate 
4720Sstevel@tonic-gate 	bzero(&dcmd, sizeof (dcmd));
4730Sstevel@tonic-gate 	dcmd.ttd_cpu = -1;
4740Sstevel@tonic-gate 	dcmd.ttd_extended = FALSE;
4750Sstevel@tonic-gate 
4760Sstevel@tonic-gate 	if (mdb_readsym(ttc, ttc_size, "trap_trace_ctl") == -1) {
4770Sstevel@tonic-gate 		mdb_warn("symbol 'trap_trace_ctl' not found; "
4780Sstevel@tonic-gate 		    "non-TRAPTRACE kernel?\n");
4790Sstevel@tonic-gate 		return (DCMD_ERR);
4800Sstevel@tonic-gate 	}
4810Sstevel@tonic-gate 
4820Sstevel@tonic-gate 	if (mdb_getopts(argc, argv,
4830Sstevel@tonic-gate 	    'x', MDB_OPT_SETBITS, TRUE, &dcmd.ttd_extended, NULL) != argc)
4840Sstevel@tonic-gate 		return (DCMD_USAGE);
4850Sstevel@tonic-gate 
4860Sstevel@tonic-gate 	if (DCMD_HDRSPEC(flags)) {
4870Sstevel@tonic-gate 		mdb_printf("%3s %15s %4s %2s %-*s%s\n", "CPU",
4883446Smrj 		    "TIMESTAMP", "TYPE", "Vec", TT_HDLR_WIDTH, "HANDLER",
4893446Smrj 		    " EIP");
4900Sstevel@tonic-gate 	}
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate 	if (flags & DCMD_ADDRSPEC) {
4930Sstevel@tonic-gate 		if (addr >= NCPU) {
4940Sstevel@tonic-gate 			if (mdb_vread(&rec, sizeof (rec), addr) == -1) {
4950Sstevel@tonic-gate 				mdb_warn("couldn't read trap trace record "
4960Sstevel@tonic-gate 				    "at %p", addr);
4970Sstevel@tonic-gate 				return (DCMD_ERR);
4980Sstevel@tonic-gate 			}
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate 			if (ttrace_walk(addr, &rec, &dcmd) == WALK_ERR)
5010Sstevel@tonic-gate 				return (DCMD_ERR);
5020Sstevel@tonic-gate 
5030Sstevel@tonic-gate 			return (DCMD_OK);
5040Sstevel@tonic-gate 		}
5050Sstevel@tonic-gate 		dcmd.ttd_cpu = addr;
5060Sstevel@tonic-gate 	}
5070Sstevel@tonic-gate 
5080Sstevel@tonic-gate 	if (mdb_walk("ttrace", (mdb_walk_cb_t)ttrace_walk, &dcmd) == -1) {
5090Sstevel@tonic-gate 		mdb_warn("couldn't walk 'ttrace'");
5100Sstevel@tonic-gate 		return (DCMD_ERR);
5110Sstevel@tonic-gate 	}
5120Sstevel@tonic-gate 
5130Sstevel@tonic-gate 	return (DCMD_OK);
5140Sstevel@tonic-gate }
5150Sstevel@tonic-gate 
5160Sstevel@tonic-gate /*ARGSUSED*/
5170Sstevel@tonic-gate int
5180Sstevel@tonic-gate mutex_owner_init(mdb_walk_state_t *wsp)
5190Sstevel@tonic-gate {
5200Sstevel@tonic-gate 	return (WALK_NEXT);
5210Sstevel@tonic-gate }
5220Sstevel@tonic-gate 
5230Sstevel@tonic-gate int
5240Sstevel@tonic-gate mutex_owner_step(mdb_walk_state_t *wsp)
5250Sstevel@tonic-gate {
5260Sstevel@tonic-gate 	uintptr_t addr = wsp->walk_addr;
5270Sstevel@tonic-gate 	mutex_impl_t mtx;
5280Sstevel@tonic-gate 	uintptr_t owner;
5290Sstevel@tonic-gate 	kthread_t thr;
5300Sstevel@tonic-gate 
5310Sstevel@tonic-gate 	if (mdb_vread(&mtx, sizeof (mtx), addr) == -1)
5320Sstevel@tonic-gate 		return (WALK_ERR);
5330Sstevel@tonic-gate 
5340Sstevel@tonic-gate 	if (!MUTEX_TYPE_ADAPTIVE(&mtx))
5350Sstevel@tonic-gate 		return (WALK_DONE);
5360Sstevel@tonic-gate 
5370Sstevel@tonic-gate 	if ((owner = (uintptr_t)MUTEX_OWNER(&mtx)) == NULL)
5380Sstevel@tonic-gate 		return (WALK_DONE);
5390Sstevel@tonic-gate 
5400Sstevel@tonic-gate 	if (mdb_vread(&thr, sizeof (thr), owner) != -1)
5410Sstevel@tonic-gate 		(void) wsp->walk_callback(owner, &thr, wsp->walk_cbdata);
5420Sstevel@tonic-gate 
5430Sstevel@tonic-gate 	return (WALK_DONE);
5440Sstevel@tonic-gate }
5450Sstevel@tonic-gate 
5460Sstevel@tonic-gate static void
5470Sstevel@tonic-gate gate_desc_dump(gate_desc_t *gate, const char *label, int header)
5480Sstevel@tonic-gate {
5490Sstevel@tonic-gate 	const char *lastnm;
5500Sstevel@tonic-gate 	uint_t lastval;
5510Sstevel@tonic-gate 	char type[4];
5520Sstevel@tonic-gate 
5530Sstevel@tonic-gate 	switch (gate->sgd_type) {
5540Sstevel@tonic-gate 	case SDT_SYSIGT:
5550Sstevel@tonic-gate 		strcpy(type, "int");
5560Sstevel@tonic-gate 		break;
5570Sstevel@tonic-gate 	case SDT_SYSTGT:
5580Sstevel@tonic-gate 		strcpy(type, "trp");
5590Sstevel@tonic-gate 		break;
5600Sstevel@tonic-gate 	case SDT_SYSTASKGT:
5610Sstevel@tonic-gate 		strcpy(type, "tsk");
5620Sstevel@tonic-gate 		break;
5630Sstevel@tonic-gate 	default:
5640Sstevel@tonic-gate 		(void) mdb_snprintf(type, sizeof (type), "%3x", gate->sgd_type);
5650Sstevel@tonic-gate 	}
5660Sstevel@tonic-gate 
5670Sstevel@tonic-gate #if defined(__amd64)
5680Sstevel@tonic-gate 	lastnm = "IST";
5690Sstevel@tonic-gate 	lastval = gate->sgd_ist;
5700Sstevel@tonic-gate #else
5710Sstevel@tonic-gate 	lastnm = "STK";
5720Sstevel@tonic-gate 	lastval = gate->sgd_stkcpy;
5730Sstevel@tonic-gate #endif
5740Sstevel@tonic-gate 
5750Sstevel@tonic-gate 	if (header) {
5760Sstevel@tonic-gate 		mdb_printf("%*s%<u>%-30s%</u> %<u>%-4s%</u> %<u>%3s%</u> "
5770Sstevel@tonic-gate 		    "%<u>%1s%</u> %<u>%3s%</u> %<u>%3s%</u>\n", strlen(label),
5780Sstevel@tonic-gate 		    "", "HANDLER", "SEL", "DPL", "P", "TYP", lastnm);
5790Sstevel@tonic-gate 	}
5800Sstevel@tonic-gate 
5810Sstevel@tonic-gate 	mdb_printf("%s", label);
5820Sstevel@tonic-gate 
5830Sstevel@tonic-gate 	if (gate->sgd_type == SDT_SYSTASKGT)
5840Sstevel@tonic-gate 		mdb_printf("%-30s ", "-");
5850Sstevel@tonic-gate 	else
5860Sstevel@tonic-gate 		mdb_printf("%-30a ", GATESEG_GETOFFSET(gate));
5870Sstevel@tonic-gate 
5880Sstevel@tonic-gate 	mdb_printf("%4x  %d  %c %3s %2x\n", gate->sgd_selector,
5890Sstevel@tonic-gate 	    gate->sgd_dpl, (gate->sgd_p ? '+' : ' '), type, lastval);
5900Sstevel@tonic-gate }
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate /*ARGSUSED*/
5930Sstevel@tonic-gate static int
5940Sstevel@tonic-gate gate_desc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5950Sstevel@tonic-gate {
5960Sstevel@tonic-gate 	gate_desc_t gate;
5970Sstevel@tonic-gate 
5980Sstevel@tonic-gate 	if (argc != 0 || !(flags & DCMD_ADDRSPEC))
5990Sstevel@tonic-gate 		return (DCMD_USAGE);
6000Sstevel@tonic-gate 
6010Sstevel@tonic-gate 	if (mdb_vread(&gate, sizeof (gate_desc_t), addr) !=
6020Sstevel@tonic-gate 	    sizeof (gate_desc_t)) {
6030Sstevel@tonic-gate 		mdb_warn("failed to read gate descriptor at %p\n", addr);
6040Sstevel@tonic-gate 		return (DCMD_ERR);
6050Sstevel@tonic-gate 	}
6060Sstevel@tonic-gate 
6070Sstevel@tonic-gate 	gate_desc_dump(&gate, "", DCMD_HDRSPEC(flags));
6080Sstevel@tonic-gate 
6090Sstevel@tonic-gate 	return (DCMD_OK);
6100Sstevel@tonic-gate }
6110Sstevel@tonic-gate 
6120Sstevel@tonic-gate /*ARGSUSED*/
6130Sstevel@tonic-gate static int
6140Sstevel@tonic-gate idt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
6150Sstevel@tonic-gate {
6160Sstevel@tonic-gate 	int i;
6170Sstevel@tonic-gate 
6180Sstevel@tonic-gate 	if (!(flags & DCMD_ADDRSPEC)) {
6195487Sjosephb 		GElf_Sym idt0_va;
6205487Sjosephb 		gate_desc_t *idt0;
6210Sstevel@tonic-gate 
6225487Sjosephb 		if (mdb_lookup_by_name("idt0", &idt0_va) < 0) {
6235487Sjosephb 			mdb_warn("failed to find VA of idt0");
6240Sstevel@tonic-gate 			return (DCMD_ERR);
6250Sstevel@tonic-gate 		}
6260Sstevel@tonic-gate 
6275487Sjosephb 		addr = idt0_va.st_value;
6285487Sjosephb 		if (mdb_vread(&idt0, sizeof (idt0), addr) != sizeof (idt0)) {
6295487Sjosephb 			mdb_warn("failed to read idt0 at %p\n", addr);
6305487Sjosephb 			return (DCMD_ERR);
6315487Sjosephb 		}
6325487Sjosephb 
6335487Sjosephb 		addr = (uintptr_t)idt0;
6340Sstevel@tonic-gate 	}
6350Sstevel@tonic-gate 
6360Sstevel@tonic-gate 	for (i = 0; i < NIDT; i++, addr += sizeof (gate_desc_t)) {
6370Sstevel@tonic-gate 		gate_desc_t gate;
6380Sstevel@tonic-gate 		char label[6];
6390Sstevel@tonic-gate 
6400Sstevel@tonic-gate 		if (mdb_vread(&gate, sizeof (gate_desc_t), addr) !=
6410Sstevel@tonic-gate 		    sizeof (gate_desc_t)) {
6420Sstevel@tonic-gate 			mdb_warn("failed to read gate descriptor at %p\n",
6430Sstevel@tonic-gate 			    addr);
6440Sstevel@tonic-gate 			return (DCMD_ERR);
6450Sstevel@tonic-gate 		}
6460Sstevel@tonic-gate 
6470Sstevel@tonic-gate 		(void) mdb_snprintf(label, sizeof (label), "%3d: ", i);
6480Sstevel@tonic-gate 		gate_desc_dump(&gate, label, i == 0);
6490Sstevel@tonic-gate 	}
6500Sstevel@tonic-gate 
6510Sstevel@tonic-gate 	return (DCMD_OK);
6520Sstevel@tonic-gate }
6530Sstevel@tonic-gate 
6543446Smrj static void
6553446Smrj htables_help(void)
6563446Smrj {
6573446Smrj 	mdb_printf(
6583446Smrj 	    "Given a (hat_t *), generates the list of all (htable_t *)s\n"
6593446Smrj 	    "that correspond to that address space\n");
6603446Smrj }
6613446Smrj 
6623446Smrj static void
6633446Smrj report_maps_help(void)
6643446Smrj {
6653446Smrj 	mdb_printf(
6663446Smrj 	    "Given a PFN, report HAT structures that map the page, or use\n"
6673446Smrj 	    "the page as a pagetable.\n"
6683446Smrj 	    "\n"
6695084Sjohnlev 	    "-m Interpret the PFN as an MFN (machine frame number)\n");
6703446Smrj }
6713446Smrj 
6723446Smrj static void
6733446Smrj ptable_help(void)
6743446Smrj {
6753446Smrj 	mdb_printf(
6763446Smrj 	    "Given a PFN holding a page table, print its contents, and\n"
6773446Smrj 	    "the address of the corresponding htable structure.\n"
6783446Smrj 	    "\n"
6795084Sjohnlev 	    "-m Interpret the PFN as an MFN (machine frame number)\n");
6803446Smrj }
6813446Smrj 
6820Sstevel@tonic-gate static const mdb_dcmd_t dcmds[] = {
6830Sstevel@tonic-gate 	{ "gate_desc", ":", "dump a gate descriptor", gate_desc },
6840Sstevel@tonic-gate 	{ "idt", ":[-v]", "dump an IDT", idt },
6850Sstevel@tonic-gate 	{ "ttrace", "[-x]", "dump trap trace buffers", ttrace },
6860Sstevel@tonic-gate 	{ "vatopfn", ":[-a as]", "translate address to physical page",
6870Sstevel@tonic-gate 	    va2pfn_dcmd },
6883446Smrj 	{ "report_maps", ":[-m]",
6893446Smrj 	    "Given PFN, report mappings / page table usage",
6903446Smrj 	    report_maps_dcmd, report_maps_help },
6913446Smrj 	{ "htables", "", "Given hat_t *, lists all its htable_t * values",
6923446Smrj 	    htables_dcmd, htables_help },
6933446Smrj 	{ "ptable", ":[-m]", "Given PFN, dump contents of a page table",
6943446Smrj 	    ptable_dcmd, ptable_help },
6950Sstevel@tonic-gate 	{ "pte", ":[-p XXXXX] [-l N]", "print human readable page table entry",
6960Sstevel@tonic-gate 	    pte_dcmd },
6970Sstevel@tonic-gate 	{ "page_num2pp", ":", "page frame number to page structure",
6980Sstevel@tonic-gate 	    page_num2pp },
6995084Sjohnlev 	{ "pfntomfn", ":", "convert physical page to hypervisor machine page",
7005084Sjohnlev 	    pfntomfn_dcmd },
7015084Sjohnlev 	{ "mfntopfn", ":", "convert hypervisor machine page to physical page",
7025084Sjohnlev 	    mfntopfn_dcmd },
7030Sstevel@tonic-gate 	{ "memseg_list", ":", "show memseg list", memseg_list },
7040Sstevel@tonic-gate 	{ NULL }
7050Sstevel@tonic-gate };
7060Sstevel@tonic-gate 
7070Sstevel@tonic-gate static const mdb_walker_t walkers[] = {
7080Sstevel@tonic-gate 	{ "ttrace", "walks trap trace buffers in reverse chronological order",
7090Sstevel@tonic-gate 		ttrace_walk_init, ttrace_walk_step, ttrace_walk_fini },
7100Sstevel@tonic-gate 	{ "mutex_owner", "walks the owner of a mutex",
7110Sstevel@tonic-gate 		mutex_owner_init, mutex_owner_step },
7120Sstevel@tonic-gate 	{ "memseg", "walk the memseg structures",
7130Sstevel@tonic-gate 		memseg_walk_init, memseg_walk_step, memseg_walk_fini },
7140Sstevel@tonic-gate 	{ NULL }
7150Sstevel@tonic-gate };
7160Sstevel@tonic-gate 
7170Sstevel@tonic-gate static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
7180Sstevel@tonic-gate 
7190Sstevel@tonic-gate const mdb_modinfo_t *
7200Sstevel@tonic-gate _mdb_init(void)
7210Sstevel@tonic-gate {
7220Sstevel@tonic-gate 	return (&modinfo);
7230Sstevel@tonic-gate }
7245084Sjohnlev 
7255084Sjohnlev void
7265084Sjohnlev _mdb_fini(void)
7275084Sjohnlev {
7285084Sjohnlev 	free_mmu();
7295084Sjohnlev }
730