From owner-svn-src-all@FreeBSD.ORG  Mon Jun  8 12:15:39 2009
Return-Path: <owner-svn-src-all@FreeBSD.ORG>
Delivered-To: svn-src-all@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B3383106566B;
	Mon,  8 Jun 2009 12:15:39 +0000 (UTC) (envelope-from raj@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id A20758FC1C;
	Mon,  8 Jun 2009 12:15:39 +0000 (UTC) (envelope-from raj@FreeBSD.org)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n58CFdCm029050;
	Mon, 8 Jun 2009 12:15:39 GMT (envelope-from raj@svn.freebsd.org)
Received: (from raj@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id n58CFdOl029049;
	Mon, 8 Jun 2009 12:15:39 GMT (envelope-from raj@svn.freebsd.org)
Message-Id: <200906081215.n58CFdOl029049@svn.freebsd.org>
From: Rafal Jaworowski <raj@FreeBSD.org>
Date: Mon, 8 Jun 2009 12:15:39 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-head@freebsd.org
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r193712 - head/sys/arm/arm
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
	user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 08 Jun 2009 12:15:40 -0000

Author: raj
Date: Mon Jun  8 12:15:39 2009
New Revision: 193712
URL: http://svn.freebsd.org/changeset/base/193712

Log:
  Invalidate cache in pmap_remove_all() on ARM.
  
  When pages are removed from virtual address space by calling pmap_remove_all()
  CPU caches were not invalidated, which led to read corruption when another
  page got mapped at this same virtual address at later time (the CPU was
  retrieving stale contents).
  
  Submitted by:	Piotr Ziecik
  Obtained from:	Semihalf

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

Modified: head/sys/arm/arm/pmap.c
==============================================================================
--- head/sys/arm/arm/pmap.c	Mon Jun  8 12:10:42 2009	(r193711)
+++ head/sys/arm/arm/pmap.c	Mon Jun  8 12:15:39 2009	(r193712)
@@ -3124,7 +3124,19 @@ pmap_remove_all(vm_page_t m)
 		if (flush == FALSE && (pv->pv_pmap == curpm ||
 		    pv->pv_pmap == pmap_kernel()))
 			flush = TRUE;
+
 		PMAP_LOCK(pv->pv_pmap);
+		/*
+		 * Cached contents were written-back in pmap_remove_write(),
+		 * but we still have to invalidate the cache entry to make
+		 * sure stale data are not retrieved when another page will be
+		 * mapped under this virtual address.
+		 */
+		if (pmap_is_current(pv->pv_pmap)) {
+			cpu_dcache_inv_range(pv->pv_va, PAGE_SIZE);
+			cpu_l2cache_inv_range(pv->pv_va, PAGE_SIZE);
+		}
+
 		l2b = pmap_get_l2_bucket(pv->pv_pmap, pv->pv_va);
 		KASSERT(l2b != NULL, ("No l2 bucket"));
 		ptep = &l2b->l2b_kva[l2pte_index(pv->pv_va)];