kernel - Fix GCC reordering problem with td_critcount
commita4d95680362b7eba0c4840b8d5598533900a2f17
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 3 Oct 2017 01:42:34 +0000 (2 18:42 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 3 Oct 2017 01:42:34 +0000 (2 18:42 -0700)
treec52e4e7eda73facad2f372608f914abb257ff530
parentbb36d905d2bf2569ce40fc3ebdab1877ae6342bf
kernel - Fix GCC reordering problem with td_critcount

* Wrap all ++td->td_critcount and --td->td_critcount use cases
  with an inline which executes cpu_ccfence() before and after,
  to guarantee that GCC does not try to reorder the operation around
  critical memory changes.

* This fixes a race in lockmgr() and possibly a few other places
  too.
sys/kern/kern_mutex.c
sys/kern/kern_spinlock.c
sys/kern/lwkt_thread.c
sys/platform/vkernel64/platform/machintr.c
sys/platform/vkernel64/x86_64/exception.c
sys/sys/mutex2.h
sys/sys/spinlock2.h
sys/sys/thread2.h