kvm_amd64dep.c revision ae115bc77f6fcde83175c75b4206dc2e50747966
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Libkvm Kernel Target Intel 64-bit component
*
* This file provides the ISA-dependent portion of the libkvm kernel target.
* For more details on the implementation refer to mdb_kvm.c.
*/
#include <sys/sysmacros.h>
#include <sys/privregs.h>
#include <strings.h>
#include <mdb/mdb_target_impl.h>
#include <mdb/mdb_disasm.h>
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_conf.h>
#include <mdb/mdb_kreg_impl.h>
#include <mdb/mdb_amd64util.h>
#include <mdb/mdb_debug.h>
static int
{
const mdb_tgt_regdesc_t *rdp;
return (set_errno(EMDB_NOREGS));
return (0);
}
}
return (set_errno(EMDB_BADREG));
}
static int
{
const mdb_tgt_regdesc_t *rdp;
return (set_errno(EMDB_NOREGS));
return (0);
}
}
return (set_errno(EMDB_BADREG));
}
/*ARGSUSED*/
int
{
return (DCMD_USAGE);
return (DCMD_OK);
}
/*
* Return a flag indicating if the specified %eip is likely to have an
* interrupt frame on the stack. We do this by comparing the address to the
* range of addresses spanned by several well-known routines, and looking
* to see if the next and previous %ebp values are "far" apart. Sigh.
*/
int
{
}
static int
{
if (flags & DCMD_ADDRSPEC) {
} else
if (argc != 0) {
return (DCMD_USAGE);
else
}
return (DCMD_OK);
}
static int
{
}
static int
{
}
const mdb_tgt_ops_t kt_amd64_ops = {
kt_setflags, /* t_setflags */
kt_setcontext, /* t_setcontext */
kt_activate, /* t_activate */
kt_deactivate, /* t_deactivate */
(void (*)()) mdb_tgt_nop, /* t_periodic */
kt_destroy, /* t_destroy */
kt_name, /* t_name */
(const char *(*)()) mdb_conf_isa, /* t_isa */
kt_platform, /* t_platform */
kt_uname, /* t_uname */
kt_dmodel, /* t_dmodel */
kt_aread, /* t_aread */
kt_awrite, /* t_awrite */
kt_vread, /* t_vread */
kt_vwrite, /* t_vwrite */
kt_pread, /* t_pread */
kt_pwrite, /* t_pwrite */
kt_fread, /* t_fread */
kt_fwrite, /* t_fwrite */
kt_vtop, /* t_vtop */
kt_lookup_by_name, /* t_lookup_by_name */
kt_lookup_by_addr, /* t_lookup_by_addr */
kt_symbol_iter, /* t_symbol_iter */
kt_mapping_iter, /* t_mapping_iter */
kt_object_iter, /* t_object_iter */
kt_addr_to_map, /* t_addr_to_map */
kt_name_to_map, /* t_name_to_map */
kt_addr_to_ctf, /* t_addr_to_ctf */
kt_name_to_ctf, /* t_name_to_ctf */
kt_status, /* t_status */
(int (*)()) mdb_tgt_notsup, /* t_run */
(int (*)()) mdb_tgt_notsup, /* t_step */
(int (*)()) mdb_tgt_notsup, /* t_step_out */
(int (*)()) mdb_tgt_notsup, /* t_step_branch */
(int (*)()) mdb_tgt_notsup, /* t_next */
(int (*)()) mdb_tgt_notsup, /* t_cont */
(int (*)()) mdb_tgt_notsup, /* t_signal */
(int (*)()) mdb_tgt_null, /* t_add_vbrkpt */
(int (*)()) mdb_tgt_null, /* t_add_sbrkpt */
(int (*)()) mdb_tgt_null, /* t_add_pwapt */
(int (*)()) mdb_tgt_null, /* t_add_vwapt */
(int (*)()) mdb_tgt_null, /* t_add_iowapt */
(int (*)()) mdb_tgt_null, /* t_add_sysenter */
(int (*)()) mdb_tgt_null, /* t_add_sysexit */
(int (*)()) mdb_tgt_null, /* t_add_signal */
(int (*)()) mdb_tgt_null, /* t_add_fault */
kt_getareg, /* t_getareg */
kt_putareg, /* t_putareg */
mdb_amd64_kvm_stack_iter, /* t_stack_iter */
};
void
{
/*
* Initialize the machine-dependent parts of the kernel target
* structure. Once this is complete and we fill in the ops
* vector, the target is now fully constructed and we can use
* the target API itself to perform the rest of our initialization.
*/
t->t_ops = &kt_amd64_ops;
(void) mdb_dis_select("amd64");
/*
* Lookup the symbols corresponding to subroutines in locore.s where
* we expect a saved regs structure to be pushed on the stack. When
* performing stack tracebacks we will attempt to detect interrupt
* frames by comparing the %eip value to these symbols.
*/
(void) mdb_tgt_lookup_by_name(t, MDB_TGT_OBJ_EXEC,
(void) mdb_tgt_lookup_by_name(t, MDB_TGT_OBJ_EXEC,
/*
* Don't attempt to load any thread or register information if
* we're examining the live operating system.
*/
return;
/*
* If the panicbuf symbol is present and we can consume a panicbuf
* header of the appropriate version from this address, then we can
* initialize our current register set based on its contents.
* Prior to the re-structuring of panicbuf, our only register data
* was the panic_regs label_t, into which a setjmp() was performed,
* or the panic_reg register pointer, which was only non-zero if
* the system panicked as a result of a trap calling die().
*/
uint_t i, n;
MDB_TGT_OBJ_EXEC, "panicbuf");
n = (pd_size - (sizeof (panic_data_t) -
sizeof (panic_nv_t))) / sizeof (panic_nv_t);
for (i = 0; i < n; i++) {
}
} else {
warn("failed to read panicbuf and panic_reg -- "
"current register set will be unavailable\n");
}
}