Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sh3/sh3 Revert rev 1.89:



details:   https://anonhg.NetBSD.org/src/rev/325305d4083c
branches:  trunk
changeset: 1023451:325305d4083c
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Sep 08 07:13:18 2021 +0000

description:
Revert rev 1.89:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/sh3/sh3/pmap.c#rev1.89

I misunderstood evaluation order of ? operator.

I should have split the commit into two parts, i.e., with and without
binary diffs, in order to avoid such a serious mistake.

Thanks rillig@ so much for careful check!!!!

diffstat:

 sys/arch/sh3/sh3/pmap.c |  120 +++++++++++++++++++++++++----------------------
 1 files changed, 64 insertions(+), 56 deletions(-)

diffs (truncated from 417 to 300 lines):

diff -r b9f66f038045 -r 325305d4083c sys/arch/sh3/sh3/pmap.c
--- a/sys/arch/sh3/sh3/pmap.c   Wed Sep 08 00:35:56 2021 +0000
+++ b/sys/arch/sh3/sh3/pmap.c   Wed Sep 08 07:13:18 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $    */
+/*     $NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $    */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.90 2021/09/08 07:13:18 rin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -153,7 +153,7 @@
        va = SH3_PHYS_TO_P1SEG(pa);
        memset((void *)va, 0, size);
 
-       return va;
+       return (va);
 }
 
 vaddr_t
@@ -162,7 +162,7 @@
        int i, n;
 
        if (maxkvaddr <= __pmap_kve)
-               return __pmap_kve;
+               return (__pmap_kve);
 
        i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
        __pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,9 +190,9 @@
                }
        }
 
-       return __pmap_kve;
+       return (__pmap_kve);
  error:
-       panic("%s: out of memory", __func__);
+       panic("pmap_growkernel: out of memory.");
        /* NOTREACHED */
 }
 
@@ -248,7 +248,7 @@
                    uvm_pagealloc(NULL, 0, NULL,
                        UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
 
-       return pmap;
+       return (pmap);
 }
 
 void
@@ -271,7 +271,7 @@
                        for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
                                KDASSERT(*pte == 0);
                }
-#endif
+#endif /* DEBUG */
                /* Purge cache entry for next use of this page. */
                if (SH_HAS_VIRTUAL_ALIAS)
                        sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@
        struct vm_page *pg;
        struct vm_page_md *pvh;
        pt_entry_t entry, *pte;
-       bool kva = pmap == pmap_kernel();
+       bool kva = (pmap == pmap_kernel());
 
        /* "flags" never exceed "prot" */
        KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,23 +362,24 @@
 
                /* Check for existing mapping */
                if (__pmap_map_change(pmap, va, pa, prot, entry))
-                       return 0;
+                       return (0);
 
                /* Add to physical-virtual map list of this page */
                if (__pmap_pv_enter(pmap, pg, va)) {
                        if (flags & PMAP_CANFAIL)
                                return ENOMEM;
-                       panic("%s: cannot allocate pv", __func__);
+                       panic("%s: __pmap_pv_enter failed", __func__);
                }
        } else {        /* bus-space (always uncached map) */
-               if (kva)
+               if (kva) {
                        entry |= PG_V | PG_SH |
-                           (prot & VM_PROT_WRITE) ?
-                           (PG_PR_KRW | PG_D) : PG_PR_KRO;
-               else
+                           ((prot & VM_PROT_WRITE) ?
+                           (PG_PR_KRW | PG_D) : PG_PR_KRO);
+               } else {
                        entry |= PG_V |
-                           (prot & VM_PROT_WRITE) ?
-                           (PG_PR_URW | PG_D) : PG_PR_URO;
+                           ((prot & VM_PROT_WRITE) ?
+                           (PG_PR_URW | PG_D) : PG_PR_URO);
+               }
        }
 
        /* Register to page table */
@@ -392,7 +393,7 @@
                                        __pmap_pv_remove(pmap, pg, va);
                                return ENOMEM;
                        }
-                       panic("%s: cannot allocate pte", __func__);
+                       panic("%s: __pmap_pte_alloc failed", __func__);
                }
        }
 
@@ -409,7 +410,7 @@
                pmap->pm_stats.wired_count++;
        pmap->pm_stats.resident_count++;
 
-       return 0;
+       return (0);
 }
 
 /*
@@ -427,13 +428,13 @@
        vaddr_t eva = va + PAGE_SIZE;
 
        if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
-           (oentry = *pte) == 0)
-               return false;           /* no mapping exists. */
+           ((oentry = *pte) == 0))
+               return (false);         /* no mapping exists. */
 
        if (pa != (oentry & PG_PPN)) {
                /* Enter a mapping at a mapping to another physical page. */
                pmap_remove(pmap, va, eva);
-               return false;
+               return (false);
        }
 
        /* Pre-existing mapping */
