Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jan 2010 15:50:52 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r202970 - in stable/7/sys/amd64: amd64 include
Message-ID:  <201001251550.o0PFoqlb007665@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001251550.o0PFoqlb007665>