All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Binbin Wu" <binbin.wu@linux.intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC PATCH v2 2/4] KVM: x86: TDX: Hide unsupported configurable CPUID bits
Date: Thu, 04 Jun 2026 02:47:17 +0000	[thread overview]
Message-ID: <20260604024718.497F21F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604023314.3907511-3-binbin.wu@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The secure-by-default CPUID allowlist is applied to KVM capability reporting but missing from TD initialization validation. This allows a malicious userspace VMM to bypass capability enumeration and supply unsupported configurable CPUID bits directly to the TDX module, potentially causing host state corruption.
--

commit e4dd30c1f72bbeeb74f3ba5a865ab30e0c17bcf6
Author: Binbin Wu <binbin.wu@linux.intel.com>

KVM: x86: TDX: Hide unsupported configurable CPUID bits

This commit introduces get_supported_cfg_cpuid() to filter the CPUID 
capabilities reported by KVM_TDX_CAPABILITIES. It replaces a hardcoded 
denylist with a secure-by-default allowlist approach to prevent exposing 
unsupported features that could lead to host state corruption.

> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 028d54c76b81e..befda6bc17b1e 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c

[ ... ]

> -static void clear_waitpkg(struct kvm_cpuid_entry2 *entry)
> +static bool tdx_unsupported_cpuid(const struct kvm_cpuid_entry2 *entry)
>  {
> -	entry->ecx &= ~__feature_bit(X86_FEATURE_WAITPKG);
> +	return has_tsx(entry) || has_waitpkg(entry);
>  }

[Severity: High]
This is a pre-existing issue, but by keeping this legacy denylist active, is
there a risk that userspace can bypass the new secure-by-default allowlist
during TD initialization?

While this patch updates capability reporting to explicitly mask unsupported 
features, the configuration path in setup_tdparams_cpuids() still appears to 
use this older denylist function to validate user input:

arch/x86/kvm/vmx/tdx.c:setup_tdparams_cpuids() {
        ...
        if (tdx_unsupported_cpuid(entry))
                return -EINVAL;

        value = &td_params->cpuid_values[i];
        value->eax = entry->eax;
        value->ebx = entry->ebx;
        value->ecx = entry->ecx;
        value->edx = entry->edx;
        ...
}

Because these user-provided CPUID values are copied directly into the hardware 
initialization parameters without being masked against the newly introduced 
get_supported_cfg_cpuid() allowlist, could a VMM explicitly request and pass 
unsupported configurable CPUID bits directly to the TDX module?

Does this still leave the door open to the host state corruption mentioned
in the commit message if the TDX module only enforces hardware-level support
rather than KVM's software constraints?

>  
> -static void tdx_clear_unsupported_cpuid(struct kvm_cpuid_entry2 *entry)
> +static u32 get_supported_cfg_cpuid(u32 function, u32 index, u8 reg)
>  {

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260604023314.3907511-1-binbin.wu@linux.intel.com?part=2

  reply	other threads:[~2026-06-04  2:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04  2:33 [RFC PATCH v2 0/4] KVM: x86: TDX: Validate directly configurable CPUID bits Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 1/4] KVM: x86: TDX: Track supported " Binbin Wu
2026-06-04  2:44   ` sashiko-bot
2026-06-04  5:37     ` Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 2/4] KVM: x86: TDX: Hide unsupported " Binbin Wu
2026-06-04  2:47   ` sashiko-bot [this message]
2026-06-04  2:54     ` Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 3/4] KVM: x86: TDX: Validate userspace CPUID input for KVM_TDX_INIT_VM Binbin Wu
2026-06-04  2:49   ` sashiko-bot
2026-06-04  3:13     ` Binbin Wu
2026-06-04  2:33 ` [RFC PATCH v2 4/4] KVM: x86: TDX: Report CORE_CAPABILITIES as supported Binbin Wu
2026-06-04  2:51   ` sashiko-bot
2026-06-04  5:32     ` Binbin Wu
2026-06-04  5:40       ` Binbin Wu
2026-06-04  6:53   ` Xiaoyao Li
2026-06-04  7:20     ` Binbin Wu

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=20260604024718.497F21F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=binbin.wu@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.