summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjake <jake@FreeBSD.org>2003-02-23 21:20:00 +0000
committerjake <jake@FreeBSD.org>2003-02-23 21:20:00 +0000
commitc614cef2af17fe4c523a48a9f77274187ebc9bc4 (patch)
treef9a063d9107dd28be16b7af3fa39b8c300d71592
parent9318f6d82c57682e409deb011440527b6179d5a0 (diff)
downloadFreeBSD-src-c614cef2af17fe4c523a48a9f77274187ebc9bc4.zip
FreeBSD-src-c614cef2af17fe4c523a48a9f77274187ebc9bc4.tar.gz
- Added macros NPGPTD, NBPTD, and NPDEPTD, for dealing with the size of the
page directory. - Use these instead of the magic constants 1 or PAGE_SIZE where appropriate. There are still numerous assumptions that the page directory is exactly 1 page. Sponsored by: DARPA, Network Associates Laboratories
-rw-r--r--sys/amd64/amd64/genassym.c1
-rw-r--r--sys/amd64/amd64/locore.S4
-rw-r--r--sys/amd64/amd64/locore.s4
-rw-r--r--sys/amd64/amd64/pmap.c13
-rw-r--r--sys/amd64/amd64/vm_machdep.c2
-rw-r--r--sys/amd64/include/pmap.h8
-rw-r--r--sys/i386/i386/genassym.c1
-rw-r--r--sys/i386/i386/locore.s4
-rw-r--r--sys/i386/i386/pmap.c13
-rw-r--r--sys/i386/i386/vm_machdep.c2
-rw-r--r--sys/i386/include/param.h6
-rw-r--r--sys/i386/include/pmap.h8
12 files changed, 37 insertions, 29 deletions
diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c
index 7d80831..e681e20 100644
--- a/sys/amd64/amd64/genassym.c
+++ b/sys/amd64/amd64/genassym.c
@@ -108,6 +108,7 @@ ASSYM(KSTACK_PAGES, KSTACK_PAGES);
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(NPTEPG, NPTEPG);
ASSYM(NPDEPG, NPDEPG);
+ASSYM(NPGPTD, NPGPTD);
ASSYM(PDESIZE, sizeof(pd_entry_t));
ASSYM(PTESIZE, sizeof(pt_entry_t));
ASSYM(PTESHIFT, PTESHIFT);
diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S
index afd9a66..38ac211 100644
--- a/sys/amd64/amd64/locore.S
+++ b/sys/amd64/amd64/locore.S
@@ -749,7 +749,7 @@ no_kernend:
movl %esi,R(KPTphys)
/* Allocate Page Table Directory */
- ALLOCPAGES(1)
+ ALLOCPAGES(NPGPTD)
movl %esi,R(IdlePTD)
/* Allocate UPAGES */
@@ -805,7 +805,7 @@ no_kernend:
/* Map page directory. */
movl R(IdlePTD), %eax
- movl $1, %ecx
+ movl $NPGPTD, %ecx
fillkptphys($PG_RW)
/* Map proc0's UPAGES in the physical way ... */
diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s
index afd9a66..38ac211 100644
--- a/sys/amd64/amd64/locore.s
+++ b/sys/amd64/amd64/locore.s
@@ -749,7 +749,7 @@ no_kernend:
movl %esi,R(KPTphys)
/* Allocate Page Table Directory */
- ALLOCPAGES(1)
+ ALLOCPAGES(NPGPTD)
movl %esi,R(IdlePTD)
/* Allocate UPAGES */
@@ -805,7 +805,7 @@ no_kernend:
/* Map page directory. */
movl R(IdlePTD), %eax
- movl $1, %ecx
+ movl $NPGPTD, %ecx
fillkptphys($PG_RW)
/* Map proc0's UPAGES in the physical way ... */
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index d141abb..e5b8a7c 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -1286,14 +1286,15 @@ pmap_pinit(pmap)
* page directory table.
*/
if (pmap->pm_pdir == NULL)
- pmap->pm_pdir =
- (pd_entry_t *)kmem_alloc_pageable(kernel_map, PAGE_SIZE);
+ pmap->pm_pdir = (pd_entry_t *)kmem_alloc_pageable(kernel_map,
+ NBPTD);
/*
* allocate object for the ptes
*/
if (pmap->pm_pteobj == NULL)
- pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI + 1);
+ pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI +
+ NPGPTD);
/*
* allocate the page directory page
@@ -1305,7 +1306,7 @@ pmap_pinit(pmap)
ptdpg->valid = VM_PAGE_BITS_ALL;
vm_page_unlock_queues();
- pmap_qenter((vm_offset_t) pmap->pm_pdir, &ptdpg, 1);
+ pmap_qenter((vm_offset_t)pmap->pm_pdir, &ptdpg, NPGPTD);
if ((ptdpg->flags & PG_ZERO) == 0)
bzero(pmap->pm_pdir, PAGE_SIZE);
@@ -3423,7 +3424,7 @@ pmap_pid_dump(int pid)
int i,j;
index = 0;
pmap = vmspace_pmap(p->p_vmspace);
- for (i = 0; i < NPDEPG; i++) {
+ for (i = 0; i < NPDEPTD; i++) {
pd_entry_t *pde;
pt_entry_t *pte;
vm_offset_t base = i << PDRSHIFT;
@@ -3483,7 +3484,7 @@ pads(pm)
if (pm == kernel_pmap)
return;
- for (i = 0; i < NPDEPG; i++)
+ for (i = 0; i < NPDEPTD; i++)
if (pm->pm_pdir[i])
for (j = 0; j < NPTEPG; j++) {
va = (i << PDRSHIFT) + (j << PAGE_SHIFT);
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index 903a2b0..45148e9 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -514,7 +514,7 @@ cpu_reset_real()
#endif
#endif /* PC98 */
/* force a shutdown by unmapping entire address space ! */
- bzero((caddr_t) PTD, PAGE_SIZE);
+ bzero((caddr_t)PTD, NBPTD);
/* "good night, sweet prince .... <THUNK!>" */
invltlb();
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h
index 44f0b25..0cd3944 100644
--- a/sys/amd64/include/pmap.h
+++ b/sys/amd64/include/pmap.h
@@ -101,9 +101,9 @@
#endif
#ifndef NKPDE
#ifdef SMP
-#define NKPDE (KVA_PAGES - 2) /* addressable number of page tables/pde's */
+#define NKPDE (KVA_PAGES - (NPGPTD + 1)) /* number of page tables/pde's */
#else
-#define NKPDE (KVA_PAGES - 1) /* addressable number of page tables/pde's */
+#define NKPDE (KVA_PAGES - NPGPTD) /* number of page tables/pde's */
#endif
#endif
@@ -115,14 +115,14 @@
*
* SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff
*/
-#define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */
+#define APTDPTDI (NPDEPG-NPGPTD) /* alt ptd entry that points to APTD */
#ifdef SMP
#define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */
#define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */
#else
#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */
#endif /* SMP */
-#define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */
+#define PTDPTDI (KPTDI-NPGPTD) /* ptd entry that points to ptd! */
#define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */
#define UMAXPTEOFF (NPTEPG) /* pte entry for user space end */
diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c
index 7d80831..e681e20 100644
--- a/sys/i386/i386/genassym.c
+++ b/sys/i386/i386/genassym.c
@@ -108,6 +108,7 @@ ASSYM(KSTACK_PAGES, KSTACK_PAGES);
ASSYM(PAGE_SIZE, PAGE_SIZE);
ASSYM(NPTEPG, NPTEPG);
ASSYM(NPDEPG, NPDEPG);
+ASSYM(NPGPTD, NPGPTD);
ASSYM(PDESIZE, sizeof(pd_entry_t));
ASSYM(PTESIZE, sizeof(pt_entry_t));
ASSYM(PTESHIFT, PTESHIFT);
diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s
index afd9a66..38ac211 100644
--- a/sys/i386/i386/locore.s
+++ b/sys/i386/i386/locore.s
@@ -749,7 +749,7 @@ no_kernend:
movl %esi,R(KPTphys)
/* Allocate Page Table Directory */
- ALLOCPAGES(1)
+ ALLOCPAGES(NPGPTD)
movl %esi,R(IdlePTD)
/* Allocate UPAGES */
@@ -805,7 +805,7 @@ no_kernend:
/* Map page directory. */
movl R(IdlePTD), %eax
- movl $1, %ecx
+ movl $NPGPTD, %ecx
fillkptphys($PG_RW)
/* Map proc0's UPAGES in the physical way ... */
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index d141abb..e5b8a7c 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -1286,14 +1286,15 @@ pmap_pinit(pmap)
* page directory table.
*/
if (pmap->pm_pdir == NULL)
- pmap->pm_pdir =
- (pd_entry_t *)kmem_alloc_pageable(kernel_map, PAGE_SIZE);
+ pmap->pm_pdir = (pd_entry_t *)kmem_alloc_pageable(kernel_map,
+ NBPTD);
/*
* allocate object for the ptes
*/
if (pmap->pm_pteobj == NULL)
- pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI + 1);
+ pmap->pm_pteobj = vm_object_allocate(OBJT_DEFAULT, PTDPTDI +
+ NPGPTD);
/*
* allocate the page directory page
@@ -1305,7 +1306,7 @@ pmap_pinit(pmap)
ptdpg->valid = VM_PAGE_BITS_ALL;
vm_page_unlock_queues();
- pmap_qenter((vm_offset_t) pmap->pm_pdir, &ptdpg, 1);
+ pmap_qenter((vm_offset_t)pmap->pm_pdir, &ptdpg, NPGPTD);
if ((ptdpg->flags & PG_ZERO) == 0)
bzero(pmap->pm_pdir, PAGE_SIZE);
@@ -3423,7 +3424,7 @@ pmap_pid_dump(int pid)
int i,j;
index = 0;
pmap = vmspace_pmap(p->p_vmspace);
- for (i = 0; i < NPDEPG; i++) {
+ for (i = 0; i < NPDEPTD; i++) {
pd_entry_t *pde;
pt_entry_t *pte;
vm_offset_t base = i << PDRSHIFT;
@@ -3483,7 +3484,7 @@ pads(pm)
if (pm == kernel_pmap)
return;
- for (i = 0; i < NPDEPG; i++)
+ for (i = 0; i < NPDEPTD; i++)
if (pm->pm_pdir[i])
for (j = 0; j < NPTEPG; j++) {
va = (i << PDRSHIFT) + (j << PAGE_SHIFT);
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c
index 903a2b0..45148e9 100644
--- a/sys/i386/i386/vm_machdep.c
+++ b/sys/i386/i386/vm_machdep.c
@@ -514,7 +514,7 @@ cpu_reset_real()
#endif
#endif /* PC98 */
/* force a shutdown by unmapping entire address space ! */
- bzero((caddr_t) PTD, PAGE_SIZE);
+ bzero((caddr_t)PTD, NBPTD);
/* "good night, sweet prince .... <THUNK!>" */
invltlb();
diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h
index cf9cfe4..54fe27a 100644
--- a/sys/i386/include/param.h
+++ b/sys/i386/include/param.h
@@ -87,8 +87,12 @@
#define PAGE_MASK (PAGE_SIZE-1)
#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
-#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t)))
+#define NPGPTD 1
#define PDRSHIFT 22 /* LOG2(NBPDR) */
+
+#define NBPTD (NPGPTD<<PAGE_SHIFT)
+#define NPDEPTD (NBPTD/(sizeof (pd_entry_t)))
+#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t)))
#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */
#define PDRMASK (NBPDR-1)
diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h
index 44f0b25..0cd3944 100644
--- a/sys/i386/include/pmap.h
+++ b/sys/i386/include/pmap.h
@@ -101,9 +101,9 @@
#endif
#ifndef NKPDE
#ifdef SMP
-#define NKPDE (KVA_PAGES - 2) /* addressable number of page tables/pde's */
+#define NKPDE (KVA_PAGES - (NPGPTD + 1)) /* number of page tables/pde's */
#else
-#define NKPDE (KVA_PAGES - 1) /* addressable number of page tables/pde's */
+#define NKPDE (KVA_PAGES - NPGPTD) /* number of page tables/pde's */
#endif
#endif
@@ -115,14 +115,14 @@
*
* SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff
*/
-#define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */
+#define APTDPTDI (NPDEPG-NPGPTD) /* alt ptd entry that points to APTD */
#ifdef SMP
#define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */
#define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */
#else
#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */
#endif /* SMP */
-#define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */
+#define PTDPTDI (KPTDI-NPGPTD) /* ptd entry that points to ptd! */
#define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */
#define UMAXPTEOFF (NPTEPG) /* pte entry for user space end */
OpenPOWER on IntegriCloud