@@ -1014,6 +1014,30 @@ static int tdx_td_vcpu_init(struct kvm_vcpu *vcpu, u64 vcpu_rcx)
return ret;
}
+static int __maybe_unused tdx_get_kvm_supported_cpuid(struct kvm_cpuid2 **cpuid)
+{
+ int r;
+ static const u32 funcs[] = {
+ 0, 0x80000000, KVM_CPUID_SIGNATURE,
+ };
+
+ *cpuid = kzalloc(sizeof(struct kvm_cpuid2) +
+ sizeof(struct kvm_cpuid_entry2) * KVM_MAX_CPUID_ENTRIES,
+ GFP_KERNEL);
+ if (!*cpuid)
+ return -ENOMEM;
+ (*cpuid)->nent = KVM_MAX_CPUID_ENTRIES;
+ r = kvm_get_supported_cpuid_internal(*cpuid, funcs, ARRAY_SIZE(funcs));
+ if (r)
+ goto err;
+
+ return 0;
+err:
+ kfree(*cpuid);
+ *cpuid = NULL;
+ return r;
+}
+
static int tdx_vcpu_init(struct kvm_vcpu *vcpu, struct kvm_tdx_cmd *cmd)
{
struct msr_data apic_base_msr;
Two future TDX ioctl's will want to filter output by supported CPUID Add a helper in TDX code instead of using kvm_get_supported_cpuid_internal() directly for two reasons: 1. Logic around which CPUID leaf ranges to query would need to be duplicated. 2. Future patches will add TDX specific fixups to the CPUID data provided by kvm_get_supported_cpuid_internal(). Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> --- uAPI breakout v1: - New patch --- arch/x86/kvm/vmx/tdx.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)