x86/virt/tdx: Add command line param for DPAMT
Subsystems (3)
Rick Edgecombe
maintainerPATCH 1/1 x86/virt/tdx: Add command line param for DPAMT
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.
---
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(+)
Documentation/admin-guide/kernel-parameters.txt +7 -0
@@ -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
arch/x86/virt/vmx/tdx/tdx.c +12 -0
@@ -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 = {};
Signature · 1 line
2.56.1
+ Sean, Ackerley, Vishal,
Quoted 17 lines · Rick 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.
Quoted 5 lines
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.
Quoted 9 lines
So add a parameter and make DPAMT default off.
Signed-off-by Rick Edgecombe <[email protected]>---
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.
Quoted 11 lines
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.
Quoted 10 lines
--- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ arch/x86/virt/vmx/tdx/tdx.c | 12 ++++++++++++ 2 files changed, 19 insertions(+)Documentation/admin-guide/kernel-parameters.txt +0
-0
Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 7568
Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -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?
Quoted 32 lines
Documentation/admin-guide/kernel-parameters.txt +5
-0+ 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" (forarch/x86/virt/vmx/tdx/tdx.c +5
-0@@ -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);
arch/x86/virt/vmx/tdx/tdx.c void tdx_free_control_page(struct page *page) · line 2329
Quoted 9 lines
arch/x86/virt/vmx/tdx/tdx.c +6
-0@@ -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);
Quoted 6 lines
arch/x86/virt/vmx/tdx/tdx.c +0
-0void tdx_sys_disable (void ) {struct tdx_module_args args = {};Signature · 1 line
2.56.1
Quoted 1 line · Yan Zhao
Would you like to have an early discussion on this direction?
To be honest, no.
If you think this is wrong, then the right way to challenge the idea is to structure the series with DPAMT support at the end. That'll show us how tiny it is and also let the maintainer just chop the patches off the end if they don't agree.
So, no. I don't want to have an early discussion. I want you to prove me wrong with code.
Quoted 10 lines · Dave Hansen
Quoted 1 line · Yan Zhao
Would you like to have an early discussion on this direction?
To be honest, no.
If you think this is wrong, then the right way to challenge the idea is to structure the series with DPAMT support at the end. That'll show us how tiny it is and also let the maintainer just chop the patches off the end if they don't agree.
I agree; it would be good to discuss this direction with reference patches available.
If DPAMT support is relatively tiny add-on, I would argue for the complete feature.
Quoted 3 lines
So, no. I don't want to have an early discussion. I want you to prove me wrong with code.
Edgecombe, Rick P
maintainerQuoted 4 lines · Yan Zhao
Quoted 2 lines
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.
Thanks! Did you test on and off? Can I add your tested-by?
Quoted 5 lines
Quoted 5 lines
---
Documentation/admin-guide/kernel-parameters.txt| 7 +++++++ arch/x86/virt/vmx/tdx/tdx.c | 12 ++++++++++++2 files changed, 19 insertions(+)
Quoted 12 lines
Documentation/admin-guide/kernel-parameters.txt Kernel parameters · line 7568
Quoted 11 lines
Documentation/admin-guide/kernel-parameters.txt +0
-0@@ -7564,6 +7564,13 @@ Kernel parameters
tdfx= [HW,DRM]Documentation/admin-guide/kernel-parameters.txt +2
-0+ tdx_dpamt= + [X86] Controls whether TDX will use Dynamic PAMT[X86] --> [X86-64] ?
Oh yea.
Quoted 1 line
And is a "KNL" tag necessary?
Oh! I had thought KNL was knights landing for some reason, the Xeon Phi thing that has nothing to do with TDX. Now I see in this file it means "Is a kernel start-up parameter." so yes I'll add it. Thanks.
Quoted 39 lines
Quoted 39 lines
Documentation/admin-guide/kernel-parameters.txt +5
-0+ 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" (forarch/x86/virt/vmx/tdx/tdx.c +0
-0@@ -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 2arch/x86/virt/vmx/tdx/tdx.c +2
-0+static bool tdx_enable_dpamt__ro_after_init ; +struct
tdx_module_state{
bool initialized;
boolsysinit_done;arch/x86/virt/vmx/tdx/tdx.c +0
-0@@ -2055,6 +2057,9 @@ EXPORT_SYMBOL_FOR_KVM(tdh_phymem_page_wbinvd_hkid);
booltdx_supports_dynamic_pamt(const struct tdx_sys_info *sysinfo){arch/x86/virt/vmx/tdx/tdx.c +3
-0+if (!tdx_enable_dpamt) +return false; +return
sysinfo->features.tdx_features0&TDX_FEATURES0_DYNAMIC_PAMT;
}EXPORT_SYMBOL_FOR_KVM(tdx_supports_dynamic_pamt);arch/x86/virt/vmx/tdx/tdx.c +0
-0@@ -2316,6 +2321,13 @@ void tdx_free_control_page(struct page *page) } EXPORT_SYMBOL_FOR_KVM(tdx_free_control_page);
Quoted 8 lines
arch/x86/virt/vmx/tdx/tdx.c void tdx_free_control_page(struct page *page) · line 2329
Quoted 6 lines
arch/x86/virt/vmx/tdx/tdx.c +6
-0+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?
Hmm... It does seem nice, but there isn't much use in the kernel actually.
Quoted 3 lines
How about:
core_param(tdx_enable_dpamt, tdx_enable_dpamt, bool, 0444);
I'm not sure about 0444. We don't even want a sysfs knob for this either. It looks like if you pass 0 it skips the sysfs knob.
Quoted 6 lines
Quoted 6 lines
void
tdx_sys_disable(void)
{
structtdx_module_argsargs = {};Signature · 1 line
2.56.1
Quoted 7 lines · Rick P
Quoted 4 lines · Yan Zhao
Quoted 2 lines
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.
Thanks! Did you test on and off? Can I add your tested-by?
Yes. On and off. Sure.
Quoted 10 lines
Quoted 8 lines
arch/x86/virt/vmx/tdx/tdx.c void tdx_free_control_page(struct page *page) · line 2329
Quoted 6 lines
arch/x86/virt/vmx/tdx/tdx.c +6
-0+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?Hmm... It does seem nice, but there isn't much use in the kernel actually.
Right, core_param() is later introduced. See
Author: Rusty Russell <[email protected]> Date: Wed Oct 22 10:00:23 2008 -0500
core_param() for genuinely core kernel parameters
There are a lot of one-liner uses of __setup() in the kernel: they're cumbersome and not queryable (definitely not settable) via /sys. Yet it's ugly to simplify them to module_param(), because by default that inserts a prefix of the module name (usually filename).
So, introduce a "core_param". The parameter gets no prefix, but appears in /sys/module/kernel/parameters/ (if non-zero perms arg). I thought about using the name "core", but that's more common than "kernel". And if you create a module called "kernel", you will die a horrible death.
It looks like __setup() is an old way, which fills "struct obs_kernel_param" and gets parsed by obsolete_checksetup() during kernel boot-up. __setup() does not have knob in sysfs.
Quoted 5 lines
Quoted 2 lines
How about:
core_param(tdx_enable_dpamt, tdx_enable_dpamt, bool, 0444);I'm not sure about 0444. We don't even want a sysfs knob for this either. It looks like if you pass 0 it skips the sysfs knob.
Hmm, a leading 0 is not a permission bit, but a C's octal prefix.
Only all 0 will skip the sysfs knob. With 0444, there's a sysfs knob:/sys/module/kernel/parameters/tdx_enable_dpamt, with perms "-r--r--r--".
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
void
tdx_sys_disable(void)
{
structtdx_module_argsargs = {};Signature · 1 line
2.56.1
Edgecombe, Rick P
maintainerQuoted 9 lines · Yan Zhao
Quoted 5 lines
Quoted 2 lines
How about:
core_param(tdx_enable_dpamt, tdx_enable_dpamt, bool, 0444);I'm not sure about 0444. We don't even want a sysfs knob for this either. It looks like if you pass 0 it skips the sysfs knob.
Hmm, a leading 0 is not a permission bit, but a C's octal prefix.
Only all 0 will skip the sysfs knob. With 0444, there's a sysfs knob:
/sys/module/kernel/parameters/tdx_enable_dpamt, with perms "-r--r--r--".
Right. I'd think to not expose anything to userspace for this.
Quoted 42 lines · Rick 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 <[email protected]>---
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.
Quoted 2 lines
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.
Edgecombe, Rick P
maintainerQuoted 5 lines · Nikolay Borisov
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.
TBH I don't have much feedback from the long tail of TDX users. It is true that some big players wanted DPAMT though.
Quoted 3 lines
And we end up with
conditionals sprinkled in the code, 99% of the time those conditionals evaluating to false.
I don't expect to see conditionals sprinkling the code. I'd expect one big off switch during setup that skips enabling a bunch of features if DPAMT is enabled. Then initial feature enabling without DPAMT extras.
Quoted 4 lines
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?
The optimization work won't help the problem of TDX series constantly being too big. Optional DPAMT is not going to solve that problem completely either, but every little bit helps.
Quoted 2 lines
Otherwise it just feels that upstream work starts with one statement and commitments, later those are revised and/or never materialize.
TBH this characterization seems a bit sensationalized.
The later DPAMT series had a patch to make it optional and default off, but Dave suggested to do it as a follow up:
https://lore.kernel.org/kvm/[email protected]/
And here we are. So I don't see any major change here actually. But plans do change sometimes... If you were eagerly awaiting the lock optimization or something, please just say.
BTW, the other decent option here is to make DPAMT optional but default on. If we have a flag, I'd think to make if default off until contention is improved. But if you would feel better that the pain was in place until the optimization materialized...
On how we should do further optimizations eventually... We do have a patch on hand that helps, but it is fairly exotic one. Now that we have basic support, further optimizations will be evaluated in a different context. I'd expect a more upleveled wholistic evaluation of what the core problem is. Are there any changes in the module that could help us avoid maintaining exotic locking dances, etc?
What was your expectation?
Quoted 3 lines · Nikolay Borisov
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.
I can see why it might look that way, but that is precisely zero of the motivation behind the idea.
Approximately all of these TDX patch series are too big. They're too big to review effectively and too big to merge quickly. DPAMT support makes them even bigger. So, if we have the opportunity to split a series into two pieces: one ignoring DPAMT, and a later one not ignoring it, I'm all for it.
It has nothing to do with DPAMT being bad or good or rushed. It's just added complexity that isn't 100% needed to turn the lights on.
Quoted 6 lines · Dave Hansen
Approximately all of these TDX patch series are too big. They're too big to review effectively and too big to merge quickly. DPAMT support makes them even bigger. So, if we have the opportunity to split a series into two pieces: one ignoring DPAMT, and a later one not ignoring it, I'm all for it.
Sure, however, right now there is DPAMT code which seems to add noise to the existing series. I'm now in the process of looking at the TDX connect stuff and in it there are patches which specifically deal with DPAMT. If it's going to be optional for the time being then why bother having the code there as well ? Specifically I'm referring to :
coco/tdx-host: Enable trusted DMA on IOMMUs on device connect
Edgecombe, Rick P
maintainerQuoted 10 lines · Nikolay Borisov
Quoted 6 lines · Dave Hansen
Approximately all of these TDX patch series are too big. They're too big to review effectively and too big to merge quickly. DPAMT support makes them even bigger. So, if we have the opportunity to split a series into two pieces: one ignoring DPAMT, and a later one not ignoring it, I'm all for it.
Quoted 7 lines
Sure, however, right now there is DPAMT code which seems to add noise to the existing series. I'm now in the process of looking at the TDX connect stuff and in it there are patches which specifically deal with DPAMT. If it's going to be optional for the time being then why bother having the code there as well ? Specifically I'm referring to :
coco/tdx-host: Enable trusted DMA on IOMMUs on device connect
The point is to remove that stuff for the initial sets. So that should be removed.
Quoted 7 lines · Nikolay Borisov
Quoted 5 lines · Dave Hansen
Approximately all of these TDX patch series are too big. They're too big to review effectively and too big to merge quickly. DPAMT support makes them even bigger. So, if we have the opportunity to split a series into two pieces: one ignoring DPAMT, and a later one not ignoring it, I'm all for it.
Quoted 7 lines
Sure, however, right now there is DPAMT code which seems to add noise to the existing series. I'm now in the process of looking at the TDX connect stuff and in it there are patches which specifically deal with DPAMT. If it's going to be optional for the time being then why bother having the code there as well ? Specifically I'm referring to :
coco/tdx-host: Enable trusted DMA on IOMMUs on device connect
It's just that: optional. I'm trying to give flexibility to the series authors, not say they must or must not have DPAMT support in the initial batch of code.
If you as a reviewer think it would be good for patch authors to take advantage of that flexibility, then that's great feedback to give.
Make sense?