diff options
author | David Hildenbrand <david@redhat.com> | 2018-02-07 06:46:42 -0500 |
---|---|---|
committer | Christian Borntraeger <borntraeger@de.ibm.com> | 2018-02-20 15:50:29 -0500 |
commit | 5fe01793dd953ab947fababe8abaf5ed5258c8df (patch) | |
tree | d03e75f8bebc3f533f56f7808852453ed32bba1d | |
parent | baabee67f4135e3de87bc874929ac50637aacb0d (diff) |
KVM: s390: take care of clock-comparator sign control
Missed when enabling the Multiple-epoch facility. If the facility is
installed and the control is set, a sign based comaprison has to be
performed.
Right now we would inject wrong interrupts and ignore interrupt
conditions. Also the sleep time is calculated in a wrong way.
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180207114647.6220-2-david@redhat.com>
Fixes: 8fa1696ea781 ("KVM: s390: Multiple Epoch Facility support")
Cc: stable@vger.kernel.org
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
-rw-r--r-- | arch/s390/kvm/interrupt.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 3f2c49b1a393..b04616b57a94 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c | |||
@@ -169,8 +169,15 @@ static int ckc_interrupts_enabled(struct kvm_vcpu *vcpu) | |||
169 | 169 | ||
170 | static int ckc_irq_pending(struct kvm_vcpu *vcpu) | 170 | static int ckc_irq_pending(struct kvm_vcpu *vcpu) |
171 | { | 171 | { |
172 | if (vcpu->arch.sie_block->ckc >= kvm_s390_get_tod_clock_fast(vcpu->kvm)) | 172 | const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm); |
173 | const u64 ckc = vcpu->arch.sie_block->ckc; | ||
174 | |||
175 | if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) { | ||
176 | if ((s64)ckc >= (s64)now) | ||
177 | return 0; | ||
178 | } else if (ckc >= now) { | ||
173 | return 0; | 179 | return 0; |
180 | } | ||
174 | return ckc_interrupts_enabled(vcpu); | 181 | return ckc_interrupts_enabled(vcpu); |
175 | } | 182 | } |
176 | 183 | ||
@@ -1047,13 +1054,19 @@ int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) | |||
1047 | 1054 | ||
1048 | static u64 __calculate_sltime(struct kvm_vcpu *vcpu) | 1055 | static u64 __calculate_sltime(struct kvm_vcpu *vcpu) |
1049 | { | 1056 | { |
1050 | u64 now, cputm, sltime = 0; | 1057 | const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm); |
1058 | const u64 ckc = vcpu->arch.sie_block->ckc; | ||
1059 | u64 cputm, sltime = 0; | ||
1051 | 1060 | ||
1052 | if (ckc_interrupts_enabled(vcpu)) { | 1061 | if (ckc_interrupts_enabled(vcpu)) { |
1053 | now = kvm_s390_get_tod_clock_fast(vcpu->kvm); | 1062 | if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) { |
1054 | sltime = tod_to_ns(vcpu->arch.sie_block->ckc - now); | 1063 | if ((s64)now < (s64)ckc) |
1055 | /* already expired or overflow? */ | 1064 | sltime = tod_to_ns((s64)ckc - (s64)now); |
1056 | if (!sltime || vcpu->arch.sie_block->ckc <= now) | 1065 | } else if (now < ckc) { |
1066 | sltime = tod_to_ns(ckc - now); | ||
1067 | } | ||
1068 | /* already expired */ | ||
1069 | if (!sltime) | ||
1057 | return 0; | 1070 | return 0; |
1058 | if (cpu_timer_interrupts_enabled(vcpu)) { | 1071 | if (cpu_timer_interrupts_enabled(vcpu)) { |
1059 | cputm = kvm_s390_get_cpu_timer(vcpu); | 1072 | cputm = kvm_s390_get_cpu_timer(vcpu); |