Re: [PATCH] KVM: VMX: Postpone IPIv setup after successful vCPU creation
From: Huang, Kai
Date: Fri Jul 17 2026 - 09:02:49 EST
>
> An easy fix would be to clear the pid_table entry in vmx_vcpu_free().
> However that would be still problematic, for the following reason:
> userspace may try to create a vCPU with the same vcpu_id as an existing
> one; vmx_vcpu_create() will succeed, and only after that
> kvm_vm_ioctl_create_vcpu() will check for the duplicate vcpu_id and
> fail with -EEXIST and then free the vCPU in the failure path. So in this
> failure path, vmx_vcpu_free() would clear the pid_table entry for that
> already existing good vCPU, i.e. effectively disable IPIv for that vCPU.
IMHO this seems a bit fragile? If something similar to pid_table coming up in
the future, we could end up with a similar problem.
The "duplicated vcpu_id check" seems the ones that should happen as early as
possible. Is it better to move the "duplicated vcpu_id check" earlier before
vmx_vcpu_create(), e.g., even before the kvm_arch_vcpu_precreate()? In this
case we can do the pid_table cleanup in vmx_vcpu_free() I think.
The downside is this is common KVM code change for all archs, but it doesn't
seem this will bring problem to other archs.