diff options
author | Andre Przywara <andre.przywara@arm.com> | 2015-03-26 10:39:35 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2015-03-26 17:43:15 -0400 |
commit | a9cf86f62b785202684c3ba92895946f03d910c8 (patch) | |
tree | 96f12c366cdb93c1c8336916bab305e6df18d489 /virt | |
parent | 6777f77f0f544f686ee3158ff0db6a7d81b7d3a2 (diff) |
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: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/arm/vgic-v2-emul.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/virt/kvm/arm/vgic-v2-emul.c b/virt/kvm/arm/vgic-v2-emul.c index 1dd183ecf96f..7460b376d090 100644 --- a/virt/kvm/arm/vgic-v2-emul.c +++ b/virt/kvm/arm/vgic-v2-emul.c | |||
@@ -506,6 +506,7 @@ static bool vgic_v2_queue_sgi(struct kvm_vcpu *vcpu, int irq) | |||
506 | static int vgic_v2_map_resources(struct kvm *kvm, | 506 | static int vgic_v2_map_resources(struct kvm *kvm, |
507 | const struct vgic_params *params) | 507 | const struct vgic_params *params) |
508 | { | 508 | { |
509 | struct vgic_dist *dist = &kvm->arch.vgic; | ||
509 | int ret = 0; | 510 | int ret = 0; |
510 | 511 | ||
511 | if (!irqchip_in_kernel(kvm)) | 512 | if (!irqchip_in_kernel(kvm)) |
@@ -516,13 +517,17 @@ static int vgic_v2_map_resources(struct kvm *kvm, | |||
516 | if (vgic_ready(kvm)) | 517 | if (vgic_ready(kvm)) |
517 | goto out; | 518 | goto out; |
518 | 519 | ||
519 | if (IS_VGIC_ADDR_UNDEF(kvm->arch.vgic.vgic_dist_base) || | 520 | if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base) || |
520 | IS_VGIC_ADDR_UNDEF(kvm->arch.vgic.vgic_cpu_base)) { | 521 | IS_VGIC_ADDR_UNDEF(dist->vgic_cpu_base)) { |
521 | kvm_err("Need to set vgic cpu and dist addresses first\n"); | 522 | kvm_err("Need to set vgic cpu and dist addresses first\n"); |
522 | ret = -ENXIO; | 523 | ret = -ENXIO; |
523 | goto out; | 524 | goto out; |
524 | } | 525 | } |
525 | 526 | ||
527 | vgic_register_kvm_io_dev(kvm, dist->vgic_dist_base, | ||
528 | KVM_VGIC_V2_DIST_SIZE, | ||
529 | vgic_dist_ranges, -1, &dist->dist_iodev); | ||
530 | |||
526 | /* | 531 | /* |
527 | * Initialize the vgic if this hasn't already been done on demand by | 532 | * Initialize the vgic if this hasn't already been done on demand by |
528 | * accessing the vgic state from userspace. | 533 | * accessing the vgic state from userspace. |
@@ -530,18 +535,23 @@ static int vgic_v2_map_resources(struct kvm *kvm, | |||
530 | ret = vgic_init(kvm); | 535 | ret = vgic_init(kvm); |
531 | if (ret) { | 536 | if (ret) { |
532 | kvm_err("Unable to allocate maps\n"); | 537 | kvm_err("Unable to allocate maps\n"); |
533 | goto out; | 538 | goto out_unregister; |
534 | } | 539 | } |
535 | 540 | ||
536 | ret = kvm_phys_addr_ioremap(kvm, kvm->arch.vgic.vgic_cpu_base, | 541 | ret = kvm_phys_addr_ioremap(kvm, dist->vgic_cpu_base, |
537 | params->vcpu_base, KVM_VGIC_V2_CPU_SIZE, | 542 | params->vcpu_base, KVM_VGIC_V2_CPU_SIZE, |
538 | true); | 543 | true); |
539 | if (ret) { | 544 | if (ret) { |
540 | kvm_err("Unable to remap VGIC CPU to VCPU\n"); | 545 | kvm_err("Unable to remap VGIC CPU to VCPU\n"); |
541 | goto out; | 546 | goto out_unregister; |
542 | } | 547 | } |
543 | 548 | ||
544 | kvm->arch.vgic.ready = true; | 549 | dist->ready = true; |
550 | goto out; | ||
551 | |||
552 | out_unregister: | ||
553 | kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &dist->dist_iodev.dev); | ||
554 | |||
545 | out: | 555 | out: |
546 | if (ret) | 556 | if (ret) |
547 | kvm_vgic_destroy(kvm); | 557 | kvm_vgic_destroy(kvm); |