git: DragonFly_RELEASE_2_8 kernel - Fix pmap deactivate/reactivation race.

Matthew Dillon dillon at
Sun Oct 24 09:39:41 PDT 2010

commit 5fe0f3a651685a127bb7332a351368a578a5fbdf
Author: Matthew Dillon <dillon at>
Date:   Sat Oct 23 09:43:18 2010 -0700

    kernel - Fix pmap deactivate/reactivation race.
    * The LWKT thread switch code clears the cpu mask bit in
      proc->p_vmspace->vm_pmap.pm_active, and the switch-in code sets the
      mask bit.
      This code has a bug because the switch code ALSO optimizes the loading
      of %cr3 to avoid reloading it if it hasn't changed, for example when
      switching between two user threads associated with the process,
      because the other cpu(s) running similar threads may lose track of
      the fact that our cpu also needs an IPI for page invalidations in the
      pmap for a short period of time.
      Because we don't reload %cr3 in this case, our tlb can become invalid.
      This can also occur with vfork() sequences.
    * Fix by testing that we are switching to the same vmspace and do not
      clear the pm_active bit in that case.  Retain the %cr3 optimization.

Summary of changes:
 sys/platform/pc32/i386/swtch.s      |   36 +++++++++--
 sys/platform/pc64/x86_64/ipl.s      |    2 +-
 sys/platform/pc64/x86_64/npx.c      |  119 -----------------------------------
 sys/platform/pc64/x86_64/swtch.s    |   51 +++++++++------
 sys/platform/pc64/x86_64/trap.c     |    1 -
 sys/platform/vkernel64/x86_64/npx.c |  119 -----------------------------------
 6 files changed, 64 insertions(+), 264 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list