Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips/mips - Rename '#ifdef DIAGNOSTIC' to '#ifdef P...



details:   https://anonhg.NetBSD.org/src/rev/b7d709e9dcad
branches:  trunk
changeset: 473132:b7d709e9dcad
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Fri May 21 05:28:31 1999 +0000

description:
- Rename '#ifdef DIAGNOSTIC' to '#ifdef PARANOIADIAG' to detect
catastrophic events to break VM machinary.  Add some more diags to
track ASID.

diffstat:

 sys/arch/mips/mips/pmap.c |  204 ++++++++++++++++++++++++---------------------
 1 files changed, 110 insertions(+), 94 deletions(-)

diffs (truncated from 506 to 300 lines):

diff -r 2e92f068a444 -r b7d709e9dcad sys/arch/mips/mips/pmap.c
--- a/sys/arch/mips/mips/pmap.c Fri May 21 04:06:20 1999 +0000
+++ b/sys/arch/mips/mips/pmap.c Fri May 21 05:28:31 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.62 1999/05/20 10:50:08 nisimura Exp $       */
+/*     $NetBSD: pmap.c,v 1.63 1999/05/21 05:28:31 nisimura Exp $       */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.62 1999/05/20 10:50:08 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.63 1999/05/21 05:28:31 nisimura Exp $");
 
 /*
  *     Manages physical address maps.
@@ -170,7 +170,7 @@
 #define PDB_PVDUMP     0x8000
 int pmapdebug = 0;
 
-#endif /* DEBUG */
+#endif
 
 struct pmap    kernel_pmap_store;
 
@@ -179,8 +179,6 @@
 vaddr_t virtual_avail;  /* VA of first avail page (after kernel bss)*/
 vaddr_t virtual_end;   /* VA of last avail page (end of kernel AS) */
 
-int            mipspagesperpage;       /* PAGE_SIZE / NBPG */
-
 struct pv_entry        *pv_table;
 int             pv_table_npages;
 
@@ -192,8 +190,11 @@
 
 boolean_t      pmap_initialized = FALSE;
 
-#define        PAGE_IS_MANAGED(pa)     (pmap_initialized == TRUE &&            \
-                                vm_physseg_find(atop(pa), NULL) != -1)
+#define PAGE_IS_MANAGED(pa)    \
+           (pmap_initialized == TRUE && vm_physseg_find(atop(pa), NULL) != -1)
+
+#define PMAP_IS_ACTIVE(pm)     \
+           (curproc != NULL && (pm) == curproc->p_vmspace->vm_map.pmap)
 
 #define        pa_to_pvh(pa)                                                   \
 ({                                                                     \
@@ -293,9 +294,6 @@
        virtual_avail = VM_MIN_KERNEL_ADDRESS;
        virtual_end = VM_MIN_KERNEL_ADDRESS + Sysmapsize * NBPG;
 
-       /* XXX need to decide how to set cnt.v_page_size */
-       mipspagesperpage = 1;
-
        /*
         * Initialize the kernel pmap.
         */
@@ -306,10 +304,6 @@
 
        MachSetPID(1);
 
-#if 0  /* no need, no good, no use */
-       proc0paddr->u_pcb.pcb_segtab = pmap_kernel()->pm_segtab = NULL;
-#endif
-
 #ifdef MIPS3
        /*
         * The R4?00 stores only one copy of the Global bit in the
@@ -400,7 +394,7 @@
                        *vendp = trunc_page(virtual_end);
 
                va = MIPS_PHYS_TO_KSEG0(pa);
-               bzero((caddr_t)va, size);
+               memset((caddr_t)va, 0, size);
                return (va);
        }
 
@@ -474,12 +468,12 @@
                return (NULL);
 
        /* XXX: is it ok to wait here? */
-       pmap = (pmap_t) malloc(sizeof *pmap, M_VMPMAP, M_WAITOK);
+       pmap = (pmap_t)malloc(sizeof *pmap, M_VMPMAP, M_WAITOK);
 #ifdef notifwewait
        if (pmap == NULL)
                panic("pmap_create: cannot allocate a pmap");
 #endif
-       bzero(pmap, sizeof(*pmap));
+       memset(pmap, 0, sizeof(*pmap));
        pmap_pinit(pmap);
        return (pmap);
 }
@@ -524,7 +518,7 @@
                pmap_zero_page(VM_PAGE_TO_PHYS(mem));
                pmap->pm_segtab = stp = (struct segtab *)
                        MIPS_PHYS_TO_KSEG0(VM_PAGE_TO_PHYS(mem));
-               i = mipspagesperpage * (NBPG / sizeof(struct segtab));
+               i = NBPG / sizeof(struct segtab);
                s = splimp();
                while (--i != 0) {
                        stp++;
@@ -533,7 +527,7 @@
                }
                splx(s);
        }
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
        for (i = 0; i < PMAP_SEGTABSIZE; i++)
                if (pmap->pm_segtab->seg_tab[i] != 0)
                        panic("pmap_pinit: pm_segtab != 0");
@@ -588,7 +582,7 @@
                pt_entry_t *pte;
                int i;
                int s;
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
                int j;
 #endif
 
@@ -597,7 +591,7 @@
                        pte = pmap->pm_segtab->seg_tab[i];
                        if (!pte)
                                continue;
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
                        for (j = 0; j < NPTEPG; j++) {
                                if ((pte+j)->pt_entry)
                                        panic("pmap_release: segmap not empty");
@@ -711,7 +705,7 @@
                pt_entry_t *pte;
 
                /* remove entries from kernel pmap */
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
                if (sva < VM_MIN_KERNEL_ADDRESS || eva > virtual_end)
                        panic("pmap_remove: kva not in range");
 #endif
@@ -727,7 +721,7 @@
 #ifdef MIPS3
                                if (CPUISMIPS3)
                                        MachFlushDCache(sva, PAGE_SIZE);
-#endif /* mips3 */
+#endif
                        }
 
                        if (CPUISMIPS3)
