kvm,mips: Fix potential swait_active() races
authorDavidlohr Bueso <dave@stgolabs.net>
Wed, 13 Sep 2017 20:08:24 +0000 (13:08 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 15 Sep 2017 14:57:13 +0000 (16:57 +0200)
commit4c0b4bc60f95de4741c89b41174760258343f091
tree60a9e39653ad9d755c962633f8ea63c4b88f76f1
parent267ad7bc2d3f69af536035b6a3e4a9a2b6ae11dc
kvm,mips: Fix potential swait_active() races

For example, the following could occur, making us miss a wakeup:

CPU0 CPU1
kvm_vcpu_block kvm_mips_comparecount_func
  [L] swait_active(&vcpu->wq)
  [S] prepare_to_swait(&vcpu->wq)
  [L] if (!kvm_vcpu_has_pending_timer(vcpu))
         schedule()                       [S] queue_timer_int(vcpu)

Ensure that the swait_active() check is not hoisted over the interrupt.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/mips/kvm/mips.c