Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Change pmap_map_entry() to work like pmap_map_chunk...



details:   https://anonhg.NetBSD.org/src/rev/45061d69b90c
branches:  trunk
changeset: 522585:45061d69b90c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Feb 22 04:49:19 2002 +0000

description:
Change pmap_map_entry() to work like pmap_map_chunk(): take a pointer
to the L1 table and a virtual address, and no pointer to the L2 table.
The L2 table will be looked up by pmap_map_entry(), which will panic
if the there is no L2 table for the requested VA.

NOTE: IT IS EXTREMELY IMPORTANT THAT THE CORRECT VIRTUAL ADDRESS
BE PROVIDED TO pmap_map_entry()!  Notably, the code that mapped
the kernel L2 tables into the kernel PT mapping L2 table were not
passing actual virtual addresses, but rather offsets into the range
mapped by the L2 table.  I have fixed up all of these call sites,
and tested the resulting kernel on both an IQ80310 and a Shark.
Other portmasters should examine their pmap_map_entry() calls if
their new kernels fail.

diffstat:

 sys/arch/acorn32/acorn32/rpc_machdep.c           |  27 +++---
 sys/arch/arm/arm32/pmap.c                        |  21 +++--
 sys/arch/cats/cats/cats_machdep.c                |  24 +++---
 sys/arch/evbarm/integrator/integrator_machdep.c  |  26 +++---
 sys/arch/evbarm/iq80310/iq80310_machdep.c        |  29 +++----
 sys/arch/hpcarm/hpcarm/hpc_machdep.c             |  35 ++++-----
 sys/arch/netwinder/netwinder/netwinder_machdep.c |  24 +++---
 sys/arch/shark/ofw/ofw.c                         |  86 ++++++++++-------------
 8 files changed, 131 insertions(+), 141 deletions(-)

diffs (truncated from 750 to 300 lines):

diff -r 9c5c57b9ec95 -r 45061d69b90c sys/arch/acorn32/acorn32/rpc_machdep.c
--- a/sys/arch/acorn32/acorn32/rpc_machdep.c    Fri Feb 22 04:30:39 2002 +0000
+++ b/sys/arch/acorn32/acorn32/rpc_machdep.c    Fri Feb 22 04:49:19 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rpc_machdep.c,v 1.22 2002/02/21 21:58:00 thorpej Exp $ */
+/*     $NetBSD: rpc_machdep.c,v 1.23 2002/02/22 04:49:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 2000-2001 Reinoud Zandijk.
@@ -57,7 +57,7 @@
 
 #include <sys/param.h>
 
-__RCSID("$NetBSD: rpc_machdep.c,v 1.22 2002/02/21 21:58:00 thorpej Exp $");
+__RCSID("$NetBSD: rpc_machdep.c,v 1.23 2002/02/22 04:49:19 thorpej Exp $");
 
 #include <sys/systm.h>
 #include <sys/kernel.h>
@@ -472,7 +472,6 @@
        u_int logical;
        u_int kerneldatasize;
        u_int l1pagetable;
-       u_int l2pagetable;
        extern char page0[], page0_end[];
        struct exec *kernexec = (struct exec *)KERNEL_TEXT_BASE;
        pv_addr_t kernel_l1pt;
@@ -703,7 +702,6 @@
 #endif
 
        /* Now we fill in the L2 pagetable for the kernel code/data */
-       l2pagetable = kernel_pt_table[KERNEL_PT_KERNEL].pv_pa;
 
        /*
         * The defines are a workaround for a recent problem that occurred
@@ -753,7 +751,7 @@
            PD_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 
        /* Map the page table that maps the kernel pages */
