Skip to content

Commit b22e7df

Browse files
chazyChristoffer Dall
authored andcommitted
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 <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Signed-off-by: Christoffer Dall <[email protected]>
1 parent d824ca5 commit b22e7df

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

virt/kvm/arm/arch_timer.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level,
189189
{
190190
int ret;
191191

192-
BUG_ON(!vgic_initialized(vcpu->kvm));
193-
194192
timer_ctx->active_cleared_last = false;
195193
timer_ctx->irq.level = new_level;
196194
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,
205203
* Check if there was a change in the timer state (should we raise or lower
206204
* the line level to the GIC).
207205
*/
208-
static int kvm_timer_update_state(struct kvm_vcpu *vcpu)
206+
static void kvm_timer_update_state(struct kvm_vcpu *vcpu)
209207
{
210208
struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
211209
struct arch_timer_context *vtimer = vcpu_vtimer(vcpu);
@@ -217,16 +215,14 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu)
217215
* because the guest would never see the interrupt. Instead wait
218216
* until we call this function from kvm_timer_flush_hwstate.
219217
*/
220-
if (!vgic_initialized(vcpu->kvm) || !timer->enabled)
221-
return -ENODEV;
218+
if (!timer->enabled)
219+
return;
222220

223221
if (kvm_timer_should_fire(vtimer) != vtimer->irq.level)
224222
kvm_timer_update_irq(vcpu, !vtimer->irq.level, vtimer);
225223

226224
if (kvm_timer_should_fire(ptimer) != ptimer->irq.level)
227225
kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer);
228-
229-
return 0;
230226
}
231227

232228
/* Schedule the background timer for the emulated timer. */
@@ -295,13 +291,16 @@ void kvm_timer_unschedule(struct kvm_vcpu *vcpu)
295291
*/
296292
void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu)
297293
{
294+
struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
298295
struct arch_timer_context *vtimer = vcpu_vtimer(vcpu);
299296
bool phys_active;
300297
int ret;
301298

302-
if (kvm_timer_update_state(vcpu))
299+
if (unlikely(!timer->enabled))
303300
return;
304301

302+
kvm_timer_update_state(vcpu);
303+
305304
/* Set the background timer for the physical timer emulation. */
306305
kvm_timer_emulate(vcpu, vcpu_ptimer(vcpu));
307306

0 commit comments

Comments
 (0)