From owner-svn-src-all@FreeBSD.ORG Mon Jan 25 15:50:52 2010 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 AAA4E1065672; Mon, 25 Jan 2010 15:50:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9936E8FC1E; Mon, 25 Jan 2010 15:50:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0PFoqOq007669; Mon, 25 Jan 2010 15:50:52 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0PFoqlb007665; Mon, 25 Jan 2010 15:50:52 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201001251550.o0PFoqlb007665@svn.freebsd.org> From: John Baldwin Date: Mon, 25 Jan 2010 15:50:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202970 - in stable/7/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: Mon, 25 Jan 2010 15:50:52 -0000 Author: jhb Date: Mon Jan 25 15:50:52 2010 New Revision: 202970 URL: http://svn.freebsd.org/changeset/base/202970 Log: MFC 190239: 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. Approved by: re (kib) Modified: stable/7/sys/amd64/amd64/pmap.c stable/7/sys/amd64/amd64/vm_machdep.c stable/7/sys/amd64/include/pmap.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/amd64/amd64/pmap.c ============================================================================== --- stable/7/sys/amd64/amd64/pmap.c Mon Jan 25 14:17:36 2010 (r202969) +++ stable/7/sys/amd64/amd64/pmap.c Mon Jan 25 15:50:52 2010 (r202970) @@ -528,7 +528,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); @@ -4569,7 +4569,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: stable/7/sys/amd64/amd64/vm_machdep.c ============================================================================== --- stable/7/sys/amd64/amd64/vm_machdep.c Mon Jan 25 14:17:36 2010 (r202969) +++ stable/7/sys/amd64/amd64/vm_machdep.c Mon Jan 25 15:50:52 2010 (r202970) @@ -109,6 +109,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) @@ -156,7 +157,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: stable/7/sys/amd64/include/pmap.h ============================================================================== --- stable/7/sys/amd64/include/pmap.h Mon Jan 25 14:17:36 2010 (r202969) +++ stable/7/sys/amd64/include/pmap.h Mon Jan 25 15:50:52 2010 (r202970) @@ -238,6 +238,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 */