Lines Matching refs:kvm
15 static void unlock_vcpus(struct kvm *kvm, int vcpu_lock_idx) in unlock_vcpus() argument
20 tmp_vcpu = kvm_get_vcpu(kvm, vcpu_lock_idx); in unlock_vcpus()
25 static void unlock_all_vcpus(struct kvm *kvm) in unlock_all_vcpus() argument
27 unlock_vcpus(kvm, atomic_read(&kvm->online_vcpus) - 1); in unlock_all_vcpus()
30 static bool lock_all_vcpus(struct kvm *kvm) in lock_all_vcpus() argument
35 kvm_for_each_vcpu(c, tmp_vcpu, kvm) { in lock_all_vcpus()
37 unlock_vcpus(kvm, c - 1); in lock_all_vcpus()
49 struct kvm *kvm = dev->kvm; in aia_create() local
52 if (irqchip_in_kernel(kvm)) in aia_create()
56 if (!lock_all_vcpus(kvm)) in aia_create()
59 kvm_for_each_vcpu(i, vcpu, kvm) { in aia_create()
65 kvm->arch.aia.in_kernel = true; in aia_create()
68 unlock_all_vcpus(kvm); in aia_create()
77 static int aia_config(struct kvm *kvm, unsigned long type, in aia_config() argument
80 struct kvm_aia *aia = &kvm->arch.aia; in aia_config()
83 if (write && kvm_riscv_aia_initialized(kvm)) in aia_config()
171 static int aia_aplic_addr(struct kvm *kvm, u64 *addr, bool write) in aia_aplic_addr() argument
173 struct kvm_aia *aia = &kvm->arch.aia; in aia_aplic_addr()
177 if (kvm_riscv_aia_initialized(kvm)) in aia_aplic_addr()
190 static int aia_imsic_addr(struct kvm *kvm, u64 *addr, in aia_imsic_addr() argument
196 vcpu = kvm_get_vcpu(kvm, vcpu_idx); in aia_imsic_addr()
203 if (kvm_riscv_aia_initialized(kvm)) in aia_imsic_addr()
252 static int aia_init(struct kvm *kvm) in aia_init() argument
258 struct kvm_aia *aia = &kvm->arch.aia; in aia_init()
262 if (kvm_riscv_aia_initialized(kvm)) in aia_init()
266 if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) in aia_init()
278 ret = kvm_riscv_aia_aplic_init(kvm); in aia_init()
283 kvm_for_each_vcpu(idx, vcpu, kvm) { in aia_init()
311 kvm->arch.aia.initialized = true; in aia_init()
317 vcpu = kvm_get_vcpu(kvm, i); in aia_init()
322 kvm_riscv_aia_aplic_cleanup(kvm); in aia_init()
339 mutex_lock(&dev->kvm->lock); in aia_set_attr()
340 r = aia_config(dev->kvm, type, &nr, true); in aia_set_attr()
341 mutex_unlock(&dev->kvm->lock); in aia_set_attr()
349 nr_vcpus = atomic_read(&dev->kvm->online_vcpus); in aia_set_attr()
350 mutex_lock(&dev->kvm->lock); in aia_set_attr()
352 r = aia_aplic_addr(dev->kvm, &addr, true); in aia_set_attr()
354 r = aia_imsic_addr(dev->kvm, &addr, in aia_set_attr()
356 mutex_unlock(&dev->kvm->lock); in aia_set_attr()
363 mutex_lock(&dev->kvm->lock); in aia_set_attr()
364 r = aia_init(dev->kvm); in aia_set_attr()
365 mutex_unlock(&dev->kvm->lock); in aia_set_attr()
374 mutex_lock(&dev->kvm->lock); in aia_set_attr()
375 r = kvm_riscv_aia_aplic_set_attr(dev->kvm, type, nr); in aia_set_attr()
376 mutex_unlock(&dev->kvm->lock); in aia_set_attr()
383 mutex_lock(&dev->kvm->lock); in aia_set_attr()
384 r = kvm_riscv_aia_imsic_rw_attr(dev->kvm, type, true, &v); in aia_set_attr()
385 mutex_unlock(&dev->kvm->lock); in aia_set_attr()
406 mutex_lock(&dev->kvm->lock); in aia_get_attr()
407 r = aia_config(dev->kvm, type, &nr, false); in aia_get_attr()
408 mutex_unlock(&dev->kvm->lock); in aia_get_attr()
420 nr_vcpus = atomic_read(&dev->kvm->online_vcpus); in aia_get_attr()
421 mutex_lock(&dev->kvm->lock); in aia_get_attr()
423 r = aia_aplic_addr(dev->kvm, &addr, false); in aia_get_attr()
425 r = aia_imsic_addr(dev->kvm, &addr, in aia_get_attr()
427 mutex_unlock(&dev->kvm->lock); in aia_get_attr()
439 mutex_lock(&dev->kvm->lock); in aia_get_attr()
440 r = kvm_riscv_aia_aplic_get_attr(dev->kvm, type, &nr); in aia_get_attr()
441 mutex_unlock(&dev->kvm->lock); in aia_get_attr()
453 mutex_lock(&dev->kvm->lock); in aia_get_attr()
454 r = kvm_riscv_aia_imsic_rw_attr(dev->kvm, type, false, &v); in aia_get_attr()
455 mutex_unlock(&dev->kvm->lock); in aia_get_attr()
486 nr_vcpus = atomic_read(&dev->kvm->online_vcpus); in aia_has_attr()
499 return kvm_riscv_aia_aplic_has_attr(dev->kvm, attr->attr); in aia_has_attr()
501 return kvm_riscv_aia_imsic_has_attr(dev->kvm, attr->attr); in aia_has_attr()
519 if (!kvm_riscv_aia_initialized(vcpu->kvm)) in kvm_riscv_vcpu_aia_update()
537 if (!kvm_riscv_aia_initialized(vcpu->kvm)) in kvm_riscv_vcpu_aia_reset()
568 if (!kvm_riscv_aia_initialized(vcpu->kvm)) in kvm_riscv_vcpu_aia_deinit()
575 int kvm_riscv_aia_inject_msi_by_id(struct kvm *kvm, u32 hart_index, in kvm_riscv_aia_inject_msi_by_id() argument
582 if (!kvm_riscv_aia_initialized(kvm)) in kvm_riscv_aia_inject_msi_by_id()
586 kvm_for_each_vcpu(idx, vcpu, kvm) { in kvm_riscv_aia_inject_msi_by_id()
596 int kvm_riscv_aia_inject_msi(struct kvm *kvm, struct kvm_msi *msi) in kvm_riscv_aia_inject_msi() argument
602 struct kvm_aia *aia = &kvm->arch.aia; in kvm_riscv_aia_inject_msi()
606 if (!kvm_riscv_aia_initialized(kvm)) in kvm_riscv_aia_inject_msi()
617 kvm_for_each_vcpu(idx, vcpu, kvm) { in kvm_riscv_aia_inject_msi()
630 int kvm_riscv_aia_inject_irq(struct kvm *kvm, unsigned int irq, bool level) in kvm_riscv_aia_inject_irq() argument
633 if (!kvm_riscv_aia_initialized(kvm)) in kvm_riscv_aia_inject_irq()
637 return kvm_riscv_aia_aplic_inject(kvm, irq, level); in kvm_riscv_aia_inject_irq()
640 void kvm_riscv_aia_init_vm(struct kvm *kvm) in kvm_riscv_aia_init_vm() argument
642 struct kvm_aia *aia = &kvm->arch.aia; in kvm_riscv_aia_init_vm()
666 void kvm_riscv_aia_destroy_vm(struct kvm *kvm) in kvm_riscv_aia_destroy_vm() argument
669 if (!kvm_riscv_aia_initialized(kvm)) in kvm_riscv_aia_destroy_vm()
673 kvm_riscv_aia_aplic_cleanup(kvm); in kvm_riscv_aia_destroy_vm()