[PATCH v5] x86/virt/tdx: Gate TDH.SYS.DISABLE on X86_FEATURE_TDX_HOST_PLATFORM
From: Challvy Tee
Date: Mon Nov 02 2026 - 21:18:21 EST
Commit 5b25f249be32 ("x86/tdx: Disable the TDX module during kexec and
kdump") made native_machine_crash_shutdown() call tdx_sys_disable(),
whose only gate is compile time (CONFIG_INTEL_TDX_HOST). A kernel that
never initialized the TDX module therefore still issues
TDH.SYS.DISABLE.
In VMX non-root operation on a SEAM-capable host, SEAMCALL causes a VM
exit instead of a native #UD. KVM injects #UD only since
commit 9d7dfb95da2c ("KVM: VMX: Inject #UD if guest tries to execute
SEAMCALL or TDCALL"), first released in v6.18. On an older host the
VMM gets KVM_EXIT_INTERNAL_ERROR and the vCPU never resumes, so
machine_kexec() is never reached and no vmcore is written. Kdump is
thus broken only in guests on SEAM-capable hosts whose hypervisor does
not handle the exit; plain kexec is unaffected because tdx_shutdown()
only runs as a syscore op, registered after init_tdx_module() succeeds.
Gate the SEAMCALL on X86_FEATURE_TDX_HOST_PLATFORM before issuing it,
the way paddr_is_tdx_private() already guards its own SEAMCALL in this
file. Without that feature the module is never initialized, so there
is nothing to disable; on a TDX host the gate is a no-op.
It also decouples kdump from the host KVM version -- a guest cannot
require its host to inject the #UD.
Fixes: 5b25f249be32 ("x86/tdx: Disable the TDX module during kexec and kdump")
Suggested-by: Kiryl Shutsemau <kas@xxxxxxxxxx>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
Reviewed-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Challvy Tee <challvy.tee@xxxxxxxxx>
---
v4 -> v5:
- Update the subject to name the X86_FEATURE_TDX_HOST_PLATFORM check,
as requested in review. No code change.
- Add the Reviewed-by tags collected on v4.
The reproduction data and the host-side KVM log are unchanged from v4:
https://lore.kernel.org/all/20261102073244.919864-1-challvy.tee@xxxxxxxxx/
arch/x86/virt/vmx/tdx/tdx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 96ced0494b68..9b01131f7b7b 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -2321,6 +2321,9 @@ void tdx_sys_disable(void)
struct tdx_module_args args = {};
u64 ret;
+ if (!boot_cpu_has(X86_FEATURE_TDX_HOST_PLATFORM))
+ return;
+
/*
* Don't loop forever.
*
--
2.52.0