Re: [PATCH v14 15/22] KVM: selftests: Call KVM_TDX_INIT_VCPU when creating a new TDX vcpu

Binbin Wu <[email protected]>
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest
Message-ID <[email protected]>
On 8/14/2026 4:32 PM, Xiaoyao Li wrote:

[...]
>>   +static void tdx_vcpu_init(struct kvm_vm *vm, struct kvm_vcpu *vcpu)
>> +{
>> +    struct kvm_cpuid2 *cpuid;
>> +
>> +    cpuid = allocate_kvm_cpuid2(MAX_NR_CPUID_ENTRIES);
>> +    tdx_vcpu_ioctl(vcpu, KVM_TDX_GET_CPUID, 0, cpuid);
> 
> If I remember correctly, though KVM_TDX_GET_CPUID is a vcpu ioctl, the data returned by KVM is retrived from TDX module and TDX module only maintains the TD scope CPUID.

KVM_TDX_GET_CPUID does return TD-scoped CPUID metadata only.

> So the CPUID returned here is TD scope, for per-vcpu CPUIDs, e.g., x2apicid, we need to update them accordingly.
> 
> This seems not a functional gap. I'm OK to leave it to the future, but please leave a TODO comment for it.
> 

The handling for legacy VMs is similar, i.e. kvm_get_supported_cpuid()also has
no per-vcpu CPUID info like APIC ID. It seems that KVM selftests doesn't test
CPUID topology enumeration.

A comment could be helpful, although it may not be a TODO comment.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.