Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Apr 2012 21:56:55 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r234155 - head/sys/powerpc/aim
Message-ID:  <201204112156.q3BLutS8097431@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Wed Apr 11 21:56:55 2012
New Revision: 234155
URL: http://svn.freebsd.org/changeset/base/234155

Log:
  Only manipulate the PGA_EXECUTABLE flag on managed pages. This is a proxy
  for whether the page is physical. On dense phys mem systems (32-bit),
  VM_PHYS_TO_PAGE will not return NULL for device memory pages if device
  memory is above physical memory even if there is no allocated vm_page.
  Attempting to use the returned page could then cause either memory
  corruption or a page fault.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.c	Wed Apr 11 21:33:45 2012	(r234154)
+++ head/sys/powerpc/aim/mmu_oea64.c	Wed Apr 11 21:56:55 2012	(r234155)
@@ -1906,17 +1906,15 @@ moea64_pvo_protect(mmu_t mmu,  pmap_t pm
 	/*
 	 * If the PVO is in the page table, update that pte as well.
 	 */
-	if (pt != -1) {
+	if (pt != -1)
 		MOEA64_PTE_CHANGE(mmu, pt, &pvo->pvo_pte.lpte,
 		    pvo->pvo_vpn);
-		if (pm != kernel_pmap && pg != NULL &&
-		    !(pg->aflags & PGA_EXECUTABLE) &&
-		    (pvo->pvo_pte.lpte.pte_lo &
-		     (LPTE_I | LPTE_G | LPTE_NOEXEC)) == 0) {
+	if (pm != kernel_pmap && pg != NULL && !(pg->aflags & PGA_EXECUTABLE) &&
+	    (pvo->pvo_pte.lpte.pte_lo & (LPTE_I | LPTE_G | LPTE_NOEXEC)) == 0) {
+		if ((pg->oflags & VPO_UNMANAGED) == 0)
 			vm_page_aflag_set(pg, PGA_EXECUTABLE);
-			moea64_syncicache(mmu, pm, PVO_VADDR(pvo),
-			    pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN, PAGE_SIZE);
-		}
+		moea64_syncicache(mmu, pm, PVO_VADDR(pvo),
+		    pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN, PAGE_SIZE);
 	}
 
 	/*
@@ -2368,9 +2366,8 @@ moea64_pvo_remove(mmu_t mmu, struct pvo_
 	 */
 	pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN);
 
-	if ((pvo->pvo_vaddr & PVO_MANAGED) == PVO_MANAGED &&
-	    (pvo->pvo_pte.lpte.pte_lo & LPTE_PP) != LPTE_BR) {
-		if (pg != NULL) {
+	if ((pvo->pvo_vaddr & PVO_MANAGED) == PVO_MANAGED && pg != NULL) {
+		if ((pvo->pvo_pte.lpte.pte_lo & LPTE_PP) != LPTE_BR) {
 			if (pvo->pvo_pte.lpte.pte_lo & LPTE_CHG)
 				vm_page_dirty(pg);
 			if (pvo->pvo_pte.lpte.pte_lo & LPTE_REF)
@@ -2378,11 +2375,10 @@ moea64_pvo_remove(mmu_t mmu, struct pvo_
 			if (LIST_EMPTY(vm_page_to_pvoh(pg)))
 				vm_page_aflag_clear(pg, PGA_WRITEABLE);
 		}
+		if (LIST_EMPTY(vm_page_to_pvoh(pg)))
+			vm_page_aflag_clear(pg, PGA_EXECUTABLE);
 	}
 
-	if (pg != NULL && LIST_EMPTY(vm_page_to_pvoh(pg)))
-		vm_page_aflag_clear(pg, PGA_EXECUTABLE);
-
 	moea64_pvo_entries--;
 	moea64_pvo_remove_calls++;
 



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