summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2010-01-11 16:01:20 +0000
committeralc <alc@FreeBSD.org>2010-01-11 16:01:20 +0000
commitcd3015a67bce7ba4abc953858bb8b741950505c6 (patch)
tree6b890fd147c809191d81c3a61219206d3cd04313
parentb71264af8e694514e68f53fd7210b617105bd60f (diff)
downloadFreeBSD-src-cd3015a67bce7ba4abc953858bb8b741950505c6.zip
FreeBSD-src-cd3015a67bce7ba4abc953858bb8b741950505c6.tar.gz
Simplify pmap_init(). Additionally, correct a harmless misbehavior on i386.
Specifically, where locore had created large page mappings for the kernel, the wrong vm page array entries were being initialized. The vm page array entries for the pages containing the kernel were being initialized instead of the vm page array entries for page table pages. MFC after: 1 week
-rw-r--r--sys/amd64/amd64/pmap.c10
-rw-r--r--sys/i386/i386/locore.s2
-rw-r--r--sys/i386/i386/pmap.c7
3 files changed, 6 insertions, 13 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 44b71f3..889a06a 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -664,7 +664,6 @@ pmap_page_init(vm_page_t m)
void
pmap_init(void)
{
- pd_entry_t *pd;
vm_page_t mpte;
vm_size_t s;
int i, pv_npg;
@@ -673,18 +672,13 @@ pmap_init(void)
* Initialize the vm page array entries for the kernel pmap's
* page table pages.
*/
- pd = pmap_pde(kernel_pmap, KERNBASE);
for (i = 0; i < NKPT; i++) {
- if ((pd[i] & (PG_PS | PG_V)) == (PG_PS | PG_V))
- continue;
- KASSERT((pd[i] & PG_V) != 0,
- ("pmap_init: page table page is missing"));
- mpte = PHYS_TO_VM_PAGE(pd[i] & PG_FRAME);
+ mpte = PHYS_TO_VM_PAGE(KPTphys + (i << PAGE_SHIFT));
KASSERT(mpte >= vm_page_array &&
mpte < &vm_page_array[vm_page_array_size],
("pmap_init: page table page is out of range"));
mpte->pindex = pmap_pde_pindex(KERNBASE) + i;
- mpte->phys_addr = pd[i] & PG_FRAME;
+ mpte->phys_addr = KPTphys + (i << PAGE_SHIFT);
}
/*
diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s
index eee9fdb..170aaf1 100644
--- a/sys/i386/i386/locore.s
+++ b/sys/i386/i386/locore.s
@@ -104,9 +104,7 @@ IdlePTD: .long 0 /* phys addr of kernel PTD */
IdlePDPT: .long 0 /* phys addr of kernel PDPT */
#endif
-#ifdef SMP
.globl KPTphys
-#endif
KPTphys: .long 0 /* phys addr of kernel page tables */
.globl proc0kstack
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 794aa02..993b13e 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -206,6 +206,7 @@ int pseflag = 0; /* PG_PS or-in */
static int nkpt;
vm_offset_t kernel_vm_end;
extern u_int32_t KERNend;
+extern u_int32_t KPTphys;
#ifdef PAE
pt_entry_t pg_nx;
@@ -659,13 +660,13 @@ pmap_init(void)
* Initialize the vm page array entries for the kernel pmap's
* page table pages.
*/
- for (i = 0; i < nkpt; i++) {
- mpte = PHYS_TO_VM_PAGE(PTD[i + KPTDI] & PG_FRAME);
+ for (i = 0; i < NKPT; i++) {
+ mpte = PHYS_TO_VM_PAGE(KPTphys + (i << PAGE_SHIFT));
KASSERT(mpte >= vm_page_array &&
mpte < &vm_page_array[vm_page_array_size],
("pmap_init: page table page is out of range"));
mpte->pindex = i + KPTDI;
- mpte->phys_addr = PTD[i + KPTDI] & PG_FRAME;
+ mpte->phys_addr = KPTphys + (i << PAGE_SHIFT);
}
/*
OpenPOWER on IntegriCloud