From 8c5af5b85a9704757e0a130c10efb488cd647718 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 21 Feb 2010 18:47:34 -0800 Subject: [PATCH] kernel - Fix some rare pmap races in i386 and x86_64 (followup) * pmap_interlock_wait() is SMP-only. Fix UP build. * pmap_setlwpvm for i386 was missing a call to pmap_interlock_wait() --- sys/platform/pc32/i386/pmap.c | 5 +++++ sys/platform/pc64/x86_64/pmap.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/platform/pc32/i386/pmap.c b/sys/platform/pc32/i386/pmap.c index 2785d817c4..0b483e957d 100644 --- a/sys/platform/pc32/i386/pmap.c +++ b/sys/platform/pc32/i386/pmap.c @@ -3422,6 +3422,8 @@ pmap_setlwpvm(struct lwp *lp, struct vmspace *newvm) pmap = vmspace_pmap(newvm); #if defined(SMP) atomic_set_int(&pmap->pm_active, mycpu->gd_cpumask); + if (pmap->pm_active & CPUMASK_LOCK) + pmap_interlock_wait(newvm); #else pmap->pm_active |= 1; #endif @@ -3441,6 +3443,7 @@ pmap_setlwpvm(struct lwp *lp, struct vmspace *newvm) crit_exit(); } +#ifdef SMP /* * Called when switching to a locked pmap */ @@ -3459,6 +3462,8 @@ pmap_interlock_wait(struct vmspace *vm) } } +#endif + vm_offset_t pmap_addr_hint(vm_object_t obj, vm_offset_t addr, vm_size_t size) { diff --git a/sys/platform/pc64/x86_64/pmap.c b/sys/platform/pc64/x86_64/pmap.c index 3f76afa229..6a24eb1d50 100644 --- a/sys/platform/pc64/x86_64/pmap.c +++ b/sys/platform/pc64/x86_64/pmap.c @@ -3755,11 +3755,11 @@ pmap_setlwpvm(struct lwp *lp, struct vmspace *newvm) pmap = vmspace_pmap(newvm); #if defined(SMP) atomic_set_int(&pmap->pm_active, mycpu->gd_cpumask); + if (pmap->pm_active & CPUMASK_LOCK) + pmap_interlock_wait(newvm); #else pmap->pm_active |= 1; #endif - if (pmap->pm_active & CPUMASK_LOCK) - pmap_interlock_wait(newvm); #if defined(SWTCH_OPTIM_STATS) tlb_flush_count++; #endif @@ -3776,6 +3776,8 @@ pmap_setlwpvm(struct lwp *lp, struct vmspace *newvm) crit_exit(); } +#ifdef SMP + /* * Called when switching to a locked pmap */ @@ -3795,6 +3797,8 @@ pmap_interlock_wait(struct vmspace *vm) } } +#endif + vm_offset_t pmap_addr_hint(vm_object_t obj, vm_offset_t addr, vm_size_t size) { -- 2.11.4.GIT