Re: [PATCH v6 04/33] KVM: x86: Check for existing Hyper-V vCPU in kvm_hv_vcpu_init()

From: Wei Liu
Date: Mon Sep 05 2022 - 13:09:34 EST


On Tue, Aug 30, 2022 at 03:37:08PM +0200, Vitaly Kuznetsov wrote:
> From: Sean Christopherson <seanjc@xxxxxxxxxx>
>
> When potentially allocating/initializing the Hyper-V vCPU struct, check
> for an existing instance in kvm_hv_vcpu_init() instead of requiring
> callers to perform the check. Relying on callers to do the check is
> risky as it's all too easy for KVM to overwrite vcpu->arch.hyperv and
> leak memory, and it adds additional burden on callers without much
> benefit.
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>

Reviewed-by: Wei Liu <wei.liu@xxxxxxxxxx>