svn commit: r205339 - projects/ppc64/sys/powerpc/aim

Nathan Whitehorn nwhitehorn at FreeBSD.org
Fri Mar 19 17:05:41 UTC 2010


Author: nwhitehorn
Date: Fri Mar 19 17:05:41 2010
New Revision: 205339
URL: http://svn.freebsd.org/changeset/base/205339

Log:
  Fix some minor races during SLB spills, and correct a comment that no
  longer reflects the truth.

Modified:
  projects/ppc64/sys/powerpc/aim/slb.c

Modified: projects/ppc64/sys/powerpc/aim/slb.c
==============================================================================
--- projects/ppc64/sys/powerpc/aim/slb.c	Fri Mar 19 16:25:05 2010	(r205338)
+++ projects/ppc64/sys/powerpc/aim/slb.c	Fri Mar 19 17:05:41 2010	(r205339)
@@ -174,10 +174,8 @@ slb_insert(pmap_t pm, struct slb *slbcac
 	uint64_t slbe, slbv;
 	int i, j, to_spill;
 
-	/*
-	 * Note: no locking is necessary in this function because all slbcaches
-	 * are either for the current thread or per-CPU.
-	 */
+	/* We don't want to be preempted while modifying the kernel map */
+	critical_enter();
 
 	to_spill = -1;
 	slbv = slb_entry->slbv;
@@ -203,6 +201,11 @@ slb_insert(pmap_t pm, struct slb *slbcac
 		panic("SLB spill on ESID %#lx, but no available candidates!\n",
 		   (slbe & SLBE_ESID_MASK) >> SLBE_ESID_SHIFT);
 
+	if (slbcache[to_spill].slbe & SLBE_VALID) {
+		/* Invalidate this first to avoid races */
+		slbcache[to_spill].slbe = 0;
+		mb();
+	}
 	slbcache[to_spill].slbv = slbv;
 	slbcache[to_spill].slbe = slbe | (uint64_t)to_spill;
 
@@ -213,6 +216,8 @@ slb_insert(pmap_t pm, struct slb *slbcac
 		    "r"(slbcache[to_spill].slbv),
 		    "r"(slbcache[to_spill].slbe)); 
 	}
+
+	critical_exit();
 }
 
 int


More information about the svn-src-projects mailing list