Commit c011f4ea106b94e5499358b62d8c2d74f7e184f9

Authored by Eric Auger
Committed by Marc Zyngier
1 parent 5ec17fbac6

KVM: arm/arm64: Check vcpu redist base before registering an iodev

As we are going to register several redist regions,
vgic_register_all_redist_iodevs() may be called several times. We need
to register a redist_iodev for a given vcpu only once. So let's
check if the base address has already been set. Initialize this latter
in kvm_vgic_vcpu_init().

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Acked-by: Christoffer Dall <christoffer.dall@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

Showing 2 changed files with 6 additions and 0 deletions Side-by-side Diff

virt/kvm/arm/vgic/vgic-init.c
... ... @@ -199,6 +199,9 @@
199 199 int ret = 0;
200 200 int i;
201 201  
  202 + vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF;
  203 + vgic_cpu->sgi_iodev.base_addr = VGIC_ADDR_UNDEF;
  204 +
202 205 INIT_LIST_HEAD(&vgic_cpu->ap_list_head);
203 206 spin_lock_init(&vgic_cpu->ap_list_lock);
204 207  
virt/kvm/arm/vgic/vgic-mmio-v3.c
... ... @@ -592,6 +592,9 @@
592 592 gpa_t rd_base, sgi_base;
593 593 int ret;
594 594  
  595 + if (!IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr))
  596 + return 0;
  597 +
595 598 /*
596 599 * We may be creating VCPUs before having set the base address for the
597 600 * redistributor region, in which case we will come back to this