* [PATCH] x86/virt/tdx: Add command line param for DPAMT
@ 2026-11-26 0:54 Rick Edgecombe
2026-11-26 8:13 ` Yan Zhao
2026-11-26 10:48 ` Nikolay Borisov
0 siblings, 2 replies; 3+ messages in thread
From: Rick Edgecombe @ 2026-11-26 0:54 UTC (permalink / raw)
To: bp, dave.hansen, hpa, kas, linux-kernel, mingo, nik.borisov,
tglx, x86, chao.gao, yan.y.zhao, yilun.xu
Cc: rick.p.edgecombe
The Physical Address Metadata Table (PAMT) holds TDX metadata for
physical memory and must be allocated by the kernel during TDX module
initialization. Dynamic PAMT (DPAMT) is a TDX module feature that can
reduce this memory use by allocating part of the PAMT dynamically.
In order to work with DPAMT, the kernel needs to perform upkeep on the
DPAMT for each page that it gives to the TDX module. Late during the
upstreaming of DPAMT, an optimization patch that avoided taking a global
lock for each maintenance operation was dropped. The plan was to follow up
the initial upstreaming with optimization work, however priority for this
work has yet to materialize.
Separately from the wrinkle of the global lock, TDX continues to struggle
with large patchsets to enable new features. Doing DPAMT maintenance for
the new types of memory these features require, further grows the initial
patchsets.
Adding a kernel parameter for DPAMT can help these two separate problems.
Having DPAMT be default off can make the offensive global lock the rare
case, while still giving some big memory conscious users the option to use
DPAMT. Having DPAMT capable of being off means that the upcoming TDX
features can be merged in smaller pieces by ignoring DPAMT to start.
So add a parameter and make DPAMT default off.
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
---
Dave, feel free to ignore.
TDX developers, this is small, but can I get a round of review on the
patch? One consideration I had was if tdx_supports_dynamic_pamt() should
be renamed, but I thought it wasn't worth the churn.
Another idea is to ignore the impact of the global lock until someone
complains. And for the new features, to make them mutually exclusive with
Dynamic PAMT support by simply keying off module support, rather than
allowing Dynamic PAMT to be disabled. But since Dynamic PAMT is available
on all newer modules, this would only appear to make the new features
enabled. In practice they would be dead code. And default off is arguably
the best default option in DPAMT's current state. So prefer the kernel
param.
Also, I cherry-picked this from the last DPAMT patchset and didn't retest
it on upstream yet. Will do, but I'm not expecting problems.
---
Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
arch/x86/virt/vmx/tdx/tdx.c | 12 ++++++++++++
2 files changed, 19 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 176648941aec2..af8b8eb54228e 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -7564,6 +7564,13 @@ Kernel parameters
tdfx= [HW,DRM]
+ tdx_dpamt=
+ [X86] Controls whether TDX will use Dynamic PAMT
+ to save memory, when supported.
+
+ Valid parameters: "on", "off"
+ Default: "off"
+
test_suspend= [SUSPEND]
Format: { "mem" | "standby" | "freeze" }[,N]
Specify "mem" (for Suspend-to-RAM) or "standby" (for
diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 96ced0494b687..ed5f37e5ebb29 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -50,6 +50,8 @@
/* Number of DPAMT pages to be provided to TDX module per 2MB region of PA */
#define TDX_DPAMT_ENTRY_PAGE_CNT 2
+static bool tdx_enable_dpamt __ro_after_init;
+
struct tdx_module_state {
bool initialized;
bool sysinit_done;
@@ -2055,6 +2057,9 @@ EXPORT_SYMBOL_FOR_KVM(tdh_phymem_page_wbinvd_hkid);
bool tdx_supports_dynamic_pamt(const struct tdx_sys_info *sysinfo)
{
+ if (!tdx_enable_dpamt)
+ return false;
+
return sysinfo->features.tdx_features0 & TDX_FEATURES0_DYNAMIC_PAMT;
}
EXPORT_SYMBOL_FOR_KVM(tdx_supports_dynamic_pamt);
@@ -2316,6 +2321,13 @@ void tdx_free_control_page(struct page *page)
}
EXPORT_SYMBOL_FOR_KVM(tdx_free_control_page);
+static int __init tdx_dpamt_setup(char *str)
+{
+ return kstrtobool(str, &tdx_enable_dpamt) == 0;
+}
+
+__setup("tdx_dpamt=", tdx_dpamt_setup);
+
void tdx_sys_disable(void)
{
struct tdx_module_args args = {};
--
2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/virt/tdx: Add command line param for DPAMT
2026-11-26 0:54 [PATCH] x86/virt/tdx: Add command line param for DPAMT Rick Edgecombe
@ 2026-11-26 8:13 ` Yan Zhao
2026-11-26 10:48 ` Nikolay Borisov
1 sibling, 0 replies; 3+ messages in thread
From: Yan Zhao @ 2026-11-26 8:13 UTC (permalink / raw)
To: Rick Edgecombe
Cc: bp, dave.hansen, hpa, kas, linux-kernel, mingo, nik.borisov,
tglx, x86, chao.gao, yilun.xu, ackerleytng, vannapurve, seanjc
+ Sean, Ackerley, Vishal,
On Wed, Nov 25, 2026 at 04:54:16PM -0800, Rick Edgecombe wrote:
> The Physical Address Metadata Table (PAMT) holds TDX metadata for
> physical memory and must be allocated by the kernel during TDX module
> initialization. Dynamic PAMT (DPAMT) is a TDX module feature that can
> reduce this memory use by allocating part of the PAMT dynamically.
>
> In order to work with DPAMT, the kernel needs to perform upkeep on the
> DPAMT for each page that it gives to the TDX module. Late during the
> upstreaming of DPAMT, an optimization patch that avoided taking a global
> lock for each maintenance operation was dropped. The plan was to follow up
> the initial upstreaming with optimization work, however priority for this
> work has yet to materialize.
>
> Separately from the wrinkle of the global lock, TDX continues to struggle
> with large patchsets to enable new features. Doing DPAMT maintenance for
> the new types of memory these features require, further grows the initial
> patchsets.
>
> Adding a kernel parameter for DPAMT can help these two separate problems.
> Having DPAMT be default off can make the offensive global lock the rare
> case, while still giving some big memory conscious users the option to use
> DPAMT. Having DPAMT capable of being off means that the upcoming TDX
> features can be merged in smaller pieces by ignoring DPAMT to start.
There is a new direction to have initial TDX huge page support without DPAMT,
as it simplifies the initial patch set and would be faster to upstream. That is,
TDX huge page support would depend on this patch that makes DPAMT optional and
default off, and huge pages would only be enabled when DPAMT is off.
Would you like to have an early discussion on this direction?
Is the mutual exclusivity between DPAMT and the initial huge page support
acceptable in practice?
Pros:
- Simplifies the diffs in tip and KVM.
Only one patch is needed under tip, and DPAMT-related handling in KVM can also
be dropped.
Cons:
- Part of the KVM implementation becomes slightly awkward, since the 4KB
mapping/unmapping code already supports DPAMT.
> So add a parameter and make DPAMT default off.
>
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
> ---
> Dave, feel free to ignore.
>
> TDX developers, this is small, but can I get a round of review on the
> patch? One consideration I had was if tdx_supports_dynamic_pamt() should
> be renamed, but I thought it wasn't worth the churn.
tdx_enables_dynamic_pamt() seems more accurate.
> Another idea is to ignore the impact of the global lock until someone
> complains. And for the new features, to make them mutually exclusive with
> Dynamic PAMT support by simply keying off module support, rather than
> allowing Dynamic PAMT to be disabled. But since Dynamic PAMT is available
> on all newer modules, this would only appear to make the new features
> enabled. In practice they would be dead code. And default off is arguably
> the best default option in DPAMT's current state. So prefer the kernel
> param.
>
> Also, I cherry-picked this from the last DPAMT patchset and didn't retest
> it on upstream yet. Will do, but I'm not expecting problems.
Tested working with kvm-x86-next-2026.11.11, which is at v7.4.0-rc2.
> ---
> Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
> arch/x86/virt/vmx/tdx/tdx.c | 12 ++++++++++++
> 2 files changed, 19 insertions(+)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 176648941aec2..af8b8eb54228e 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -7564,6 +7564,13 @@ Kernel parameters
>
> tdfx= [HW,DRM]
>
> + tdx_dpamt=
> + [X86] Controls whether TDX will use Dynamic PAMT
[X86] --> [X86-64] ?
And is a "KNL" tag necessary?
> + to save memory, when supported.
> +
> + Valid parameters: "on", "off"
> + Default: "off"
> +
> test_suspend= [SUSPEND]
> Format: { "mem" | "standby" | "freeze" }[,N]
> Specify "mem" (for Suspend-to-RAM) or "standby" (for
> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index 96ced0494b687..ed5f37e5ebb29 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
> @@ -50,6 +50,8 @@
> /* Number of DPAMT pages to be provided to TDX module per 2MB region of PA */
> #define TDX_DPAMT_ENTRY_PAGE_CNT 2
>
> +static bool tdx_enable_dpamt __ro_after_init;
> +
> struct tdx_module_state {
> bool initialized;
> bool sysinit_done;
> @@ -2055,6 +2057,9 @@ EXPORT_SYMBOL_FOR_KVM(tdh_phymem_page_wbinvd_hkid);
>
> bool tdx_supports_dynamic_pamt(const struct tdx_sys_info *sysinfo)
> {
> + if (!tdx_enable_dpamt)
> + return false;
> +
> return sysinfo->features.tdx_features0 & TDX_FEATURES0_DYNAMIC_PAMT;
> }
> EXPORT_SYMBOL_FOR_KVM(tdx_supports_dynamic_pamt);
> @@ -2316,6 +2321,13 @@ void tdx_free_control_page(struct page *page)
> }
> EXPORT_SYMBOL_FOR_KVM(tdx_free_control_page);
>
> +static int __init tdx_dpamt_setup(char *str)
> +{
> + return kstrtobool(str, &tdx_enable_dpamt) == 0;
> +}
> +
> +__setup("tdx_dpamt=", tdx_dpamt_setup);
It looks like core_param() is perferred over __setup() for a simple typed
variable set from the cmdline?
How about:
core_param(tdx_enable_dpamt, tdx_enable_dpamt, bool, 0444);
> void tdx_sys_disable(void)
> {
> struct tdx_module_args args = {};
> --
> 2.56.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/virt/tdx: Add command line param for DPAMT
2026-11-26 0:54 [PATCH] x86/virt/tdx: Add command line param for DPAMT Rick Edgecombe
2026-11-26 8:13 ` Yan Zhao
@ 2026-11-26 10:48 ` Nikolay Borisov
1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2026-11-26 10:48 UTC (permalink / raw)
To: Rick Edgecombe, bp, dave.hansen, hpa, kas, linux-kernel, mingo,
tglx, x86, chao.gao, yan.y.zhao, yilun.xu
On 26.11.26 г. 2:54 ч., Rick Edgecombe wrote:
> The Physical Address Metadata Table (PAMT) holds TDX metadata for
> physical memory and must be allocated by the kernel during TDX module
> initialization. Dynamic PAMT (DPAMT) is a TDX module feature that can
> reduce this memory use by allocating part of the PAMT dynamically.
>
> In order to work with DPAMT, the kernel needs to perform upkeep on the
> DPAMT for each page that it gives to the TDX module. Late during the
> upstreaming of DPAMT, an optimization patch that avoided taking a global
> lock for each maintenance operation was dropped. The plan was to follow up
> the initial upstreaming with optimization work, however priority for this
> work has yet to materialize.
>
> Separately from the wrinkle of the global lock, TDX continues to struggle
> with large patchsets to enable new features. Doing DPAMT maintenance for
> the new types of memory these features require, further grows the initial
> patchsets.
>
> Adding a kernel parameter for DPAMT can help these two separate problems.
> Having DPAMT be default off can make the offensive global lock the rare
> case, while still giving some big memory conscious users the option to use
> DPAMT. Having DPAMT capable of being off means that the upcoming TDX
> features can be merged in smaller pieces by ignoring DPAMT to start.
>
> So add a parameter and make DPAMT default off.
>
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
> ---
> Dave, feel free to ignore.
>
> TDX developers, this is small, but can I get a round of review on the
> patch? One consideration I had was if tdx_supports_dynamic_pamt() should
> be renamed, but I thought it wasn't worth the churn.
>
> Another idea is to ignore the impact of the global lock until someone
> complains. And for the new features, to make them mutually exclusive with
> Dynamic PAMT support by simply keying off module support, rather than
> allowing Dynamic PAMT to be disabled. But since Dynamic PAMT is available
> on all newer modules, this would only appear to make the new features
> enabled. In practice they would be dead code. And default off is arguably
> the best default option in DPAMT's current state. So prefer the kernel
> param.
>
> Also, I cherry-picked this from the last DPAMT patchset and didn't retest
> it on upstream yet. Will do, but I'm not expecting problems.
To me all this seems like "DPAMT upstream was rushed because it is
helpful for some few big players", and because 99% of the other people
aren't going to use it let's make it optional. And we end up with
conditionals sprinkled in the code, 99% of the time those conditionals
evaluating to false.
Wouldn't it be better if Intel gets it act together, upstreams the
optimisation work, making DPAMT a first-class citizen and just get rid
of the optional and ensure that DPAMT is used in 99% of the cases?
Otherwise it just feels that upstream work starts with one statement and
commitments, later those are revised and/or never materialize.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-26 10:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 0:54 [PATCH] x86/virt/tdx: Add command line param for DPAMT Rick Edgecombe
2026-11-26 8:13 ` Yan Zhao
2026-11-26 10:48 ` Nikolay Borisov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®