Source-Changes-HG archive

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

[src/netbsd-2-0]: src/sys/arch/sparc64/sparc64 Pull up revision 1.158 (reques...



details:   https://anonhg.NetBSD.org/src/rev/48e47311664d
branches:  netbsd-2-0
changeset: 564649:48e47311664d
user:      jdc <jdc%NetBSD.org@localhost>
date:      Fri Jan 07 14:28:19 2005 +0000

description:
Pull up revision 1.158 (requested by martin in ticket #1014).

Better return value checking for pseg_get/pseg_set. Turn Debugger() calls
into proper panics and sprinkle some KASSERTs. Closes PR 27288.

diffstat:

 sys/arch/sparc64/sparc64/pmap.c |  154 ++++++++++++++++++++++-----------------
 1 files changed, 86 insertions(+), 68 deletions(-)

diffs (truncated from 376 to 300 lines):

diff -r 11e2d6bac60d -r 48e47311664d sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c   Fri Jan 07 14:21:57 2005 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c   Fri Jan 07 14:28:19 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.156.2.1 2005/01/07 14:21:57 jdc Exp $       */
+/*     $NetBSD: pmap.c,v 1.156.2.2 2005/01/07 14:28:19 jdc Exp $       */
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.156.2.1 2005/01/07 14:21:57 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.156.2.2 2005/01/07 14:28:19 jdc Exp $");
 
 #undef NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define        HWREF
@@ -1766,6 +1766,7 @@
        struct pmap *pm = pmap_kernel();
        int64_t data;
        paddr_t pa;
+       int rv;
        boolean_t flush = FALSE;
 
        KASSERT(va < INTSTACK || va > EINTSTACK);
@@ -1795,11 +1796,10 @@
                 * clear the access statistics.
                 */
 
-               if (pseg_set(pm, va, 0, 0)) {
-                       printf("pmap_kremove: pseg empty!\n");
-                       Debugger();
-                       /* panic? */
-               }
+               rv = pseg_set(pm, va, 0, 0);
+               if (rv & 1)
+                       panic("pmap_kremove: pseg_set needs spare, rv=%d\n",
+                           rv);
                DPRINTF(PDB_DEMAP, ("pmap_kremove: seg %x pdir %x pte %x\n",
                    (int)va_to_seg(va), (int)va_to_dir(va),
                    (int)va_to_pte(va)));
@@ -2092,6 +2092,7 @@
        paddr_t pa;
        struct vm_page *pg;
        pv_entry_t pv;
+       int rv;
        boolean_t flush = FALSE;
 
        /*
@@ -2140,11 +2141,11 @@
                 * clear the access statistics.
                 */
 
-               if (pseg_set(pm, va, 0, 0)) {
-                       printf("pmap_remove: pseg empty!\n");
-                       Debugger();
-                       /* panic? */
-               }
+               rv = pseg_set(pm, va, 0, 0);
+               if (rv & 1)
+                       panic("pmap_remove: pseg_set needed spare, rv=%d!\n",
+                           rv);
+
                DPRINTF(PDB_REMOVE, (" clearing seg %x pte %x\n",
                                     (int)va_to_seg(va), (int)va_to_pte(va)));
                REMOVE_STAT(removes);
@@ -2190,6 +2191,7 @@
        int64_t data;
        struct vm_page *pg;
        pv_entry_t pv;
+       int rv;
 
        KASSERT(pm != pmap_kernel() || eva < INTSTACK || sva > EINTSTACK);
        KASSERT(pm != pmap_kernel() || eva < kdata || sva > ekdata);
@@ -2244,11 +2246,10 @@
                if ((prot & VM_PROT_EXECUTE) == 0)
                        data &= ~(TLB_EXEC);
 
-               if (pseg_set(pm, sva, data, 0)) {
-                       printf("pmap_protect: gotten pseg empty!\n");
-                       Debugger();
-                       /* panic? */
-               }
+               rv = pseg_set(pm, sva, data, 0);
+               if (rv & 1)
+                       panic("pmap_protect: pseg_set needs spare! rv=%d\n",
+                           rv);
 
                if (!pm->pm_ctx && pm != pmap_kernel())
                        continue;
@@ -2338,15 +2339,19 @@
 {
        struct pmap *pm = pmap_kernel();
        int64_t data;
+       int rv;
 
        simple_lock(&pm->pm_lock);
        data = pseg_get(pm, va);
+       KASSERT(data & TLB_V);
        if (prot & VM_PROT_WRITE) {
                data |= (TLB_W|TLB_REAL_W);
        } else {
                data &= ~(TLB_W|TLB_REAL_W);
        }
-       (void) pseg_set(pm, va, data, 0);
+       rv = pseg_set(pm, va, data, 0);
+       if (rv & 1)
+               panic("pmap_kprotect: pseg_set needs spare! rv=%d", rv);
        tsb_invalidate(pm->pm_ctx, va);
        tlb_flush_pte(va, pm->pm_ctx);
        simple_unlock(&pm->pm_lock);
@@ -2540,6 +2545,7 @@
        struct vm_page *pg;
 {
        pv_entry_t pv;
+       int rv;
        int changed = 0;
 #ifdef DEBUG
        int modified = 0;
@@ -2574,6 +2580,7 @@
                        simple_lock(&pmap->pm_lock);
                        /* First clear the mod bit in the PTE and make it R/O */
                        data = pseg_get(pmap, va);
+                       KASSERT(data & TLB_V);
                        /* Need to both clear the modify and write bits */
                        if (data & TLB_MODIFY)
                                changed |= 1;
@@ -2582,11 +2589,10 @@
 #else
                        data &= ~(TLB_MODIFY|TLB_W|TLB_REAL_W);
 #endif
-                       if (pseg_set(pmap, va, data, 0)) {
-                               printf("pmap_clear_modify: pseg empty!\n");
-                               Debugger();
-                               /* panic? */
-                       }
+                       rv = pseg_set(pmap, va, data, 0);
+                       if (rv & 1)
+                               printf("pmap_clear_modify: pseg_set needs"
+                                   " spare! rv=%d\n", rv);
                        if (pmap->pm_ctx || pmap == pmap_kernel()) {
                                tsb_invalidate(pmap->pm_ctx, va);
                                tlb_flush_pte(va, pmap->pm_ctx);
@@ -2621,6 +2627,7 @@
 {
        paddr_t pa = VM_PAGE_TO_PHYS(pg);
        pv_entry_t pv;
+       int rv;
        int changed = 0;
 #ifdef DEBUG
        int referenced = 0;
@@ -2649,6 +2656,7 @@
 
                        simple_lock(&pmap->pm_lock);
                        data = pseg_get(pmap, va);
+                       KASSERT(data & TLB_V);
                        DPRINTF(PDB_CHANGEPROT,
                            ("clearing ref pm:%p va:%p ctx:%lx data:%llx\n",
                             pmap, (void *)(u_long)va, (u_long)pmap->pm_ctx,
@@ -2662,11 +2670,10 @@
                                changed |= 1;
                        data = 0;
 #endif
-                       if (pseg_set(pmap, va, data, 0)) {
-                               printf("pmap_clear_reference: pseg empty!\n");
-                               Debugger();
-                               /* panic? */
-                       }
+                       rv = pseg_set(pmap, va, data, 0);
+                       if (rv & 1)
+                               panic("pmap_clear_reference: pseg_set needs"
+                                   " spare! rv=%d\n", rv);
                        if (pmap->pm_ctx || pmap == pmap_kernel()) {
                                tsb_invalidate(pmap->pm_ctx, va);
                                tlb_flush_pte(va, pmap->pm_ctx);
@@ -2720,6 +2727,7 @@
                        int64_t data;
 
                        data = pseg_get(npv->pv_pmap, npv->pv_va & PV_VAMASK);
+                       KASSERT(data & TLB_V);
                        if (data & TLB_MODIFY)
                                i = 1;
 
@@ -2765,6 +2773,7 @@
                        int64_t data;
 
                        data = pseg_get(npv->pv_pmap, npv->pv_va & PV_VAMASK);
+                       KASSERT(data & TLB_V);
                        if (data & TLB_ACCESS)
                                i = 1;
 
@@ -2799,6 +2808,7 @@
        vaddr_t va;
 {
        int64_t data;
+       int rv;
 
        DPRINTF(PDB_MMU_STEAL, ("pmap_unwire(%p, %lx)\n", pmap, va));
 
@@ -2815,12 +2825,11 @@
 #endif
        simple_lock(&pmap->pm_lock);
        data = pseg_get(pmap, va & PV_VAMASK);
+       KASSERT(data & TLB_V);
        data &= ~TLB_TSB_LOCK;
-       if (pseg_set(pmap, va & PV_VAMASK, data, 0)) {
-               printf("pmap_unwire: gotten pseg empty!\n");
-               Debugger();
-               /* panic? */
-       }
+       rv = pseg_set(pmap, va & PV_VAMASK, data, 0);
+       if (rv & 1)
+               panic("pmap_unwire: pseg_set needs spare! rv=%d\n", rv);
        simple_unlock(&pmap->pm_lock);
        pv_check();
 }
@@ -2838,6 +2847,7 @@
 {
        int64_t clear, set;
        int64_t data = 0;
+       int rv;
        paddr_t pa = VM_PAGE_TO_PHYS(pg);
        pv_entry_t pv, npv, firstpv;
        struct pmap *pmap;
@@ -2877,6 +2887,7 @@
                                         "RO va %p of pg %p...\n",
                                         (void *)(u_long)pv->pv_va, pg));
                                data = pseg_get(pmap, va);
+                               KASSERT(data & TLB_V);
 
                                /* Save REF/MOD info */
                                if (data & TLB_ACCESS)
@@ -2886,12 +2897,11 @@
 
                                data &= ~clear;
                                data |= set;
-                               if (pseg_set(pmap, va, data, 0)) {
-                                       printf("pmap_page_protect: "
-                                              "pseg empty!\n");
-                                       Debugger();
-                                       /* panic? */
-                               }
+                               rv = pseg_set(pmap, va, data, 0);
+                               if (rv & 1)
+                                       panic("pmap_page_protect: "
+                                              "pseg_set needs spare! rv=%d\n",
+                                              rv);
                                if (pmap->pm_ctx || pmap == pmap_kernel()) {
                                        tsb_invalidate(pmap->pm_ctx, va);
                                        tlb_flush_pte(va, pmap->pm_ctx);
@@ -2920,6 +2930,7 @@
 
                        /* clear the entry in the page table */
                        data = pseg_get(pmap, va);
+                       KASSERT(data & TLB_V);
 
                        /* Save ref/mod info */
                        if (data & TLB_ACCESS)
@@ -2927,11 +2938,10 @@
                        if (data & TLB_MODIFY)
                                firstpv->pv_va |= PV_MOD;
                        /* Clear mapping */
-                       if (pseg_set(pmap, va, 0, 0)) {
-                               printf("pmap_page_protect: pseg empty!\n");
-                               Debugger();
-                               /* panic? */
-                       }
+                       rv = pseg_set(pmap, va, 0, 0);
+                       if (rv & 1)
+                               panic("pmap_page_protect: pseg_set needs"
+                                    " spare! rv=%d\n", rv);
                        if (pmap->pm_ctx || pmap == pmap_kernel()) {
                                tsb_invalidate(pmap->pm_ctx, va);
                                tlb_flush_pte(va, pmap->pm_ctx);
@@ -2966,16 +2976,16 @@
                                 (void *)(u_long)va, pg, pmap));
 
                        data = pseg_get(pmap, va);
+                       KASSERT(data & TLB_V);
                        /* Save ref/mod info */
                        if (data & TLB_ACCESS)
                                pv->pv_va |= PV_REF;
                        if (data & TLB_MODIFY)
                                pv->pv_va |= PV_MOD;
-                       if (pseg_set(pmap, va, 0, 0)) {
-                               printf("pmap_page_protect: pseg empty!\n");
-                               Debugger();
-                               /* panic? */
-                       }
+                       rv = pseg_set(pmap, va, 0, 0);
+                       if (rv & 1)
+                               panic("pmap_page_protect: pseg_set needs"
+                                   " spare! rv=%d\n", rv);
                        if (pv->pv_pmap->pm_ctx ||
                            pv->pv_pmap == pmap_kernel()) {
                                tsb_invalidate(pmap->pm_ctx, va);
@@ -3276,6 +3286,7 @@
         */
        if (pmap == pvh->pv_pmap && PV_MATCH(pvh, va)) {



Home | Main Index | Thread Index | Old Index