kernel - Add additional safety assertions in the pmap path
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 8 Dec 2011 04:16:36 +0000 (20:16 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 8 Dec 2011 04:16:36 +0000 (20:16 -0800)
* Assert additional state is correct in pmap_pinit()

* Assert that the critical section count makes preemption impossible
  in pmap_interlock_wait(), which is called from the depths of swtch.s
  during a thread switch.

sys/platform/pc64/x86_64/pmap.c

index 0023cdc..53615d8 100644 (file)
@@ -1361,6 +1361,10 @@ pmap_pinit(struct pmap *pmap)
                KKASSERT(pv->pv_m->flags & PG_MAPPED);
                KKASSERT(pv->pv_m->flags & PG_WRITEABLE);
        }
+       KKASSERT(pmap->pm_pml4[255] == 0);
+       KKASSERT(RB_ROOT(&pmap->pm_pvroot) == pv);
+       KKASSERT(pv->pv_entry.rbe_left == NULL);
+       KKASSERT(pv->pv_entry.rbe_right == NULL);
 }
 
 /*
@@ -4045,6 +4049,7 @@ pmap_interlock_wait(struct vmspace *vm)
 
        if (pmap->pm_active & CPUMASK_LOCK) {
                crit_enter();
+               KKASSERT(curthread->td_critcount >= 2);
                DEBUG_PUSH_INFO("pmap_interlock_wait");
                while (pmap->pm_active & CPUMASK_LOCK) {
                        cpu_ccfence();