aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2017-09-13 16:08:24 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2017-09-15 10:57:13 -0400
commit4c0b4bc60f95de4741c89b41174760258343f091 (patch)
tree60a9e39653ad9d755c962633f8ea63c4b88f76f1
parent267ad7bc2d3f69af536035b6a3e4a9a2b6ae11dc (diff)
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>
-rw-r--r--arch/mips/kvm/mips.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index bce2a6431430..d535edc01434 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -514,7 +514,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
514 514
515 dvcpu->arch.wait = 0; 515 dvcpu->arch.wait = 0;
516 516
517 if (swait_active(&dvcpu->wq)) 517 if (swq_has_sleeper(&dvcpu->wq))
518 swake_up(&dvcpu->wq); 518 swake_up(&dvcpu->wq);
519 519
520 return 0; 520 return 0;
@@ -1179,7 +1179,7 @@ static void kvm_mips_comparecount_func(unsigned long data)
1179 kvm_mips_callbacks->queue_timer_int(vcpu); 1179 kvm_mips_callbacks->queue_timer_int(vcpu);
1180 1180
1181 vcpu->arch.wait = 0; 1181 vcpu->arch.wait = 0;
1182 if (swait_active(&vcpu->wq)) 1182 if (swq_has_sleeper(&vcpu->wq))
1183 swake_up(&vcpu->wq); 1183 swake_up(&vcpu->wq);
1184} 1184}
1185 1185