Module Name:    src
Committed By:   palle
Date:           Thu Sep  4 18:48:29 UTC 2014

Modified Files:
        src/sys/arch/sparc64/include: cpu.h pmap.h
        src/sys/arch/sparc64/sparc64: genassym.cf locore.s pmap.c

Log Message:
sun4v: All cpus must be setup with a TSB descriptor, so pmap_setup_tsb_sun4v() 
must take a pointer to the TSB descriptor


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/sparc64/include/cpu.h
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/sparc64/include/pmap.h
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/sparc64/sparc64/genassym.cf
cvs rdiff -u -r1.371 -r1.372 src/sys/arch/sparc64/sparc64/locore.s
cvs rdiff -u -r1.289 -r1.290 src/sys/arch/sparc64/sparc64/pmap.c

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/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.111 src/sys/arch/sparc64/include/cpu.h:1.112
--- src/sys/arch/sparc64/include/cpu.h:1.111	Sun Jun  8 17:33:24 2014
+++ src/sys/arch/sparc64/include/cpu.h	Thu Sep  4 18:48:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.111 2014/06/08 17:33:24 palle Exp $ */
+/*	$NetBSD: cpu.h,v 1.112 2014/09/04 18:48:29 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -71,6 +71,9 @@
 #include <machine/cpuset.h>
 #include <sparc64/sparc64/intreg.h>
 #endif
+#ifdef SUN4V
+#include <sparc64/hypervisor.h>
+#endif
 
 #include <sys/cpu_data.h>
 #include <sys/evcnt.h>
@@ -174,6 +177,9 @@ struct cpu_info {
 	pte_t			*ci_tsb_dmmu;
 	pte_t			*ci_tsb_immu;
 
+	/* TSB description (sun4v). */
+	struct tsb_desc         *ci_tsb_desc;
+	
 	/* MMU Fault Status Area (sun4v).
 	 * Will be initialized to the physical address of the bottom of
 	 * the interrupt stack.

Index: src/sys/arch/sparc64/include/pmap.h
diff -u src/sys/arch/sparc64/include/pmap.h:1.58 src/sys/arch/sparc64/include/pmap.h:1.59
--- src/sys/arch/sparc64/include/pmap.h:1.58	Mon Apr 14 10:54:08 2014
+++ src/sys/arch/sparc64/include/pmap.h	Thu Sep  4 18:48:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.58 2014/04/14 10:54:08 martin Exp $	*/
+/*	$NetBSD: pmap.h,v 1.59 2014/09/04 18:48:29 palle Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -40,6 +40,9 @@
 #include <uvm/uvm_object.h>
 #ifdef _KERNEL
 #include <machine/cpuset.h>
+#ifdef SUN4V
+#include <sparc64/hypervisor.h>
+#endif
 #endif
 #endif
 
@@ -234,7 +237,7 @@ void		pmap_zero_page_phys(paddr_t);
 #ifdef SUN4V
 /* sun4v specific */
 void		pmap_setup_intstack_sun4v(paddr_t);
-void		pmap_setup_tsb_sun4v(void);
+void		pmap_setup_tsb_sun4v(struct tsb_desc*);
 #endif
 
 /* Installed physical memory, as discovered during bootstrap. */

Index: src/sys/arch/sparc64/sparc64/genassym.cf
diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.73 src/sys/arch/sparc64/sparc64/genassym.cf:1.74
--- src/sys/arch/sparc64/sparc64/genassym.cf:1.73	Fri Feb 21 18:00:09 2014
+++ src/sys/arch/sparc64/sparc64/genassym.cf	Thu Sep  4 18:48:29 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.73 2014/02/21 18:00:09 palle Exp $
+#	$NetBSD: genassym.cf,v 1.74 2014/09/04 18:48:29 palle Exp $
 
 #
 # Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -168,6 +168,7 @@ define	CI_CTXBUSY	offsetof(struct cpu_in
 define	CI_TSB_DMMU	offsetof(struct cpu_info, ci_tsb_dmmu)
 define	CI_TSB_IMMU	offsetof(struct cpu_info, ci_tsb_immu)
 define	CI_MMFSA	offsetof(struct cpu_info, ci_mmfsa)
+define	CI_TSB_DESC	offsetof(struct cpu_info, ci_tsb_desc)
 ifdef MULTIPROCESSOR
 define	CI_IPIEVC	offsetof(struct cpu_info, ci_ipi_evcnt[0].ev_count)
 endif

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.371 src/sys/arch/sparc64/sparc64/locore.s:1.372
--- src/sys/arch/sparc64/sparc64/locore.s:1.371	Sun Aug 31 18:49:42 2014
+++ src/sys/arch/sparc64/sparc64/locore.s	Thu Sep  4 18:48:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.371 2014/08/31 18:49:42 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.372 2014/09/04 18:48:29 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -4521,6 +4521,7 @@ ENTRY_NOPROFILE(cpu_initialize)	/* for c
 	 nop
 
 	/* sun4v */
