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 3/6] x86/virt/tdx: Add extra memory to TDX module for the extensions
Date: Mon, 05 Oct 2026 17:56:52 +0000	[thread overview]
Message-ID: <20261005175653.03C341F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261006-tdx-module-ext-v3-3-db52cb05b918@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] x86/virt/tdx: kzalloc() breaks page alignment for hardware-facing struct under debug
--

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

x86/virt/tdx: Add extra memory to TDX module for the extensions

This commit introduces a new SEAMCALL leaf TDH.EXT.MEM.ADD to allocate and
add execution environment memory to the TDX module for extensions. It allocates
a page-sized structure tdx_hpa_list to pass the physical addresses of the
allocated memory to the hardware.

> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index f08278a47affc..c445359335516 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c

[ ... ]

> +static __init u64 to_hpa_list_info(struct tdx_hpa_list *hpa_list,
> +				   unsigned int nr_pages)
> +{
> +	return FIELD_PREP(HPA_LIST_INFO_FIRST_ENTRY, 0) |
> +	       FIELD_PREP(HPA_LIST_INFO_PFN, PFN_DOWN(__pa(hpa_list))) |

[Severity: High]
If the hpa_list pointer is unaligned due to slab redzones, does this
PFN_DOWN() truncation cause the TDX module to read the redzone metadata
instead of the actual array?

> +	       FIELD_PREP(HPA_LIST_INFO_LAST_ENTRY, nr_pages - 1);
> +}

[ ... ]

> +static __init int tdx_ext_mem_setup(void)
> +{
> +	unsigned int required_pages, added_pages;
> +	struct tdx_sys_info_ext sysinfo_ext;
> +	struct tdx_hpa_list *hpa_list;
> +	struct page *page;
> +	int ret;

[ ... ]

> +	/*
> +	 * Allocate the container page for the HPA_LIST. tdx_hpa_list is
> +	 * guaranteed to be page-sized by static_assert(), so kzalloc()
> +	 * guarantees the page alignment.
> +	 */
> +	hpa_list = kzalloc_obj(*hpa_list);

[Severity: High]
Does kzalloc_obj() actually guarantee page alignment when CONFIG_KASAN or
CONFIG_SLUB_DEBUG are enabled?

Since slab redzones offset the object within the page, a PAGE_SIZE allocation
through the slab allocator might not return a page-aligned address under
these debug configurations.

Would it be safer to use the page allocator (e.g. alloc_page() or
get_zeroed_page()) instead of the slab allocator for a structure that requires
strict page alignment when passed to hardware?

> +	if (!hpa_list)
> +		return -ENOMEM;

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

  reply	other threads:[~2026-10-05 17:56 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 [this message]
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
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=20261005175653.03C341F000FF@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