From 4729bd79cbe35c3b82edb036e2b7f40e696954ca Mon Sep 17 00:00:00 2001 From: Svatopluk Kraus Date: Wed, 16 Dec 2015 10:55:19 +0000 Subject: [PATCH] Adopt assert from amd64 in pmap_remove_pages(). Suggested by: kib Approved by: kib (mentor) --- sys/arm/arm/pmap-v6-new.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sys/arm/arm/pmap-v6-new.c b/sys/arm/arm/pmap-v6-new.c index 4e58cf68e4c3..8d14ed7a07ef 100644 --- a/sys/arm/arm/pmap-v6-new.c +++ b/sys/arm/arm/pmap-v6-new.c @@ -4153,10 +4153,25 @@ pmap_remove_pages(pmap_t pmap) uint32_t inuse, bitmask; boolean_t allfree; - if (pmap != vmspace_pmap(curthread->td_proc->p_vmspace)) { - printf("warning: %s called with non-current pmap\n", __func__); - return; + /* + * Assert that the given pmap is only active on the current + * CPU. Unfortunately, we cannot block another CPU from + * activating the pmap while this function is executing. + */ + KASSERT(pmap == vmspace_pmap(curthread->td_proc->p_vmspace), + ("%s: non-current pmap %p", __func__, pmap)); +#if defined(SMP) && defined(INVARIANTS) + { + cpuset_t other_cpus; + + sched_pin(); + other_cpus = pmap->pm_active; + CPU_CLR(PCPU_GET(cpuid), &other_cpus); + sched_unpin(); + KASSERT(CPU_EMPTY(&other_cpus), + ("%s: pmap %p active on other cpus", __func__, pmap)); } +#endif SLIST_INIT(&free); rw_wlock(&pvh_global_lock); PMAP_LOCK(pmap);