mach_sfmmu.c revision 7dacfc4494f6d14358974ef2830b5cd8c66a84de
/*
* 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"
#include <vm/hat_sfmmu.h>
#include <sys/sysmacros.h>
#include <sys/machparam.h>
#include <sys/archsystm.h>
#include <sys/machsystm.h>
#include <sys/vm_machparam.h>
#include <sys/prom_isa.h>
#include <sys/prom_plat.h>
#include <sys/prom_debug.h>
#include <sys/privregs.h>
#include <sys/bootconf.h>
#include <sys/memlist_plat.h>
#include <sys/cpu_module.h>
#include <sys/hypervisor_api.h>
/*
* External routines and data structures
*/
extern void sfmmu_cache_flushcolor(int, pfn_t);
extern uint_t mmu_page_sizes;
/*
* Static routines
*/
static void sfmmu_set_tlb(void);
/*
* Global Data:
*/
int enable_bigktsb = 1;
int shtsb4m_first = 0;
int bigktsb_nttes = 0;
/*
* Controls the logic which enables the use of the
* QUAD_LDD_PHYS ASI for TSB accesses.
*/
int ktsb_phys = 1;
#ifdef SET_MMU_STATS
#endif /* SET_MMU_STATS */
#ifdef DEBUG
/*
* The following two variables control if the hypervisor/hardware will
* be used to do the TSB table walk for kernel and user contexts.
*/
int hv_use_0_tsb = 1;
int hv_use_non0_tsb = 1;
#endif /* DEBUG */
static void
{
extern caddr_t mmu_fault_status_area;
mmfsa_va =
}
void
{
#ifdef DEBUG
if (hv_use_0_tsb == 0)
return;
#endif /* DEBUG */
prom_printf("cpu%d: hv_set_ctx0() returned %lx\n",
getprocessorid(), rv);
#ifdef SET_MMU_STATS
sizeof (mmu_stat_area[0]));
prom_printf("cpu%d: hv_mmu_set_stat_area() returned %lx\n",
getprocessorid(), rv);
#endif /* SET_MMU_STATS */
}
/*
* This routine remaps the kernel using large ttes
* All entries except locked ones will be removed from the tlb.
* It assumes that both the text and data segments reside in a separate
* 4mb virtual and physical contigous memory chunk. This routine
* is only executed by the first cpu. The remaining cpus execute
* sfmmu_mp_startup() instead.
* XXX It assumes that the start of the text segment is KERNELBASE. It should
* actually be based on start.
*/
void
sfmmu_remap_kernel(void)
{
int flags;
extern char end[];
if (pfn == PFN_INVALID)
prom_panic("can't find kernel text pfn");
/*
* We set the lock bit in the tte to lock the translation in
* the tlb.
*/
if (pfn == PFN_INVALID)
prom_panic("can't find kernel data pfn");
/*
* We set the lock bit in the tte to lock the translation in
* the tlb. We also set the mod bit to avoid taking dirty bit
* traps on kernel data.
*/
/*
* create bigktsb ttes if necessary.
*/
if (enable_bigktsb) {
int i = 0;
while (tsbsz != 0) {
ASSERT(i < MAX_BIGKTSB_TTES);
/*
* No need to lock if we use physical addresses.
* Since we invalidate the kernel TSB using virtual
* addresses, it's an optimization to load them now
* so that we won't have to load them later.
*/
if (!ktsb_phys) {
}
bigktsb_ttes[i] = tte;
va += MMU_PAGESIZE4M;
tsbsz -= MMU_PAGESIZE4M;
i++;
}
bigktsb_nttes = i;
}
}
/*
* Setup the kernel's locked tte's
*/
void
sfmmu_set_tlb(void)
{
MAP_DTLB);
if (!ktsb_phys && enable_bigktsb) {
int i;
for (i = 0; i < bigktsb_nttes; i++) {
MAP_DTLB);
va += MMU_PAGESIZE4M;
}
}
}
/*
* This routine is executed by all other cpus except the first one
* at initialization time. It is responsible for taking over the
* mmu from the prom. We follow these steps.
* Lock the kernel's ttes in the TLB
* Initialize the tsb hardware registers
* Take over the trap table
* Flush the prom's locked entries from the TLB
*/
void
sfmmu_mp_startup(void)
{
/*
* sfmmu_set_fault_status_area() takes over trap_table
*/
}
void
{
"va=0x%p, hv error code 0x%lx",
}
}
void
{
}
/*
* Clear machine specific TSB information for a user process
*/
void
{
(void) hv_set_ctxnon0(0, NULL);
}
/*
* The tsbord[] array is set up to translate from the order of tsbs in the sfmmu
* list to the order of tsbs in the tsb descriptor array passed to the hv, which
* is the search order used during Hardware Table Walk.
* So, the tsb with index i in the sfmmu list will have search order tsbord[i].
*
* The order of tsbs in the sfmmu list will be as follows:
*
* 0 8K - 512K private TSB
* 1 4M - 256M private TSB
* 2 8K - 512K shared TSB
* 3 4M - 256M shared TSB
*
* Shared TSBs are only used if a process is part of an SCD.
*
* So, e.g. tsbord[3] = 1;
* corresponds to searching the shared 4M TSB second.
*
* The search order is selected so that the 8K-512K private TSB is always first.
* Currently shared context is not expected to map many 8K-512K pages that cause
* TLB misses so we order the shared TSB for 4M-256M pages in front of the
* shared TSB for 8K-512K pages. We also expect more TLB misses against private
* context mappings than shared context mappings and place private TSBs ahead of
* be used to change the default ordering of private and shared TSBs for
* 4M-256M pages.
*/
void
{
int i;
int j;
int scd = 0;
int tsbord[NHV_TSB_INFO];
#ifdef DEBUG
ASSERT(max_mmu_ctxdoms > 0);
/* Process should have INVALID_CONTEXT on all MMUs. */
for (i = 0; i < max_mmu_ctxdoms; i++) {
}
}
#endif
return;
}
tsbord[0] = 0;
} else {
ulong_t shared_4mttecnt = 0;
ulong_t priv_4mttecnt = 0;
for (i = TTE4M; i < MMU_PAGE_SIZES; i++) {
if (scd4mtsb) {
sfmmup->sfmmu_scdismttecnt[i] +
sfmmup->sfmmu_scdrttecnt[i];
}
sfmmup->sfmmu_ismttecnt[i];
}
}
if (shared_4mttecnt) {
} else {
}
} else if (priv_4mttecnt) {
if (shared_4mttecnt) {
} else {
}
} else if (shared_4mttecnt) {
} else {
}
}
if (i == 0) {
}
j = tsbord[i];
tdp->hvtsb_rsvd = 0;
tsbinfop =
scd = 1;
}
}
}
/*
* Invalidate a TSB via processor specific TSB invalidation routine
*/
void
{
}
/*
* Completely flush the D-cache on all cpus.
* Not applicable to sun4v.
*/
void
{
}