Lines Matching defs:kvm

10 #include <kvm/arm_vgic.h>
46 * @kvm: The VM whose VGIC districutor should be initialized
52 void kvm_vgic_early_init(struct kvm *kvm)
54 struct vgic_dist *dist = &kvm->arch.vgic;
68 * @kvm: kvm struct pointer
71 int kvm_vgic_create(struct kvm *kvm, u32 type)
88 lockdep_assert_held(&kvm->lock);
91 if (!lock_all_vcpus(kvm))
94 mutex_lock(&kvm->arch.config_lock);
96 if (irqchip_in_kernel(kvm)) {
101 kvm_for_each_vcpu(i, vcpu, kvm) {
108 kvm->max_vcpus = VGIC_V2_MAX_CPUS;
110 kvm->max_vcpus = VGIC_V3_MAX_CPUS;
112 if (atomic_read(&kvm->online_vcpus) > kvm->max_vcpus) {
117 kvm->arch.vgic.in_kernel = true;
118 kvm->arch.vgic.vgic_model = type;
120 kvm->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF;
123 kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF;
125 INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions);
128 mutex_unlock(&kvm->arch.config_lock);
129 unlock_all_vcpus(kvm);
137 * @kvm: kvm struct pointer
140 static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
142 struct vgic_dist *dist = &kvm->arch.vgic;
143 struct kvm_vcpu *vcpu0 = kvm_get_vcpu(kvm, 0);
197 struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
230 if (!irqchip_in_kernel(vcpu->kvm))
238 mutex_lock(&vcpu->kvm->slots_lock);
240 mutex_unlock(&vcpu->kvm->slots_lock);
262 int vgic_init(struct kvm *kvm)
264 struct vgic_dist *dist = &kvm->arch.vgic;
269 lockdep_assert_held(&kvm->arch.config_lock);
271 if (vgic_initialized(kvm))
275 if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus))
282 ret = kvm_vgic_dist_init(kvm, dist->nr_spis);
287 kvm_for_each_vcpu(idx, vcpu, kvm) {
308 if (vgic_has_its(kvm))
309 vgic_lpi_translation_cache_init(kvm);
316 if (vgic_supports_direct_msis(kvm)) {
317 ret = vgic_v4_init(kvm);
322 kvm_for_each_vcpu(idx, vcpu, kvm)
325 ret = kvm_vgic_setup_default_irq_routing(kvm);
329 vgic_debug_init(kvm);
343 static void kvm_vgic_dist_destroy(struct kvm *kvm)
345 struct vgic_dist *dist = &kvm->arch.vgic;
364 if (vgic_has_its(kvm))
365 vgic_lpi_translation_cache_destroy(kvm);
367 if (vgic_supports_direct_msis(kvm))
368 vgic_v4_teardown(kvm);
382 if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) {
390 struct kvm *kvm = vcpu->kvm;
392 mutex_lock(&kvm->slots_lock);
394 mutex_unlock(&kvm->slots_lock);
397 void kvm_vgic_destroy(struct kvm *kvm)
402 mutex_lock(&kvm->slots_lock);
404 vgic_debug_destroy(kvm);
406 kvm_for_each_vcpu(i, vcpu, kvm)
409 mutex_lock(&kvm->arch.config_lock);
411 kvm_vgic_dist_destroy(kvm);
413 mutex_unlock(&kvm->arch.config_lock);
414 mutex_unlock(&kvm->slots_lock);
421 * @kvm: kvm struct pointer
423 int vgic_lazy_init(struct kvm *kvm)
427 if (unlikely(!vgic_initialized(kvm))) {
434 if (kvm->arch.vgic.vgic_model != KVM_DEV_TYPE_ARM_VGIC_V2)
437 mutex_lock(&kvm->arch.config_lock);
438 ret = vgic_init(kvm);
439 mutex_unlock(&kvm->arch.config_lock);
454 * @kvm: kvm struct pointer
456 int kvm_vgic_map_resources(struct kvm *kvm)
458 struct vgic_dist *dist = &kvm->arch.vgic;
463 if (likely(vgic_ready(kvm)))
466 mutex_lock(&kvm->slots_lock);
467 mutex_lock(&kvm->arch.config_lock);
468 if (vgic_ready(kvm))
471 if (!irqchip_in_kernel(kvm))
475 ret = vgic_v2_map_resources(kvm);
478 ret = vgic_v3_map_resources(kvm);
487 mutex_unlock(&kvm->arch.config_lock);
489 ret = vgic_register_dist_iodev(kvm, dist_base, type);
495 mutex_unlock(&kvm->arch.config_lock);
497 mutex_unlock(&kvm->slots_lock);
500 kvm_vgic_destroy(kvm);