From owner-svn-src-projects@FreeBSD.ORG Thu Sep 19 01:12:59 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id AD1FF354; Thu, 19 Sep 2013 01:12:59 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9AE98243D; Thu, 19 Sep 2013 01:12:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8J1Cxer089839; Thu, 19 Sep 2013 01:12:59 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8J1CxF0089838; Thu, 19 Sep 2013 01:12:59 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201309190112.r8J1CxF0089838@svn.freebsd.org> From: Neel Natu Date: Thu, 19 Sep 2013 01:12:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r255683 - 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: Thu, 19 Sep 2013 01:12:59 -0000 Author: neel Date: Thu Sep 19 01:12:59 2013 New Revision: 255683 URL: http://svnweb.freebsd.org/changeset/base/255683 Log: For a nested pmap make sure that its 'pm_cr3' is invalid and thus is guaranteed to trigger an exception if loaded into the host's %cr3. Requested by: kib@ 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 19 00:32:07 2013 (r255682) +++ projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Thu Sep 19 01:12:59 2013 (r255683) @@ -2139,6 +2139,7 @@ pmap_pinit_type(pmap_t pmap, enum pmap_t { vm_page_t pml4pg; pt_entry_t PG_A, PG_M; + vm_paddr_t pml4phys; int i; /* @@ -2148,9 +2149,10 @@ pmap_pinit_type(pmap_t pmap, enum pmap_t VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_ZERO)) == NULL) VM_WAIT; - pmap->pm_cr3 = VM_PAGE_TO_PHYS(pml4pg); - pmap->pm_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(pmap->pm_cr3); + pml4phys = VM_PAGE_TO_PHYS(pml4pg); + pmap->pm_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(pml4phys); pmap->pm_pcid = -1; + pmap->pm_cr3 = ~0; /* initialize to an invalid value */ if ((pml4pg->flags & PG_ZERO) == 0) pagezero(pmap->pm_pml4); @@ -2164,6 +2166,8 @@ pmap_pinit_type(pmap_t pmap, enum pmap_t PG_A = pmap_accessed_bit(pmap); PG_M = pmap_modified_bit(pmap); + pmap->pm_cr3 = pml4phys; + /* Wire in kernel global address entries. */ for (i = 0; i < NKPML4E; i++) { pmap->pm_pml4[KPML4BASE + i] = (KPDPphys + ptoa(i)) |