From: sashiko-bot@kernel.org
To: "Binbin Wu" <binbin.wu@linux.intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC PATCH v2 1/4] KVM: x86: TDX: Track supported configurable CPUID bits
Date: Thu, 04 Jun 2026 02:44:24 +0000 [thread overview]
Message-ID: <20260604024425.4923D1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604023314.3907511-2-binbin.wu@linux.intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The `tdx_cpu_cfg_cap_init` macro is highly fragile and relies on the caller providing a mandatory trailing comma, which will cause obscure syntax errors if omitted.
--
commit 8aa0677abade944ac536d7acccef89b12ace7386
Author: Binbin Wu <binbin.wu@linux.intel.com>
KVM: x86: TDX: Track supported configurable CPUID bits
This patch introduces an allowlist for TDX directly configurable CPUID bits
supported by KVM. It tracks the supported bits by statically initializing
multi-bit fields and dynamically populating feature bits during hardware
setup using a new initialization macro.
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index b8c3d3d8bbfe5..028d54c76b81e 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
[ ... ]
> @@ -52,6 +52,178 @@
> +#define TDX_F(name) \
> +({ \
> + tdx_cpu_cfg_caps |= feature_bit(name); \
> +})
> +
> +#define tdx_cpu_cfg_cap_init(_func, _index, _reg, feature_initializers...) \
> +do { \
> + u32 tdx_cpu_cfg_caps = 0; \
> + \
> + for (int i = 0; i < ARRAY_SIZE(tdx_kvm_supported_cpuid); i++) { \
> + struct tdx_supported_cpuid_reg *r = &tdx_kvm_supported_cpuid[i]; \
> + \
> + if (r->function == _func && r->index == _index && r->reg == _reg) { \
> + feature_initializers \
> + r->mask |= tdx_cpu_cfg_caps; \
[Severity: Low]
Is this macro design relying on the caller providing a mandatory trailing
comma?
Because feature_initializers expands to a list of statement expressions
like ({ tdx_cpu_cfg_caps |= feature_bit(name); }), omitting the trailing
comma in the macro invocation would result in a syntax error immediately
before r->mask |= tdx_cpu_cfg_caps.
Could TDX_F be redesigned to return the bitmask directly so they can be
combined using bitwise-OR, avoiding the strict trailing comma dependency?
> + break; \
> + } \
> + } \
> + \
> + WARN_ON_ONCE(!tdx_cpu_cfg_caps); \
> +} while (0)
> +
> +/* Only for TDX directly configurable CPUID feature bits */
> +static void __init tdx_initialize_cpu_cfg_caps(void)
> +{
> + tdx_cpu_cfg_cap_init(0x1, 0, CPUID_ECX,
> + TDX_F(MWAIT),
> + TDX_F(TSC_DEADLINE_TIMER),
> + TDX_F(AVX),
> + TDX_F(F16C),
> + );
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260604023314.3907511-1-binbin.wu@linux.intel.com?part=1
next prev parent reply other threads:[~2026-06-04 2:44 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 [this message]
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
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=20260604024425.4923D1F00893@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox