Re: [PATCH v5 1/5] KVM: TDX: Check unsupported CPUID bits against the TDX module's subleaf
From: Sean Christopherson
Date: Fri Oct 16 2026 - 19:26:44 EST
On Sat, Oct 17, 2026, Binbin Wu wrote:
> On 10/16/2026 11:25 PM, Sean Christopherson wrote:
> > On Fri, Oct 16, 2026, Binbin Wu wrote:
> > @@ -2386,7 +2390,7 @@ static int setup_tdparams_cpuids(struct kvm_cpuid2 *cpuid,
> > if (!entry)
> > continue;
> >
> > - if (tdx_unsupported_cpuid(entry))
> > + if (tdx_is_unsupported_cpuid_entry(entry))
> > return -EINVAL;
> >
> > copy_cnt++;
> >
> > Can you test the attached patches? If they boot TDX with QEMU, I'll go ahead
> > and post.
>
> Patch 3 "KVM: TDX: Don't zero non-significant CPUID entry indices" breaks QEMU.
>
> QEMU uses zero as index for cpuid entries when index is not significant.
Drat. __do_cpuid_func() => do_host_cpuid() also zeros the index for
KVM_GET_SUPPORTED_CPUID, so the ABI is definitely baked at this point.
> And in QEMU, the lookup function doesn't consult the flags at all.
>
> struct kvm_cpuid_entry2 *cpuid_find_entry(struct kvm_cpuid2 *cpuid,
> uint32_t function,
> uint32_t index)
> {
> int i;
> for (i = 0; i < cpuid->nent; ++i) {
> if (cpuid->entries[i].function == function &&
> cpuid->entries[i].index == index) {
Bad QEMU, bad! :-)
> return &cpuid->entries[i];
> }
> }
> /* not found: */
> return NULL;
> }
>
> If KVM doesn't zero the index for the non-significant, QEMU cannot find
> any entry for non-significant entries returned by KVM_TDX_CAPABILITIES.
I'll opportunistically add a comment to call out that even though the index
should be meaningless, it has become ABI that userspace relies on.
> And 0x80000008 is used to pass GPAW, and KVM_TDX_INIT_VM fails when QEMU
> doesn't pass it.
>
> After dropping patch 3, QEMU can boot TD.
> Also our internal TDX CI cases passed.
Thanks much!