arm: KVM: Don't return PSCI_INVAL if waitqueue is inactive
[linux-2.6-block.git] / arch / arm / kvm / psci.c
index 0881bf169fbce5cf09db6da3ff0996df6cf989cb..448f60e8d23ca0c9886baa72ea437087b4fea41e 100644 (file)
@@ -54,15 +54,15 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
                }
        }
 
-       if (!vcpu)
+       /*
+        * Make sure the caller requested a valid CPU and that the CPU is
+        * turned off.
+        */
+       if (!vcpu || !vcpu->arch.pause)
                return KVM_PSCI_RET_INVAL;
 
        target_pc = *vcpu_reg(source_vcpu, 2);
 
-       wq = kvm_arch_vcpu_wq(vcpu);
-       if (!waitqueue_active(wq))
-               return KVM_PSCI_RET_INVAL;
-
        kvm_reset_vcpu(vcpu);
 
        /* Gracefully handle Thumb2 entry point */
@@ -79,6 +79,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
        vcpu->arch.pause = false;
        smp_mb();               /* Make sure the above is visible */
 
+       wq = kvm_arch_vcpu_wq(vcpu);
        wake_up_interruptible(wq);
 
        return KVM_PSCI_RET_SUCCESS;