Lines Matching refs:vcpu

66 	struct kvm_vcpu *vcpu = *(struct kvm_vcpu **)dev_id;  in kvm_arch_timer_handler()  local
74 pr_warn("Unexpected interrupt %d on vcpu %p\n", irq, vcpu); in kvm_arch_timer_handler()
84 struct kvm_vcpu *vcpu; in kvm_timer_inject_irq_work() local
86 vcpu = container_of(work, struct kvm_vcpu, arch.timer_cpu.expired); in kvm_timer_inject_irq_work()
87 vcpu->arch.timer_cpu.armed = false; in kvm_timer_inject_irq_work()
89 WARN_ON(!kvm_timer_should_fire(vcpu)); in kvm_timer_inject_irq_work()
95 kvm_vcpu_kick(vcpu); in kvm_timer_inject_irq_work()
98 static u64 kvm_timer_compute_delta(struct kvm_vcpu *vcpu) in kvm_timer_compute_delta() argument
102 cval = vcpu->arch.timer_cpu.cntv_cval; in kvm_timer_compute_delta()
103 now = kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff; in kvm_timer_compute_delta()
121 struct kvm_vcpu *vcpu; in kvm_timer_expire() local
125 vcpu = container_of(timer, struct kvm_vcpu, arch.timer_cpu); in kvm_timer_expire()
132 ns = kvm_timer_compute_delta(vcpu); in kvm_timer_expire()
142 static bool kvm_timer_irq_can_fire(struct kvm_vcpu *vcpu) in kvm_timer_irq_can_fire() argument
144 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_irq_can_fire()
150 bool kvm_timer_should_fire(struct kvm_vcpu *vcpu) in kvm_timer_should_fire() argument
152 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_should_fire()
155 if (!kvm_timer_irq_can_fire(vcpu)) in kvm_timer_should_fire()
159 now = kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff; in kvm_timer_should_fire()
164 static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level) in kvm_timer_update_irq() argument
167 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_update_irq()
169 BUG_ON(!vgic_initialized(vcpu->kvm)); in kvm_timer_update_irq()
172 trace_kvm_timer_update_irq(vcpu->vcpu_id, timer->map->virt_irq, in kvm_timer_update_irq()
174 ret = kvm_vgic_inject_mapped_irq(vcpu->kvm, vcpu->vcpu_id, in kvm_timer_update_irq()
184 static int kvm_timer_update_state(struct kvm_vcpu *vcpu) in kvm_timer_update_state() argument
186 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_update_state()
194 if (!vgic_initialized(vcpu->kvm)) in kvm_timer_update_state()
197 if (kvm_timer_should_fire(vcpu) != timer->irq.level) in kvm_timer_update_state()
198 kvm_timer_update_irq(vcpu, !timer->irq.level); in kvm_timer_update_state()
208 void kvm_timer_schedule(struct kvm_vcpu *vcpu) in kvm_timer_schedule() argument
210 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_schedule()
219 if (kvm_timer_should_fire(vcpu)) in kvm_timer_schedule()
226 if (!kvm_timer_irq_can_fire(vcpu)) in kvm_timer_schedule()
230 timer_arm(timer, kvm_timer_compute_delta(vcpu)); in kvm_timer_schedule()
233 void kvm_timer_unschedule(struct kvm_vcpu *vcpu) in kvm_timer_unschedule() argument
235 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_unschedule()
246 void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) in kvm_timer_flush_hwstate() argument
248 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_flush_hwstate()
252 if (kvm_timer_update_state(vcpu)) in kvm_timer_flush_hwstate()
272 if (timer->irq.level || kvm_vgic_map_is_active(vcpu, timer->map)) in kvm_timer_flush_hwstate()
290 void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu) in kvm_timer_sync_hwstate() argument
292 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_sync_hwstate()
300 kvm_timer_update_state(vcpu); in kvm_timer_sync_hwstate()
303 int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu, in kvm_timer_vcpu_reset() argument
306 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_vcpu_reset()
324 kvm_timer_update_state(vcpu); in kvm_timer_vcpu_reset()
330 map = kvm_vgic_map_phys_irq(vcpu, irq->irq, host_vtimer_irq); in kvm_timer_vcpu_reset()
338 void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu) in kvm_timer_vcpu_init() argument
340 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_vcpu_init()
352 int kvm_arm_timer_set_reg(struct kvm_vcpu *vcpu, u64 regid, u64 value) in kvm_arm_timer_set_reg() argument
354 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_arm_timer_set_reg()
361 vcpu->kvm->arch.timer.cntvoff = kvm_phys_timer_read() - value; in kvm_arm_timer_set_reg()
370 kvm_timer_update_state(vcpu); in kvm_arm_timer_set_reg()
374 u64 kvm_arm_timer_get_reg(struct kvm_vcpu *vcpu, u64 regid) in kvm_arm_timer_get_reg() argument
376 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_arm_timer_get_reg()
382 return kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff; in kvm_arm_timer_get_reg()
472 void kvm_timer_vcpu_terminate(struct kvm_vcpu *vcpu) in kvm_timer_vcpu_terminate() argument
474 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; in kvm_timer_vcpu_terminate()
478 kvm_vgic_unmap_phys_irq(vcpu, timer->map); in kvm_timer_vcpu_terminate()