diff options
author | Suresh E. Warrier <warrier@linux.vnet.ibm.com> | 2014-11-03 15:52:00 +1100 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-12-15 13:27:25 +0100 |
commit | 1bc5d59c35976d39b39b14f86abb76c08364cf97 (patch) | |
tree | a74507c75182d8e542940477be7f0c3ea7bbea17 /arch/powerpc | |
parent | ffada016fb22fbbb9849d3cc5ec72ca8f0377681 (diff) | |
download | linux-1bc5d59c35976d39b39b14f86abb76c08364cf97.tar.gz linux-1bc5d59c35976d39b39b14f86abb76c08364cf97.tar.bz2 linux-1bc5d59c35976d39b39b14f86abb76c08364cf97.zip |
KVM: PPC: Book3S HV: Check wait conditions before sleeping in kvmppc_vcore_blocked
The kvmppc_vcore_blocked() code does not check for the wait condition
after putting the process on the wait queue. This means that it is
possible for an external interrupt to become pending, but the vcpu to
remain asleep until the next decrementer interrupt. The fix is to
make one last check for pending exceptions and ceded state before
calling schedule().
Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kvm/book3s_hv.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index cd7e030087f8..1a7a281be3bd 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1828,9 +1828,29 @@ static void kvmppc_wait_for_exec(struct kvm_vcpu *vcpu, int wait_state) */ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) { + struct kvm_vcpu *vcpu; + int do_sleep = 1; + DEFINE_WAIT(wait); prepare_to_wait(&vc->wq, &wait, TASK_INTERRUPTIBLE); + + /* + * Check one last time for pending exceptions and ceded state after + * we put ourselves on the wait queue + */ + list_for_each_entry(vcpu, &vc->runnable_threads, arch.run_list) { + if (vcpu->arch.pending_exceptions || !vcpu->arch.ceded) { + do_sleep = 0; + break; + } + } + + if (!do_sleep) { + finish_wait(&vc->wq, &wait); + return; + } + vc->vcore_state = VCORE_SLEEPING; spin_unlock(&vc->lock); schedule(); |