#include <linux/uaccess.h>
#include <linux/interrupt.h>
#include <linux/cpu.h>
#include <linux/kvm_host.h>
#include <kvm/arm_vgic.h>
#include <asm/kvm_emulate.h>
#include <asm/kvm_mmu.h>
#include "vgic.h"
Go to the source code of this file.
◆ __kvm_vgic_vcpu_destroy()
| static void __kvm_vgic_vcpu_destroy |
( |
struct kvm_vcpu * |
vcpu | ) |
|
|
static |
Definition at line 371 of file vgic-init.c.
382 if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) {
struct vgic_io_device rd_iodev
struct list_head ap_list_head
void vgic_unregister_redist_iodev(struct kvm_vcpu *vcpu)
void vgic_flush_pending_lpis(struct kvm_vcpu *vcpu)
◆ kvm_vgic_cpu_down()
| void kvm_vgic_cpu_down |
( |
void |
| ) |
|
Definition at line 513 of file vgic-init.c.
struct vgic_global kvm_vgic_global_state
◆ kvm_vgic_cpu_up()
| void kvm_vgic_cpu_up |
( |
void |
| ) |
|
◆ kvm_vgic_create()
| int kvm_vgic_create |
( |
struct kvm * |
kvm, |
|
|
u32 |
type |
|
) |
| |
kvm_vgic_create: triggered by the instantiation of the VGIC device by user space, either through the legacy KVM_CREATE_IRQCHIP ioctl (v2 only) or through the generic KVM_CREATE_DEVICE API ioctl. irqchip_in_kernel() tells you if this function succeeded or not. @kvm: kvm struct pointer @type: KVM_DEV_TYPE_ARM_VGIC_V[23]
Definition at line 71 of file vgic-init.c.
73 struct kvm_vcpu *vcpu;
83 if (type == KVM_DEV_TYPE_ARM_VGIC_V2 &&
88 lockdep_assert_held(&kvm->lock);
94 mutex_lock(&kvm->arch.config_lock);
101 kvm_for_each_vcpu(i, vcpu, kvm) {
102 if (vcpu_has_run_once(vcpu))
107 if (type == KVM_DEV_TYPE_ARM_VGIC_V2)
112 if (atomic_read(&kvm->online_vcpus) > kvm->max_vcpus) {
117 kvm->arch.vgic.in_kernel =
true;
118 kvm->arch.vgic.vgic_model = type;
122 if (type == KVM_DEV_TYPE_ARM_VGIC_V2)
125 INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions);
128 mutex_unlock(&kvm->arch.config_lock);
bool lock_all_vcpus(struct kvm *kvm)
void unlock_all_vcpus(struct kvm *kvm)
#define irqchip_in_kernel(k)
◆ kvm_vgic_destroy()
| void kvm_vgic_destroy |
( |
struct kvm * |
kvm | ) |
|
Definition at line 397 of file vgic-init.c.
399 struct kvm_vcpu *vcpu;
402 mutex_lock(&kvm->slots_lock);
406 kvm_for_each_vcpu(i, vcpu, kvm)
409 mutex_lock(&kvm->arch.config_lock);
413 mutex_unlock(&kvm->arch.config_lock);
414 mutex_unlock(&kvm->slots_lock);
void vgic_debug_destroy(struct kvm *kvm)
static void __kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
static void kvm_vgic_dist_destroy(struct kvm *kvm)
◆ kvm_vgic_dist_destroy()
| static void kvm_vgic_dist_destroy |
( |
struct kvm * |
kvm | ) |
|
|
static |
Definition at line 343 of file vgic-init.c.
345 struct vgic_dist *dist = &kvm->arch.vgic;
356 if (dist->
vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) {
struct list_head rd_regions
void vgic_lpi_translation_cache_destroy(struct kvm *kvm)
bool vgic_has_its(struct kvm *kvm)
bool vgic_supports_direct_msis(struct kvm *kvm)
void vgic_v3_free_redist_region(struct vgic_redist_region *rdreg)
void vgic_v4_teardown(struct kvm *kvm)
◆ kvm_vgic_dist_init()
| static int kvm_vgic_dist_init |
( |
struct kvm * |
kvm, |
|
|
unsigned int |
nr_spis |
|
) |
| |
|
static |
kvm_vgic_dist_init: initialize the dist data structures @kvm: kvm struct pointer @nr_spis: number of spis, frozen by caller
Definition at line 140 of file vgic-init.c.
142 struct vgic_dist *dist = &kvm->arch.vgic;
143 struct kvm_vcpu *vcpu0 = kvm_get_vcpu(kvm, 0);
146 dist->
spis = kcalloc(nr_spis,
sizeof(
struct vgic_irq), GFP_KERNEL_ACCOUNT);
158 for (i = 0; i < nr_spis; i++) {
168 case KVM_DEV_TYPE_ARM_VGIC_V2:
172 case KVM_DEV_TYPE_ARM_VGIC_V3:
#define VGIC_NR_PRIVATE_IRQS
struct kvm_vcpu * target_vcpu
◆ kvm_vgic_early_init()
| void kvm_vgic_early_init |
( |
struct kvm * |
kvm | ) |
|
kvm_vgic_early_init() - Initialize static VGIC VCPU data structures @kvm: The VM whose VGIC districutor should be initialized
Only do initialization of static structures that don't require any allocation or sizing information from userspace. vgic_init() called kvm_vgic_dist_init() which takes care of the rest.
Definition at line 52 of file vgic-init.c.
struct list_head lpi_translation_cache
struct list_head lpi_list_head
raw_spinlock_t lpi_list_lock
◆ kvm_vgic_hyp_init()
| int kvm_vgic_hyp_init |
( |
void |
| ) |
|
kvm_vgic_hyp_init: populates the kvm_vgic_global_state variable according to the host GIC model. Accordingly calls either vgic_v2/v3_probe which registers the KVM_DEVICE that can be instantiated by a guest later on .
Definition at line 564 of file vgic-init.c.
575 kvm_err(
"No vgic maintenance irq\n");
584 kvm_info(
"Non-architectural vgic, tainting kernel\n");
585 add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
597 kvm_info(
"GIC system register CPU interface enabled\n");
619 kvm_err(
"Cannot register interrupt %d\n",
struct kvm_vcpu *__percpu * kvm_get_running_vcpus(void)
struct static_key_false gicv3_cpuif
static irqreturn_t vgic_maintenance_handler(int irq, void *data)
static struct gic_kvm_info * gic_kvm_info
int vgic_v2_probe(const struct gic_kvm_info *info)
int vgic_v3_probe(const struct gic_kvm_info *info)
◆ kvm_vgic_init_cpu_hardware()
| void kvm_vgic_init_cpu_hardware |
( |
void |
| ) |
|
kvm_vgic_init_cpu_hardware - initialize the GIC VE hardware
For a specific CPU, initialize the GIC VE hardware.
Definition at line 544 of file vgic-init.c.
546 BUG_ON(preemptible());
void vgic_v2_init_lrs(void)
void __vgic_v3_init_lrs(void)
◆ kvm_vgic_map_resources()
| int kvm_vgic_map_resources |
( |
struct kvm * |
kvm | ) |
|
Map the MMIO regions depending on the VGIC model exposed to the guest called on the first VCPU run. Also map the virtual CPU interface into the VM. v2 calls vgic_init() if not already done. v3 and derivatives return an error if the VGIC is not initialized. vgic_ready() returns true if this function has succeeded. @kvm: kvm struct pointer
Definition at line 456 of file vgic-init.c.
458 struct vgic_dist *dist = &kvm->arch.vgic;
466 mutex_lock(&kvm->slots_lock);
467 mutex_lock(&kvm->arch.config_lock);
474 if (dist->
vgic_model == KVM_DEV_TYPE_ARM_VGIC_V2) {
487 mutex_unlock(&kvm->arch.config_lock);
491 kvm_err(
"Unable to register VGIC dist MMIO regions\n");
495 mutex_unlock(&kvm->arch.config_lock);
497 mutex_unlock(&kvm->slots_lock);
void kvm_vgic_destroy(struct kvm *kvm)
int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address, enum vgic_type type)
int vgic_v2_map_resources(struct kvm *kvm)
int vgic_v3_map_resources(struct kvm *kvm)
◆ kvm_vgic_vcpu_destroy()
| void kvm_vgic_vcpu_destroy |
( |
struct kvm_vcpu * |
vcpu | ) |
|
Definition at line 388 of file vgic-init.c.
390 struct kvm *kvm = vcpu->kvm;
392 mutex_lock(&kvm->slots_lock);
394 mutex_unlock(&kvm->slots_lock);
◆ kvm_vgic_vcpu_enable()
| static void kvm_vgic_vcpu_enable |
( |
struct kvm_vcpu * |
vcpu | ) |
|
|
static |
Definition at line 245 of file vgic-init.c.
void vgic_v2_enable(struct kvm_vcpu *vcpu)
void vgic_v3_enable(struct kvm_vcpu *vcpu)
◆ kvm_vgic_vcpu_init()
| int kvm_vgic_vcpu_init |
( |
struct kvm_vcpu * |
vcpu | ) |
|
kvm_vgic_vcpu_init() - Initialize static VGIC VCPU data structures and register VCPU-specific KVM iodevs
@vcpu: pointer to the VCPU being created and initialized
Only do initialization, but do not actually enable the VGIC CPU interface
Definition at line 194 of file vgic-init.c.
197 struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
237 if (dist->
vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) {
238 mutex_lock(&
vcpu->kvm->slots_lock);
240 mutex_unlock(&
vcpu->kvm->slots_lock);
struct vgic_irq private_irqs[VGIC_NR_PRIVATE_IRQS]
raw_spinlock_t ap_list_lock
struct vgic_v3_cpu_if vgic_v3
enum vgic_irq_config config
int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
#define vgic_irq_is_sgi(intid)
◆ vgic_init()
| int vgic_init |
( |
struct kvm * |
kvm | ) |
|
Definition at line 262 of file vgic-init.c.
264 struct vgic_dist *dist = &kvm->arch.vgic;
265 struct kvm_vcpu *vcpu;
269 lockdep_assert_held(&kvm->arch.config_lock);
275 if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus))
287 kvm_for_each_vcpu(idx, vcpu, kvm) {
293 case KVM_DEV_TYPE_ARM_VGIC_V3:
295 irq->
mpidr = kvm_vcpu_get_mpidr_aff(
vcpu);
297 case KVM_DEV_TYPE_ARM_VGIC_V2:
322 kvm_for_each_vcpu(idx,
vcpu, kvm)
#define VGIC_NR_IRQS_LEGACY
#define KVM_VGIC_IMP_REV_LATEST
#define vgic_initialized(k)
void vgic_debug_init(struct kvm *kvm)
static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
static void kvm_vgic_vcpu_enable(struct kvm_vcpu *vcpu)
int kvm_vgic_setup_default_irq_routing(struct kvm *kvm)
void vgic_lpi_translation_cache_init(struct kvm *kvm)
int vgic_v4_init(struct kvm *kvm)
◆ vgic_lazy_init()
| int vgic_lazy_init |
( |
struct kvm * |
kvm | ) |
|
vgic_lazy_init: Lazy init is only allowed if the GIC exposed to the guest is a GICv2. A GICv3 must be explicitly initialized by userspace using the KVM_DEV_ARM_VGIC_GRP_CTRL KVM_DEVICE group. @kvm: kvm struct pointer
Definition at line 423 of file vgic-init.c.
434 if (kvm->arch.vgic.vgic_model != KVM_DEV_TYPE_ARM_VGIC_V2)
437 mutex_lock(&kvm->arch.config_lock);
439 mutex_unlock(&kvm->arch.config_lock);
int vgic_init(struct kvm *kvm)
◆ vgic_maintenance_handler()
| static irqreturn_t vgic_maintenance_handler |
( |
int |
irq, |
|
|
void * |
data |
|
) |
| |
|
static |
◆ vgic_set_kvm_info()
| void __init vgic_set_kvm_info |
( |
const struct gic_kvm_info * |
info | ) |
|
◆ gic_kvm_info
| struct gic_kvm_info* gic_kvm_info |
|
static |