From: sashiko-bot@kernel.org
To: "Rick Edgecombe" <rick.p.edgecombe@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v8 02/11] x86/virt/tdx: Allocate page bitmap for Dynamic PAMT
Date: Sat, 25 Jul 2026 00:33:43 +0000 [thread overview]
Message-ID: <20260725003343.65E951F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260725002302.3337017-3-rick.p.edgecombe@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The 16-bit TDX metadata field for 'pamt_page_bitmap_entry_bits' is silently truncated to 8 bits, potentially causing severe memory under-allocation on future TDX modules.
--
--- Patch [2]: [PATCH v8 02/11] x86/virt/tdx: Allocate page bitmap for Dynamic PAMT ---
commit 88c7f3b3a7c606e18ce66049ee20b819855d481e
Author: Kiryl Shutsemau <kas@kernel.org>
x86/virt/tdx: Allocate page bitmap for Dynamic PAMT
This commit begins implementing Dynamic PAMT by reading the bits-per-page
metadata required for Dynamic PAMT and calculating the needed bitmap size.
It then allocates a page bitmap instead of the normal 4KB PAMT if Dynamic
PAMT is supported by the TDX module.
> diff --git a/arch/x86/include/asm/tdx_global_metadata.h b/arch/x86/include/asm/tdx_global_metadata.h
> index 41150d546589c..2a42551fc33cd 100644
> --- a/arch/x86/include/asm/tdx_global_metadata.h
> +++ b/arch/x86/include/asm/tdx_global_metadata.h
[ ... ]
> @@ -21,6 +21,9 @@ struct tdx_sys_info_tdmr {
> u16 pamt_4k_entry_size;
> u16 pamt_2m_entry_size;
> u16 pamt_1g_entry_size;
> +
> + /* Optional metadata, if Dynamic PAMT is supported */
> + u8 pamt_page_bitmap_entry_bits;
> };
[ ... ]
> diff --git a/arch/x86/virt/vmx/tdx/tdx_global_metadata.c b/arch/x86/virt/vmx/tdx/tdx_global_metadata.c
> index e49c300f23d43..8393d2aa59dbe 100644
> --- a/arch/x86/virt/vmx/tdx/tdx_global_metadata.c
> +++ b/arch/x86/virt/vmx/tdx/tdx_global_metadata.c
[ ... ]
> @@ -33,6 +33,18 @@ static __init int get_tdx_sys_info_features(struct tdx_sys_info_features *sysinf
> return ret;
> }
>
> +static __init int get_tdx_sys_info_tdmr_dpamt(struct tdx_sys_info_tdmr *sysinfo_tdmr)
> +{
> + int ret;
> + u64 val;
> +
> + ret = read_sys_metadata_field(0x9100000100000013, &val);
> + if (!ret)
> + sysinfo_tdmr->pamt_page_bitmap_entry_bits = val;
[Severity: Medium]
Does assigning val to pamt_page_bitmap_entry_bits result in an unsafe
truncation?
Since pamt_page_bitmap_entry_bits is declared as a u8 in
struct tdx_sys_info_tdmr, and the metadata field ID 0x9100000100000013
specifies a 16-bit value according to the TDX ABI (bits 33:32 are '01'),
a value from the hardware might be silently truncated.
If a future TDX module increases the required bitmap entry size to 256 bits
or more, wouldn't this truncation cause severe memory under-allocation for
the physically contiguous PAMT memory?
> +
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260725002302.3337017-1-rick.p.edgecombe@intel.com?part=2
next prev parent reply other threads:[~2026-07-25 0:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 0:22 [PATCH v8 00/11] Dynamic PAMT Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 01/11] x86/virt/tdx: Simplify PAMT layout calculation Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 02/11] x86/virt/tdx: Allocate page bitmap for Dynamic PAMT Rick Edgecombe
2026-07-25 0:33 ` sashiko-bot [this message]
2026-07-25 0:22 ` [PATCH v8 03/11] x86/virt/tdx: Add tdx_alloc/free_control_page() helpers Rick Edgecombe
2026-07-25 0:35 ` sashiko-bot
2026-07-25 0:22 ` [PATCH v8 04/11] x86/virt/tdx: Allocate refcounts for Dynamic PAMT memory Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 05/11] x86/virt/tdx: Handle multiple callers in tdx_pamt_get/put() Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 06/11] KVM: TDX: Allocate PAMT memory for TD and vCPU control structures Rick Edgecombe
2026-07-25 0:35 ` sashiko-bot
2026-07-25 0:22 ` [PATCH v8 07/11] x86/tdx: Add APIs to support Dynamic PAMT ops from KVM's fault path Rick Edgecombe
2026-07-25 0:22 ` [PATCH v8 08/11] KVM: TDX: Get/put PAMT pages when (un)mapping private memory Rick Edgecombe
2026-07-25 0:46 ` sashiko-bot
2026-07-25 0:22 ` [PATCH v8 09/11] x86/virt/tdx: Enable Dynamic PAMT Rick Edgecombe
2026-07-25 0:23 ` [PATCH v8 10/11] Documentation/x86: Add documentation for TDX's " Rick Edgecombe
2026-07-25 0:23 ` [PATCH v8 11/11] x86/virt/tdx: Optimize tdx_pamt_get/put() Rick Edgecombe
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=20260725003343.65E951F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=rick.p.edgecombe@intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.