Lines Matching refs:ctx

227 	struct arch_timer_context *ctx;
242 ctx = map.direct_vtimer;
244 ctx = map.direct_ptimer;
246 if (kvm_timer_should_fire(ctx))
247 kvm_timer_update_irq(vcpu, true, ctx);
296 struct arch_timer_context *ctx;
298 ctx = (vcpu_has_nv(vcpu) && is_hyp_ctxt(vcpu)) ? vcpu_hvtimer(vcpu)
301 return kvm_counter_compute_delta(ctx, val);
314 struct arch_timer_context *ctx = &vcpu->arch.timer_cpu.timers[i];
316 WARN(ctx->loaded, "timer %d loaded\n", i);
317 if (kvm_timer_irq_can_fire(ctx))
318 min_delta = min(min_delta, kvm_timer_compute_delta(ctx));
357 struct arch_timer_context *ctx;
361 ctx = container_of(hrt, struct arch_timer_context, hrtimer);
362 vcpu = ctx->vcpu;
364 trace_kvm_timer_hrtimer_expire(ctx);
371 ns = kvm_timer_compute_delta(ctx);
377 kvm_timer_update_irq(vcpu, true, ctx);
465 static void timer_emulate(struct arch_timer_context *ctx)
467 bool should_fire = kvm_timer_should_fire(ctx);
469 trace_kvm_timer_emulate(ctx, should_fire);
471 if (should_fire != ctx->irq.level) {
472 kvm_timer_update_irq(ctx->vcpu, should_fire, ctx);
481 if (should_fire || !kvm_timer_irq_can_fire(ctx))
484 soft_timer_start(&ctx->hrtimer, kvm_timer_compute_delta(ctx));
498 static void timer_save_state(struct arch_timer_context *ctx)
500 struct arch_timer_cpu *timer = vcpu_timer(ctx->vcpu);
501 enum kvm_arch_timers index = arch_timer_ctx_index(ctx);
509 if (!ctx->loaded)
517 timer_set_ctl(ctx, read_sysreg_el0(SYS_CNTV_CTL));
518 timer_set_cval(ctx, read_sysreg_el0(SYS_CNTV_CVAL));
543 timer_set_ctl(ctx, read_sysreg_el0(SYS_CNTP_CTL));
546 cval -= timer_get_offset(ctx);
548 timer_set_cval(ctx, cval);
560 trace_kvm_timer_save_state(ctx);
562 ctx->loaded = false;
604 static void timer_restore_state(struct arch_timer_context *ctx)
606 struct arch_timer_cpu *timer = vcpu_timer(ctx->vcpu);
607 enum kvm_arch_timers index = arch_timer_ctx_index(ctx);
615 if (ctx->loaded)
623 set_cntvoff(timer_get_offset(ctx));
624 write_sysreg_el0(timer_get_cval(ctx), SYS_CNTV_CVAL);
626 write_sysreg_el0(timer_get_ctl(ctx), SYS_CNTV_CTL);
630 cval = timer_get_cval(ctx);
631 offset = timer_get_offset(ctx);
636 write_sysreg_el0(timer_get_ctl(ctx), SYS_CNTP_CTL);
642 trace_kvm_timer_restore_state(ctx);
644 ctx->loaded = true;
649 static inline void set_timer_irq_phys_active(struct arch_timer_context *ctx, bool active)
652 r = irq_set_irqchip_state(ctx->host_timer_irq, IRQCHIP_STATE_ACTIVE, active);
656 static void kvm_timer_vcpu_load_gic(struct arch_timer_context *ctx)
658 struct kvm_vcpu *vcpu = ctx->vcpu;
667 kvm_timer_update_irq(ctx->vcpu, kvm_timer_should_fire(ctx), ctx);
670 phys_active = kvm_vgic_map_is_active(vcpu, timer_irq(ctx));
672 phys_active |= ctx->irq.level;
674 set_timer_irq_phys_active(ctx, phys_active);
1463 struct arch_timer_context *ctx;
1466 ctx = vcpu_get_timer(vcpu, i);
1467 irq = timer_irq(ctx);
1468 if (kvm_vgic_set_owner(vcpu, irq, ctx))
1496 struct arch_timer_context *ctx;
1498 ctx = vcpu_get_timer(vcpu, i);
1499 if (timer_irq(ctx) == vintid)
1500 return kvm_timer_should_fire(ctx);