kernel - Fix pmap deactivate/reactivation race.
commit5fe0f3a651685a127bb7332a351368a578a5fbdf
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 23 Oct 2010 16:43:18 +0000 (23 09:43 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 24 Oct 2010 16:36:45 +0000 (24 09:36 -0700)
tree10d81bbbb6479502206ee0fa308dbc82915a75ef
parent9bbe2f36c777e6ba8ea574616ed330c1eb4cf653
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.
sys/platform/pc32/i386/swtch.s
sys/platform/pc64/x86_64/ipl.s
sys/platform/pc64/x86_64/npx.c
sys/platform/pc64/x86_64/swtch.s
sys/platform/pc64/x86_64/trap.c
sys/platform/vkernel64/x86_64/npx.c