17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5843e1988Sjohnlev  * Common Development and Distribution License (the "License").
6843e1988Sjohnlev  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227b9b3bf3Sedp  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
24399ca3a7SJohn Levon  *
25399ca3a7SJohn Levon  * Copyright 2018 Joyent, Inc.
26*a48fdbefSBryan Cantrill  * Copyright 2024 Oxide Computer Company
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Libkvm Kernel Target Intel 32-bit component
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  * This file provides the ISA-dependent portion of the libkvm kernel target.
337c478bd9Sstevel@tonic-gate  * For more details on the implementation refer to mdb_kvm.c.
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <sys/regset.h>
387c478bd9Sstevel@tonic-gate #include <sys/frame.h>
397c478bd9Sstevel@tonic-gate #include <sys/stack.h>
407c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
417c478bd9Sstevel@tonic-gate #include <sys/panic.h>
427c478bd9Sstevel@tonic-gate #include <strings.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #include <mdb/mdb_target_impl.h>
457c478bd9Sstevel@tonic-gate #include <mdb/mdb_disasm.h>
467c478bd9Sstevel@tonic-gate #include <mdb/mdb_modapi.h>
477c478bd9Sstevel@tonic-gate #include <mdb/mdb_conf.h>
487c478bd9Sstevel@tonic-gate #include <mdb/mdb_kreg_impl.h>
499c3024a3SHans Rosenfeld #include <mdb/mdb_isautil.h>
507c478bd9Sstevel@tonic-gate #include <mdb/mdb_ia32util.h>
51843e1988Sjohnlev #include <mdb/kvm_isadep.h>
527c478bd9Sstevel@tonic-gate #include <mdb/mdb_kvm.h>
537c478bd9Sstevel@tonic-gate #include <mdb/mdb_err.h>
547c478bd9Sstevel@tonic-gate #include <mdb/mdb_debug.h>
557c478bd9Sstevel@tonic-gate #include <mdb/mdb.h>
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*ARGSUSED*/
597c478bd9Sstevel@tonic-gate int
607c478bd9Sstevel@tonic-gate kt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
617c478bd9Sstevel@tonic-gate {
62843e1988Sjohnlev 	mdb_ia32_printregs((const mdb_tgt_gregset_t *)addr);
637c478bd9Sstevel@tonic-gate 	return (DCMD_OK);
647c478bd9Sstevel@tonic-gate }
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate static int
677c478bd9Sstevel@tonic-gate kt_stack_common(uintptr_t addr, uint_t flags, int argc,
687c478bd9Sstevel@tonic-gate     const mdb_arg_t *argv, mdb_tgt_stack_f *func)
697c478bd9Sstevel@tonic-gate {
707c478bd9Sstevel@tonic-gate 	kt_data_t *kt = mdb.m_target->t_data;
717c478bd9Sstevel@tonic-gate 	void *arg = (void *)mdb.m_nargs;
727c478bd9Sstevel@tonic-gate 	mdb_tgt_gregset_t gregs, *grp;
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate 	if (flags & DCMD_ADDRSPEC) {
757c478bd9Sstevel@tonic-gate 		bzero(&gregs, sizeof (gregs));
767c478bd9Sstevel@tonic-gate 		gregs.kregs[KREG_EBP] = addr;
777c478bd9Sstevel@tonic-gate 		grp = &gregs;
787c478bd9Sstevel@tonic-gate 	} else
797c478bd9Sstevel@tonic-gate 		grp = kt->k_regs;
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	if (argc != 0) {
827c478bd9Sstevel@tonic-gate 		if (argv->a_type == MDB_TYPE_CHAR || argc > 1)
837c478bd9Sstevel@tonic-gate 			return (DCMD_USAGE);
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 		if (argv->a_type == MDB_TYPE_STRING)
867c478bd9Sstevel@tonic-gate 			arg = (void *)(uint_t)mdb_strtoull(argv->a_un.a_str);
877c478bd9Sstevel@tonic-gate 		else
887c478bd9Sstevel@tonic-gate 			arg = (void *)(uint_t)argv->a_un.a_val;
897c478bd9Sstevel@tonic-gate 	}
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 	(void) mdb_ia32_kvm_stack_iter(mdb.m_target, grp, func, arg);
927c478bd9Sstevel@tonic-gate 	return (DCMD_OK);
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate 
95843e1988Sjohnlev int
967c478bd9Sstevel@tonic-gate kt_stack(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
977c478bd9Sstevel@tonic-gate {
987c478bd9Sstevel@tonic-gate 	return (kt_stack_common(addr, flags, argc, argv, mdb_ia32_kvm_frame));
997c478bd9Sstevel@tonic-gate }
1007c478bd9Sstevel@tonic-gate 
101843e1988Sjohnlev int
1027c478bd9Sstevel@tonic-gate kt_stackv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1037c478bd9Sstevel@tonic-gate {
1047c478bd9Sstevel@tonic-gate 	return (kt_stack_common(addr, flags, argc, argv, mdb_ia32_kvm_framev));
1057c478bd9Sstevel@tonic-gate }
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate const mdb_tgt_ops_t kt_ia32_ops = {
1087c478bd9Sstevel@tonic-gate 	kt_setflags,				/* t_setflags */
1097c478bd9Sstevel@tonic-gate 	kt_setcontext,				/* t_setcontext */
1107c478bd9Sstevel@tonic-gate 	kt_activate,				/* t_activate */
1117c478bd9Sstevel@tonic-gate 	kt_deactivate,				/* t_deactivate */
1122c687d68SToomas Soome 	(void (*)())(uintptr_t)mdb_tgt_nop,	/* t_periodic */
1137c478bd9Sstevel@tonic-gate 	kt_destroy,				/* t_destroy */
1147c478bd9Sstevel@tonic-gate 	kt_name,				/* t_name */
1157c478bd9Sstevel@tonic-gate 	(const char *(*)())mdb_conf_isa,	/* t_isa */
1167c478bd9Sstevel@tonic-gate 	kt_platform,				/* t_platform */
1177c478bd9Sstevel@tonic-gate 	kt_uname,				/* t_uname */
1187c478bd9Sstevel@tonic-gate 	kt_dmodel,				/* t_dmodel */
1197c478bd9Sstevel@tonic-gate 	kt_aread,				/* t_aread */
1207c478bd9Sstevel@tonic-gate 	kt_awrite,				/* t_awrite */
1217c478bd9Sstevel@tonic-gate 	kt_vread,				/* t_vread */
1227c478bd9Sstevel@tonic-gate 	kt_vwrite,				/* t_vwrite */
1237c478bd9Sstevel@tonic-gate 	kt_pread,				/* t_pread */
1247c478bd9Sstevel@tonic-gate 	kt_pwrite,				/* t_pwrite */
1257c478bd9Sstevel@tonic-gate 	kt_fread,				/* t_fread */
1267c478bd9Sstevel@tonic-gate 	kt_fwrite,				/* t_fwrite */
1277c478bd9Sstevel@tonic-gate 	(ssize_t (*)())mdb_tgt_notsup,		/* t_ioread */
1287c478bd9Sstevel@tonic-gate 	(ssize_t (*)())mdb_tgt_notsup,		/* t_iowrite */
1297c478bd9Sstevel@tonic-gate 	kt_vtop,				/* t_vtop */
1307c478bd9Sstevel@tonic-gate 	kt_lookup_by_name,			/* t_lookup_by_name */
1317c478bd9Sstevel@tonic-gate 	kt_lookup_by_addr,			/* t_lookup_by_addr */
1327c478bd9Sstevel@tonic-gate 	kt_symbol_iter,				/* t_symbol_iter */
1337c478bd9Sstevel@tonic-gate 	kt_mapping_iter,			/* t_mapping_iter */
1347c478bd9Sstevel@tonic-gate 	kt_object_iter,				/* t_object_iter */
1357c478bd9Sstevel@tonic-gate 	kt_addr_to_map,				/* t_addr_to_map */
1367c478bd9Sstevel@tonic-gate 	kt_name_to_map,				/* t_name_to_map */
1377c478bd9Sstevel@tonic-gate 	kt_addr_to_ctf,				/* t_addr_to_ctf */
1387c478bd9Sstevel@tonic-gate 	kt_name_to_ctf,				/* t_name_to_ctf */
1397c478bd9Sstevel@tonic-gate 	kt_status,				/* t_status */
1407c478bd9Sstevel@tonic-gate 	(int (*)())mdb_tgt_notsup,		/* t_run */
1417c478bd9Sstevel@tonic-gate 	(int (*)())mdb_tgt_notsup,		/* t_step */
1427c478bd9Sstevel@tonic-gate 	(int (*)())mdb_tgt_notsup,		/* t_step_out */
1437c478bd9Sstevel@tonic-gate 	(int (*)())mdb_tgt_notsup,		/* t_next */
1447c478bd9Sstevel@tonic-gate 	(int (*)())mdb_tgt_notsup,		/* t_cont */
1457c478bd9Sstevel@tonic-gate 	(int (*)())mdb_tgt_notsup,		/* t_signal */
1462c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_vbrkpt */
1472c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_sbrkpt */
1482c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_pwapt */
1492c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_vwapt */
1502c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_iowapt */
1512c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_sysenter */
1522c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_sysexit */
1532c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_signal */
1542c687d68SToomas Soome 	(int (*)())(uintptr_t)mdb_tgt_null,	/* t_add_fault */
1557c478bd9Sstevel@tonic-gate 	kt_getareg,				/* t_getareg */
1567c478bd9Sstevel@tonic-gate 	kt_putareg,				/* t_putareg */
1577c478bd9Sstevel@tonic-gate 	mdb_ia32_kvm_stack_iter,		/* t_stack_iter */
158*a48fdbefSBryan Cantrill 	(int (*)())mdb_tgt_notsup,		/* t_auxv */
159*a48fdbefSBryan Cantrill 	(int (*)())(uintptr_t)mdb_tgt_notsup	/* t_thread_name */
1607c478bd9Sstevel@tonic-gate };
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate void
163843e1988Sjohnlev kt_regs_to_kregs(struct regs *regs, mdb_tgt_gregset_t *gregs)
164843e1988Sjohnlev {
165843e1988Sjohnlev 	gregs->kregs[KREG_SAVFP] = regs->r_savfp;
166843e1988Sjohnlev 	gregs->kregs[KREG_SAVPC] = regs->r_savpc;
167843e1988Sjohnlev 	gregs->kregs[KREG_EAX] = regs->r_eax;
168843e1988Sjohnlev 	gregs->kregs[KREG_EBX] = regs->r_ebx;
169843e1988Sjohnlev 	gregs->kregs[KREG_ECX] = regs->r_ecx;
170843e1988Sjohnlev 	gregs->kregs[KREG_EDX] = regs->r_edx;
171843e1988Sjohnlev 	gregs->kregs[KREG_ESI] = regs->r_esi;
172843e1988Sjohnlev 	gregs->kregs[KREG_EDI] = regs->r_edi;
173843e1988Sjohnlev 	gregs->kregs[KREG_EBP] = regs->r_ebp;
174843e1988Sjohnlev 	gregs->kregs[KREG_ESP] = regs->r_esp;
175843e1988Sjohnlev 	gregs->kregs[KREG_CS] = regs->r_cs;
176843e1988Sjohnlev 	gregs->kregs[KREG_DS] = regs->r_ds;
177843e1988Sjohnlev 	gregs->kregs[KREG_SS] = regs->r_ss;
178843e1988Sjohnlev 	gregs->kregs[KREG_ES] = regs->r_es;
179843e1988Sjohnlev 	gregs->kregs[KREG_FS] = regs->r_fs;
180843e1988Sjohnlev 	gregs->kregs[KREG_GS] = regs->r_gs;
181843e1988Sjohnlev 	gregs->kregs[KREG_EFLAGS] = regs->r_efl;
182843e1988Sjohnlev 	gregs->kregs[KREG_EIP] = regs->r_eip;
183843e1988Sjohnlev 	gregs->kregs[KREG_UESP] = regs->r_uesp;
184843e1988Sjohnlev 	gregs->kregs[KREG_TRAPNO] = regs->r_trapno;
185843e1988Sjohnlev 	gregs->kregs[KREG_ERR] = regs->r_err;
186843e1988Sjohnlev }
187843e1988Sjohnlev 
188843e1988Sjohnlev void
1897c478bd9Sstevel@tonic-gate kt_ia32_init(mdb_tgt_t *t)
1907c478bd9Sstevel@tonic-gate {
1917c478bd9Sstevel@tonic-gate 	kt_data_t *kt = t->t_data;
1927c478bd9Sstevel@tonic-gate 	panic_data_t pd;
1937c478bd9Sstevel@tonic-gate 	label_t label;
1947c478bd9Sstevel@tonic-gate 	struct regs regs;
195843e1988Sjohnlev 	kreg_t *kregs;
1967c478bd9Sstevel@tonic-gate 	uintptr_t addr;
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate 	/*
1997c478bd9Sstevel@tonic-gate 	 * Initialize the machine-dependent parts of the kernel target
2007c478bd9Sstevel@tonic-gate 	 * structure.  Once this is complete and we fill in the ops
2017c478bd9Sstevel@tonic-gate 	 * vector, the target is now fully constructed and we can use
2027c478bd9Sstevel@tonic-gate 	 * the target API itself to perform the rest of our initialization.
2037c478bd9Sstevel@tonic-gate 	 */
2047c478bd9Sstevel@tonic-gate 	kt->k_rds = mdb_ia32_kregs;
2057c478bd9Sstevel@tonic-gate 	kt->k_regs = mdb_zalloc(sizeof (mdb_tgt_gregset_t), UM_SLEEP);
2067c478bd9Sstevel@tonic-gate 	kt->k_regsize = sizeof (mdb_tgt_gregset_t);
2077c478bd9Sstevel@tonic-gate 	kt->k_dcmd_regs = kt_regs;
2087c478bd9Sstevel@tonic-gate 	kt->k_dcmd_stack = kt_stack;
2097c478bd9Sstevel@tonic-gate 	kt->k_dcmd_stackv = kt_stackv;
2107c478bd9Sstevel@tonic-gate 	kt->k_dcmd_stackr = kt_stackv;
211843e1988Sjohnlev 	kt->k_dcmd_cpustack = kt_cpustack;
212843e1988Sjohnlev 	kt->k_dcmd_cpuregs = kt_cpuregs;
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate 	t->t_ops = &kt_ia32_ops;
2157c478bd9Sstevel@tonic-gate 	kregs = kt->k_regs->kregs;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 	(void) mdb_dis_select("ia32");
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate 	/*
2207c478bd9Sstevel@tonic-gate 	 * Lookup the symbols corresponding to subroutines in locore.s where
2217c478bd9Sstevel@tonic-gate 	 * we expect a saved regs structure to be pushed on the stack.  When
2227c478bd9Sstevel@tonic-gate 	 * performing stack tracebacks we will attempt to detect interrupt
2237c478bd9Sstevel@tonic-gate 	 * frames by comparing the %eip value to these symbols.
2247c478bd9Sstevel@tonic-gate 	 */
2257c478bd9Sstevel@tonic-gate 	(void) mdb_tgt_lookup_by_name(t, MDB_TGT_OBJ_EXEC,
2267c478bd9Sstevel@tonic-gate 	    "cmnint", &kt->k_intr_sym, NULL);
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 	(void) mdb_tgt_lookup_by_name(t, MDB_TGT_OBJ_EXEC,
2297c478bd9Sstevel@tonic-gate 	    "cmntrap", &kt->k_trap_sym, NULL);
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate 	/*
2327c478bd9Sstevel@tonic-gate 	 * Don't attempt to load any thread or register information if
2337c478bd9Sstevel@tonic-gate 	 * we're examining the live operating system.
2347c478bd9Sstevel@tonic-gate 	 */
235843e1988Sjohnlev 	if (kt->k_symfile != NULL && strcmp(kt->k_symfile, "/dev/ksyms") == 0)
2367c478bd9Sstevel@tonic-gate 		return;
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate 	/*
2397c478bd9Sstevel@tonic-gate 	 * If the panicbuf symbol is present and we can consume a panicbuf
2407c478bd9Sstevel@tonic-gate 	 * header of the appropriate version from this address, then we can
2417c478bd9Sstevel@tonic-gate 	 * initialize our current register set based on its contents.
2427c478bd9Sstevel@tonic-gate 	 * Prior to the re-structuring of panicbuf, our only register data
2437c478bd9Sstevel@tonic-gate 	 * was the panic_regs label_t, into which a setjmp() was performed,
2447c478bd9Sstevel@tonic-gate 	 * or the panic_reg register pointer, which was only non-zero if
2457c478bd9Sstevel@tonic-gate 	 * the system panicked as a result of a trap calling die().
2467c478bd9Sstevel@tonic-gate 	 */
2477c478bd9Sstevel@tonic-gate 	if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &pd, sizeof (pd),
2487c478bd9Sstevel@tonic-gate 	    MDB_TGT_OBJ_EXEC, "panicbuf") == sizeof (pd) &&
2497c478bd9Sstevel@tonic-gate 	    pd.pd_version == PANICBUFVERS) {
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate 		size_t pd_size = MIN(PANICBUFSIZE, pd.pd_msgoff);
2527c478bd9Sstevel@tonic-gate 		panic_data_t *pdp = mdb_zalloc(pd_size, UM_SLEEP);
2537c478bd9Sstevel@tonic-gate 		uint_t i, n;
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate 		(void) mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, pdp, pd_size,
2567c478bd9Sstevel@tonic-gate 		    MDB_TGT_OBJ_EXEC, "panicbuf");
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate 		n = (pd_size - (sizeof (panic_data_t) -
2597c478bd9Sstevel@tonic-gate 		    sizeof (panic_nv_t))) / sizeof (panic_nv_t);
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 		for (i = 0; i < n; i++) {
2627c478bd9Sstevel@tonic-gate 			(void) kt_putareg(t, kt->k_tid,
2637c478bd9Sstevel@tonic-gate 			    pdp->pd_nvdata[i].pnv_name,
2647c478bd9Sstevel@tonic-gate 			    pdp->pd_nvdata[i].pnv_value);
2657c478bd9Sstevel@tonic-gate 		}
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate 		mdb_free(pdp, pd_size);
2687c478bd9Sstevel@tonic-gate 
269843e1988Sjohnlev 		return;
270843e1988Sjohnlev 	}
271843e1988Sjohnlev 
272843e1988Sjohnlev 	if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &addr, sizeof (addr),
273892ad162SToomas Soome 	    MDB_TGT_OBJ_EXEC, "panic_reg") == sizeof (addr) && addr != 0 &&
2747c478bd9Sstevel@tonic-gate 	    mdb_tgt_vread(t, &regs, sizeof (regs), addr) == sizeof (regs)) {
275843e1988Sjohnlev 		kt_regs_to_kregs(&regs, kt->k_regs);
276843e1988Sjohnlev 		return;
277843e1988Sjohnlev 	}
2787c478bd9Sstevel@tonic-gate 
279843e1988Sjohnlev 	/*
280843e1988Sjohnlev 	 * If we can't read any panic regs, then our penultimate try is for any
281843e1988Sjohnlev 	 * CPU context that may have been stored (for example, in Xen core
282843e1988Sjohnlev 	 * dumps).  As this can only succeed for kernels with the above
283843e1988Sjohnlev 	 * methods available, we let it over-ride the older panic_regs method,
284843e1988Sjohnlev 	 * which will always manage to read the label_t, even if there's
285843e1988Sjohnlev 	 * nothing useful there.
286843e1988Sjohnlev 	 */
287843e1988Sjohnlev 	if (kt_kvmregs(t, 0, kt->k_regs) == 0)
288843e1988Sjohnlev 		return;
2897c478bd9Sstevel@tonic-gate 
290843e1988Sjohnlev 	if (mdb_tgt_readsym(t, MDB_TGT_AS_VIRT, &label, sizeof (label),
2917c478bd9Sstevel@tonic-gate 	    MDB_TGT_OBJ_EXEC, "panic_regs") == sizeof (label)) {
2927c478bd9Sstevel@tonic-gate 		kregs[KREG_EDI] = label.val[0];
2937c478bd9Sstevel@tonic-gate 		kregs[KREG_ESI] = label.val[1];
2947c478bd9Sstevel@tonic-gate 		kregs[KREG_EBX] = label.val[2];
2957c478bd9Sstevel@tonic-gate 		kregs[KREG_EBP] = label.val[3];
2967c478bd9Sstevel@tonic-gate 		kregs[KREG_ESP] = label.val[4];
2977c478bd9Sstevel@tonic-gate 		kregs[KREG_EIP] = label.val[5];
298843e1988Sjohnlev 		return;
299843e1988Sjohnlev 	}
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 	warn("failed to read panicbuf, panic_reg and panic_regs -- "
3027c478bd9Sstevel@tonic-gate 	    "current register set will be unavailable\n");
3037c478bd9Sstevel@tonic-gate }
304