Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xu Yilun" <yilun.xu@linux.intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 4/6] x86/virt/tdx: Make TDX module initialize the extensions
Date: Mon, 05 Oct 2026 18:00:31 +0000	[thread overview]
Message-ID: <20261005180031.98BC61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261006-tdx-module-ext-v3-4-db52cb05b918@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] x86/tdx: missing cache flush for extension memory before TDH_EXT_MEM_ADD
--

commit 218ae840fc4855126ea1a0f203de6a4e414fa8d7
Author: Xu Yilun <yilun.xu@linux.intel.com>

x86/virt/tdx: Make TDX module initialize the extensions

TDX module extensions need memory for their execution environment
to serve SEAMCALL leafs. Several add-on features depend on the
extensions to execute their SEAMCALL leafs.

After providing all required memory to the TDX module, initialize TDX
module extensions via TDH.EXT.INIT, then those add-on features can use
their SEAMCALL leafs normally.

> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index c445359335516..d8df3b2b1d17d 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
> @@ -1348,12 +1348,35 @@ static __init int tdx_ext_mem_setup(void)
[ ... ]
>  static __init int init_tdx_module_extensions(void)
>  {
> +	int ret;
> +
>  	if (!(tdx_sysinfo.features.tdx_features0 & TDX_FEATURES0_EXT))
>  		return 0;
>  
> -	return tdx_ext_mem_setup();
> +	ret = tdx_ext_mem_setup();

[Severity: High]
Does tdx_ext_mem_setup() need to explicitly flush the extension memory cache
lines?

During TDX module initialization, a global cache flush (wbinvd_on_all_cpus())
is performed via config_global_keyid(). After this global flush,
init_tdx_module_extensions() is called, allocating memory via
alloc_contig_pages() in tdx_ext_mem_setup().

Because this memory is allocated after the wbinvd, it may contain dirty cache
lines. The pages are then passed to tdx_ext_mem_add() without an explicit
cache flush (such as tdx_clflush_page()):

arch/x86/virt/vmx/tdx/tdx.c:tdx_ext_mem_setup() {
    ...
		for (i = 0; i < chunk_pages; i++)
			hpa_list->phys[i] = page_to_phys(chunk + i);

		ret = tdx_ext_mem_add(hpa_list, chunk_pages);
    ...
}

Could missing cache flushes when transferring memory from the host (KeyID 0)
to the TDX module (which uses the global private KeyID) cause MKTME KeyID
aliasing MCEs? If dirty cache lines associated with KeyID 0 remain in the CPU
caches and are later evicted, they could corrupt the TDX module's private
memory.

> +	if (ret)
> +		return ret;
> +
> +	return tdx_ext_init();
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-tdx-module-ext-v3-0-db52cb05b918@linux.intel.com?part=4

  reply	other threads:[~2026-10-05 18:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 17:41 [PATCH v3 0/6] Enable TDX module extensions Xu Yilun
2026-10-05 17:41 ` [PATCH v3 1/6] x86/virt/tdx: Move TDH.SYS.CONFIG operations into a wrapper Xu Yilun
2026-10-06 23:27   ` Edgecombe, Rick P
2026-10-05 17:41 ` [PATCH v3 2/6] x86/virt/tdx: Configure add-on features on TDX module init Xu Yilun
2026-10-06 23:56   ` Edgecombe, Rick P
2026-10-08  4:18     ` Xu Yilun
2026-10-08 16:06       ` Edgecombe, Rick P
2026-10-05 17:41 ` [PATCH v3 3/6] x86/virt/tdx: Add extra memory to TDX module for the extensions Xu Yilun
2026-10-05 17:56   ` sashiko-bot
2026-10-05 17:41 ` [PATCH v3 4/6] x86/virt/tdx: Make TDX module initialize " Xu Yilun
2026-10-05 18:00   ` sashiko-bot [this message]
2026-10-08  4:25     ` Xu Yilun
2026-10-05 17:41 ` [PATCH v3 5/6] x86/virt/tdx: Re-initialize the extensions on runtime TDX module update Xu Yilun
2026-10-05 17:58   ` sashiko-bot
2026-10-08  4:47     ` Xu Yilun
2026-10-06  4:32   ` Tony Lindgren
2026-10-05 17:41 ` [PATCH v3 6/6] x86/virt/tdx: Support DPAMT when adding memory for the extensions Xu Yilun
2026-10-05 17:57   ` sashiko-bot
2026-10-08  4:31     ` Xu Yilun
2026-10-08 18:19       ` Edgecombe, Rick P
2026-10-06  4:36   ` Tony Lindgren
2026-10-08  4:39     ` Xu Yilun
2026-10-08  5:37       ` Tony Lindgren

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=20261005180031.98BC61F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yilun.xu@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