/*
* 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"
/*
* HAT interfaces used by the kernel debugger to interact with the VM system.
* These interfaces are invoked when the world is stopped. As such, no blocking
* operations may be performed.
*/
#include <sys/kdi_impl.h>
#include <sys/sysmacros.h>
#include <sys/bootconf.h>
#include <vm/seg_kmem.h>
#if defined(__xpv)
#include <sys/hypervisor.h>
#endif
#include <sys/bootinfo.h>
#include <vm/kboot_mmu.h>
#include <sys/machsystm.h>
/*
* The debugger needs direct access to the PTE of one page table entry
*/
#if !defined(__xpv)
#endif
/*
* Get the address for remapping physical pages during boot
*/
void
hat_boot_kdi_init(void)
{
}
/*
* Switch to using a page in the kernel's va range for physical memory access.
* We need to allocate a virtual page, then permanently map in the page that
* contains the PTE to it.
*/
void
hat_kdi_init(void)
{
/*LINTED:set but not used in function*/
/*
* Get an kernel page VA to use for phys mem access. Then make sure
* the VA has a page table.
*/
use_kbm = 0;
#ifndef __xpv
/*
* Get an address at which to put the pagetable and devload it.
*/
#endif
}
#ifdef __xpv
/*
* translate machine address to physical address
*/
static uint64_t
{
}
/*
* This is like mfn_to_pfn(), but we can't use ontrap() from kmdb.
* Instead we let the fault happen and kmdb deals with it.
*/
static uint64_t
{
return (ma | PFN_IS_FOREIGN_MFN);
return (ma | PFN_IS_FOREIGN_MFN);
}
#else
#define kdi_mtop(m) (m)
#define kdi_ptom(p) (p)
#endif
/*ARGSUSED*/
int
{
int level;
int index;
/*
* if the mmu struct isn't relevant yet, we need to probe
* the boot loader's pagetables.
*/
if (!khat_running) {
return (ENOENT);
return (ENOENT);
return (0);
}
/*
* We can't go through normal hat routines, so we'll use
* kdi_pread() to walk the page tables
*/
#if defined(__xpv)
#else
#endif
pte = 0;
return (ENOENT);
if (pte == 0)
return (ENOENT);
(pte & PT_PAGESIZE)) {
break;
} else {
if (level == 0)
break;
}
}
return (0);
}
static int
{
/*
* if this is called before any initialization - fail
*/
if (hat_kdi_page == 0)
return (EAGAIN);
while (nbytes > 0) {
/*
* figure out the addresses and construct a minimal PTE
*/
if (doread) {
} else {
}
/*
* map the physical page
*/
if (use_kbm)
#if defined(__xpv)
else
(void) HYPERVISOR_update_va_mapping(
#else
else if (hat_kdi_use_pae)
*hat_kdi_pte = pte;
else
#endif
/*
* erase the mapping
*/
if (use_kbm)
kbm_pop();
#if defined(__xpv)
else
(void) HYPERVISOR_update_va_mapping(
#else
else if (hat_kdi_use_pae)
*hat_kdi_pte = 0;
else
*(x86pte32_t *)hat_kdi_pte = 0;
#endif
}
if (ncopied == 0)
return (ENOENT);
return (0);
}
int
{
}
int
{
}
/*
* Return the number of bytes, relative to the beginning of a given range, that
* are non-toxic (can be read from and written to with relative impunity).
*/
/*ARGSUSED*/
{
#if defined(__amd64)
extern uintptr_t toxic_addr;
extern size_t toxic_size;
/*
* Check 64 bit toxic range.
*/
if (toxic_addr != 0 &&
/*
* avoid any Virtual Address hole
*/
return (sz);
uintptr_t v;
if (v == 0)
return (sz);
else if (v <= va)
return (0);
else
return (v - va);
#endif /* __i386 */
}