/* * 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 * or http://www.opensolaris.org/os/licensing. * 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 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * VM - Hardware Address Translation management. * * This file describes the contents of the sun reference mmu (sfmmu) * specific hat data structures and the sfmmu specific hat procedures. * The machine independent interface is described in . */ #ifndef _VM_MACH_SFMMU_H #define _VM_MACH_SFMMU_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* * Define UTSB_PHYS if user TSB is always accessed via physical address. * On sun4v platform, user TSB is accessed via physical address. */ #define UTSB_PHYS 1 /* * Hypervisor TSB info */ #define NHV_TSB_INFO 4 #ifndef _ASM struct hv_tsb_block { uint64_t hv_tsb_info_pa; /* hypervisor TSB info PA */ uint64_t hv_tsb_info_cnt; /* hypervisor TSB info count */ hv_tsb_info_t hv_tsb_info[NHV_TSB_INFO]; /* hypervisor TSB info */ }; /* * Defines for hypervisor pagesize search API. */ #define TLB_PGSZ_ENABLE_SHIFT 15 #define TLB_PGSZ_CTX_SHIFT 7 #define TLB_PGSZ_ENABLE (1< ptr */ ;\ add tsbe, tmp1, tsbe /* add entry offset to TSB base */ ;\ /* END CSTYLED */ /* * Will probe the first TSB, and if it finds a match, will insert it * into the TLB and retry. * * tsbe_ptr = precomputed first TSB entry pointer (in, ro) * vpg_4m = 4M virtual page number for tag matching (in, ro) * label = where to branch to if this is a miss (text) * %asi = atomic ASI to use for the TSB access * * For trapstat, we have to explicily use these registers. * g4 = location tag will be retrieved into from TSB (out) * g5 = location data(tte) will be retrieved into from TSB (out) */ #define PROBE_1ST_DTSB(tsbe_ptr, vpg_4m, label) /* g4/g5 clobbered */ \ /* BEGIN CSTYLED */ \ ldda [tsbe_ptr]ASI_QUAD_LDD_PHYS, %g4 /* g4 = tag, g5 = data */ ;\ cmp %g4, vpg_4m /* compare tag w/ TSB */ ;\ bne,pn %xcc, label/**/1 /* branch if !match */ ;\ nop ;\ brgez,pn %g5, label/**/1 ;\ nop ;\ TT_TRACE(trace_tsbhit) ;\ DTLB_STUFF(%g5, %g1, %g2, %g3, %g4) ;\ /* trapstat expects tte in %g5 */ ;\ retry /* retry faulted instruction */ ;\ label/**/1: \ /* END CSTYLED */ /* * Same as above, only if the TTE doesn't have the execute * bit set, will branch to exec_fault directly. */ #define PROBE_1ST_ITSB(tsbe_ptr, vpg_4m, label) \ /* BEGIN CSTYLED */ \ ldda [tsbe_ptr]ASI_QUAD_LDD_PHYS, %g4 /* g4 = tag, g5 = data */ ;\ cmp %g4, vpg_4m /* compare tag w/ TSB */ ;\ bne,pn %xcc, label/**/1 /* branch if !match */ ;\ nop ;\ brgez,pn %g5, label/**/1 ;\ nop ;\ andcc %g5, TTE_EXECPRM_INT, %g0 /* check execute bit */ ;\ bz,pn %icc, exec_fault ;\ nop ;\ TT_TRACE(trace_tsbhit) ;\ ITLB_STUFF(%g5, %g1, %g2, %g3, %g4) ;\ retry /* retry faulted instruction */ ;\ label/**/1: \ /* END CSTYLED */ /* * vpg_4m = 4M virtual page number for tag matching (in) * tsbe_ptr = precomputed second TSB entry pointer (in) * label = label to use to make branch targets unique (text) * * For trapstat, we have to explicity use these registers. * g4 = tag portion of TSBE (out) * g5 = data portion of TSBE (out) */ #define PROBE_2ND_DTSB(tsbe_ptr, vpg_4m, label) \ /* BEGIN CSTYLED */ \ ldda [tsbe_ptr]ASI_QUAD_LDD_PHYS, %g4 /* g4 = tag, g5 = data */ ;\ /* since we are looking at 2nd tsb, if it's valid, it must be 4M */ ;\ cmp %g4, vpg_4m ;\ bne,pn %xcc, label/**/1 ;\ nop ;\ brgez,pn %g5, label/**/1 ;\ nop ;\ mov tsbe_ptr, %g1 /* trace_tsbhit wants ptr in %g1 */ ;\ TT_TRACE(trace_tsbhit) ;\ DTLB_STUFF(%g5, %g1, %g2, %g3, %g4) ;\ /* trapstat expects tte in %g5 */ ;\ retry /* retry faulted instruction */ ;\ label/**/1: \ /* END CSTYLED */ /* * Same as above, with the following additions: * If the TTE found is not executable, branch directly * to exec_fault. If a TSB miss, branch to TSB miss handler. */ #define PROBE_2ND_ITSB(tsbe_ptr, vpg_4m) \ /* BEGIN CSTYLED */ \ ldda [tsbe_ptr]ASI_QUAD_LDD_PHYS, %g4 /* g4 = tag, g5 = data */ ;\ cmp %g4, vpg_4m /* compare tag w/ TSB */ ;\ bne,pn %xcc, sfmmu_tsb_miss_tt /* branch if !match */ ;\ nop ;\ brgez,pn %g5, sfmmu_tsb_miss_tt ;\ nop ;\ andcc %g5, TTE_EXECPRM_INT, %g0 /* check execute bit */ ;\ bz,pn %icc, exec_fault ;\ mov tsbe_ptr, %g1 /* trap trace wants ptr in %g1 */ ;\ TT_TRACE(trace_tsbhit) ;\ ITLB_STUFF(%g5, %g1, %g2, %g3, %g4) ;\ retry /* retry faulted instruction */ \ /* END CSTYLED */ /* * 1. Get ctx1. The traptype is supplied by caller. * 2. If iTSB miss, store in MMFSA_I_CTX * 3. if dTSB miss, store in MMFSA_D_CTX * 4. Thus the [D|I]TLB_STUFF will work as expected. */ #define SAVE_CTX1(traptype, ctx1, tmp, label) \ /* BEGIN CSTYLED */ \ mov MMU_SCONTEXT1, tmp ;\ ldxa [tmp]ASI_MMU_CTX, ctx1 ;\ MMU_FAULT_STATUS_AREA(tmp) ;\ cmp traptype, FAST_IMMU_MISS_TT ;\ be,a,pn %icc, label ;\ stx ctx1, [tmp + MMFSA_I_CTX] ;\ cmp traptype, T_INSTR_MMU_MISS ;\ be,a,pn %icc, label ;\ stx ctx1, [tmp + MMFSA_I_CTX] ;\ stx ctx1, [tmp + MMFSA_D_CTX] ;\ label: /* END CSTYLED */ /* * For shared context mappings, check against the page size bitmap in the * tsbmiss area to decide if we should use private mappings instead to reduce * the number of shared page size searches on Rock based platforms. * In: * tsbarea (not clobbered) * tte (not clobbered) * tmp (clobbered) * Out: * use_shctx - changed to 0 if page size bit is not set in mask. */ #define CHECK_SHARED_PGSZ(tsbarea, tte, tmp, use_shctx, label) \ /* BEGIN CSTYLED */ \ brz use_shctx, label/**/1 ;\ and tte, TTE_SZ_BITS, tmp ;\ ldub [tsbarea + TSBMISS_PGSZ_BITMAP], use_shctx ;\ srlx use_shctx, tmp, use_shctx ;\ and use_shctx, 0x1, use_shctx ;\ label/**/1: /* END CSTYLED */ #endif /* _ASM */ #ifdef __cplusplus } #endif #endif /* _VM_MACH_SFMMU_H */