diff options
author | Marc Zyngier <maz@kernel.org> | 2021-11-16 16:03:57 +0000 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-12-08 04:24:13 -0500 |
commit | 27592ae8dbe41033261b6fdf27d78998aabd2665 (patch) | |
tree | 5f06cd37a666f3e8bf4a13465a92287a41f8bbdf /arch/riscv/kvm/vm.c | |
parent | dc1ce45575b3401102568dd60ba8894849d1d64b (diff) | |
download | linux-stable-27592ae8dbe41033261b6fdf27d78998aabd2665.tar.gz linux-stable-27592ae8dbe41033261b6fdf27d78998aabd2665.tar.bz2 linux-stable-27592ae8dbe41033261b6fdf27d78998aabd2665.zip |
KVM: Move wiping of the kvm->vcpus array to common code
All architectures have similar loops iterating over the vcpus,
freeing one vcpu at a time, and eventually wiping the reference
off the vcpus array. They are also inconsistently taking
the kvm->lock mutex when wiping the references from the array.
Make this code common, which will simplify further changes.
The locking is dropped altogether, as this should only be called
when there is no further references on the kvm structure.
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Message-Id: <20211116160403.4074052-2-maz@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/riscv/kvm/vm.c')
-rw-r--r-- | arch/riscv/kvm/vm.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c index fb18af34a4b5..7619691d8953 100644 --- a/arch/riscv/kvm/vm.c +++ b/arch/riscv/kvm/vm.c @@ -46,15 +46,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) void kvm_arch_destroy_vm(struct kvm *kvm) { - int i; - - for (i = 0; i < KVM_MAX_VCPUS; ++i) { - if (kvm->vcpus[i]) { - kvm_vcpu_destroy(kvm->vcpus[i]); - kvm->vcpus[i] = NULL; - } - } - atomic_set(&kvm->online_vcpus, 0); + kvm_destroy_vcpus(kvm); } int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) |