From owner-svn-src-projects@FreeBSD.ORG Thu Jun 28 19:19:38 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EEF3F1065670; Thu, 28 Jun 2012 19:19:38 +0000 (UTC) (envelope-from cherry@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C08518FC08; Thu, 28 Jun 2012 19:19:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5SJJcsY093936; Thu, 28 Jun 2012 19:19:38 GMT (envelope-from cherry@svn.freebsd.org) Received: (from cherry@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5SJJcEP093934; Thu, 28 Jun 2012 19:19:38 GMT (envelope-from cherry@svn.freebsd.org) Message-Id: <201206281919.q5SJJcEP093934@svn.freebsd.org> From: "Cherry G. Mathew" Date: Thu, 28 Jun 2012 19:19:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237723 - projects/amd64_xen_pv/sys/amd64/xen X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 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, 28 Jun 2012 19:19:39 -0000 Author: cherry Date: Thu Jun 28 19:19:38 2012 New Revision: 237723 URL: http://svn.freebsd.org/changeset/base/237723 Log: Initialise kernel and process0 pmaps. Approved by: gibbs (implicit) Modified: projects/amd64_xen_pv/sys/amd64/xen/pmap.c Modified: projects/amd64_xen_pv/sys/amd64/xen/pmap.c ============================================================================== --- projects/amd64_xen_pv/sys/amd64/xen/pmap.c Thu Jun 28 18:52:40 2012 (r237722) +++ projects/amd64_xen_pv/sys/amd64/xen/pmap.c Thu Jun 28 19:19:38 2012 (r237723) @@ -119,6 +119,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -615,14 +616,51 @@ pmap_init(void) void pmap_pinit0(pmap_t pmap) { - KASSERT(0, ("XXX: TODO\n")); + PMAP_LOCK_INIT(pmap); + pmap->pm_pml4 = (void *) KPML4phys; + pmap->pm_root = NULL; + CPU_ZERO(&pmap->pm_active); + PCPU_SET(curpmap, pmap); + TAILQ_INIT(&pmap->pm_pvchunk); + bzero(&pmap->pm_stats, sizeof pmap->pm_stats); } int pmap_pinit(pmap_t pmap) { - KASSERT(0, ("XXX: TODO\n")); - return -1; + + KASSERT(pmap != kernel_pmap, + ("kernel map re-initialised!")); + + PMAP_LOCK_INIT(pmap); + + /* + * allocate the page directory page + */ + pmap->pm_pml4 = (void *) kmem_alloc(kernel_map, PAGE_SIZE); + bzero(pmap->pm_pml4, PAGE_SIZE); + + /* + * We do not wire in kernel space, or the self-referencial + * entry in userspace pmaps for two reasons: + * i) both kernel and userland run in ring3 (same CPU + * privilege level). This means that userland that has kernel + * address space mapped in, can access kernel memory! + * Instead, we make the kernel pmap is exclusive and + * unshared, and we switch to it on *every* kernel + * entry. This is facilitated by the hypervisor. + * ii) we access the user pmap from within kernel VA. The + * self-referencing entry is useful if we access the pmap + * from the *user* VA. + * XXX: review this when userland is up. + */ + + pmap->pm_root = NULL; + CPU_ZERO(&pmap->pm_active); + TAILQ_INIT(&pmap->pm_pvchunk); + bzero(&pmap->pm_stats, sizeof pmap->pm_stats); + + return 1; } void @@ -737,6 +775,7 @@ void * pmap_kenter_temporary(vm_paddr_t pa, int i) { KASSERT(0, ("XXX: TODO\n")); + return NULL; } void