+	LDPTR	[%l7 + CI_TSB_DESC], %o0
 	call	_C_LABEL(pmap_setup_tsb_sun4v)
 	 nop
 	ba	1f

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.289 src/sys/arch/sparc64/sparc64/pmap.c:1.290
--- src/sys/arch/sparc64/sparc64/pmap.c:1.289	Thu Jul 10 06:24:02 2014
+++ src/sys/arch/sparc64/sparc64/pmap.c	Thu Sep  4 18:48:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.289 2014/07/10 06:24:02 jdc Exp $	*/
+/*	$NetBSD: pmap.c,v 1.290 2014/09/04 18:48:29 palle Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.289 2014/07/10 06:24:02 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.290 2014/09/04 18:48:29 palle Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -149,10 +149,6 @@ int tsbsize;		/* tsbents = 512 * 2^^tsbs
 #define TSBENTS (512<<tsbsize)
 #define	TSBSIZE	(TSBENTS * 16)
 
-#ifdef SUN4V
-struct tsb_desc *tsb_desc;
-#endif
-
 static struct pmap kernel_pmap_;
 struct pmap *const kernel_pmap_ptr = &kernel_pmap_;
 
@@ -1157,8 +1153,10 @@ pmap_bootstrap(u_long kernelstart, u_lon
 		cpus->ci_spinup = main; /* Call main when we're running. */
 		cpus->ci_paddr = cpu0paddr;
 #ifdef SUN4V
-		if (CPU_ISSUN4V)
+		if (CPU_ISSUN4V) {
 			cpus->ci_mmfsa = cpu0paddr;
+			cpus->ci_tsb_desc = NULL;
+		}
 #endif
 		cpus->ci_cpcb = (struct pcb *)u0va;
 		cpus->ci_idepth = -1;
@@ -1244,22 +1242,21 @@ cpu_pmap_prepare(struct cpu_info *ci, bo
 	}
 
 #ifdef SUN4V
-	if (initial && CPU_ISSUN4V) {
-		tsb_desc = (struct tsb_desc *)kdata_alloc(
+	if (CPU_ISSUN4V) {
+		ci->ci_tsb_desc = (struct tsb_desc *)kdata_alloc(
 			sizeof(struct tsb_desc), 16);
-		memset(tsb_desc, 0, sizeof(struct tsb_desc));
+		memset(ci->ci_tsb_desc, 0, sizeof(struct tsb_desc));
 		/* 8K page size used for TSB index computation */
-		tsb_desc->td_idxpgsz = 0;
-		tsb_desc->td_assoc = 1;
-		tsb_desc->td_size = TSBENTS;
-		tsb_desc->td_ctxidx = -1;
-		tsb_desc->td_pgsz = 0xf;
-		tsb_desc->td_pa = pmap_kextract((vaddr_t)ci->ci_tsb_dmmu);
+		ci->ci_tsb_desc->td_idxpgsz = 0;
+		ci->ci_tsb_desc->td_assoc = 1;
+		ci->ci_tsb_desc->td_size = TSBENTS;
+		ci->ci_tsb_desc->td_ctxidx = -1;
+		ci->ci_tsb_desc->td_pgsz = 0xf;
+		ci->ci_tsb_desc->td_pa = pmap_kextract((vaddr_t)ci->ci_tsb_dmmu);
 		BDPRINTF(PDB_BOOT1, ("cpu %d: TSB descriptor allocated at %p "
 		    "size %08x - td_pa at %p\n",
-		    ci->ci_index, tsb_desc, sizeof(struct tsb_desc),
-		    tsb_desc->td_pa));
-		
+		    ci->ci_index, ci->ci_tsb_desc, sizeof(struct tsb_desc),
+		    ci->ci_tsb_desc->td_pa));
 	}
 #endif
 
@@ -3808,14 +3805,12 @@ pmap_setup_intstack_sun4v(paddr_t pa)
 }
 
 void
-pmap_setup_tsb_sun4v(void)
+pmap_setup_tsb_sun4v(struct tsb_desc* tsb_desc)
 {
 	int err;
-	extern struct tsb_desc *tsb_desc;
-	extern paddr_t pmap_kextract(vaddr_t va);
 	paddr_t tsb_desc_p;
 	tsb_desc_p = pmap_kextract((vaddr_t)tsb_desc);
-	if ( !tsb_desc_p ) {
+	if (!tsb_desc_p) {
 		panic("pmap_setup_tsb_sun4v() pmap_kextract() failed");
 	}
 	err = hv_mmu_tsb_ctx0(1, tsb_desc_p);

Reply via email to