@@ -453,10 +454,10 @@
        } else if (entry & _PG_WIRED) {
                /* unwired -> wired. make sure to reflect "flags" */
                pmap_remove(pmap, va, eva);
-               return false;
+               return (false);
        }
 
-       return true;    /* mapping was changed. */
+       return (true);  /* mapping was changed. */
 }
 
 /*
@@ -574,7 +575,7 @@
 #ifdef DEBUG
        /* Check duplicated map. */
        SLIST_FOREACH(pv, &pvh->pvh_head, pv_link)
-               KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
+           KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
 #endif
        splx(s);
 }
@@ -637,17 +638,17 @@
        if (pmap == pmap_kernel() && (va >> 30) == 2) {
                if (pap != NULL)
                        *pap = va & SH3_PHYS_MASK;
-               return true;
+               return (true);
        }
 
        pte = __pmap_pte_lookup(pmap, va);
        if (pte == NULL || *pte == 0)
-               return false;
+               return (false);
 
        if (pap != NULL)
                *pap = (*pte & PG_PPN) | (va & PGOFSET);
 
-       return true;
+       return (true);
 }
 
 void
@@ -666,20 +667,23 @@
 
        switch (prot) {
        default:
-               panic("%s: invalid protection mode %x", __func__, prot);
+               panic("pmap_protect: invalid protection mode %x", prot);
                /* NOTREACHED */
        case VM_PROT_READ:
+               /* FALLTHROUGH */
        case VM_PROT_READ | VM_PROT_EXECUTE:
                protbits = kernel ? PG_PR_KRO : PG_PR_URO;
                break;
        case VM_PROT_READ | VM_PROT_WRITE:
+               /* FALLTHROUGH */
        case VM_PROT_ALL:
                protbits = kernel ? PG_PR_KRW : PG_PR_URW;
                break;
        }
 
        for (va = sva; va < eva; va += PAGE_SIZE) {
-               if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
+
+               if (((pte = __pmap_pte_lookup(pmap, va)) == NULL) ||
                    (entry = *pte) == 0)
                        continue;
 
@@ -709,10 +713,12 @@
 
        switch (prot) {
        case VM_PROT_READ | VM_PROT_WRITE:
+               /* FALLTHROUGH */
        case VM_PROT_ALL:
                break;
 
        case VM_PROT_READ:
+               /* FALLTHROUGH */
        case VM_PROT_READ | VM_PROT_EXECUTE:
                s = splvm();
                SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) {
@@ -775,8 +781,9 @@
                /* sync cache since we access via P2. */
                sh_dcache_wbinv_all();
                memset((void *)SH3_PHYS_TO_P2SEG(phys), 0, PAGE_SIZE);
-       } else
+       } else {
                memset((void *)SH3_PHYS_TO_P1SEG(phys), 0, PAGE_SIZE);
+       }
 }
 
 void
@@ -788,9 +795,10 @@
                sh_dcache_wbinv_all();
                memcpy((void *)SH3_PHYS_TO_P2SEG(dst),
                    (void *)SH3_PHYS_TO_P2SEG(src), PAGE_SIZE);
-       } else
+       } else {
                memcpy((void *)SH3_PHYS_TO_P1SEG(dst),
                    (void *)SH3_PHYS_TO_P1SEG(src), PAGE_SIZE);
+       }
 }
 
 bool
@@ -798,7 +806,7 @@
 {
        struct vm_page_md *pvh = VM_PAGE_TO_MD(pg);
 
-       return (pvh->pvh_flags & PVH_REFERENCED) ? true : false;
+       return ((pvh->pvh_flags & PVH_REFERENCED) ? true : false);
 }
 
 bool
@@ -833,7 +841,7 @@
        }
        splx(s);
 
-       return true;
+       return (true);
 }
 
 bool
@@ -841,7 +849,7 @@
 {
        struct vm_page_md *pvh = VM_PAGE_TO_MD(pg);
 
-       return (pvh->pvh_flags & PVH_MODIFIED) ? true : false;
+       return ((pvh->pvh_flags & PVH_MODIFIED) ? true : false);
 }
 
 bool
@@ -857,14 +865,14 @@
 
        modified = pvh->pvh_flags & PVH_MODIFIED;
        if (!modified)
-               return false;
+               return (false);
 
        pvh->pvh_flags &= ~PVH_MODIFIED;
 
        s = splvm();
        if (SLIST_EMPTY(&pvh->pvh_head)) {/* no map on this page */
                splx(s);
-               return true;
+               return (true);
        }
 
        /* Write-back and invalidate TLB entry */
@@ -889,14 +897,14 @@
        }
        splx(s);
 
-       return true;
+       return (true);
 }
 



Home | Main Index | Thread Index | Old Index