Commit 101068b5 authored by Marc Zyngier's avatar Marc Zyngier

KVM: arm64: Consolidate dist->ready setting into kvm_vgic_map_resources()

dist->ready setting is pointlessly spread across the two vgic
backends, while it could be consolidated in kvm_vgic_map_resources().

Move it there, and slightly simplify the flows in both backends.
Suggested-by: default avatarEric Auger <eric.auger@redhat.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 282ff801
...@@ -446,6 +446,8 @@ int kvm_vgic_map_resources(struct kvm *kvm) ...@@ -446,6 +446,8 @@ int kvm_vgic_map_resources(struct kvm *kvm)
if (ret) if (ret)
__kvm_vgic_destroy(kvm); __kvm_vgic_destroy(kvm);
else
dist->ready = true;
out: out:
mutex_unlock(&kvm->lock); mutex_unlock(&kvm->lock);
......
...@@ -309,14 +309,12 @@ int vgic_v2_map_resources(struct kvm *kvm) ...@@ -309,14 +309,12 @@ int vgic_v2_map_resources(struct kvm *kvm)
if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base) || if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base) ||
IS_VGIC_ADDR_UNDEF(dist->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; return -ENXIO;
goto out;
} }
if (!vgic_v2_check_base(dist->vgic_dist_base, dist->vgic_cpu_base)) { if (!vgic_v2_check_base(dist->vgic_dist_base, dist->vgic_cpu_base)) {
kvm_err("VGIC CPU and dist frames overlap\n"); kvm_err("VGIC CPU and dist frames overlap\n");
ret = -EINVAL; return -EINVAL;
goto out;
} }
/* /*
...@@ -326,13 +324,13 @@ int vgic_v2_map_resources(struct kvm *kvm) ...@@ -326,13 +324,13 @@ int vgic_v2_map_resources(struct kvm *kvm)
ret = vgic_init(kvm); ret = vgic_init(kvm);
if (ret) { if (ret) {
kvm_err("Unable to initialize VGIC dynamic data structures\n"); kvm_err("Unable to initialize VGIC dynamic data structures\n");
goto out; return ret;
} }
ret = vgic_register_dist_iodev(kvm, dist->vgic_dist_base, VGIC_V2); ret = vgic_register_dist_iodev(kvm, dist->vgic_dist_base, VGIC_V2);
if (ret) { if (ret) {
kvm_err("Unable to register VGIC MMIO regions\n"); kvm_err("Unable to register VGIC MMIO regions\n");
goto out; return ret;
} }
if (!static_branch_unlikely(&vgic_v2_cpuif_trap)) { if (!static_branch_unlikely(&vgic_v2_cpuif_trap)) {
...@@ -341,14 +339,11 @@ int vgic_v2_map_resources(struct kvm *kvm) ...@@ -341,14 +339,11 @@ int vgic_v2_map_resources(struct kvm *kvm)
KVM_VGIC_V2_CPU_SIZE, true); KVM_VGIC_V2_CPU_SIZE, 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; return ret;
} }
} }
dist->ready = true; return 0;
out:
return ret;
} }
DEFINE_STATIC_KEY_FALSE(vgic_v2_cpuif_trap); DEFINE_STATIC_KEY_FALSE(vgic_v2_cpuif_trap);
......
...@@ -505,21 +505,18 @@ int vgic_v3_map_resources(struct kvm *kvm) ...@@ -505,21 +505,18 @@ int vgic_v3_map_resources(struct kvm *kvm)
if (IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr)) { if (IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr)) {
kvm_debug("vcpu %d redistributor base not set\n", c); kvm_debug("vcpu %d redistributor base not set\n", c);
ret = -ENXIO; return -ENXIO;
goto out;
} }
} }
if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base)) { if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base)) {
kvm_err("Need to set vgic distributor addresses first\n"); kvm_err("Need to set vgic distributor addresses first\n");
ret = -ENXIO; return -ENXIO;
goto out;
} }
if (!vgic_v3_check_base(kvm)) { if (!vgic_v3_check_base(kvm)) {
kvm_err("VGIC redist and dist frames overlap\n"); kvm_err("VGIC redist and dist frames overlap\n");
ret = -EINVAL; return -EINVAL;
goto out;
} }
/* /*
...@@ -527,22 +524,19 @@ int vgic_v3_map_resources(struct kvm *kvm) ...@@ -527,22 +524,19 @@ int vgic_v3_map_resources(struct kvm *kvm)
* the VGIC before we need to use it. * the VGIC before we need to use it.
*/ */
if (!vgic_initialized(kvm)) { if (!vgic_initialized(kvm)) {
ret = -EBUSY; return -EBUSY;
goto out;
} }
ret = vgic_register_dist_iodev(kvm, dist->vgic_dist_base, VGIC_V3); ret = vgic_register_dist_iodev(kvm, dist->vgic_dist_base, VGIC_V3);
if (ret) { if (ret) {
kvm_err("Unable to register VGICv3 dist MMIO regions\n"); kvm_err("Unable to register VGICv3 dist MMIO regions\n");
goto out; return ret;
} }
if (kvm_vgic_global_state.has_gicv4_1) if (kvm_vgic_global_state.has_gicv4_1)
vgic_v4_configure_vsgis(kvm); vgic_v4_configure_vsgis(kvm);
dist->ready = true;
out: return 0;
return ret;
} }
DEFINE_STATIC_KEY_FALSE(vgic_v3_cpuif_trap); DEFINE_STATIC_KEY_FALSE(vgic_v3_cpuif_trap);
......
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