* [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* Re: [PATCH] KVM: arm/arm64: kvm_arch_destroy_vm cleanups
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
0 siblings, 1 reply; 4+ messages in thread
From: Christoffer Dall @ 2017-12-01 8:09 UTC (permalink / raw)
To: Andrew Jones; +Cc: marc.zyngier, kvmarm
Hi Drew,
On Mon, Nov 27, 2017 at 07:17:18PM +0100, Andrew Jones wrote:
> 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.
Could this commit message be rewritten to:
kvm_vgic_vcpu_destroy already gets called from kvm_vgic_destroy for
each vcpu, so we don't have to call it from 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.
?
Thanks,
-Christoffer
>
> 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 [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: arm/arm64: kvm_arch_destroy_vm cleanups
2017-12-01 8:09 ` Christoffer Dall
@ 2017-12-01 8:18 ` Andrew Jones
2017-12-01 9:46 ` Christoffer Dall
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Jones @ 2017-12-01 8:18 UTC (permalink / raw)
To: Christoffer Dall; +Cc: marc.zyngier, kvmarm
On Fri, Dec 01, 2017 at 09:09:19AM +0100, Christoffer Dall wrote:
> Hi Drew,
>
> On Mon, Nov 27, 2017 at 07:17:18PM +0100, Andrew Jones wrote:
> > 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.
>
> Could this commit message be rewritten to:
>
> kvm_vgic_vcpu_destroy already gets called from kvm_vgic_destroy for
> each vcpu, so we don't have to call it from 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.
Sure, I don't mind you removing the '-v' (verbose) from it. Should I
respin? Or is that something you don't mind doing while applying?
Thanks,
drew
>
> ?
>
> Thanks,
> -Christoffer
>
>
>
> >
> > 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 [flat|nested] 4+ messages in thread* Re: [PATCH] KVM: arm/arm64: kvm_arch_destroy_vm cleanups
2017-12-01 8:18 ` Andrew Jones
@ 2017-12-01 9:46 ` Christoffer Dall
0 siblings, 0 replies; 4+ messages in thread
From: Christoffer Dall @ 2017-12-01 9:46 UTC (permalink / raw)
To: Andrew Jones; +Cc: marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu
On Fri, Dec 1, 2017 at 8:18 AM, Andrew Jones <drjones@redhat.com> wrote:
> On Fri, Dec 01, 2017 at 09:09:19AM +0100, Christoffer Dall wrote:
>> Hi Drew,
>>
>> On Mon, Nov 27, 2017 at 07:17:18PM +0100, Andrew Jones wrote:
>> > 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.
>>
>> Could this commit message be rewritten to:
>>
>> kvm_vgic_vcpu_destroy already gets called from kvm_vgic_destroy for
>> each vcpu, so we don't have to call it from 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.
>
> Sure, I don't mind you removing the '-v' (verbose) from it. Should I
> respin? Or is that something you don't mind doing while applying?
>
No need to respin, I already applied your patch with the adjusted
commit message.
Thanks,
-Christoffer
^ permalink raw reply [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