@@ -748,9 +742,19 @@
                return;
        }
 
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
        if (eva > VM_MAXUSER_ADDRESS)
                panic("pmap_remove: uva not in range");
+       if (PMAP_IS_ACTIVE(pmap)) {
+               unsigned asid;
+
+               __asm __volatile("mfc0 %0,$10; nop" : "=r"(asid));
+               asid = (asid & 0xfc0) >> 6;
+               if (asid != pmap->pm_asid) {
+                       panic("inconsistency for active TLB flush: %d <-> %d",
+                               asid, pmap->pm_asid);
+               }
+       }
 #endif
        asid = pmap->pm_asid << MIPS_TLB_PID_SHIFT;
        needflush = (pmap->pm_asidgen == pmap_asid_generation);
@@ -769,7 +773,7 @@
                /*
                 * Invalidate every valid mapping within this segment.
                 */
-               pte += uvtopte(sva);
+               pte += (sva >> PGSHIFT) & (NPTEPG - 1);
                for (; sva < nssva; sva += NBPG, pte++) {
                        entry = pte->pt_entry;
                        if (!mips_pg_v(entry))
@@ -777,11 +781,11 @@
                        if (mips_pg_wired(entry))
                                pmap->pm_stats.wired_count--;
                        pmap->pm_stats.resident_count--;
-                       if(pmap_remove_pv(pmap, sva, pfn_to_vad(entry))) {
+                       if (pmap_remove_pv(pmap, sva, pfn_to_vad(entry))) {
 #ifdef MIPS3
                                if (CPUISMIPS3)
                                        MachFlushDCache(sva, PAGE_SIZE);
-#endif /* mips3 */
+#endif
                        }
                        pte->pt_entry = mips_pg_nv_bit();
                        /*
@@ -900,7 +904,7 @@
                 * executed much. The common case is to make a user page
                 * read-only.
                 */
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
                if (sva < VM_MIN_KERNEL_ADDRESS || eva > virtual_end)
                        panic("pmap_protect: kva not in range");
 #endif
@@ -920,9 +924,19 @@
                return;
        }
 
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
        if (eva > VM_MAXUSER_ADDRESS)
                panic("pmap_protect: uva not in range");
+       if (PMAP_IS_ACTIVE(pmap)) {
+               unsigned asid;
+
+               __asm __volatile("mfc0 %0,$10; nop" : "=r"(asid));
+               asid = (asid & 0xfc0) >> 6;
+               if (asid != pmap->pm_asid) {
+                       panic("inconsistency for active TLB update: %d <-> %d",
+                               asid, pmap->pm_asid);
+               }
+       }
 #endif
        asid = pmap->pm_asid << MIPS_TLB_PID_SHIFT;
        needupdate = (pmap->pm_asidgen == pmap_asid_generation);
@@ -1075,7 +1089,7 @@
 
        splx(s);
 }
-#endif /* MIPS3 */     /* r4000,r4400,r4600 */
+#endif
 
 /*
  *     Insert the given physical page (p) at
@@ -1100,7 +1114,6 @@
 {
        pt_entry_t *pte;
        u_int npte;
-       int i;
        vm_page_t mem;
        unsigned asid;
 
@@ -1109,7 +1122,7 @@
                printf("pmap_enter(%p, %lx, %lx, %x, %x)\n",
                       pmap, va, pa, prot, wired);
 #endif
-#ifdef DIAGNOSTIC
+#ifdef PARANOIADIAG
        if (!pmap)
                panic("pmap_enter: pmap");
        if (pmap == pmap_kernel()) {
@@ -1205,32 +1218,27 @@
                        npte |= vad_to_pfn(pa) | MIPS1_PG_V | MIPS1_PG_G;
 
                if (wired) {
-                       pmap->pm_stats.wired_count += mipspagesperpage;
+                       pmap->pm_stats.wired_count++;
                        npte |= mips_pg_wired_bit();
                }
-               i = mipspagesperpage;
-               do {
-#ifdef DIAGNOSTIC
-                       if (mips_pg_wired(pte->pt_entry))
-                               panic("pmap_enter: kernel wired");
+#ifdef PARANOIADIAG
+               if (mips_pg_wired(pte->pt_entry))
+                       panic("pmap_enter: kernel wired");
 #endif
-                       if (pfn_to_vad(pte->pt_entry) !=  pa) {
-                               pmap_remove(pmap, va, va  + NBPG);
+               if (pfn_to_vad(pte->pt_entry) !=  pa) {
+                       pmap_remove(pmap, va, va + NBPG);
 #ifdef DEBUG
-                               enter_stats.mchange++;
+                       enter_stats.mchange++;
 #endif
-                       }
-                       if (!mips_pg_v(pte->pt_entry))
-                               pmap->pm_stats.resident_count++;
-                       /*
-                        * Update the same virtual address entry.
-                        */
-                       MachTLBUpdate(va, npte);
-                       pte->pt_entry = npte;
-                       va += NBPG;
-                       npte += vad_to_pfn(NBPG);
-                       pte++;
-               } while (--i != 0);
+               }
+               if (!mips_pg_v(pte->pt_entry))
+                       pmap->pm_stats.resident_count++;
+
+               pte->pt_entry = npte;
+               /*
+                * Update the same virtual address entry.
+                */
+               MachTLBUpdate(va, npte);
                return;
        }
 
@@ -1249,11 +1257,13 @@
                pmap_zero_page(VM_PAGE_TO_PHYS(mem));



Home | Main Index | Thread Index | Old Index