Commit a9cf86f6 authored by Andre Przywara's avatar Andre Przywara Committed by Marc Zyngier

KVM: arm/arm64: prepare GICv2 emulation to be handled by kvm_io_bus

Using the framework provided by the recent vgic.c changes we register
a kvm_io_bus device when initializing the virtual GICv2.
Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
parent 6777f77f
...@@ -251,6 +251,7 @@ struct vgic_dist { ...@@ -251,6 +251,7 @@ struct vgic_dist {
unsigned long *irq_active_on_cpu; unsigned long *irq_active_on_cpu;
struct vgic_vm_ops vm_ops; struct vgic_vm_ops vm_ops;
struct vgic_io_device dist_iodev;
}; };
struct vgic_v2_cpu_if { struct vgic_v2_cpu_if {
......
...@@ -506,6 +506,7 @@ static bool vgic_v2_queue_sgi(struct kvm_vcpu *vcpu, int irq) ...@@ -506,6 +506,7 @@ static bool vgic_v2_queue_sgi(struct kvm_vcpu *vcpu, int irq)
static int vgic_v2_map_resources(struct kvm *kvm, static int vgic_v2_map_resources(struct kvm *kvm,
const struct vgic_params *params) const struct vgic_params *params)
{ {
struct vgic_dist *dist = &kvm->arch.vgic;
int ret = 0; int ret = 0;
if (!irqchip_in_kernel(kvm)) if (!irqchip_in_kernel(kvm))
...@@ -516,13 +517,17 @@ static int vgic_v2_map_resources(struct kvm *kvm, ...@@ -516,13 +517,17 @@ static int vgic_v2_map_resources(struct kvm *kvm,
if (vgic_ready(kvm)) if (vgic_ready(kvm))
goto out; goto out;
if (IS_VGIC_ADDR_UNDEF(kvm->arch.vgic.vgic_dist_base) || if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base) ||
IS_VGIC_ADDR_UNDEF(kvm->arch.vgic.vgic_cpu_base)) { IS_VGIC_ADDR_UNDEF(dist->vgic_cpu_base)) {
kvm_err("Need to set vgic cpu and dist addresses first\n"); kvm_err("Need to set vgic cpu and dist addresses first\n");
ret = -ENXIO; ret = -ENXIO;
goto out; goto out;
} }
vgic_register_kvm_io_dev(kvm, dist->vgic_dist_base,
KVM_VGIC_V2_DIST_SIZE,
vgic_dist_ranges, -1, &dist->dist_iodev);
/* /*
* Initialize the vgic if this hasn't already been done on demand by * Initialize the vgic if this hasn't already been done on demand by
* accessing the vgic state from userspace. * accessing the vgic state from userspace.
...@@ -530,18 +535,23 @@ static int vgic_v2_map_resources(struct kvm *kvm, ...@@ -530,18 +535,23 @@ static int vgic_v2_map_resources(struct kvm *kvm,
ret = vgic_init(kvm); ret = vgic_init(kvm);
if (ret) { if (ret) {
kvm_err("Unable to allocate maps\n"); kvm_err("Unable to allocate maps\n");
goto out; goto out_unregister;
} }
ret = kvm_phys_addr_ioremap(kvm, kvm->arch.vgic.vgic_cpu_base, ret = kvm_phys_addr_ioremap(kvm, dist->vgic_cpu_base,
params->vcpu_base, KVM_VGIC_V2_CPU_SIZE, params->vcpu_base, KVM_VGIC_V2_CPU_SIZE,
true); true);
if (ret) { if (ret) {
kvm_err("Unable to remap VGIC CPU to VCPU\n"); kvm_err("Unable to remap VGIC CPU to VCPU\n");
goto out; goto out_unregister;
} }
kvm->arch.vgic.ready = true; dist->ready = true;
goto out;
out_unregister:
kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &dist->dist_iodev.dev);
out: out:
if (ret) if (ret)
kvm_vgic_destroy(kvm); kvm_vgic_destroy(kvm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment