PERFORCE change 30685 for review
Marcel Moolenaar
marcel at FreeBSD.org
Tue May 6 19:56:56 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=30685
Change 30685 by marcel at marcel_nfs on 2003/05/06 19:56:03
pmap_growkernel:
o Turn this function into a critical section.
o Move initialization of kernel_vm_end to pmap_bootstrap()
to avoid having to do it here.
o Don't further adjust kernel_vm_end by looking at the
page table directory entry, as if we cannot trust the
value.
pmap_install:
o Do not treat kernel maps differently by not installing
them. This breaks the common usage of temporarily installing
a new map and then switch back again if the original map
is the kernel map.
o Clear the pm_active bit for this CPU on the old map, not
the new map. Hence, we never cleared pm_active...
Affected files ...
.. //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#9 edit
Differences ...
==== //depot/projects/ia64_epc/sys/ia64/ia64/pmap.c#9 (text+ko) ====
@@ -354,6 +354,7 @@
ia64_kptdir[i] = (void*)pmap_steal_memory(PAGE_SIZE);
}
nkpt = NKPT;
+ kernel_vm_end = NKPT * PAGE_SIZE * NKPTEPG + VM_MIN_KERNEL_ADDRESS;
avail_start = phys_avail[0];
for (i = 0; phys_avail[i+2]; i+= 2) ;
@@ -875,40 +876,30 @@
struct ia64_lpte *ptepage;
vm_page_t nkpg;
- if (kernel_vm_end == 0) {
- kernel_vm_end = nkpt * PAGE_SIZE * NKPTEPG
- + VM_MIN_KERNEL_ADDRESS;
- }
- addr = (addr + PAGE_SIZE * NKPTEPG) & ~(PAGE_SIZE * NKPTEPG - 1);
+ if (kernel_vm_end >= addr)
+ return;
+
+ critical_enter();
+
while (kernel_vm_end < addr) {
- if (ia64_kptdir[KPTE_DIR_INDEX(kernel_vm_end)]) {
- kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NKPTEPG)
- & ~(PAGE_SIZE * NKPTEPG - 1);
- continue;
- }
-
- /*
- * We could handle more by increasing the size of kptdir.
- */
+ /* We could handle more by increasing the size of kptdir. */
if (nkpt == MAXKPT)
panic("pmap_growkernel: out of kernel address space");
- /*
- * This index is bogus, but out of the way
- */
nkpg = vm_page_alloc(NULL, nkpt,
VM_ALLOC_NOOBJ | VM_ALLOC_SYSTEM | VM_ALLOC_WIRED);
if (!nkpg)
panic("pmap_growkernel: no memory to grow kernel");
-
- nkpt++;
ptepage = (struct ia64_lpte *)
- IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(nkpg));
+ IA64_PHYS_TO_RR7(VM_PAGE_TO_PHYS(nkpg));
bzero(ptepage, PAGE_SIZE);
ia64_kptdir[KPTE_DIR_INDEX(kernel_vm_end)] = ptepage;
- kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NKPTEPG) & ~(PAGE_SIZE * NKPTEPG - 1);
+ nkpt++;
+ kernel_vm_end += PAGE_SIZE * NKPTEPG;
}
+
+ critical_exit();
}
/***************************************************
@@ -1171,9 +1162,9 @@
pmap_find_kpte(vm_offset_t va)
{
KASSERT((va >> 61) == 5,
- ("kernel mapping 0x%lx not in region 5", va));
+ ("kernel mapping 0x%lx not in region 5", va));
KASSERT(IA64_RR_MASK(va) < (nkpt * PAGE_SIZE * NKPTEPG),
- ("kernel mapping 0x%lx out of range", va));
+ ("kernel mapping 0x%lx out of range", va));
return (&ia64_kptdir[KPTE_DIR_INDEX(va)][KPTE_PTE_INDEX(va)]);
}
@@ -2531,39 +2522,37 @@
critical_enter();
oldpmap = PCPU_GET(current_pmap);
-
- if (pmap == oldpmap || pmap == kernel_pmap) {
+ if (oldpmap == pmap) {
critical_exit();
- return pmap;
+ return (oldpmap);
}
- if (oldpmap) {
- atomic_clear_32(&pmap->pm_active, PCPU_GET(cpumask));
- }
+ if (oldpmap != NULL)
+ atomic_clear_32(&oldpmap->pm_active, PCPU_GET(cpumask));
PCPU_SET(current_pmap, pmap);
- if (!pmap) {
- /*
- * RIDs 0..4 have no mappings to make sure we generate
- * page faults on accesses.
- */
+
+ if (pmap == NULL) {
+ /* Invalidate regions 0-4. */
ia64_set_rr(IA64_RR_BASE(0), (0 << 8)|(PAGE_SHIFT << 2)|1);
ia64_set_rr(IA64_RR_BASE(1), (1 << 8)|(PAGE_SHIFT << 2)|1);
ia64_set_rr(IA64_RR_BASE(2), (2 << 8)|(PAGE_SHIFT << 2)|1);
ia64_set_rr(IA64_RR_BASE(3), (3 << 8)|(PAGE_SHIFT << 2)|1);
ia64_set_rr(IA64_RR_BASE(4), (4 << 8)|(PAGE_SHIFT << 2)|1);
critical_exit();
- return oldpmap;
+ return (oldpmap);
}
atomic_set_32(&pmap->pm_active, PCPU_GET(cpumask));
- for (i = 0; i < 5; i++)
+ for (i = 0; i < 5; i++) {
ia64_set_rr(IA64_RR_BASE(i),
- (pmap->pm_rid[i] << 8)|(PAGE_SHIFT << 2)|1);
+ (pmap->pm_rid[i] << 8)|(PAGE_SHIFT << 2)|1);
+ }
critical_exit();
- return oldpmap;
+
+ return (oldpmap);
}
vm_offset_t
More information about the p4-projects
mailing list