Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/arch/powerpc/ibm4xx Pull up following revision(s) (re...



details:   https://anonhg.NetBSD.org/src/rev/8851d30325f3
branches:  netbsd-9
changeset: 745291:8851d30325f3
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Feb 27 18:23:10 2020 +0000

description:
Pull up following revision(s) (requested by rin in ticket #731):

        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.80
        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.77
        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.78
        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.79

Fix NULL dereference; "pap" argument of pmap_extract(9) can be NULL.

 -

Fix off-by-one error for ctx (ASID).

 -

Note that NUM_CTX = 256 = 0 stands for disabling protection by ASID.
Clear ti_ctx when flushing a TLB entry for clarity.

 -

In ppc4xx_tlb_find_victim(), mark kernel stack page TLBF_REF instead of
TLBF_USED. This should be originally intended behavior of this code
segment, because
- TLBF_USED is already checked just before, so marking this page
  TLBF_USED is no-op.
- TLBF_REF flag exempts that page from being flushed from TLB in next
  scan, when kernel stack may be still there with high probability.

diffstat:

 sys/arch/powerpc/ibm4xx/pmap.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (62 lines):

diff -r 115404883a50 -r 8851d30325f3 sys/arch/powerpc/ibm4xx/pmap.c
--- a/sys/arch/powerpc/ibm4xx/pmap.c    Thu Feb 27 17:28:57 2020 +0000
+++ b/sys/arch/powerpc/ibm4xx/pmap.c    Thu Feb 27 18:23:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.76 2016/12/24 19:02:16 cherry Exp $ */
+/*     $NetBSD: pmap.c,v 1.76.20.1 2020/02/27 18:23:10 martin Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76 2016/12/24 19:02:16 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76.20.1 2020/02/27 18:23:10 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -1021,7 +1021,7 @@
        int s;
 
        s = splvm();
-       if (pm->pm_ptbl[seg] && (pa = pm->pm_ptbl[seg][ptn])) {
+       if (pm->pm_ptbl[seg] && (pa = pm->pm_ptbl[seg][ptn]) && pap) {
                *pap = TTE_PA(pa) | (va & PGOFSET);
        }
        splx(s);
@@ -1276,7 +1276,7 @@
                            (tlb_info[tlbnext].ti_ctx == KERNEL_PID) &&
                             (flags & TLBF_USED)) {
                                /* Kernel stack page */
-                               flags |= TLBF_USED;
+                               flags |= TLBF_REF;
                                tlb_info[tlbnext].ti_flags = flags;
                        } else {
                                /* Found it! */
@@ -1535,6 +1535,7 @@
 #endif
                        /* Invalidate particular TLB entry regardless of locked status */
                        __asm volatile("tlbwe %0,%1,0" : :"r"(0),"r"(i));
+                       tlb_info[i].ti_ctx = 0;
                        tlb_info[i].ti_flags = 0;
                }
        }
@@ -1563,7 +1564,7 @@
        /* Find a likely context. */
        cnum = next;
        do {
-               if ((++cnum) > NUMCTX)
+               if ((++cnum) >= NUMCTX)
                        cnum = MINCTX;
        } while (ctxbusy[cnum] != NULL && cnum != next);
 
@@ -1573,7 +1574,7 @@
                cnum = MINCTX; /* Never steal ctx 0 or 1 */
        if (ctx_flush(cnum)) {
                /* oops -- something's wired. */
-               if ((++cnum) > NUMCTX)
+               if ((++cnum) >= NUMCTX)
                        cnum = MINCTX;
                goto oops;
        }



Home | Main Index | Thread Index | Old Index