From owner-svn-src-projects@FreeBSD.ORG Wed Jun 26 05:36:53 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 00734CAB; Wed, 26 Jun 2013 05:36:52 +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 D58421EF9; Wed, 26 Jun 2013 05:36:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5Q5aqbW001656; Wed, 26 Jun 2013 05:36:52 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5Q5aquI001654; Wed, 26 Jun 2013 05:36:52 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201306260536.r5Q5aquI001654@svn.freebsd.org> From: Neel Natu Date: Wed, 26 Jun 2013 05:36:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r252244 - in projects/bhyve_npt_pmap/sys/amd64: amd64 include 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: Wed, 26 Jun 2013 05:36:53 -0000 Author: neel Date: Wed Jun 26 05:36:51 2013 New Revision: 252244 URL: http://svnweb.freebsd.org/changeset/base/252244 Log: Add a function to initialize a pmap with the specified type. The existing pmap_pinit() now becomes a wrapper around this function. Install the shared kernel mappings only in regular x86 page tables. These mappings are meaningless in a nested page table which describes the guest physical address space. This was prompted by a discussion with Alax Cox. Modified: projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c projects/bhyve_npt_pmap/sys/amd64/include/pmap.h Modified: projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Wed Jun 26 05:03:47 2013 (r252243) +++ projects/bhyve_npt_pmap/sys/amd64/amd64/pmap.c Wed Jun 26 05:36:51 2013 (r252244) @@ -1669,7 +1669,7 @@ pmap_pinit0(pmap_t pmap) * such as one in a vmspace structure. */ int -pmap_pinit(pmap_t pmap) +pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type) { vm_page_t pml4pg; int i; @@ -1688,17 +1688,24 @@ pmap_pinit(pmap_t pmap) if ((pml4pg->flags & PG_ZERO) == 0) pagezero(pmap->pm_pml4); - /* Wire in kernel global address entries. */ - pmap->pm_pml4[KPML4I] = KPDPphys | PG_RW | PG_V | PG_U; - for (i = 0; i < NDMPML4E; i++) { - pmap->pm_pml4[DMPML4I + i] = (DMPDPphys + (i << PAGE_SHIFT)) | - PG_RW | PG_V | PG_U; - } + /* + * Do not install the host kernel mappings in the nested page + * tables. These mappings are meaningless in the guest physical + * address space. + */ + if ((pmap->pm_type = pm_type) == PT_X86) { + /* Wire in kernel global address entries. */ + pmap->pm_pml4[KPML4I] = KPDPphys | PG_RW | PG_V | PG_U; + for (i = 0; i < NDMPML4E; i++) { + pmap->pm_pml4[DMPML4I + i] = + (DMPDPphys + (i << PAGE_SHIFT)) | PG_RW | PG_V | PG_U; + } - /* install self-referential address mapping entry(s) */ - pmap->pm_pml4[PML4PML4I] = VM_PAGE_TO_PHYS(pml4pg) | PG_V | PG_RW | PG_A | PG_M; + /* install self-referential address mapping entry(s) */ + pmap->pm_pml4[PML4PML4I] = + VM_PAGE_TO_PHYS(pml4pg) | PG_V | PG_RW | PG_A | PG_M; + } - pmap->pm_type = PT_X86; pmap->pm_root.rt_root = 0; CPU_ZERO(&pmap->pm_active); TAILQ_INIT(&pmap->pm_pvchunk); @@ -1707,6 +1714,13 @@ pmap_pinit(pmap_t pmap) return (1); } +int +pmap_pinit(pmap_t pmap) +{ + + return (pmap_pinit_type(pmap, PT_X86)); +} + /* * This routine is called if the desired page table page does not exist. * Modified: projects/bhyve_npt_pmap/sys/amd64/include/pmap.h ============================================================================== --- projects/bhyve_npt_pmap/sys/amd64/include/pmap.h Wed Jun 26 05:03:47 2013 (r252243) +++ projects/bhyve_npt_pmap/sys/amd64/include/pmap.h Wed Jun 26 05:36:51 2013 (r252244) @@ -272,6 +272,8 @@ extern struct pmap kernel_pmap_store; #define PMAP_MTX(pmap) (&(pmap)->pm_mtx) #define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) #define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) + +int pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type); #endif /*