Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Binbin Wu <binbin.wu@linux.intel.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: seanjc@google.com, pbonzini@redhat.com,
	dave.hansen@linux.intel.com, andrew.cooper3@citrix.com,
	nik.borisov@suse.com, kas@kernel.org, rick.p.edgecombe@intel.com,
	chao.gao@intel.com, tony.lindgren@linux.intel.com,
	kishen.maloor@intel.com, dedekind1@gmail.com,
	adrian.hunter@intel.com
Subject: Re: [PATCH v5 5/5] KVM: TDX: Validate userspace CPUID input for KVM_TDX_INIT_VM
Date: Fri, 23 Oct 2026 15:46:01 +0800	[thread overview]
Message-ID: <32413bfd-a448-483b-b2b5-7f4ff6cbc56a@intel.com> (raw)
In-Reply-To: <20261016091422.3182216-6-binbin.wu@linux.intel.com>

On 10/16/2026 5:14 PM, Binbin Wu wrote:
> Validate the CPUID configuration provided by userspace through
> KVM_TDX_INIT_VM against KVM's TDX allowlist, and drop the hardcoded
> denylist-based check.
> 
> The TDX module lets the VMM directly configure certain CPUID bits for a TD
> at initialization time, but KVM must strictly govern which of those bits
> userspace can set, otherwise a feature that clobbers host state could be
> enabled behind KVM's back.  The existing denylist rejects only TSX and
> WAITPKG, and thus would accept any bit that a future TDX module makes
> configurable, even if KVM knows nothing about the associated feature.
> 
> Add tdx_has_unsupported_cpuid_cfg_bit() and reject KVM_TDX_INIT_VM if
> userspace sets any bit outside of the mask returned by
> tdx_get_cpuid_cfg_mask(), i.e. the same mask used to filter
> KVM_TDX_CAPABILITIES.  Don't bother intersecting the userspace input with
> the bits that the TDX module reports as directly configurable, as the TDX
> module itself rejects any bit outside that set.
> 
> As with the existing check, use the subleaf reported by the TDX module to
> look up the allowed mask.  For leaves without subleaves, the TDX module's
> "no subleaf" index is normalized to 0, which matches how such leaves are
> tracked in reverse_cpuid[].
> 
> Note, the change is user-visible, as KVM_TDX_INIT_VM now rejects some
> input that was previously accepted.  The ABI itself is unchanged: KVM
> already rejected unsupported CPUID bits, albeit via a denylist, and
> userspace has always been required to consult KVM_TDX_CAPABILITIES and set
> only the bits reported as configurable.
> 
> The change isn't expected to break userspace or guests:
>  - The newly rejected bits are no longer reported as configurable by
>    KVM_TDX_CAPABILITIES, so userspace that honors KVM_TDX_CAPABILITIES
>    won't set them.
>  - CORE_CAPABILITIES, which older TDX module specs defined as fixed-1, is
>    still allowed.
>  - The dropped features are either obsolete or unsupported by KVM, and in
>    the latter case, a guest relying on them would already have run into
>    problems.
> 
> Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
> Reviewed-by: Tony Lindgren <tony.lindgren@linux.intel.com>

The patch generally looks good to me. However, since it depends on Patch 1,
which, I assume, is going to be replaced by Sean's series[1]. If that's case,
the patch will need a rebase and adjust on top.

Free feel to add

Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>

if there is no big design change in the end.

[1] https://lore.kernel.org/all/20261022210134.612848-1-seanjc@google.com/

  parent reply	other threads:[~2026-10-23  7:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  9:14 [PATCH v5 0/5] KVM: TDX: Validate directly configurable CPUID bits Binbin Wu
2026-10-16  9:14 ` [PATCH v5 1/5] KVM: TDX: Check unsupported CPUID bits against the TDX module's subleaf Binbin Wu
2026-10-16 15:25   ` Sean Christopherson
2026-10-16 22:15     ` Binbin Wu
2026-10-16 23:26       ` Sean Christopherson
2026-10-16  9:14 ` [PATCH v5 2/5] KVM: TDX: Track configurable CPUID bits allowed by KVM Binbin Wu
2026-10-23  3:24   ` Chao Gao
2026-10-23  7:35   ` Xiaoyao Li
2026-10-16  9:14 ` [PATCH v5 3/5] KVM: TDX: Add CORE_CAPABILITIES to the allowlist Binbin Wu
2026-10-23  3:25   ` Chao Gao
2026-10-16  9:14 ` [PATCH v5 4/5] KVM: TDX: Report only KVM-allowed CPUIDs in KVM_TDX_CAPABILITIES Binbin Wu
2026-10-21  0:39   ` Edgecombe, Rick P
2026-10-21  2:15     ` Binbin Wu
2026-10-21 17:19       ` Edgecombe, Rick P
2026-10-22  2:20         ` Binbin Wu
2026-10-23  7:42           ` Xiaoyao Li
2026-10-23  3:27   ` Chao Gao
2026-10-16  9:14 ` [PATCH v5 5/5] KVM: TDX: Validate userspace CPUID input for KVM_TDX_INIT_VM Binbin Wu
2026-10-16  9:24   ` sashiko-bot
2026-10-20  1:34     ` Binbin Wu
2026-10-23  3:37   ` Chao Gao
2026-10-23  7:46   ` Xiaoyao Li [this message]
2026-10-23  7:48     ` Binbin Wu
2026-10-21  0:59 ` [PATCH v5 0/5] KVM: TDX: Validate directly configurable CPUID bits Edgecombe, Rick P
2026-10-21 17:43 ` Nikolay Borisov

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=32413bfd-a448-483b-b2b5-7f4ff6cbc56a@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=chao.gao@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dedekind1@gmail.com \
    --cc=kas@kernel.org \
    --cc=kishen.maloor@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nik.borisov@suse.com \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=tony.lindgren@linux.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