xref: /onnv-gate/usr/src/uts/sun4u/os/mach_trap.c (revision 5084:7d838c5c0eed)
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 /*
223446Smrj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <sys/trap.h>
290Sstevel@tonic-gate #include <sys/machtrap.h>
300Sstevel@tonic-gate #include <sys/machsystm.h>
310Sstevel@tonic-gate #include <sys/cpu_module.h>
320Sstevel@tonic-gate #include <sys/panic.h>
330Sstevel@tonic-gate #include <sys/uadmin.h>
340Sstevel@tonic-gate #include <sys/kobj.h>
350Sstevel@tonic-gate #include <sys/contract/process_impl.h>
360Sstevel@tonic-gate #include <vm/hat_sfmmu.h>
370Sstevel@tonic-gate #include <sys/reboot.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef  TRAPTRACE
400Sstevel@tonic-gate #include <sys/traptrace.h>
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate void showregs(unsigned, struct regs *, caddr_t, uint_t);
440Sstevel@tonic-gate 
450Sstevel@tonic-gate extern int tudebug;
460Sstevel@tonic-gate 
470Sstevel@tonic-gate void
480Sstevel@tonic-gate mmu_print_sfsr(uint_t sfsr)
490Sstevel@tonic-gate {
500Sstevel@tonic-gate 	printf("MMU sfsr=%x:", sfsr);
510Sstevel@tonic-gate 	switch (X_FAULT_TYPE(sfsr)) {
520Sstevel@tonic-gate 	case FT_NONE:
530Sstevel@tonic-gate 		printf(" No error");
540Sstevel@tonic-gate 		break;
550Sstevel@tonic-gate 	case FT_PRIV:
560Sstevel@tonic-gate 		printf(" Privilege violation");
570Sstevel@tonic-gate 		break;
580Sstevel@tonic-gate 	case FT_SPEC_LD:
590Sstevel@tonic-gate 		printf(" Speculative load on E-bit page");
600Sstevel@tonic-gate 		break;
610Sstevel@tonic-gate 	case FT_ATOMIC_NC:
620Sstevel@tonic-gate 		printf(" Atomic to uncacheable page");
630Sstevel@tonic-gate 		break;
640Sstevel@tonic-gate 	case FT_ILL_ALT:
650Sstevel@tonic-gate 		printf(" Illegal lda or sta");
660Sstevel@tonic-gate 		break;
670Sstevel@tonic-gate 	case FT_NFO:
680Sstevel@tonic-gate 		printf(" Normal access to NFO page");
690Sstevel@tonic-gate 		break;
700Sstevel@tonic-gate 	case FT_RANGE:
710Sstevel@tonic-gate 		printf(" Data or instruction address out of range");
720Sstevel@tonic-gate 		break;
730Sstevel@tonic-gate 	case FT_RANGE_REG:
740Sstevel@tonic-gate 		printf(" Jump to register out of range");
750Sstevel@tonic-gate 		break;
760Sstevel@tonic-gate 	default:
770Sstevel@tonic-gate 		printf(" Unknown error");
780Sstevel@tonic-gate 		break;
790Sstevel@tonic-gate 	}
800Sstevel@tonic-gate 	if (sfsr) {
810Sstevel@tonic-gate 		printf(" on ASI 0x%x E %d CID %d PRIV %d W %d OW %d FV %d",
82*5084Sjohnlev 		    (sfsr & SFSR_ASI) >> SFSR_ASI_SHIFT,
83*5084Sjohnlev 		    (sfsr & SFSR_E) != 0,
84*5084Sjohnlev 		    (sfsr & SFSR_CTX) >> SFSR_CT_SHIFT,
85*5084Sjohnlev 		    (sfsr & SFSR_PR) != 0,
86*5084Sjohnlev 		    (sfsr & SFSR_W) != 0,
87*5084Sjohnlev 		    (sfsr & SFSR_OW) != 0,
88*5084Sjohnlev 		    (sfsr & SFSR_FV) != 0);
890Sstevel@tonic-gate 	}
900Sstevel@tonic-gate 	printf("\n");
910Sstevel@tonic-gate }
920Sstevel@tonic-gate 
930Sstevel@tonic-gate 
940Sstevel@tonic-gate /*
950Sstevel@tonic-gate  * Handle an asynchronous hardware error, i.e. an E-$ parity error.
960Sstevel@tonic-gate  * The policy is currently to send a hardware error contract event to
970Sstevel@tonic-gate  * the process's process contract and to kill the process.  Eventually
980Sstevel@tonic-gate  * we may want to instead send a special signal whose default
990Sstevel@tonic-gate  * disposition is to generate the contract event.
1000Sstevel@tonic-gate  */
1010Sstevel@tonic-gate void
1020Sstevel@tonic-gate trap_async_hwerr(void)
1030Sstevel@tonic-gate {
1040Sstevel@tonic-gate 	k_siginfo_t si;
1050Sstevel@tonic-gate 	proc_t *p = ttoproc(curthread);
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 	errorq_drain(ue_queue); /* flush pending async error messages */
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate 	contract_process_hwerr(p->p_ct_process, p);
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate 	bzero(&si, sizeof (k_siginfo_t));
1120Sstevel@tonic-gate 	si.si_signo = SIGKILL;
1130Sstevel@tonic-gate 	si.si_code = SI_NOINFO;
1140Sstevel@tonic-gate 	trapsig(&si, 1);
1150Sstevel@tonic-gate }
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /*
1180Sstevel@tonic-gate  * Handle bus error and bus timeout for a user process by sending SIGBUS
1190Sstevel@tonic-gate  * The type is either ASYNC_BERR or ASYNC_BTO.
1200Sstevel@tonic-gate  */
1210Sstevel@tonic-gate void
1220Sstevel@tonic-gate trap_async_berr_bto(int type, struct regs *rp)
1230Sstevel@tonic-gate {
1240Sstevel@tonic-gate 	k_siginfo_t si;
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate 	errorq_drain(ue_queue); /* flush pending async error messages */
1270Sstevel@tonic-gate 	bzero(&si, sizeof (k_siginfo_t));
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate 	si.si_signo = SIGBUS;
1300Sstevel@tonic-gate 	si.si_code = (type == ASYNC_BERR ? BUS_OBJERR : BUS_ADRERR);
1310Sstevel@tonic-gate 	si.si_addr = (caddr_t)rp->r_pc; /* AFAR unavailable - future RFE */
1320Sstevel@tonic-gate 	si.si_errno = ENXIO;
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 	trapsig(&si, 1);
1350Sstevel@tonic-gate }
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate #ifdef TRAPWINDOW
1380Sstevel@tonic-gate long trap_window[25];
1390Sstevel@tonic-gate #endif /* TRAPWINDOW */
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate /*
1420Sstevel@tonic-gate  * Print out debugging info.
1430Sstevel@tonic-gate  */
1440Sstevel@tonic-gate /*ARGSUSED*/
1450Sstevel@tonic-gate void
1460Sstevel@tonic-gate showregs(uint_t type, struct regs *rp, caddr_t addr, uint_t mmu_fsr)
1470Sstevel@tonic-gate {
1480Sstevel@tonic-gate 	int s;
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate 	s = spl7();
1510Sstevel@tonic-gate 	type &= ~T_USER;
1523446Smrj 	printf("%s: ", PTOU(curproc)->u_comm);
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 	switch (type) {
1550Sstevel@tonic-gate 	case T_SYS_RTT_ALIGN:
1560Sstevel@tonic-gate 	case T_ALIGNMENT:
1570Sstevel@tonic-gate 		printf("alignment error:\n");
1580Sstevel@tonic-gate 		break;
1590Sstevel@tonic-gate 	case T_INSTR_EXCEPTION:
1600Sstevel@tonic-gate 		printf("text access exception:\n");
1610Sstevel@tonic-gate 		break;
1620Sstevel@tonic-gate 	case T_DATA_EXCEPTION:
1630Sstevel@tonic-gate 		printf("data access exception:\n");
1640Sstevel@tonic-gate 		break;
1650Sstevel@tonic-gate 	case T_PRIV_INSTR:
1660Sstevel@tonic-gate 		printf("privileged instruction fault:\n");
1670Sstevel@tonic-gate 		break;
1680Sstevel@tonic-gate 	case T_UNIMP_INSTR:
1690Sstevel@tonic-gate 		printf("illegal instruction fault:\n");
1700Sstevel@tonic-gate 		break;
1710Sstevel@tonic-gate 	case T_IDIV0:
1720Sstevel@tonic-gate 		printf("integer divide zero trap:\n");
1730Sstevel@tonic-gate 		break;
1740Sstevel@tonic-gate 	case T_DIV0:
1750Sstevel@tonic-gate 		printf("zero divide trap:\n");
1760Sstevel@tonic-gate 		break;
1770Sstevel@tonic-gate 	case T_INT_OVERFLOW:
1780Sstevel@tonic-gate 		printf("integer overflow:\n");
1790Sstevel@tonic-gate 		break;
1800Sstevel@tonic-gate 	case T_BREAKPOINT:
1810Sstevel@tonic-gate 		printf("breakpoint trap:\n");
1820Sstevel@tonic-gate 		break;
1830Sstevel@tonic-gate 	case T_TAG_OVERFLOW:
1840Sstevel@tonic-gate 		printf("tag overflow:\n");
1850Sstevel@tonic-gate 		break;
1860Sstevel@tonic-gate 	default:
1870Sstevel@tonic-gate 		if (type >= T_SOFTWARE_TRAP && type <= T_ESOFTWARE_TRAP)
1880Sstevel@tonic-gate 			printf("software trap 0x%x\n", type - T_SOFTWARE_TRAP);
1890Sstevel@tonic-gate 		else
1900Sstevel@tonic-gate 			printf("trap type = 0x%x\n", type);
1910Sstevel@tonic-gate 		break;
1920Sstevel@tonic-gate 	}
1930Sstevel@tonic-gate 	if (type == T_DATA_EXCEPTION || type == T_INSTR_EXCEPTION) {
1940Sstevel@tonic-gate 		mmu_print_sfsr(mmu_fsr);
1950Sstevel@tonic-gate 	} else if (addr) {
1960Sstevel@tonic-gate 		printf("addr=0x%p\n", (void *)addr);
1970Sstevel@tonic-gate 	}
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate 	printf("pid=%d, pc=0x%lx, sp=0x%llx, tstate=0x%llx, context=0x%x\n",
2000Sstevel@tonic-gate 	    (ttoproc(curthread) && ttoproc(curthread)->p_pidp) ?
2010Sstevel@tonic-gate 	    (ttoproc(curthread)->p_pid) : 0, rp->r_pc, rp->r_sp,
2020Sstevel@tonic-gate 	    rp->r_tstate, sfmmu_getctx_sec());
2030Sstevel@tonic-gate 	if (USERMODE(rp->r_tstate)) {
2040Sstevel@tonic-gate 		printf("o0-o7: %llx, %llx, %llx, %llx, %llx, %llx, "
2050Sstevel@tonic-gate 		    "%llx, %llx\n", rp->r_o0, rp->r_o1, rp->r_o2, rp->r_o3,
2060Sstevel@tonic-gate 		    rp->r_o4, rp->r_o5, rp->r_o6, rp->r_o7);
2070Sstevel@tonic-gate 	}
2080Sstevel@tonic-gate 	printf("g1-g7: %llx, %llx, %llx, %llx, %llx, %llx, %llx\n",
2090Sstevel@tonic-gate 	    rp->r_g1, rp->r_g2, rp->r_g3,
2100Sstevel@tonic-gate 	    rp->r_g4, rp->r_g5, rp->r_g6, rp->r_g7);
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate #ifdef TRAPWINDOW
2130Sstevel@tonic-gate 	printf("trap_window: wim=%x\n", trap_window[24]);
2140Sstevel@tonic-gate 	printf("o0-o7: %x, %x, %x, %x, %x, %x, %x, %x\n",
2150Sstevel@tonic-gate 	    trap_window[0], trap_window[1], trap_window[2], trap_window[3],
2160Sstevel@tonic-gate 	    trap_window[4], trap_window[5], trap_window[6], trap_window[7]);
2170Sstevel@tonic-gate 	printf("l0-l7: %x, %x, %x, %x, %x, %x, %x, %x\n",
2180Sstevel@tonic-gate 	    trap_window[8], trap_window[9], trap_window[10], trap_window[11],
2190Sstevel@tonic-gate 	    trap_window[12], trap_window[13], trap_window[14], trap_window[15]);
2200Sstevel@tonic-gate 	printf("i0-i7: %x, %x, %x, %x, %x, %x, %x, %x\n",
2210Sstevel@tonic-gate 	    trap_window[16], trap_window[17], trap_window[18], trap_window[19],
2220Sstevel@tonic-gate 	    trap_window[20], trap_window[21], trap_window[22], trap_window[23]);
2230Sstevel@tonic-gate #endif /* TRAPWINDOW */
2240Sstevel@tonic-gate 	if (tudebug > 1 && (boothowto & RB_DEBUG)) {
2250Sstevel@tonic-gate 		debug_enter((char *)NULL);
2260Sstevel@tonic-gate 	}
2270Sstevel@tonic-gate 	splx(s);
2280Sstevel@tonic-gate }
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate static void
2310Sstevel@tonic-gate ptl1_showtrap(ptl1_state_t *pstate)
2320Sstevel@tonic-gate {
2330Sstevel@tonic-gate 	ptl1_regs_t *rp = &pstate->ptl1_regs;
2340Sstevel@tonic-gate 	short i, j, maxtl = rp->ptl1_trap_regs[0].ptl1_tl;
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate 	printf("%%tl %%tpc              %%tnpc             %%tstate"
2370Sstevel@tonic-gate 	    "           %%tt\n");
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate 	for (i = maxtl - 1; i >= 0; i--) {
2400Sstevel@tonic-gate 		ptl1_trapregs_t *ptp = &rp->ptl1_trap_regs[i];
2410Sstevel@tonic-gate 		uint64_t tstate = ptp->ptl1_tstate;
2420Sstevel@tonic-gate 		uint32_t ccr, asi, cwp, pstate;
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate 		cwp = (tstate >> TSTATE_CWP_SHIFT) & TSTATE_CWP_MASK;
2450Sstevel@tonic-gate 		pstate = (tstate >> TSTATE_PSTATE_SHIFT) & TSTATE_PSTATE_MASK;
2460Sstevel@tonic-gate 		asi = (tstate >> TSTATE_ASI_SHIFT) & TSTATE_ASI_MASK;
2470Sstevel@tonic-gate 		ccr = (tstate >> TSTATE_CCR_SHIFT) & TSTATE_CCR_MASK;
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate 		printf(" %d  %016" PRIx64 "  %016" PRIx64 "  %010" PRIx64
2500Sstevel@tonic-gate 		    "        %03x\n", ptp->ptl1_tl, ptp->ptl1_tpc,
2510Sstevel@tonic-gate 		    ptp->ptl1_tnpc, tstate, ptp->ptl1_tt);
2520Sstevel@tonic-gate 		printf("    %%ccr: %02x  %%asi: %02x  %%cwp: %x  "
2530Sstevel@tonic-gate 		    "%%pstate: %b\n", ccr, asi, cwp, pstate, PSTATE_BITS);
2540Sstevel@tonic-gate 	}
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate 	printf("%%g0-3: %016x %016" PRIx64 " %016" PRIx64 " %016"
2570Sstevel@tonic-gate 	    PRIx64 "\n", 0, rp->ptl1_g1, rp->ptl1_g2, rp->ptl1_g3);
2580Sstevel@tonic-gate 	printf("%%g4-7: %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016"
2590Sstevel@tonic-gate 	    PRIx64 "\n", rp->ptl1_g4, rp->ptl1_g5, rp->ptl1_g6, rp->ptl1_g7);
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate 	i = rp->ptl1_cwp;
2620Sstevel@tonic-gate 	j = rp->ptl1_canrestore;
2630Sstevel@tonic-gate 	for (; j >= 0; i--, j--) {
2640Sstevel@tonic-gate 		struct rwindow *wp;
2650Sstevel@tonic-gate 		ulong_t off;
2660Sstevel@tonic-gate 		char *sym;
2670Sstevel@tonic-gate 
2680Sstevel@tonic-gate 		if (i < 0)
2690Sstevel@tonic-gate 			i += MAXWIN;
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate 		wp = &rp->ptl1_rwindow[i];
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate 		if ((sym = kobj_getsymname(wp->rw_in[7], &off)) != NULL) {
2740Sstevel@tonic-gate 			printf("Register window %d, caller %s+%lx\n",
2750Sstevel@tonic-gate 			    i, sym, off);
2760Sstevel@tonic-gate 		} else {
2770Sstevel@tonic-gate 			printf("Register window %d, caller %lx\n",
2780Sstevel@tonic-gate 			    i, wp->rw_in[7]);
2790Sstevel@tonic-gate 		}
2800Sstevel@tonic-gate 
2810Sstevel@tonic-gate 		if (i == rp->ptl1_cwp) {
2820Sstevel@tonic-gate 			struct rwindow *nwp;
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 			if (i == MAXWIN - 1)
2850Sstevel@tonic-gate 				nwp = &rp->ptl1_rwindow[0];
2860Sstevel@tonic-gate 			else
2870Sstevel@tonic-gate 				nwp = &rp->ptl1_rwindow[i+1];
2880Sstevel@tonic-gate 			printf("%%o0-3: %016lx %016lx %016lx %016lx\n"
2890Sstevel@tonic-gate 			    "%%o4-7: %016lx %016lx %016lx %016lx\n",
2900Sstevel@tonic-gate 			    nwp->rw_in[0], nwp->rw_in[1], nwp->rw_in[2],
2910Sstevel@tonic-gate 			    nwp->rw_in[3], nwp->rw_in[4], nwp->rw_in[5],
2920Sstevel@tonic-gate 			    nwp->rw_in[6], nwp->rw_in[7]);
2930Sstevel@tonic-gate 		}
2940Sstevel@tonic-gate 		printf("%%l0-3: %016lx %016lx %016lx %016lx\n"
2950Sstevel@tonic-gate 		    "%%l4-7: %016lx %016lx %016lx %016lx\n",
2960Sstevel@tonic-gate 		    wp->rw_local[0], wp->rw_local[1], wp->rw_local[2],
2970Sstevel@tonic-gate 		    wp->rw_local[3], wp->rw_local[4], wp->rw_local[5],
2980Sstevel@tonic-gate 		    wp->rw_local[6], wp->rw_local[7]);
2990Sstevel@tonic-gate 
3000Sstevel@tonic-gate 		printf("%%i0-3: %016lx %016lx %016lx %016lx\n"
3010Sstevel@tonic-gate 		    "%%i4-7: %016lx %016lx %016lx %016lx\n",
3020Sstevel@tonic-gate 		    wp->rw_in[0], wp->rw_in[1], wp->rw_in[2], wp->rw_in[3],
3030Sstevel@tonic-gate 		    wp->rw_in[4], wp->rw_in[5], wp->rw_in[6], wp->rw_in[7]);
3040Sstevel@tonic-gate 	}
3050Sstevel@tonic-gate }
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate void
308*5084Sjohnlev panic_showtrap(struct panic_trap_info *tip)
3090Sstevel@tonic-gate {
3100Sstevel@tonic-gate 	ptl1_state_t *pstate = &CPU->cpu_m.ptl1_state;
3110Sstevel@tonic-gate 	/*
3120Sstevel@tonic-gate 	 * If ptl1_panic() was called, print out the information
3130Sstevel@tonic-gate 	 * saved in the ptl1_state struture.
3140Sstevel@tonic-gate 	 */
3150Sstevel@tonic-gate 	if (pstate->ptl1_entry_count) {
3160Sstevel@tonic-gate 		ptl1_showtrap(pstate);
3170Sstevel@tonic-gate 		return;
3180Sstevel@tonic-gate 	}
3190Sstevel@tonic-gate 
3200Sstevel@tonic-gate 	showregs(tip->trap_type, tip->trap_regs, tip->trap_addr,
3210Sstevel@tonic-gate 	    tip->trap_mmu_fsr);
3220Sstevel@tonic-gate }
3230Sstevel@tonic-gate 
3240Sstevel@tonic-gate static void
3250Sstevel@tonic-gate ptl1_savetrap(panic_data_t *pdp, ptl1_state_t *pstate)
3260Sstevel@tonic-gate {
3270Sstevel@tonic-gate 	ptl1_regs_t *rp = &pstate->ptl1_regs;
3280Sstevel@tonic-gate 	short i, maxtl = rp->ptl1_trap_regs[0].ptl1_tl;
3290Sstevel@tonic-gate 	panic_nv_t *pnv = PANICNVGET(pdp);
3300Sstevel@tonic-gate 	char name[PANICNVNAMELEN];
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 	for (i = maxtl - 1; i >= 0; i--) {
3330Sstevel@tonic-gate 		ptl1_trapregs_t *ptp = &rp->ptl1_trap_regs[i];
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tl[%d]", i);
3360Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tl);
3370Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tt[%d]", i);
3380Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tt);
3390Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tpc[%d]", i);
3400Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tpc);
3410Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tnpc[%d]", i);
3420Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tnpc);
3430Sstevel@tonic-gate 		(void) snprintf(name, sizeof (name), "tstate[%d]", i);
3440Sstevel@tonic-gate 		PANICNVADD(pnv, name, ptp->ptl1_tstate);
3450Sstevel@tonic-gate 	}
3460Sstevel@tonic-gate 
3470Sstevel@tonic-gate 	PANICNVSET(pdp, pnv);
3480Sstevel@tonic-gate }
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate void
351*5084Sjohnlev panic_savetrap(panic_data_t *pdp, struct panic_trap_info *tip)
3520Sstevel@tonic-gate {
3530Sstevel@tonic-gate 	panic_nv_t *pnv;
3540Sstevel@tonic-gate 	ptl1_state_t *pstate = &CPU->cpu_m.ptl1_state;
3550Sstevel@tonic-gate 	/*
3560Sstevel@tonic-gate 	 * If ptl1_panic() was called, save the trap registers
3570Sstevel@tonic-gate 	 * stored in the ptl1_state struture.
3580Sstevel@tonic-gate 	 */
3590Sstevel@tonic-gate 	if (pstate->ptl1_entry_count) {
3600Sstevel@tonic-gate 		ptl1_savetrap(pdp, pstate);
3610Sstevel@tonic-gate 		return;
3620Sstevel@tonic-gate 	}
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate 	panic_saveregs(pdp, tip->trap_regs);
3650Sstevel@tonic-gate 	pnv = PANICNVGET(pdp);
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate 	PANICNVADD(pnv, "sfsr", tip->trap_mmu_fsr);
3680Sstevel@tonic-gate 	PANICNVADD(pnv, "sfar", tip->trap_addr);
3690Sstevel@tonic-gate 	PANICNVADD(pnv, "tt", tip->trap_type);
3700Sstevel@tonic-gate 
3710Sstevel@tonic-gate 	PANICNVSET(pdp, pnv);
3720Sstevel@tonic-gate }
373