The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] x86/virt/tdx: Warn on !4K level in tdh_mem_page_aug()
@ 2026-08-25  2:55 Yan Zhao
  2026-08-25 13:31 ` Sean Christopherson
  2026-08-25 17:15 ` Edgecombe, Rick P
  0 siblings, 2 replies; 5+ messages in thread
From: Yan Zhao @ 2026-08-25  2:55 UTC (permalink / raw)
  To: kas, dave.hansen
  Cc: x86, linux-kernel, kvm, linux-coco, rick.p.edgecombe, seanjc,
	pbonzini, tglx, mingo, bp, kai.huang, yilun.xu, vannapurve,
	ackerleytng, sagis, binbin.wu, xiaoyao.li, yan.y.zhao,
	Dave Hansen

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@kernel.org>
Closes: https://lore.kernel.org/all/abvxiuJfK2eM_1UX@thinkstation
Suggested-by: Dave Hansen <dave.hansen@intel.com>
Suggested-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-25 18:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25  2:55 [PATCH] x86/virt/tdx: Warn on !4K level in tdh_mem_page_aug() Yan Zhao
2026-08-25 13:31 ` Sean Christopherson
2026-08-25 17:15 ` Edgecombe, Rick P
2026-08-25 17:48   ` Sean Christopherson
2026-08-25 18:19     ` Edgecombe, Rick P

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox