From owner-svn-src-all@FreeBSD.ORG Sun Mar 22 04:32:06 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57766106564A; Sun, 22 Mar 2009 04:32:06 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3A7348FC13; Sun, 22 Mar 2009 04:32:06 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2M4W5WZ056685; Sun, 22 Mar 2009 04:32:05 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2M4W5bH056682; Sun, 22 Mar 2009 04:32:05 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200903220432.n2M4W5bH056682@svn.freebsd.org> From: Alan Cox Date: Sun, 22 Mar 2009 04:32:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190239 - in head/sys/amd64: amd64 include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Mar 2009 04:32:06 -0000 Author: alc Date: Sun Mar 22 04:32:05 2009 New Revision: 190239 URL: http://svn.freebsd.org/changeset/base/190239 Log: In general, the kernel virtual address of the pml4 page table page that is stored in the pmap is from the direct map region. The two exceptions have been the kernel pmap and the swapper's pmap. These pmaps have used a kernel virtual address established by pmap_bootstrap() for their shared pml4 page table page. However, there is no reason not to use the direct map for these pmaps as well. Modified: head/sys/amd64/amd64/pmap.c head/sys/amd64/amd64/vm_machdep.c head/sys/amd64/include/pmap.h Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Sun Mar 22 04:19:36 2009 (r190238) +++ head/sys/amd64/amd64/pmap.c Sun Mar 22 04:32:05 2009 (r190239) @@ -542,7 +542,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr) * Initialize the kernel pmap (which is statically allocated). */ PMAP_LOCK_INIT(kernel_pmap); - kernel_pmap->pm_pml4 = (pdp_entry_t *) (KERNBASE + KPML4phys); + kernel_pmap->pm_pml4 = (pdp_entry_t *)PHYS_TO_DMAP(KPML4phys); kernel_pmap->pm_root = NULL; kernel_pmap->pm_active = -1; /* don't allow deactivation */ TAILQ_INIT(&kernel_pmap->pm_pvchunk); @@ -1351,7 +1351,7 @@ pmap_pinit0(pmap_t pmap) { PMAP_LOCK_INIT(pmap); - pmap->pm_pml4 = (pml4_entry_t *)(KERNBASE + KPML4phys); + pmap->pm_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(KPML4phys); pmap->pm_root = NULL; pmap->pm_active = 0; TAILQ_INIT(&pmap->pm_pvchunk); @@ -4695,7 +4695,7 @@ if (oldpmap) /* XXX FIXME */ oldpmap->pm_active &= ~PCPU_GET(cpumask); pmap->pm_active |= PCPU_GET(cpumask); #endif - cr3 = vtophys(pmap->pm_pml4); + cr3 = DMAP_TO_PHYS((vm_offset_t)pmap->pm_pml4); td->td_pcb->pcb_cr3 = cr3; load_cr3(cr3); critical_exit(); Modified: head/sys/amd64/amd64/vm_machdep.c ============================================================================== --- head/sys/amd64/amd64/vm_machdep.c Sun Mar 22 04:19:36 2009 (r190238) +++ head/sys/amd64/amd64/vm_machdep.c Sun Mar 22 04:32:05 2009 (r190239) @@ -103,6 +103,7 @@ cpu_fork(td1, p2, td2, flags) register struct proc *p1; struct pcb *pcb2; struct mdproc *mdp2; + pmap_t pmap2; p1 = td1->td_proc; if ((flags & RFPROC) == 0) @@ -150,7 +151,8 @@ cpu_fork(td1, p2, td2, flags) * Set registers for trampoline to user mode. Leave space for the * return address on stack. These are the kernel mode register values. */ - pcb2->pcb_cr3 = vtophys(vmspace_pmap(p2->p_vmspace)->pm_pml4); + pmap2 = vmspace_pmap(p2->p_vmspace); + pcb2->pcb_cr3 = DMAP_TO_PHYS((vm_offset_t)pmap2->pm_pml4); pcb2->pcb_r12 = (register_t)fork_return; /* fork_trampoline argument */ pcb2->pcb_rbp = 0; pcb2->pcb_rsp = (register_t)td2->td_frame - sizeof(void *); Modified: head/sys/amd64/include/pmap.h ============================================================================== --- head/sys/amd64/include/pmap.h Sun Mar 22 04:19:36 2009 (r190238) +++ head/sys/amd64/include/pmap.h Sun Mar 22 04:32:05 2009 (r190239) @@ -243,6 +243,10 @@ struct md_page { TAILQ_HEAD(,pv_entry) pv_list; }; +/* + * The kernel virtual address (KVA) of the level 4 page table page is always + * within the direct map (DMAP) region. + */ struct pmap { struct mtx pm_mtx; pml4_entry_t *pm_pml4; /* KVA of level 4 page table */