Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Jun 2009 09:09:46 +0000 (UTC)
From:      Rafal Jaworowski <raj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r193489 - head/sys/powerpc/booke
Message-ID:  <200906050909.n5599kOe019892@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: raj
Date: Fri Jun  5 09:09:46 2009
New Revision: 193489
URL: http://svn.freebsd.org/changeset/base/193489

Log:
  Fill PTEs covering kernel code and data.
  
  Without this fix pte_vatopa() was not able to retrieve physical address of
  data structures inside kernel, for example EFAULT was reported while acessing
  /dev/kmem ('netstat -nr').
  
  Submitted by:	Piotr Ziecik
  Obtained from:	Semihalf

Modified:
  head/sys/powerpc/booke/pmap.c

Modified: head/sys/powerpc/booke/pmap.c
==============================================================================
--- head/sys/powerpc/booke/pmap.c	Fri Jun  5 09:08:53 2009	(r193488)
+++ head/sys/powerpc/booke/pmap.c	Fri Jun  5 09:09:46 2009	(r193489)
@@ -966,8 +966,9 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset
 	u_int s, e, sz;
 	u_int phys_avail_count;
 	vm_size_t physsz, hwphyssz, kstack0_sz;
-	vm_offset_t kernel_pdir, kstack0;
+	vm_offset_t kernel_pdir, kstack0, va;
 	vm_paddr_t kstack0_phys;
+	pte_t *pte;
 
 	debugf("mmu_booke_bootstrap: entered\n");
 
@@ -1216,6 +1217,19 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset
 		/* Initialize each CPU's tidbusy entry 0 with kernel_pmap */
 		tidbusy[i][0] = kernel_pmap;
 	}
+
+	/*
+	 * Fill in PTEs covering kernel code and data. They are not required
+	 * for address translation, as this area is covered by static TLB1
+	 * entries, but for pte_vatopa() to work correctly with kernel area
+	 * addresses.
+	 */
+	for (va = KERNBASE; va < data_end; va += PAGE_SIZE) {
+		pte = &(kernel_pmap->pm_pdir[PDIR_IDX(va)][PTBL_IDX(va)]);
+		pte->rpn = kernload + (va - KERNBASE);
+		pte->flags = PTE_M | PTE_SR | PTE_SW | PTE_SX | PTE_WIRED |
+		    PTE_VALID;
+	}
 	/* Mark kernel_pmap active on all CPUs */
 	kernel_pmap->pm_active = ~0;
 



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