aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@linaro.org>2016-09-27 15:08:04 -0400
committerChristoffer Dall <cdall@linaro.org>2017-04-09 10:49:37 -0400
commitb22e7df2d85fcbe8b36bab909b98c3d0239e69e6 (patch)
treea7d58a10ebc8b3370696c9e6e4fbfb97982eb037
parentd824ca52abd020a36948d12f2c6704ea2ae12513 (diff)
KVM: arm/arm64: Cleanup the arch timer code's irqchip checking
Currently we check if we have an in-kernel irqchip and if the vgic was properly implemented several places in the arch timer code. But, we already predicate our enablement of the arm timers on having a valid and initialized gic, so we can simply check if the timers are enabled or not. This also gets rid of the ugly "error that's not an error but used to signal that the timer shouldn't poke the gic" construct we have. Reviewed-by: Alexander Graf <agraf@suse.de> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
-rw-r--r--virt/kvm/arm/arch_timer.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index 35d7100e0815..363f0d2cfc79 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -189,8 +189,6 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level,
189{ 189{
190 int ret; 190 int ret;
191 191
192 BUG_ON(!vgic_initialized(vcpu->kvm));
193
194 timer_ctx->active_cleared_last = false; 192 timer_ctx->active_cleared_last = false;
195 timer_ctx->irq.level = new_level; 193 timer_ctx->irq.level = new_level;
196 trace_kvm_timer_update_irq(vcpu->vcpu_id, timer_ctx->irq.irq, 194 trace_kvm_timer_update_irq(vcpu->vcpu_id, timer_ctx->irq.irq,
@@ -205,7 +203,7 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level,
205 * Check if there was a change in the timer state (should we raise or lower 203 * Check if there was a change in the timer state (should we raise or lower
206 * the line level to the GIC). 204 * the line level to the GIC).
207 */ 205 */
208static int kvm_timer_update_state(struct kvm_vcpu *vcpu) 206static void kvm_timer_update_state(struct kvm_vcpu *vcpu)
209{ 207{
210 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; 208 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
211 struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); 209 struct arch_timer_context *vtimer = vcpu_vtimer(vcpu);
@@ -217,16 +215,14 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu)
217 * because the guest would never see the interrupt. Instead wait 215 * because the guest would never see the interrupt. Instead wait
218 * until we call this function from kvm_timer_flush_hwstate. 216 * until we call this function from kvm_timer_flush_hwstate.
219 */ 217 */
220 if (!vgic_initialized(vcpu->kvm) || !timer->enabled) 218 if (!timer->enabled)
221 return -ENODEV; 219 return;
222 220
223 if (kvm_timer_should_fire(vtimer) != vtimer->irq.level) 221 if (kvm_timer_should_fire(vtimer) != vtimer->irq.level)
224 kvm_timer_update_irq(vcpu, !vtimer->irq.level, vtimer); 222 kvm_timer_update_irq(vcpu, !vtimer->irq.level, vtimer);
225 223
226 if (kvm_timer_should_fire(ptimer) != ptimer->irq.level) 224 if (kvm_timer_should_fire(ptimer) != ptimer->irq.level)
227 kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer); 225 kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer);
228
229 return 0;
230} 226}
231 227
232/* Schedule the background timer for the emulated timer. */ 228/* Schedule the background timer for the emulated timer. */
@@ -295,13 +291,16 @@ void kvm_timer_unschedule(struct kvm_vcpu *vcpu)
295 */ 291 */
296void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) 292void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu)
297{ 293{
294 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
298 struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); 295 struct arch_timer_context *vtimer = vcpu_vtimer(vcpu);
299 bool phys_active; 296 bool phys_active;
300 int ret; 297 int ret;
301 298
302 if (kvm_timer_update_state(vcpu)) 299 if (unlikely(!timer->enabled))
303 return; 300 return;
304 301
302 kvm_timer_update_state(vcpu);
303
305 /* Set the background timer for the physical timer emulation. */ 304 /* Set the background timer for the physical timer emulation. */
306 kvm_timer_emulate(vcpu, vcpu_ptimer(vcpu)); 305 kvm_timer_emulate(vcpu, vcpu_ptimer(vcpu));
307 306