xref: /titanic_50/usr/src/uts/sfmmu/ml/sfmmu_kdi.s (revision 9d0d62ad2e60e8f742a2e723d06e88352ee6a1f3)
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
51ae08745Sheppo * Common Development and Distribution License (the "License").
61ae08745Sheppo * 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 */
211ae08745Sheppo
227c478bd9Sstevel@tonic-gate/*
23*9d0d62adSJason Beloro * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate#if !defined(lint)
287c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
297c478bd9Sstevel@tonic-gate#include "assym.h"
307c478bd9Sstevel@tonic-gate#endif
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate#include <sys/sun4asi.h>
337c478bd9Sstevel@tonic-gate#include <sys/machparam.h>
347c478bd9Sstevel@tonic-gate#include <vm/hat_sfmmu.h>
357c478bd9Sstevel@tonic-gate
367c478bd9Sstevel@tonic-gate/*
377c478bd9Sstevel@tonic-gate * This file contains a kmdb-support function which retrieves the TTE for a
387c478bd9Sstevel@tonic-gate * given VA/context pair, and returns it to the caller if the TTE is valid.
397c478bd9Sstevel@tonic-gate * The code here is essentially an assembly implementation of the unix-tte
407c478bd9Sstevel@tonic-gate * word used to allow OBP to do the same thing.
417c478bd9Sstevel@tonic-gate *
427c478bd9Sstevel@tonic-gate * Depending on the invocation context, the translator may be invoked either
437c478bd9Sstevel@tonic-gate * as a normal function (kdi_vatotte) or as a trap handler fragment
447c478bd9Sstevel@tonic-gate * (kdi_trap_vatotte).
457c478bd9Sstevel@tonic-gate */
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate/*
487c478bd9Sstevel@tonic-gate * uint64_t
497c478bd9Sstevel@tonic-gate * kdi_hme_hash_function(sfmmu_t *sfmmup, uintptr_t va, uint_t hmeshift)
507c478bd9Sstevel@tonic-gate * {
517c478bd9Sstevel@tonic-gate *	uintptr_t hash = (uintptr_t)sfmmup ^ (va >> hmeshift);
527c478bd9Sstevel@tonic-gate *
537c478bd9Sstevel@tonic-gate *	if (sfmmup == KHATID) {
547c478bd9Sstevel@tonic-gate *		return (khme_hash_pa + (hash & KHMEHASH_SZ) *
557c478bd9Sstevel@tonic-gate *		    sizeof (struct hmehash_bucket));
567c478bd9Sstevel@tonic-gate *	} else {
577c478bd9Sstevel@tonic-gate *		return (uhme_hash_pa + (hash & UHMEHASH_SZ) *
587c478bd9Sstevel@tonic-gate *		    sizeof (struct hmehash_bucket));
597c478bd9Sstevel@tonic-gate *	}
607c478bd9Sstevel@tonic-gate * }
617c478bd9Sstevel@tonic-gate */
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate/*
647c478bd9Sstevel@tonic-gate * Parameters:	%g1: VA, %g2: sfmmup, %g4: hmeshift
657c478bd9Sstevel@tonic-gate * Scratch:	%g4, %g5, %g6 available
667c478bd9Sstevel@tonic-gate * Return:	Hash value in %g4
677c478bd9Sstevel@tonic-gate */
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate#define	KDI_HME_HASH_FUNCTION \
707c478bd9Sstevel@tonic-gate	srlx	%g1, %g4, %g4;		/* va >> hmeshift */		\
717c478bd9Sstevel@tonic-gate	xor	%g4, %g2, %g4;		/* hash in g4 */		\
727c478bd9Sstevel@tonic-gate	set	KHATID, %g5;						\
737c478bd9Sstevel@tonic-gate	ldx	[%g5], %g5;						\
747c478bd9Sstevel@tonic-gate	cmp	%g2, %g5;						\
757c478bd9Sstevel@tonic-gate	be	%xcc, is_khat;						\
767c478bd9Sstevel@tonic-gate	nop;								\
777c478bd9Sstevel@tonic-gate									\
787c478bd9Sstevel@tonic-gate	/* sfmmup != KHATID */						\
797c478bd9Sstevel@tonic-gate	set	UHMEHASH_SZ, %g5;					\
807c478bd9Sstevel@tonic-gate	ld	[%g5], %g5;						\
817c478bd9Sstevel@tonic-gate	and	%g4, %g5, %g4;						\
827c478bd9Sstevel@tonic-gate	mulx	%g4, HMEBUCK_SIZE, %g4; /* g4 = off from hash_pa */	\
837c478bd9Sstevel@tonic-gate	set	uhme_hash_pa, %g5;					\
847c478bd9Sstevel@tonic-gate	ldx	[%g5], %g5;						\
857c478bd9Sstevel@tonic-gate	ba	hash_done;						\
867c478bd9Sstevel@tonic-gate	add	%g4, %g5, %g4;						\
877c478bd9Sstevel@tonic-gate									\
887c478bd9Sstevel@tonic-gateis_khat: /* sfmmup == KHATID */						\
897c478bd9Sstevel@tonic-gate	set	KHMEHASH_SZ, %g5;					\
907c478bd9Sstevel@tonic-gate	ld	[%g5], %g5;						\
917c478bd9Sstevel@tonic-gate	and	%g4, %g5, %g4;						\
927c478bd9Sstevel@tonic-gate	mulx	%g4, HMEBUCK_SIZE, %g4;	/* g4 = off from hash_pa */	\
937c478bd9Sstevel@tonic-gate	set	khme_hash_pa, %g5;					\
947c478bd9Sstevel@tonic-gate	ldx	[%g5], %g5;						\
957c478bd9Sstevel@tonic-gate	add	%g4, %g5, %g4;						\
967c478bd9Sstevel@tonic-gate									\
977c478bd9Sstevel@tonic-gatehash_done:
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate/*
1007c478bd9Sstevel@tonic-gate * uint64_t
1017c478bd9Sstevel@tonic-gate * kdi_hme_hash_tag(uint64_t rehash, uintptr_t va)
1027c478bd9Sstevel@tonic-gate * {
1037c478bd9Sstevel@tonic-gate *	uint_t hmeshift = HME_HASH_SHIFT(rehash);
1047c478bd9Sstevel@tonic-gate *	uint64_t bspage = HME_HASH_BSPAGE(va, hmeshift);
10505d3dc4bSpaulsan *	return (rehash | (bspage << HTAG_BSPAGE_SHIFT));
1067c478bd9Sstevel@tonic-gate * }
1077c478bd9Sstevel@tonic-gate */
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate/*
1107c478bd9Sstevel@tonic-gate * Parameters:	%g1: VA, %g3: rehash
1117c478bd9Sstevel@tonic-gate * Scratch:	%g5, %g6 available
1127c478bd9Sstevel@tonic-gate * Return:	hmeblk tag in %g5
1137c478bd9Sstevel@tonic-gate */
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gate#define	KDI_HME_HASH_TAG \
1167c478bd9Sstevel@tonic-gate	cmp	%g3, TTE8K;					\
1177c478bd9Sstevel@tonic-gate	be,a	%xcc, bspage;					\
1187c478bd9Sstevel@tonic-gate	mov	HBLK_RANGE_SHIFT, %g5;				\
1197c478bd9Sstevel@tonic-gate	mulx	%g3, 3, %g5;					\
1207c478bd9Sstevel@tonic-gate	add	%g5, MMU_PAGESHIFT, %g5;			\
1217c478bd9Sstevel@tonic-gate								\
1227c478bd9Sstevel@tonic-gatebspage:	/* TTE_PAGE_SHIFT in %g5 */				\
1237c478bd9Sstevel@tonic-gate	srlx	%g1, %g5, %g6;					\
1247c478bd9Sstevel@tonic-gate	sub	%g5, MMU_PAGESHIFT, %g5;			\
1257c478bd9Sstevel@tonic-gate	sllx	%g6, %g5, %g5;					\
1267c478bd9Sstevel@tonic-gate								\
1277c478bd9Sstevel@tonic-gate	/* BSPAGE in %g5 */					\
12805d3dc4bSpaulsan	sllx	%g5, HTAG_BSPAGE_SHIFT, %g5;			\
12905d3dc4bSpaulsan	sllx	%g3, HTAG_REHASH_SHIFT, %g6;			\
13005d3dc4bSpaulsan	or	%g6, SFMMU_INVALID_SHMERID, %g6;		\
13105d3dc4bSpaulsan	or	%g5, %g6, %g5
1327c478bd9Sstevel@tonic-gate
1337c478bd9Sstevel@tonic-gate/*
1347c478bd9Sstevel@tonic-gate * uint64_t
1357c478bd9Sstevel@tonic-gate * kdi_hme_hash_table_search(sfmmu_t *sfmmup, uint64_t hmebpa, uint64_t hblktag)
1367c478bd9Sstevel@tonic-gate * {
1377c478bd9Sstevel@tonic-gate *	struct hme_blk *hblkp;
1387c478bd9Sstevel@tonic-gate *	uint64_t blkpap = hmebpa + HMEBP_HBLK;
1397c478bd9Sstevel@tonic-gate *	uint64_t blkpa;
1407c478bd9Sstevel@tonic-gate *
1415f87cd85SAmritpal Sandhu *	while ((blkpa = lddphys(blkpap)) != HMEBLK_ENDPA) {
1427c478bd9Sstevel@tonic-gate *		if (lddphys(blkpa + HMEBLK_TAG) == hblktag) {
1437c478bd9Sstevel@tonic-gate *			if ((sfmmu_t *)lddphys(blkpa + HMEBLK_TAG + 8) ==
1447c478bd9Sstevel@tonic-gate *			    sfmmup)
1457c478bd9Sstevel@tonic-gate *				return (blkpa);
1467c478bd9Sstevel@tonic-gate *		}
1477c478bd9Sstevel@tonic-gate *
1487c478bd9Sstevel@tonic-gate *		blkpap = blkpa + HMEBLK_NEXTPA;
1497c478bd9Sstevel@tonic-gate *	}
1507c478bd9Sstevel@tonic-gate *
1517c478bd9Sstevel@tonic-gate *	return (NULL);
1527c478bd9Sstevel@tonic-gate * }
1537c478bd9Sstevel@tonic-gate */
1547c478bd9Sstevel@tonic-gate
1557c478bd9Sstevel@tonic-gate/*
1567c478bd9Sstevel@tonic-gate * Parameters:	%g2: sfmmup, %g4: hmebp PA, %g5: hmeblk tag
1577c478bd9Sstevel@tonic-gate * Scratch:	%g4, %g5, %g6 available
1587c478bd9Sstevel@tonic-gate * Return:	hmeblk PA in %g4
1597c478bd9Sstevel@tonic-gate */
1607c478bd9Sstevel@tonic-gate
1617c478bd9Sstevel@tonic-gate#define	KDI_HME_HASH_TABLE_SEARCH \
1627c478bd9Sstevel@tonic-gate	add	%g4, HMEBUCK_NEXTPA, %g4; /* %g4 is hmebucket PA */	\
1637c478bd9Sstevel@tonic-gatesearch_loop:								\
1647c478bd9Sstevel@tonic-gate	ldxa	[%g4]ASI_MEM, %g4;					\
1650a90a7fdSAmritpal Sandhu	cmp	%g4, HMEBLK_ENDPA;					\
1665f87cd85SAmritpal Sandhu	be,a,pn	%xcc, search_done;					\
1675f87cd85SAmritpal Sandhu	clr 	%g4;							\
1687c478bd9Sstevel@tonic-gate									\
1697c478bd9Sstevel@tonic-gate	add	%g4, HMEBLK_TAG, %g4;	/* %g4 is now hmeblk PA */	\
1707c478bd9Sstevel@tonic-gate	ldxa	[%g4]ASI_MEM, %g6;					\
1717c478bd9Sstevel@tonic-gate	sub	%g4, HMEBLK_TAG, %g4;					\
1727c478bd9Sstevel@tonic-gate	cmp	%g5, %g6;						\
1737c478bd9Sstevel@tonic-gate	bne,a	%xcc, search_loop;					\
1747c478bd9Sstevel@tonic-gate	add	%g4, HMEBLK_NEXTPA, %g4;				\
1757c478bd9Sstevel@tonic-gate									\
1767c478bd9Sstevel@tonic-gate	/* Found a match.  Is it in the right address space? */		\
1777c478bd9Sstevel@tonic-gate	add	%g4, (HMEBLK_TAG + 8), %g4;				\
1787c478bd9Sstevel@tonic-gate	ldxa	[%g4]ASI_MEM, %g6;					\
1797c478bd9Sstevel@tonic-gate	sub	%g4, (HMEBLK_TAG + 8), %g4;				\
1807c478bd9Sstevel@tonic-gate	cmp	%g6, %g2;						\
1817c478bd9Sstevel@tonic-gate	bne,a	%xcc, search_loop;					\
1827c478bd9Sstevel@tonic-gate	add	%g4, HMEBLK_NEXTPA, %g4;				\
1837c478bd9Sstevel@tonic-gate									\
1847c478bd9Sstevel@tonic-gatesearch_done:
1857c478bd9Sstevel@tonic-gate
1867c478bd9Sstevel@tonic-gate/*
1877c478bd9Sstevel@tonic-gate * uint64_t
1887c478bd9Sstevel@tonic-gate * kdi_hblk_to_ttep(uint64_t hmeblkpa, uintptr_t va)
1897c478bd9Sstevel@tonic-gate * {
1907c478bd9Sstevel@tonic-gate *	size_t ttesz = ldphys(hmeblkpa + HMEBLK_MISC) & HBLK_SZMASK;
1917c478bd9Sstevel@tonic-gate *	uint_t idx;
1927c478bd9Sstevel@tonic-gate *
1937c478bd9Sstevel@tonic-gate *	if (ttesz == TTE8K)
1947c478bd9Sstevel@tonic-gate *		idx = (va >> MMU_PAGESHIFT) & (NHMENTS - 1);
1957c478bd9Sstevel@tonic-gate *	else
1967c478bd9Sstevel@tonic-gate *		idx = 0;
1977c478bd9Sstevel@tonic-gate *
1987c478bd9Sstevel@tonic-gate *	return (hmeblkpa + (idx * sizeof (struct sf_hment)) +
1997c478bd9Sstevel@tonic-gate *	    HMEBLK_HME + SFHME_TTE);
2007c478bd9Sstevel@tonic-gate * }
2017c478bd9Sstevel@tonic-gate */
2027c478bd9Sstevel@tonic-gate
2037c478bd9Sstevel@tonic-gate/*
2047c478bd9Sstevel@tonic-gate * Parameters:	%g1: VA, %g4: hmeblk PA
2057c478bd9Sstevel@tonic-gate * Scratch:	%g1, %g2, %g3, %g4, %g5, %g6 available
2067c478bd9Sstevel@tonic-gate * Return:	TTE PA in %g2
2077c478bd9Sstevel@tonic-gate */
2087c478bd9Sstevel@tonic-gate
2097c478bd9Sstevel@tonic-gate#define	KDI_HBLK_TO_TTEP \
2107c478bd9Sstevel@tonic-gate	add	%g4, HMEBLK_MISC, %g3;				\
2117c478bd9Sstevel@tonic-gate	lda	[%g3]ASI_MEM, %g3;				\
2127c478bd9Sstevel@tonic-gate	and	%g3, HBLK_SZMASK, %g3;	/* ttesz in %g3 */	\
2137c478bd9Sstevel@tonic-gate								\
2147c478bd9Sstevel@tonic-gate	cmp	%g3, TTE8K;					\
2157c478bd9Sstevel@tonic-gate	bne,a	ttep_calc;					\
2167c478bd9Sstevel@tonic-gate	clr	%g1;						\
2177c478bd9Sstevel@tonic-gate	srlx	%g1, MMU_PAGESHIFT, %g1;			\
2187c478bd9Sstevel@tonic-gate	and	%g1, NHMENTS - 1, %g1;				\
2197c478bd9Sstevel@tonic-gate								\
2207c478bd9Sstevel@tonic-gatettep_calc:	/* idx in %g1 */				\
2217c478bd9Sstevel@tonic-gate	mulx	%g1, SFHME_SIZE, %g2;				\
2227c478bd9Sstevel@tonic-gate	add	%g2, %g4, %g2;					\
2237c478bd9Sstevel@tonic-gate	add	%g2, (HMEBLK_HME1 + SFHME_TTE), %g2;
2247c478bd9Sstevel@tonic-gate
2257c478bd9Sstevel@tonic-gate/*
2267c478bd9Sstevel@tonic-gate * uint64_t
2277c478bd9Sstevel@tonic-gate * kdi_vatotte(uintptr_t va, int cnum)
2287c478bd9Sstevel@tonic-gate * {
2291e2e7a75Shuah *	sfmmu_t *sfmmup = ksfmmup;
2307c478bd9Sstevel@tonic-gate *	uint64_t hmebpa, hmetag, hmeblkpa;
2317c478bd9Sstevel@tonic-gate *	int i;
2327c478bd9Sstevel@tonic-gate *
2337c478bd9Sstevel@tonic-gate *	for (i = 1; i < DEFAULT_MAX_HASHCNT + 1; i++) {
2347c478bd9Sstevel@tonic-gate *		hmebpa = kdi_c_hme_hash_function(sfmmup, va, HME_HASH_SHIFT(i));
2357c478bd9Sstevel@tonic-gate *		hmetag = kdi_c_hme_hash_tag(i, va);
2367c478bd9Sstevel@tonic-gate *		hmeblkpa = kdi_c_hme_hash_table_search(sfmmup, hmebpa, hmetag);
2377c478bd9Sstevel@tonic-gate *
2387c478bd9Sstevel@tonic-gate *		if (hmeblkpa != NULL) {
2397c478bd9Sstevel@tonic-gate *			uint64_t tte = lddphys(kdi_c_hblk_to_ttep(hmeblkpa,
2407c478bd9Sstevel@tonic-gate *			    va));
2417c478bd9Sstevel@tonic-gate *
2427c478bd9Sstevel@tonic-gate *			if ((int64_t)tte < 0)
2437c478bd9Sstevel@tonic-gate *				return (tte);
2447c478bd9Sstevel@tonic-gate *			else
2457c478bd9Sstevel@tonic-gate *				return (0);
2467c478bd9Sstevel@tonic-gate *		}
2477c478bd9Sstevel@tonic-gate *	}
2487c478bd9Sstevel@tonic-gate *
2497c478bd9Sstevel@tonic-gate *	return (0);
2507c478bd9Sstevel@tonic-gate * }
2517c478bd9Sstevel@tonic-gate */
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gate#if defined(lint)
2547c478bd9Sstevel@tonic-gate/*ARGSUSED*/
2557c478bd9Sstevel@tonic-gateint
2567c478bd9Sstevel@tonic-gatekdi_vatotte(uintptr_t va, int cnum, tte_t *ttep)
2577c478bd9Sstevel@tonic-gate{
2587c478bd9Sstevel@tonic-gate	return (0);
2597c478bd9Sstevel@tonic-gate}
2607c478bd9Sstevel@tonic-gate
2617c478bd9Sstevel@tonic-gatevoid
2627c478bd9Sstevel@tonic-gatekdi_trap_vatotte(void)
2637c478bd9Sstevel@tonic-gate{
2647c478bd9Sstevel@tonic-gate}
2657c478bd9Sstevel@tonic-gate
2667c478bd9Sstevel@tonic-gate#else
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate	/*
2691e2e7a75Shuah	 * Invocation in normal context as a VA-to-TTE translator
2701e2e7a75Shuah	 * for kernel context only. This routine returns 0 on
2711e2e7a75Shuah	 * success and -1 on error.
2721e2e7a75Shuah	 *
2731e2e7a75Shuah	 * %o0 = VA, input register
2741e2e7a75Shuah	 * %o1 = KCONTEXT
2751e2e7a75Shuah	 * %o2 = ttep, output register
2767c478bd9Sstevel@tonic-gate	 */
2777c478bd9Sstevel@tonic-gate	ENTRY_NP(kdi_vatotte)
2787c478bd9Sstevel@tonic-gate	mov	%o0, %g1		/* VA in %g1 */
2797c478bd9Sstevel@tonic-gate	mov	%o1, %g2		/* cnum in %g2 */
2807c478bd9Sstevel@tonic-gate
2817c478bd9Sstevel@tonic-gate	set	kdi_trap_vatotte, %g3
2827c478bd9Sstevel@tonic-gate	jmpl	%g3, %g7		/* => %g1: TTE or 0 */
2837c478bd9Sstevel@tonic-gate	add	%g7, 8, %g7
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate	brz	%g1, 1f
2867c478bd9Sstevel@tonic-gate	nop
2877c478bd9Sstevel@tonic-gate
2887c478bd9Sstevel@tonic-gate	/* Got a valid TTE */
2897c478bd9Sstevel@tonic-gate	stx	%g1, [%o2]
2907c478bd9Sstevel@tonic-gate	retl
2917c478bd9Sstevel@tonic-gate	clr	%o0
2927c478bd9Sstevel@tonic-gate
2937c478bd9Sstevel@tonic-gate	/* Failed translation */
2947c478bd9Sstevel@tonic-gate1:	retl
2957c478bd9Sstevel@tonic-gate	mov	-1, %o0
2967c478bd9Sstevel@tonic-gate	SET_SIZE(kdi_vatotte)
2977c478bd9Sstevel@tonic-gate
2981e2e7a75Shuah	/*
2991e2e7a75Shuah	 * %g1 = vaddr passed in, tte or 0 (error) when return
3001e2e7a75Shuah	 * %g2 = KCONTEXT
3011e2e7a75Shuah	 * %g7 = return address
3021e2e7a75Shuah	 */
3037c478bd9Sstevel@tonic-gate	ENTRY_NP(kdi_trap_vatotte)
3041e2e7a75Shuah
3051e2e7a75Shuah	cmp	%g2, KCONTEXT		/* make sure called in kernel ctx */
3061e2e7a75Shuah	bne,a,pn %icc, 6f
3077c478bd9Sstevel@tonic-gate	  clr	%g1
3087c478bd9Sstevel@tonic-gate
3091e2e7a75Shuah	sethi   %hi(ksfmmup), %g2
3101e2e7a75Shuah        ldx     [%g2 + %lo(ksfmmup)], %g2
3117c478bd9Sstevel@tonic-gate
3121e2e7a75Shuah	mov	1, %g3			/* VA %g1, ksfmmup %g2, idx %g3 */
3131ae08745Sheppo	mov	HBLK_RANGE_SHIFT, %g4
3141ae08745Sheppo	ba	3f
3151ae08745Sheppo	nop
3161ae08745Sheppo
3171ae08745Sheppo1:	mulx	%g3, 3, %g4		/* 3: see TTE_BSZS_SHIFT */
3187c478bd9Sstevel@tonic-gate	add	%g4, MMU_PAGESHIFT, %g4
3197c478bd9Sstevel@tonic-gate
3207c478bd9Sstevel@tonic-gate3:	KDI_HME_HASH_FUNCTION		/* %g1, %g2, %g4 => hash in %g4 */
3217c478bd9Sstevel@tonic-gate	KDI_HME_HASH_TAG		/* %g1, %g3 => tag in %g5 */
3227c478bd9Sstevel@tonic-gate	KDI_HME_HASH_TABLE_SEARCH	/* %g2, %g4, %g5 => hmeblk PA in %g4 */
3237c478bd9Sstevel@tonic-gate
3247c478bd9Sstevel@tonic-gate	brz	%g4, 5f
3257c478bd9Sstevel@tonic-gate	nop
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate	KDI_HBLK_TO_TTEP		/* %g1, %g4 => TTE PA in %g2 */
3287c478bd9Sstevel@tonic-gate	ldxa	[%g2]ASI_MEM, %g1
3297c478bd9Sstevel@tonic-gate	brgez,a	%g1, 4f
3307c478bd9Sstevel@tonic-gate	clr	%g1
331*9d0d62adSJason Beloro4:	ba,a	6f
3327c478bd9Sstevel@tonic-gate
3337c478bd9Sstevel@tonic-gate5:	add	%g3, 1, %g3
3341ae08745Sheppo	set	mmu_hashcnt, %g4
3351ae08745Sheppo	lduw	[%g4], %g4
3361ae08745Sheppo	cmp	%g3, %g4
3377c478bd9Sstevel@tonic-gate	ble	1b
3387c478bd9Sstevel@tonic-gate	nop
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate	clr	%g1
3417c478bd9Sstevel@tonic-gate
3427c478bd9Sstevel@tonic-gate6:	jmp	%g7
3437c478bd9Sstevel@tonic-gate	nop
3447c478bd9Sstevel@tonic-gate	SET_SIZE(kdi_trap_vatotte)
3457c478bd9Sstevel@tonic-gate
3467c478bd9Sstevel@tonic-gate#endif	/* lint */
347