Re: [PATCH v2 24/25] KVM: x86: Introduce KVM_TDX_GET_CPUID
From: Edgecombe, Rick P
Date: Tue Jan 21 2025 - 15:25:14 EST
On Fri, 2025-01-10 at 12:47 +0800, Xiaoyao Li wrote:
> 0x1f needs clarification here.
>
> If it's going to use the maximum leaf KVM can support, it should be 0x24
> to align with __do_cpuid_func().
>
> alternatively, it can use the EAX value of leaf 0 returned by TDX
> module. That is the value TDX module presents to the TD guest.
>
> > + output_e = &td_cpuid->entries[i];
> > + i += tdx_vcpu_get_cpuid_leaf(vcpu, leaf,
> > + KVM_MAX_CPUID_ENTRIES - i - 1,
> > + output_e);
> > + }
> > +
> > + for (leaf = 0x80000000; leaf <= 0x80000008; leaf++) {
> > + output_e = &td_cpuid->entries[i];
> > + i += tdx_vcpu_get_cpuid_leaf(vcpu, leaf,
> > + KVM_MAX_CPUID_ENTRIES - i - 1,
> > + output_e);
Since we are not filtering by KVM supported features anymore, maybe just use the
max leaf for the host CPU, like:
@@ -2790,14 +2791,14 @@ static int tdx_vcpu_get_cpuid(struct kvm_vcpu *vcpu,
struct kvm_tdx_cmd *cmd)
if (!td_cpuid)
return -ENOMEM;
- for (leaf = 0; leaf <= 0x1f; leaf++) {
+ for (leaf = 0; leaf <= boot_cpu_data.cpuid_level; leaf++) {
output_e = &td_cpuid->entries[i];
i += tdx_vcpu_get_cpuid_leaf(vcpu, leaf,
KVM_MAX_CPUID_ENTRIES - i - 1,
output_e);
}
- for (leaf = 0x80000000; leaf <= 0x80000008; leaf++) {
+ for (leaf = 0x80000000; leaf <= boot_cpu_data.extended_cpuid_level;
leaf++) {
output_e = &td_cpuid->entries[i];
i += tdx_vcpu_get_cpuid_leaf(vcpu, leaf,
KVM_MAX_CPUID_ENTRIES - i - 1,