Re: [PATCH v16 12/20] KVM: selftests: Call KVM_TDX_INIT_VCPU when creating a new TDX vcpu
From: Ackerley Tng
Date: Mon Nov 09 2026 - 15:00:17 EST
Lisa Wang <wyihan@xxxxxxxxxx> writes:
> From: Sagi Shahar <sagis@xxxxxxxxxx>
>
> TDX VMs need to issue the KVM_TDX_INIT_VCPU ioctl for each vcpu after
> vcpu creation.
>
> KVM_TDX_INIT_VCPU has a strict prerequisite for the CPUID state. To
> satisfy this requirement, call KVM_TDX_GET_CPUID and KVM_SET_CPUID2 to
> pull the CPUID configuration from the TDCS and commit it into KVM,
> allowing KVM_TDX_INIT_VCPU to succeed.
>
> Additionally, unlike tdx_vm_ioctl(), tdx_vcpu_ioctl() doesn't check
> hw_error. KVM's vCPU-scoped TDX ioctl handlers don't propagate SEAMCALL
> errors into hw_error: the error is handled in the kernel and only an
> errno is returned. Checking the ioctl's return value and errno is
> therefore sufficient.
>
> Signed-off-by: Sagi Shahar <sagis@xxxxxxxxxx>
> Signed-off-by: Lisa Wang <wyihan@xxxxxxxxxx>
>
> [...snip...]
>
Reviewed-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>