Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Sep 2013 00:40:14 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r255283 - projects/bhyve_npt_pmap/sys/amd64/amd64
Message-ID:  <201309060040.r860eEiT036146@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Fri Sep  6 00:40:14 2013
New Revision: 255283
URL: http://svnweb.freebsd.org/changeset/base/255283

Log:
  Reduce diffs with respect to HEAD in anticipation of the merge of the PCID
  related changes in pmap.c

Modified:
  projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c

Modified: projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c
==============================================================================
--- projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c	Thu Sep  5 23:28:50 2013	(r255282)
+++ projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c	Fri Sep  6 00:40:14 2013	(r255283)
@@ -1264,29 +1264,27 @@ pmap_invalidate_page(pmap_t pmap, vm_off
 	cpuset_t other_cpus;
 	u_int cpuid;
 
-	sched_pin();
-	switch (pmap->pm_type) {
-	case PT_X86:
-		if (pmap == kernel_pmap ||
-		    !CPU_CMP(&pmap->pm_active, &all_cpus)) {
-			invlpg(va);
-			smp_invlpg(va);
-		} else {
-			cpuid = PCPU_GET(cpuid);
-			other_cpus = all_cpus;
-			CPU_CLR(cpuid, &other_cpus);
-			if (CPU_ISSET(cpuid, &pmap->pm_active))
-				invlpg(va);
-			CPU_AND(&other_cpus, &pmap->pm_active);
-			if (!CPU_EMPTY(&other_cpus))
-				smp_masked_invlpg(other_cpus, va);
-		}
-		break;
-	case PT_EPT:
+	if (pmap->pm_type == PT_EPT) {
 		pmap_invalidate_ept(pmap);
-		break;
-	default:
+		return;
+	}
+
+	if (pmap->pm_type != PT_X86)
 		panic("pmap_invalidate_page: invalid type %d", pmap->pm_type);
+
+	sched_pin();
+	if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
+		invlpg(va);
+		smp_invlpg(va);
+	} else {
+		cpuid = PCPU_GET(cpuid);
+		other_cpus = all_cpus;
+		CPU_CLR(cpuid, &other_cpus);
+		if (CPU_ISSET(cpuid, &pmap->pm_active))
+			invlpg(va);
+		CPU_AND(&other_cpus, &pmap->pm_active);
+		if (!CPU_EMPTY(&other_cpus))
+			smp_masked_invlpg(other_cpus, va);
 	}
 	sched_unpin();
 }
@@ -1298,31 +1296,29 @@ pmap_invalidate_range(pmap_t pmap, vm_of
 	vm_offset_t addr;
 	u_int cpuid;
 
+	if (pmap->pm_type == PT_EPT) {
+		pmap_invalidate_ept(pmap);
+		return;
+	}
+
+	if (pmap->pm_type != PT_X86)
+		panic("pmap_invalidate_range: invalid type %d", pmap->pm_type);
+
 	sched_pin();
-	switch (pmap->pm_type) {
-	case PT_X86:
-		if (pmap == kernel_pmap ||
-		    !CPU_CMP(&pmap->pm_active, &all_cpus)) {
+	if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
+		for (addr = sva; addr < eva; addr += PAGE_SIZE)
+			invlpg(addr);
+		smp_invlpg_range(sva, eva);
+	} else {
+		cpuid = PCPU_GET(cpuid);
+		other_cpus = all_cpus;
+		CPU_CLR(cpuid, &other_cpus);
+		if (CPU_ISSET(cpuid, &pmap->pm_active))
 			for (addr = sva; addr < eva; addr += PAGE_SIZE)
 				invlpg(addr);
-			smp_invlpg_range(sva, eva);
-		} else {
-			cpuid = PCPU_GET(cpuid);
-			other_cpus = all_cpus;
-			CPU_CLR(cpuid, &other_cpus);
-			if (CPU_ISSET(cpuid, &pmap->pm_active))
-				for (addr = sva; addr < eva; addr += PAGE_SIZE)
-					invlpg(addr);
-			CPU_AND(&other_cpus, &pmap->pm_active);
-			if (!CPU_EMPTY(&other_cpus))
-				smp_masked_invlpg_range(other_cpus, sva, eva);
-		}
-		break;
-	case PT_EPT:
-		pmap_invalidate_ept(pmap);
-		break;
-	default:
-		panic("pmap_invalidate_range: invalid type %d", pmap->pm_type);
+		CPU_AND(&other_cpus, &pmap->pm_active);
+		if (!CPU_EMPTY(&other_cpus))
+			smp_masked_invlpg_range(other_cpus, sva, eva);
 	}
 	sched_unpin();
 }
@@ -1333,29 +1329,27 @@ pmap_invalidate_all(pmap_t pmap)
 	cpuset_t other_cpus;
 	u_int cpuid;
 
-	sched_pin();
-	switch (pmap->pm_type) {
-	case PT_X86:
-		if (pmap == kernel_pmap ||
-		    !CPU_CMP(&pmap->pm_active, &all_cpus)) {
-			invltlb();
-			smp_invltlb();
-		} else {
-			cpuid = PCPU_GET(cpuid);
-			other_cpus = all_cpus;
-			CPU_CLR(cpuid, &other_cpus);
-			if (CPU_ISSET(cpuid, &pmap->pm_active))
-				invltlb();
-			CPU_AND(&other_cpus, &pmap->pm_active);
-			if (!CPU_EMPTY(&other_cpus))
-				smp_masked_invltlb(other_cpus);
-		}
-		break;
-	case PT_EPT:
+	if (pmap->pm_type == PT_EPT) {
 		pmap_invalidate_ept(pmap);
-		break;
-	default:
+		return;
+	}
+
+	if (pmap->pm_type != PT_X86)
 		panic("pmap_invalidate_all: invalid type %d", pmap->pm_type);
+
+	sched_pin();
+	if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
+		invltlb();
+		smp_invltlb();
+	} else {
+		cpuid = PCPU_GET(cpuid);
+		other_cpus = all_cpus;
+		CPU_CLR(cpuid, &other_cpus);
+		if (CPU_ISSET(cpuid, &pmap->pm_active))
+			invltlb();
+		CPU_AND(&other_cpus, &pmap->pm_active);
+		if (!CPU_EMPTY(&other_cpus))
+			smp_masked_invltlb(other_cpus);
 	}
 	sched_unpin();
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309060040.r860eEiT036146>