Re: [PATCH v4 14/24] x86/virt/tdx: Reset software states during TDX Module shutdown

From: Huang, Kai

Date: Wed Mar 04 2026 - 18:06:39 EST



> @@ -1179,6 +1179,7 @@ EXPORT_SYMBOL_FOR_KVM(tdx_enable);
> int tdx_module_shutdown(void)
> {
> struct tdx_module_args args = {};
> + int ret, cpu;
>
> /*
> * Shut down the TDX Module and prepare handoff data for the next
> @@ -1188,7 +1189,17 @@ int tdx_module_shutdown(void)
> * modules as new modules likely have higher handoff version.
> */
> args.rcx = tdx_sysinfo.handoff.module_hv;
> - return seamcall_prerr(TDH_SYS_SHUTDOWN, &args);
> + ret = seamcall_prerr(TDH_SYS_SHUTDOWN, &args);
> + if (ret)
> + return ret;
> +
> + tdx_module_status = TDX_MODULE_UNINITIALIZED;
> + sysinit_done = false;
> + sysinit_ret = 0;
> +
> + for_each_online_cpu(cpu)
> + per_cpu(tdx_lp_initialized, cpu) = false;

Maybe add a comment like:

/*
* By reaching here CPUHP is disabled and all present CPUs
* are online. It's safe to just loop all online CPUs and
* and reset the per-cpu flag.
*/


And maybe a helper function like reset_tdx_kernel_states() would be nice,
but it's also fine to me as-is:

Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>