Date: Thu, 28 Jun 2012 19:19:38 +0000 (UTC) From: "Cherry G. Mathew" <cherry@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r237723 - projects/amd64_xen_pv/sys/amd64/xen Message-ID: <201206281919.q5SJJcEP093934@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/param.h> #include <sys/systm.h> +#include <sys/cpuset.h> #include <sys/ktr.h> #include <sys/lock.h> #include <sys/msgbuf.h> @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206281919.q5SJJcEP093934>