diff options
author | Christoffer Dall <christoffer.dall@linaro.org> | 2014-11-06 06:47:39 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-11-26 08:40:44 -0500 |
commit | 6b50f54064a02b77a7b990032b80234fee59bcd6 (patch) | |
tree | 8fd347d96d760a81c9e866b999a534ac89627a0d /virt/kvm | |
parent | db7dedd0de714a59d8fa2a1be3b6b00543ad415a (diff) |
arm/arm64: KVM: vgic: Fix error code in kvm_vgic_create()
If we detect another vCPU is running we just exit and return 0 as if we
succesfully created the VGIC, but the VGIC wouldn't actual be created.
This shouldn't break in-kernel behavior because the kernel will not
observe the failed the attempt to create the VGIC, but userspace could
be rightfully confused.
Cc: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r-- | virt/kvm/arm/vgic.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 3aaca49de325..aacdb59f30de 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c | |||
@@ -1933,7 +1933,7 @@ out: | |||
1933 | 1933 | ||
1934 | int kvm_vgic_create(struct kvm *kvm) | 1934 | int kvm_vgic_create(struct kvm *kvm) |
1935 | { | 1935 | { |
1936 | int i, vcpu_lock_idx = -1, ret = 0; | 1936 | int i, vcpu_lock_idx = -1, ret; |
1937 | struct kvm_vcpu *vcpu; | 1937 | struct kvm_vcpu *vcpu; |
1938 | 1938 | ||
1939 | mutex_lock(&kvm->lock); | 1939 | mutex_lock(&kvm->lock); |
@@ -1948,6 +1948,7 @@ int kvm_vgic_create(struct kvm *kvm) | |||
1948 | * vcpu->mutex. By grabbing the vcpu->mutex of all VCPUs we ensure | 1948 | * vcpu->mutex. By grabbing the vcpu->mutex of all VCPUs we ensure |
1949 | * that no other VCPUs are run while we create the vgic. | 1949 | * that no other VCPUs are run while we create the vgic. |
1950 | */ | 1950 | */ |
1951 | ret = -EBUSY; | ||
1951 | kvm_for_each_vcpu(i, vcpu, kvm) { | 1952 | kvm_for_each_vcpu(i, vcpu, kvm) { |
1952 | if (!mutex_trylock(&vcpu->mutex)) | 1953 | if (!mutex_trylock(&vcpu->mutex)) |
1953 | goto out_unlock; | 1954 | goto out_unlock; |
@@ -1955,11 +1956,10 @@ int kvm_vgic_create(struct kvm *kvm) | |||
1955 | } | 1956 | } |
1956 | 1957 | ||
1957 | kvm_for_each_vcpu(i, vcpu, kvm) { | 1958 | kvm_for_each_vcpu(i, vcpu, kvm) { |
1958 | if (vcpu->arch.has_run_once) { | 1959 | if (vcpu->arch.has_run_once) |
1959 | ret = -EBUSY; | ||
1960 | goto out_unlock; | 1960 | goto out_unlock; |
1961 | } | ||
1962 | } | 1961 | } |
1962 | ret = 0; | ||
1963 | 1963 | ||
1964 | spin_lock_init(&kvm->arch.vgic.lock); | 1964 | spin_lock_init(&kvm->arch.vgic.lock); |
1965 | kvm->arch.vgic.in_kernel = true; | 1965 | kvm->arch.vgic.in_kernel = true; |