[PATCH] x86/virt/tdx: Warn on !4K level in tdh_mem_page_aug()

From: Yan Zhao

Date: Mon Aug 24 2026 - 22:56:09 EST


Add a warning on a !4K level to loudly flag the unexpected condition when
callers pass in a level > 4K before tdh_mem_page_aug() supports huge pages.

The warning makes the unexpected condition more obvious since the SEAMCALL
TDH_MEM_PAGE_AUG does not necessarily fail when the level is above 4K,
while tdh_mem_page_aug() only flushes the cache for a 4K page before huge
page support is added.

Do not drop the "level" parameter instead, as it will be needed once huge
page support is added.

Do not use a stronger BUG_ON() because the cache flush is only needed when
the TDX module exposes a CLFLUSH_BEFORE_ALLOC bit, which has not yet been
observed in any TDX modules.

Reported-by: Kiryl Shutsemau <kas@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/abvxiuJfK2eM_1UX@thinkstation
Suggested-by: Dave Hansen <dave.hansen@xxxxxxxxx>
Suggested-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
Signed-off-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
---
arch/x86/virt/vmx/tdx/tdx.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 42df8ea464c4..5c0e91b4aa4f 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -1722,6 +1722,8 @@ u64 tdh_mem_page_aug(struct tdx_td *td, u64 gpa, enum pg_level level,
};
u64 ret;

+ /* TODO: handle large pages. */
+ WARN_ON_ONCE(level != PG_LEVEL_4K);
tdx_clflush_pfn(pfn);
ret = seamcall_ret(TDH_MEM_PAGE_AUG, &args);


base-commit: 1b731e5ded480bd1e5546aed35584238661ce72e
--
2.43.2