Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm/pmap KERNEL_PID is > 0 on powerpc/ibm4xx, need to ma...



details:   https://anonhg.NetBSD.org/src/rev/e9a49425eaa3
branches:  trunk
changeset: 829999:e9a49425eaa3
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Wed Feb 21 21:53:54 2018 +0000

description:
KERNEL_PID is > 0 on powerpc/ibm4xx, need to mask all bits <0,
KERNEL_PID> to avoid triggering KASSERT() checking allocated asid
is bigger than KERNEL_PID; adjust also TLBINFO_ASID_INITIAL_FREE()
accordingly

discussed with Nick

diffstat:

 sys/uvm/pmap/pmap_tlb.c |  49 ++++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 23 deletions(-)

diffs (113 lines):

diff -r 498ef67af04c -r e9a49425eaa3 sys/uvm/pmap/pmap_tlb.c
--- a/sys/uvm/pmap/pmap_tlb.c   Wed Feb 21 17:04:52 2018 +0000
+++ b/sys/uvm/pmap/pmap_tlb.c   Wed Feb 21 21:53:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_tlb.c,v 1.25 2018/02/19 22:01:15 jdolecek Exp $   */
+/*     $NetBSD: pmap_tlb.c,v 1.26 2018/02/21 21:53:54 jdolecek Exp $   */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.25 2018/02/19 22:01:15 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.26 2018/02/21 21:53:54 jdolecek Exp $");
 
 /*
  * Manages address spaces in a TLB.
@@ -144,14 +144,30 @@
 #error "KERNEL_PID expected in range 0-31"
 #endif
 
+#define        TLBINFO_ASID_MARK_UNUSED(ti, asid) \
+       __BITMAP_CLR((asid), &(ti)->ti_asid_bitmap)
+#define        TLBINFO_ASID_MARK_USED(ti, asid) \
+       __BITMAP_SET((asid), &(ti)->ti_asid_bitmap)
+#define        TLBINFO_ASID_INUSE_P(ti, asid) \
+       __BITMAP_ISSET((asid), &(ti)->ti_asid_bitmap)
+#define        TLBINFO_ASID_RESET(ti) \
+       do {                                                            \
+               __BITMAP_ZERO(&ti->ti_asid_bitmap);                     \
+               for (tlb_asid_t asid = 0; asid <= KERNEL_PID; asid++)   \
+                       TLBINFO_ASID_MARK_USED(ti, asid);               \
+       } while (0)
+#define        TLBINFO_ASID_INITIAL_FREE(asid_max) \
+       (asid_max + 1 /* 0 */ - (1 + KERNEL_PID))
+
 struct pmap_tlb_info pmap_tlb0_info = {
        .ti_name = "tlb0",
        .ti_asid_hint = KERNEL_PID + 1,
 #ifdef PMAP_TLB_NUM_PIDS
        .ti_asid_max = IFCONSTANT(PMAP_TLB_NUM_PIDS - 1),
-       .ti_asids_free = IFCONSTANT(PMAP_TLB_NUM_PIDS - (1 + KERNEL_PID)),
+       .ti_asids_free = IFCONSTANT(
+               TLBINFO_ASID_INITIAL_FREE(PMAP_TLB_NUM_PIDS - 1)),
 #endif
-       .ti_asid_bitmap._b[0] = __BIT(KERNEL_PID),
+       .ti_asid_bitmap._b[0] = __BITS(0, KERNEL_PID),
 #ifdef PMAP_TLB_WIRED_UPAGES
        .ti_wired = PMAP_TLB_WIRED_UPAGES,
 #endif
@@ -171,20 +187,6 @@
 u_int pmap_ntlbs = 1;
 #endif
 
-#define        TLBINFO_ASID_MARK_UNUSED(ti, asid) \
-       __BITMAP_CLR((asid), &(ti)->ti_asid_bitmap)
-#define        TLBINFO_ASID_MARK_USED(ti, asid) \
-       __BITMAP_SET((asid), &(ti)->ti_asid_bitmap)
-#define        TLBINFO_ASID_INUSE_P(ti, asid) \
-       __BITMAP_ISSET((asid), &(ti)->ti_asid_bitmap)
-#define        TLBINFO_ASID_RESET(ti) \
-       do {                                            \
-               __BITMAP_ZERO(&ti->ti_asid_bitmap);     \
-               TLBINFO_ASID_MARK_USED(ti, KERNEL_PID); \
-       } while (0)
-#define        TLBINFO_ASID_INITIAL_FREE(ti) \
-       ((ti)->ti_asid_max + 1 /* 0 */ - 1 /* reserved KERNEL_PID */)
-
 #ifdef MULTIPROCESSOR
 __unused static inline bool
 pmap_tlb_intersecting_active_p(pmap_t pm, struct pmap_tlb_info *ti)
@@ -338,10 +340,10 @@
                KASSERT(pmap_tlbs[pmap_ntlbs] == NULL);
 
                ti->ti_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SCHED);
-               TLBINFO_ASID_MARK_USED(ti, KERNEL_PID);
+               TLBINFO_ASID_RESET(ti);
                ti->ti_asid_hint = KERNEL_PID + 1;
                ti->ti_asid_max = pmap_tlbs[0]->ti_asid_max;
-               ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti);
+               ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti->ti_asid_max);
                ti->ti_tlbinvop = TLBINV_NOBODY;
                ti->ti_victim = NULL;
                kcpuset_create(&ti->ti_kcpuset, true);
@@ -368,7 +370,7 @@
        //printf("asid ");
        if (ti->ti_asid_max == 0) {
                ti->ti_asid_max = pmap_md_tlb_asid_max();
-               ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti);
+               ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti->ti_asid_max);
        }
 
        KASSERT(ti->ti_asid_max < PMAP_TLB_BITMAP_LENGTH);
@@ -427,7 +429,7 @@
         * First, clear the ASID bitmap (except for ASID 0 which belongs
         * to the kernel).
         */
-       ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti);
+       ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti->ti_asid_max);
        ti->ti_asid_hint = KERNEL_PID + 1;
        TLBINFO_ASID_RESET(ti);
 
@@ -471,7 +473,8 @@
                        tlb_invalidate_all();
 #endif /* MULTIPROCESSOR && !PMAP_TLB_NEED_SHOOTDOWN */
                        TLBINFO_ASID_RESET(ti);
-                       ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti);
+                       ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(
+                               ti->ti_asid_max);
 #if !defined(MULTIPROCESSOR) || defined(PMAP_TLB_NEED_SHOOTDOWN)
                } else {
                        ti->ti_asids_free -= asids_found;



Home | Main Index | Thread Index | Old Index