public inbox for kvmarm@lists.cs.columbia.edu
 help / color / mirror / Atom feed
* [PATCH] KVM: arm/arm64: kvm_arch_destroy_vm cleanups
@ 2017-11-27 18:17 Andrew Jones
  2017-12-01  8:09 ` Christoffer Dall
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Jones @ 2017-11-27 18:17 UTC (permalink / raw)
  To: kvmarm; +Cc: marc.zyngier, cdall

Recently commit b2c9a85dd75a ("KVM: arm/arm64: vgic: Move
kvm_vgic_destroy call around") caught my eye. When I looked closer I
saw that while it made the code saner, it wasn't changing anything.
kvm_for_each_vcpu() checks for NULL kvm->vcpus[i], so there wasn't
a NULL dereference being fixed, and because kvm_vgic_vcpu_destroy()
was called by kvm_arch_vcpu_free() it was still getting called, just
not by kvm_vgic_destroy() as intended. But now the call from
kvm_arch_vcpu_free() is redundant, and while currently harmless, it
should be removed in case kvm_vgic_vcpu_destroy() were ever to
want to reference vgic state, as kvm_vgic_destroy() now comes before
kvm_arch_vcpu_free(). Additionally the other architectures set
kvm->online_vcpus to zero after freeing them. We might as well do
that for ARM too.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 virt/kvm/arm/arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c
index a6524ff27de4..c5bc79c4ccf7 100644
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
@@ -188,6 +188,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
 			kvm->vcpus[i] = NULL;
 		}
 	}
+	atomic_set(&kvm->online_vcpus, 0);
 }
 
 int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
@@ -296,7 +297,6 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
 {
 	kvm_mmu_free_memory_caches(vcpu);
 	kvm_timer_vcpu_terminate(vcpu);
-	kvm_vgic_vcpu_destroy(vcpu);
 	kvm_pmu_vcpu_destroy(vcpu);
 	kvm_vcpu_uninit(vcpu);
 	kmem_cache_free(kvm_vcpu_cache, vcpu);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-01  9:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-27 18:17 [PATCH] KVM: arm/arm64: kvm_arch_destroy_vm cleanups Andrew Jones
2017-12-01  8:09 ` Christoffer Dall
2017-12-01  8:18   ` Andrew Jones
2017-12-01  9:46     ` Christoffer Dall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox