From: Binbin Wu <binbin.wu@linux.intel.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org, Xiaoyao Li <xiaoyao.li@intel.com>
Subject: Re: [RFC PATCH v2 4/4] KVM: x86: TDX: Report CORE_CAPABILITIES as supported
Date: Thu, 4 Jun 2026 13:40:41 +0800 [thread overview]
Message-ID: <84ed35cd-9767-4fc3-916b-05c5db9f200e@linux.intel.com> (raw)
In-Reply-To: <f33a2ef6-0f81-4417-89c4-ecf3d3e11e56@linux.intel.com>
On 6/4/2026 1:32 PM, Binbin Wu wrote:
>
>
> On 6/4/2026 10:51 AM, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>> - [High] Missing handling of MSR_IA32_CORE_CAPS in tdx_set_msr() causes KVM_SET_MSRS to fail, breaking VM initialization and live migration.
>> --
>>
>> commit 217a78047d73d2be68ef27e206470a6c237db79a
>> Author: Binbin Wu <binbin.wu@linux.intel.com>
>>
>> KVM: x86: TDX: Report CORE_CAPABILITIES as supported
>>
>> This commit adds CORE_CAPABILITIES to the TDX configurable CPUID allowlist
>> to accommodate legacy TDX module behavior. It also modifies tdx_get_msr()
>> to return 0 for MSR_IA32_CORE_CAPS.
>>
>>> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
>>> index 26a5ad59a5694..b7661ba98a8d4 100644
>>> --- a/arch/x86/kvm/vmx/tdx.c
>>> +++ b/arch/x86/kvm/vmx/tdx.c
>>
>> [ ... ]
>>
>>> @@ -2319,6 +2319,14 @@ int tdx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
>>> return 1;
>>> msr->data = vcpu->arch.mcg_ext_ctl;
>>> return 0;
>>> + case MSR_IA32_CORE_CAPS:
>>> + /*
>>> + * KVM doesn't support MSR_IA32_CORE_CAPS, however, in some old
>>> + * TDX modules, CPUID.0x7.0.EDX[30] is fixed-1. As a workaround,
>>> + * just return 0 for this MSR.
>>> + */
>>> + msr->data = 0;
>>> + return 0;
>>
>> [Severity: High]
>> Since MSR_IA32_CORE_CAPS is now exposed to userspace via tdx_get_msr(), does
> MSR_IA32_CORE_CAPS is not exposed to userspace via KVM_GET_MSR_INDEX_LIST.
> I suppose userspace should retrieve the supported MSRs via KVM_GET_MSR_INDEX_LIST
or KVM_GET_MSR_FEATURE_INDEX_LIST
> before KVM_GET_MSRS/KVM_SET_MSRS?
>
>
> Had a second thought, this MSR code could be dropped.
> In Linux kernel, MSR_IA32_CORE_CAPS is either read by the safe version or skipped
> when it's running in virtualized environment. Also, there was no complain about
> the access of this MSR in any guest so far.
>
> We can just report CORE_CAPABILITIES as a TDX configurable CPUID bit to userspace.
> Userspace can do some change to remove any bit that reported as configurable from
> fixed1 bits. Since KVM doesn't support CORE_CAPABILITIES via KVM_GET_CPUID2,
> userspace then should not enable CORE_CAPABILITIES bit for TDX guests.
>
>
>> tdx_set_msr() need a corresponding update to accept host-initiated writes?
>>
>> During VM migration or state restore, userspace typically reads MSRs on the
>> source and writes them to the destination. If tdx_set_msr() doesn't handle
>> MSR_IA32_CORE_CAPS, the KVM_SET_MSRS ioctl will fall through to the default
>> case.
>>
>> Because tdx_has_emulated_msr() does not include MSR_IA32_CORE_CAPS, won't
>> tdx_set_msr() return an error and immediately abort the migration?
>>
>>> default:
>>> if (!tdx_has_emulated_msr(msr->index))
>>> return 1;
>>
>
>
>
>
>
next prev parent reply other threads:[~2026-06-04 5:40 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
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 [this message]
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=84ed35cd-9767-4fc3-916b-05c5db9f200e@linux.intel.com \
--to=binbin.wu@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--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