svn commit: r261919 - head/sys/arm/arm

Zbigniew Bodek zbb at FreeBSD.org
Sat Feb 15 13:20:18 UTC 2014


Author: zbb
Date: Sat Feb 15 13:20:17 2014
New Revision: 261919
URL: http://svnweb.freebsd.org/changeset/base/261919

Log:
  Fix superpage promotion on ARM with respect to RO/RW and wired attributes
  
  It was possible to create RW superpage mapping even if
  the base pages were RO due to wrong setting of the prot
  flag passed to pmap_map_section().
  Promotion attempt should be canceled in case of attributes
  mismatch between any two base pages. Since we still use
  pv_flags to maintain permission to write (PVF_WRITE) and
  wired status (PVF_WIRED) for a page, it is also necessary
  to take those variables into account.

Modified:
  head/sys/arm/arm/pmap-v6.c

Modified: head/sys/arm/arm/pmap-v6.c
==============================================================================
--- head/sys/arm/arm/pmap-v6.c	Sat Feb 15 13:17:51 2014	(r261918)
+++ head/sys/arm/arm/pmap-v6.c	Sat Feb 15 13:20:17 2014	(r261919)
@@ -3794,10 +3794,13 @@ pmap_promote_section(pmap_t pmap, vm_off
 	 * we just configure protections for the section mapping
 	 * that is going to be created.
 	 */
-	if (!L2_S_WRITABLE(firstpte) && (first_pve->pv_flags & PVF_WRITE)) {
-		first_pve->pv_flags &= ~PVF_WRITE;
+	if ((first_pve->pv_flags & PVF_WRITE) != 0) {
+		if (!L2_S_WRITABLE(firstpte)) {
+			first_pve->pv_flags &= ~PVF_WRITE;
+			prot &= ~VM_PROT_WRITE;
+		}
+	} else
 		prot &= ~VM_PROT_WRITE;
-	}
 
 	if (!L2_S_EXECUTABLE(firstpte))
 		prot &= ~VM_PROT_EXECUTE;
@@ -3842,6 +3845,12 @@ pmap_promote_section(pmap_t pmap, vm_off
 
 		if (!L2_S_WRITABLE(oldpte) && (pve->pv_flags & PVF_WRITE))
 			pve->pv_flags &= ~PVF_WRITE;
+		if (pve->pv_flags != first_pve->pv_flags) {
+			pmap_section_p_failures++;
+			CTR2(KTR_PMAP, "pmap_promote_section: failure for "
+			    "va %#x in pmap %p", va, pmap);
+			return;
+		}
 
 		old_va -= PAGE_SIZE;
 		pa -= PAGE_SIZE;


More information about the svn-src-all mailing list