From: Andrew Jones <drjones@redhat.com>
To: kvmarm@lists.cs.columbia.edu
Cc: marc.zyngier@arm.com, cdall@linaro.org
Subject: [PATCH] KVM: arm/arm64: kvm_arch_destroy_vm cleanups
Date: Mon, 27 Nov 2017 19:17:18 +0100 [thread overview]
Message-ID: <20171127181718.5290-1-drjones@redhat.com> (raw)
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
next reply other threads:[~2017-11-27 18:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-27 18:17 Andrew Jones [this message]
2017-12-01 8:09 ` [PATCH] KVM: arm/arm64: kvm_arch_destroy_vm cleanups Christoffer Dall
2017-12-01 8:18 ` Andrew Jones
2017-12-01 9:46 ` Christoffer Dall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171127181718.5290-1-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=cdall@linaro.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox