Re: [PATCH v2 24/25] KVM: x86: Introduce KVM_TDX_GET_CPUID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/22/2025 4:24 AM, Edgecombe, Rick P wrote:
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:

host value is not matched with the value returned by TDX module.
I.e., On my SPR machine, the boot_cpu_data.cpuid_level is 0x20, while TDX module returns 0x23. It at least fails to report the leaf 0x21 to userspace, which is a always valid leaf for TD guest.

@@ -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,






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux