KVM: s390: switch to get_tod_clock() and fix STP sync races
[firefly-linux-kernel-4.4.55.git] / arch / s390 / kvm / priv.c
index 4d21dc4d1a845ba38c86290594c07116b651d17c..b253de5b894561a72c11ba4ac577049bcc60a7d6 100644 (file)
@@ -34,7 +34,7 @@
 static int handle_set_clock(struct kvm_vcpu *vcpu)
 {
        struct kvm_vcpu *cpup;
-       s64 hostclk, val;
+       s64 val;
        int i, rc;
        ar_t ar;
        u64 op2;
@@ -49,15 +49,11 @@ static int handle_set_clock(struct kvm_vcpu *vcpu)
        if (rc)
                return kvm_s390_inject_prog_cond(vcpu, rc);
 
-       if (store_tod_clock(&hostclk)) {
-               kvm_s390_set_psw_cc(vcpu, 3);
-               return 0;
-       }
        VCPU_EVENT(vcpu, 3, "SCK: setting guest TOD to 0x%llx", val);
-       val = (val - hostclk) & ~0x3fUL;
 
        mutex_lock(&vcpu->kvm->lock);
        preempt_disable();
+       val = (val - get_tod_clock()) & ~0x3fUL;
        kvm_for_each_vcpu(i, cpup, vcpu->kvm)
                cpup->arch.sie_block->epoch = val;
        preempt_enable();