-       pmap_map_entry(l2pagetable, kernel_ptpt.pv_pa - physical_start,
+       pmap_map_entry(l1pagetable, kernel_ptpt.pv_pa - physical_start,
            kernel_ptpt.pv_pa, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 
 
@@ -778,20 +776,24 @@
         * Basically every kernel page table gets mapped here
         */
        /* The -2 is slightly bogus, it should be -log2(sizeof(pt_entry_t)) */
-       l2pagetable = kernel_ptpt.pv_pa;
-       pmap_map_entry(l2pagetable, (KERNEL_BASE >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (KERNEL_BASE >> (PGSHIFT-2)),
            kernel_pt_table[KERNEL_PT_KERNEL].pv_pa, VM_PROT_READ|VM_PROT_WRITE,
            PTE_NOCACHE);
-       pmap_map_entry(l2pagetable, (PROCESS_PAGE_TBLS_BASE >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (PROCESS_PAGE_TBLS_BASE >> (PGSHIFT-2)),
            kernel_ptpt.pv_pa, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
-       pmap_map_entry(l2pagetable, (VMEM_VBASE >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (VMEM_VBASE >> (PGSHIFT-2)),
            kernel_pt_table[KERNEL_PT_VMEM].pv_pa, VM_PROT_READ|VM_PROT_WRITE,
            PTE_NOCACHE);
-       pmap_map_entry(l2pagetable, (0x00000000 >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE+ (0x00000000 >> (PGSHIFT-2)),
            kernel_pt_table[KERNEL_PT_SYS].pv_pa, VM_PROT_READ|VM_PROT_WRITE,
            PTE_NOCACHE);
        for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; ++loop) {
-               pmap_map_entry(l2pagetable, ((KERNEL_VM_BASE +
+               pmap_map_entry(l1pagetable,
+                   PROCESS_PAGE_TBLS_BASE + ((KERNEL_VM_BASE +
                    (loop * 0x00400000)) >> (PGSHIFT-2)),
                    kernel_pt_table[KERNEL_PT_VMDATA + loop].pv_pa,
                    VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
@@ -801,8 +803,7 @@
         * Map the system page in the kernel page table for the bottom 1Meg
         * of the virtual memory map.
         */
-       l2pagetable = kernel_pt_table[KERNEL_PT_SYS].pv_pa;
-       pmap_map_entry(l2pagetable, 0x0000000, systempage.pv_pa,
+       pmap_map_entry(l1pagetable, 0x0000000, systempage.pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
 
        /* Map the core memory needed before autoconfig */
diff -r 9c5c57b9ec95 -r 45061d69b90c sys/arch/arm/arm32/pmap.c
--- a/sys/arch/arm/arm32/pmap.c Fri Feb 22 04:30:39 2002 +0000
+++ b/sys/arch/arm/arm32/pmap.c Fri Feb 22 04:49:19 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.46 2002/02/21 21:58:01 thorpej Exp $        */
+/*     $NetBSD: pmap.c,v 1.47 2002/02/22 04:49:20 thorpej Exp $        */
 
 /*
  * Copyright (c) 2001 Richard Earnshaw
@@ -142,7 +142,7 @@
 #include <machine/param.h>
 #include <arm/arm32/katelib.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.46 2002/02/21 21:58:01 thorpej Exp $");        
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.47 2002/02/22 04:49:20 thorpej Exp $");        
 #ifdef PMAP_DEBUG
 #define        PDEBUG(_lev_,_stat_) \
        if (pmap_debug_level >= (_lev_)) \
@@ -3766,19 +3766,24 @@
  *     Create a single page mapping.
  */
 void
-pmap_map_entry(vaddr_t l2pt, vaddr_t va, paddr_t pa, int prot, int cache)
+pmap_map_entry(vaddr_t l1pt, vaddr_t va, paddr_t pa, int prot, int cache)
 {
-       pt_entry_t *pte = (pt_entry_t *) l2pt;
+       pd_entry_t *pde = (pd_entry_t *) l1pt;
        pt_entry_t ap = (prot & VM_PROT_WRITE) ? AP_KRW : AP_KR;
        pt_entry_t fl = (cache == PTE_CACHE) ? pte_cache_mode : 0;
+       pt_entry_t *pte;
 
        KASSERT(((va | pa) & PGOFSET) == 0);
 
-#ifdef cats    /* XXXJRT */
-       pte[(va >> PGSHIFT) & 0x7ff] = L2_SPTE(pa & PG_FRAME, ap, fl);
-#else
+       if ((pde[va >> PDSHIFT] & L1_MASK) != L1_PAGE)
+               panic("pmap_map_entry: no L2 table for VA 0x%08lx", va);
+
+       pte = (pt_entry_t *)
+           kernel_pt_lookup(pde[va >> PDSHIFT] & PG_FRAME);
+       if (pte == NULL)
+               panic("pmap_map_entry: can't find L2 table for VA 0x%08lx", va);
+
        pte[(va >> PGSHIFT) & 0x3ff] = L2_SPTE(pa & PG_FRAME, ap, fl);
-#endif
 }
 
 /*
diff -r 9c5c57b9ec95 -r 45061d69b90c sys/arch/cats/cats/cats_machdep.c
--- a/sys/arch/cats/cats/cats_machdep.c Fri Feb 22 04:30:39 2002 +0000
+++ b/sys/arch/cats/cats/cats_machdep.c Fri Feb 22 04:49:19 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cats_machdep.c,v 1.21 2002/02/21 21:58:02 thorpej Exp $        */
+/*     $NetBSD: cats_machdep.c,v 1.22 2002/02/22 04:49:20 thorpej Exp $        */
 
 /*
  * Copyright (c) 1997,1998 Mark Brinicombe.
@@ -338,7 +338,6 @@
        int loop1;
        u_int logical;
        u_int l1pagetable;
-       u_int l2pagetable;
        extern char page0[], page0_end[];
        struct exec *kernexec = (struct exec *)KERNEL_TEXT_BASE;
        pv_addr_t kernel_l1pt;
@@ -555,7 +554,6 @@
 #endif
 
        /* Now we fill in the L2 pagetable for the kernel static code/data */
-       l2pagetable = kernel_pt_table[KERNEL_PT_KERNEL].pv_pa;
 
        if (N_GETMAGIC(kernexec[0]) != ZMAGIC)
                panic("Illegal kernel format\n");
@@ -596,7 +594,7 @@
 #endif
 
        /* Map the boot arguments page */
-       pmap_map_entry(l2pagetable, ebsabootinfo.bt_vargp,
+       pmap_map_entry(l1pagetable, ebsabootinfo.bt_vargp,
            ebsabootinfo.bt_pargp, VM_PROT_READ, PTE_CACHE);
 
        /* Map the stack pages */
@@ -613,7 +611,7 @@
            PD_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 
        /* Map the page table that maps the kernel pages */
-       pmap_map_entry(l2pagetable, kernel_ptpt.pv_pa, kernel_ptpt.pv_pa,
+       pmap_map_entry(l1pagetable, kernel_ptpt.pv_pa, kernel_ptpt.pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 
        /*
@@ -621,21 +619,24 @@
         * Basically every kernel page table gets mapped here
         */
        /* The -2 is slightly bogus, it should be -log2(sizeof(pt_entry_t)) */
-       l2pagetable = kernel_ptpt.pv_pa;
        for (loop = 0; loop < KERNEL_PT_KERNEL_NUM; loop++)
-               pmap_map_entry(l2pagetable, ((KERNEL_BASE +
+               pmap_map_entry(l1pagetable,
+                   PROCESS_PAGE_TBLS_BASE + ((KERNEL_BASE +
                    (loop * 0x00400000)) >> (PGSHIFT-2)),
                    kernel_pt_table[KERNEL_PT_KERNEL + loop].pv_pa,
                    VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 
-       pmap_map_entry(l2pagetable, (PROCESS_PAGE_TBLS_BASE >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (PROCESS_PAGE_TBLS_BASE >> (PGSHIFT-2)),
            kernel_ptpt.pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
-       pmap_map_entry(l2pagetable, (0x00000000 >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (0x00000000 >> (PGSHIFT-2)),
            kernel_pt_table[KERNEL_PT_SYS].pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
        for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; ++loop)
-               pmap_map_entry(l2pagetable, ((KERNEL_VM_BASE +
+               pmap_map_entry(l1pagetable,
+                   PROCESS_PAGE_TBLS_BASE + ((KERNEL_VM_BASE +
                    (loop * 0x00400000)) >> (PGSHIFT-2)),
                    kernel_pt_table[KERNEL_PT_VMDATA + loop].pv_pa,
                    VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
@@ -644,8 +645,7 @@
         * Map the system page in the kernel page table for the bottom 1Meg
         * of the virtual memory map.
         */
-       l2pagetable = kernel_pt_table[KERNEL_PT_SYS].pv_pa;
-       pmap_map_entry(l2pagetable, 0x00000000, systempage.pv_pa,
+       pmap_map_entry(l1pagetable, 0x00000000, systempage.pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
 
        /* Map the core memory needed before autoconfig */
diff -r 9c5c57b9ec95 -r 45061d69b90c sys/arch/evbarm/integrator/integrator_machdep.c
--- a/sys/arch/evbarm/integrator/integrator_machdep.c   Fri Feb 22 04:30:39 2002 +0000
+++ b/sys/arch/evbarm/integrator/integrator_machdep.c   Fri Feb 22 04:49:19 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: integrator_machdep.c,v 1.14 2002/02/21 21:58:02 thorpej Exp $  */
+/*     $NetBSD: integrator_machdep.c,v 1.15 2002/02/22 04:49:20 thorpej Exp $  */
 
 /*
  * Copyright (c) 2001 ARM Ltd
@@ -357,7 +357,6 @@
        int loop;
        int loop1;
        u_int l1pagetable;
-       u_int l2pagetable;
        extern char page0[], page0_end[];
        extern int etext asm ("_etext");
        extern int end asm ("_end");
@@ -630,7 +629,6 @@
 #endif
 
        /* Now we fill in the L2 pagetable for the kernel static code/data */
-       l2pagetable = kernel_pt_table[KERNEL_PT_KERNEL].pv_pa;
 
        {
                u_int logical;
@@ -666,7 +664,7 @@
 
        /* Map the boot arguments page */
 #if 0
-       pmap_map_entry(l2pagetable, intbootinfo.bt_vargp,
+       pmap_map_entry(l1pagetable, intbootinfo.bt_vargp,
            intbootinfo.bt_pargp, VM_PROT_READ, PTE_CACHE);
 #endif
 
@@ -684,7 +682,7 @@
            PD_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 
        /* Map the page table that maps the kernel pages */
-       pmap_map_entry(l2pagetable, kernel_ptpt.pv_pa, kernel_ptpt.pv_pa,
+       pmap_map_entry(l1pagetable, kernel_ptpt.pv_pa, kernel_ptpt.pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 
        /*
@@ -692,18 +690,21 @@
         * Basically every kernel page table gets mapped here
         */
        /* The -2 is slightly bogus, it should be -log2(sizeof(pt_entry_t)) */
-       l2pagetable = kernel_ptpt.pv_pa;
-       pmap_map_entry(l2pagetable, (KERNEL_BASE >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (KERNEL_BASE >> (PGSHIFT-2)),
            kernel_pt_table[KERNEL_PT_KERNEL].pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
-       pmap_map_entry(l2pagetable, (PROCESS_PAGE_TBLS_BASE >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (PROCESS_PAGE_TBLS_BASE >> (PGSHIFT-2)),
            kernel_ptpt.pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
-       pmap_map_entry(l2pagetable, (0x00000000 >> (PGSHIFT-2)),
+       pmap_map_entry(l1pagetable,
+           PROCESS_PAGE_TBLS_BASE + (0x00000000 >> (PGSHIFT-2)),
            kernel_pt_table[KERNEL_PT_SYS].pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
        for (loop = 0; loop < KERNEL_PT_VMDATA_NUM; ++loop)
-               pmap_map_entry(l2pagetable, ((KERNEL_VM_BASE +
+               pmap_map_entry(l1pagetable,
+                   PROCESS_PAGE_TBLS_BASE + ((KERNEL_VM_BASE +
                    (loop * 0x00400000)) >> (PGSHIFT-2)),
                    kernel_pt_table[KERNEL_PT_VMDATA + loop].pv_pa,
                    VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
@@ -712,14 +713,13 @@
         * Map the system page in the kernel page table for the bottom 1Meg
         * of the virtual memory map.
         */
-       l2pagetable = kernel_pt_table[KERNEL_PT_SYS].pv_pa;
 #if 1
        /* MULTI-ICE requires that page 0 is NC/NB so that it can download
           the cache-clean code there.  */
-       pmap_map_entry(l2pagetable, 0x00000000, systempage.pv_pa,
+       pmap_map_entry(l1pagetable, 0x00000000, systempage.pv_pa,
            VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE);
 #else
-       pmap_map_entry(l2pagetable, 0x00000000, systempage.pv_pa,
+       pmap_map_entry(l1pagetable, 0x00000000, systempage.pv_pa,



Home | Main Index | Thread Index | Old Index