From owner-svn-src-projects@FreeBSD.ORG Mon Jul 1 19:58:13 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B81C9A2F; Mon, 1 Jul 2013 19:58:13 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id AB0231E7E; Mon, 1 Jul 2013 19:58:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r61JwDd0034751; Mon, 1 Jul 2013 19:58:13 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r61JwD20034750; Mon, 1 Jul 2013 19:58:13 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201307011958.r61JwD20034750@svn.freebsd.org> From: Neel Natu Date: Mon, 1 Jul 2013 19:58:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r252474 - projects/bhyve_npt_pmap/sys/amd64/amd64 X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jul 2013 19:58:13 -0000 Author: neel Date: Mon Jul 1 19:58:13 2013 New Revision: 252474 URL: http://svnweb.freebsd.org/changeset/base/252474 Log: If a superpage mapping is being removed then we need to ignore the PG_PDE_PAT bit when looking up the vm_page associated with the superpage's physical address. If the caching attribute for the mapping is write combining or write protected then the PG_PDE_PAT bit will be set and thus cause an 'off-by-one' error when looking up the vm_page. Fix this by using the PG_PS_FRAME mask to compute the physical address for a superpage mapping instead of PG_FRAME. 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 Mon Jul 1 18:58:59 2013 (r252473) +++ projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Mon Jul 1 19:58:13 2013 (r252474) @@ -4752,6 +4752,7 @@ pmap_remove_pages(pmap_t pmap) int64_t bit; uint64_t inuse, bitmask; int allfree, field, freed, idx; + vm_paddr_t pa; if (pmap != PCPU_GET(curpmap)) { printf("warning: pmap_remove_pages called with non-current pmap\n"); @@ -4784,7 +4785,7 @@ pmap_remove_pages(pmap_t pmap) pte = (pt_entry_t *)PHYS_TO_DMAP(tpte & PG_FRAME); pte = &pte[pmap_pte_index(pv->pv_va)]; - tpte = *pte & ~PG_PTE_PAT; + tpte = *pte; } if ((tpte & PG_V) == 0) { panic("bad pte va %lx pte %lx", @@ -4799,8 +4800,13 @@ pmap_remove_pages(pmap_t pmap) continue; } - m = PHYS_TO_VM_PAGE(tpte & PG_FRAME); - KASSERT(m->phys_addr == (tpte & PG_FRAME), + if (tpte & PG_PS) + pa = tpte & PG_PS_FRAME; + else + pa = tpte & PG_FRAME; + + m = PHYS_TO_VM_PAGE(pa); + KASSERT(m->phys_addr == pa, ("vm_page_t %p phys_addr mismatch %016jx %016jx", m, (uintmax_t)m->phys_addr, (uintmax_t)tpte));