Linux Confidential Computing Development
 help / color / mirror / Atom feed
From: Binbin Wu <binbin.wu@linux.intel.com>
To: seanjc@google.com, Changyuan Lyu <changyuanl@google.com>,
	rick.p.edgecombe@intel.com
Cc: binbin.wu@intel.com, bp@alien8.de, dave.hansen@linux.intel.com,
	hpa@zytor.com, isaku.yamahata@intel.com, kas@kernel.org,
	kvm@vger.kernel.org, linux-coco@lists.linux.dev,
	linux-kernel@vger.kernel.org, mingo@redhat.com,
	pbonzini@redhat.com, tglx@kernel.org, x86@kernel.org,
	xiaoyao.li@intel.com, Binbin Wu <binbin.wu@linux.intel.com>
Subject: Re: [PATCH] KVM: TDX: Set SIGNIFCANT_INDEX flag for supported CPUIDs
Date: Tue, 13 Oct 2026 13:20:24 +0800	[thread overview]
Message-ID: <a578b2ff-52a4-4959-832d-a84b24ccb80e@linux.intel.com> (raw)
In-Reply-To: <20260224212939.2081828-1-changyuanl@google.com>

On 2/25/2026 5:29 AM, Changyuan Lyu wrote:

[...]

> -----------------------
> 
>>From 18b967b718911c09872c3717d8ab083fa59c4a70 Mon Sep 17 00:00:00 2001
> From: Changyuan Lyu <changyuanl@google.com>
> Date: Fri, 20 Feb 2026 09:55:28 -0800
> Subject: [PATCH] KVM: TDX: Set SIGNIFCANT_INDEX flag for supported CPUIDs
> 
> Set the KVM_CPUID_FLAG_SIGNIFCANT_INDEX flag in the kvm_cpuid_entry2
> structures returned by KVM_TDX_CAPABILITIES if the CPUID is indexed.
> This ensures consistency with the CPUID entries returned by
> KVM_GET_SUPPORTED_CPUID.
> 
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Changyuan Lyu <changyuanl@google.com>


Hi Sean,

When I was preparing the v5 of the TDX CPUID patch series, the internal sashiko
reported a issue:
  > @@ -2359,6 +2359,15 @@ static int setup_tdparams_cpuids(struct kvm_cpuid2 *cpuid,
  >  		if (!entry)
  >  			continue;
  >  
  > +		/*
  > +		 * Reject entries whose index doesn't match the expected one.
  > +		 * This catches userspace passing a CPUID entry with the
  > +		 * KVM_CPUID_FLAG_SIGNIFCANT_INDEX flag cleared when the index
  > +		 * is significant.
  > +		 */
  > +		if (entry->index != tmp.index)
  > +			return -EINVAL;
  
  [Severity: Medium]
  Does this unconditional check inadvertently break userspace VMMs that provide
  valid CPUID entries but leave the index field uninitialized for
  non-significant leaves?
  
  Since kvm_find_cpuid_entry2() ignores the index field when
  KVM_CPUID_FLAG_SIGNIFCANT_INDEX is cleared, VMMs are not architecturally
  required to zero the index for non-significant leaves. This check forces
  the index to be exactly 0 (since tmp.index is normalized to 0) even for
  leaves that do not have architecturally significant subleaves.


I think the issue is valid, so it needs to know whether the entry
is a subleaf or not. I think it's more reliable to do it via the information
reported by the TDX module. i.e. my patch set will rely on this patch to set
KVM_CPUID_FLAG_SIGNIFCANT_INDEX for entries that are indexed.

Will you apply this patch?
Or I can include this patch in my patch set. Also, 0x23 is still missing in
cpuid_function_is_indexed(), I can add a patch to add 0x23 as well.


> ---
>  arch/x86/kvm/vmx/tdx.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 2d7a4d52ccfb4..1c039eab2f3d8 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -167,6 +167,7 @@ static void td_init_cpuid_entry2(struct kvm_cpuid_entry2 *entry, unsigned char i
> 
>  	entry->function = (u32)td_conf->cpuid_config_leaves[idx];
>  	entry->index = td_conf->cpuid_config_leaves[idx] >> 32;
> +	entry->flags = 0;
>  	entry->eax = (u32)td_conf->cpuid_config_values[idx][0];
>  	entry->ebx = td_conf->cpuid_config_values[idx][0] >> 32;
>  	entry->ecx = (u32)td_conf->cpuid_config_values[idx][1];
> @@ -174,6 +175,9 @@ static void td_init_cpuid_entry2(struct kvm_cpuid_entry2 *entry, unsigned char i
> 
>  	if (entry->index == KVM_TDX_CPUID_NO_SUBLEAF)
>  		entry->index = 0;
> +	else
> +		entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
> +
> 
>  	/*
>  	 * The TDX module doesn't allow configuring the guest phys addr bits
> --
> 2.53.0.414.gf7e9f6c205-goog


      reply	other threads:[~2026-10-13  5:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 21:43 [PATCH] KVM: TDX: Set SIGNIFCANT_INDEX flag for supported CPUIDs Changyuan Lyu
2026-02-24  1:57 ` Edgecombe, Rick P
2026-02-24  8:50   ` Binbin Wu
2026-02-24 16:03     ` Sean Christopherson
2026-02-24 18:45       ` Edgecombe, Rick P
2026-02-24 20:42         ` Sean Christopherson
2026-02-24 21:44           ` Edgecombe, Rick P
2026-02-25  0:18       ` Binbin Wu
2026-02-25  3:23       ` Binbin Wu
2026-02-25 13:59         ` Sean Christopherson
2026-02-25 15:03           ` Binbin Wu
2026-02-24 21:29   ` Changyuan Lyu
2026-10-13  5:20     ` Binbin Wu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a578b2ff-52a4-4959-832d-a84b24ccb80e@linux.intel.com \
    --to=binbin.wu@linux.intel.com \
    --cc=binbin.wu@intel.com \
    --cc=bp@alien8.de \
    --cc=changyuanl@google.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox