Re: [PATCH 24/25] KVM: x86: Filter directly configurable TDX CPUID bits

From: Paolo Bonzini
Date: Tue Sep 10 2024 - 13:41:32 EST


On 8/13/24 00:48, Rick Edgecombe wrote:
+
+ cpuid_e = kvm_find_cpuid_entry2(supported_cpuid->entries, supported_cpuid->nent,
+ dest->leaf, dest->sub_leaf);
+ if (!cpuid_e) {
+ dest->eax = dest->ebx = dest->ecx = dest->edx = 0;
+ } else {
+ dest->eax &= cpuid_e->eax;
+ dest->ebx &= cpuid_e->ebx;
+ dest->ecx &= cpuid_e->ecx;
+ dest->edx &= cpuid_e->edx;
+ }

This can only work with CPUID entries that consists of 4*32 features, so it has to be done specifically for each leaf, unfortunately. I suggest defining a kvm_merge_cpuid_entries in cpuid.c that takes two struct cpuid_entry2* that refer to the same leaf and subleaf.

Paolo