Module Name:    src
Committed By:   palle
Date:           Sat Jun  4 21:24:41 UTC 2016

Modified Files:
        src/sys/arch/sparc64/sparc64: locore.s

Log Message:
sun4v: rtf_user now uses macros GET_MMU_CONTEXTID and SET_MMU_CONTEXTID. Tested 
on sun4u (QEMU) and sun4v (T2000). Parts from OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.397 -r1.398 src/sys/arch/sparc64/sparc64/locore.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.397 src/sys/arch/sparc64/sparc64/locore.s:1.398
--- src/sys/arch/sparc64/sparc64/locore.s:1.397	Wed May 18 15:14:08 2016
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Jun  4 21:24:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.397 2016/05/18 15:14:08 nakayama Exp $	*/
+/*	$NetBSD: locore.s,v 1.398 2016/06/04 21:24:41 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -150,6 +150,34 @@
 3:
 	.endm
 
+	.macro	GET_MMU_CONTEXTID_SUN4U ctxid,ctx
+	ldxa	[\ctx] ASI_DMMU, \ctxid
+	.endm
+
+#ifdef SUN4V
+	.macro	GET_MMU_CONTEXTID_SUN4V ctxid,ctx
+	ldxa	[\ctx] ASI_MMU_CONTEXTID, \ctxid
+	.endm
+#endif	
+		
+	.macro	GET_MMU_CONTEXTID ctxid,ctx,scratch
+#ifdef SUN4V
+	sethi	%hi(cputyp), \scratch
+	ld	[\scratch + %lo(cputyp)], \scratch
+	cmp	\scratch, CPU_SUN4V
+	bne,pt	%icc, 2f
+	 nop
+	/* sun4v */
+	GET_MMU_CONTEXTID_SUN4V \ctxid,\ctx
+	ba	3f
+	 nop
+2:		
+#endif	
+	/* sun4u */
+	GET_MMU_CONTEXTID_SUN4U \ctxid,\ctx
+3:
+	.endm
+	
 #ifdef SUN4V
 	.macro	NORMAL_GLOBALS_SUN4V
 	 wrpr	%g0, 0, %gl				! Set globals to level 0
@@ -4619,12 +4647,14 @@ badregs:
 	andn	%g1, CWP, %g1			! Clear it from %tstate
 	wrpr	%g1, %g7, %tstate		! Set %tstate with %cwp
 
-	wr	%g0, ASI_DMMU, %asi		! restore the user context
-	ldxa	[CTX_SECONDARY] %asi, %g4
+	mov	CTX_SECONDARY, %g1		! Restore the user context
+	GET_MMU_CONTEXTID %g4, %g1, %g3
+	mov	CTX_PRIMARY, %g2
+	SET_MMU_CONTEXTID %g4, %g2, %g3
 	sethi	%hi(KERNBASE), %g7		! Should not be needed due to retry
-	stxa	%g4, [CTX_PRIMARY] %asi
 	membar	#Sync				! Should not be needed due to retry
 	flush	%g7				! Should not be needed due to retry
+
 	CLRTT
 #ifdef TRAPSTATS
 	set	_C_LABEL(rftudone), %g1

Reply via email to