Re: [PATCH v7 12/22] x86/virt/tdx: Reset software states during TDX module shutdown
From: Edgecombe, Rick P
Date: Fri Apr 10 2026 - 21:57:13 EST
On Tue, 2026-03-31 at 05:41 -0700, Chao Gao wrote:
> The TDX module requires a one-time global initialization (TDH.SYS.INIT) and
> per-CPU initialization (TDH.SYS.LP.INIT) before use. These initializations
> are guarded by software flags to prevent repetition.
>
> After TDX module updates, the new TDX module requires the same global and
> per-CPU initializations, but the existing software flags prevent
> re-initialization.
>
> Reset all software flags guarding the initialization flows to allow the
> global and per-CPU initializations to be triggered again after updates.
>
> Set tdx_module_status to ERROR to indicate the module is unavailable. This
> is to prevent re-initialization/tdx_sysinfo reporting on a failed update.
> Using ERROR instead of UNINITIALIZED as the latter implicitly depends on
> get_tdx_sys_info() failing early to prevent re-init after successful
> shutdown followed by failed update.
>
> Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
> Reviewed-by: Tony Lindgren <tony.lindgren@xxxxxxxxxxxxxxx>
> Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>
Reviewed-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
The existing code around sysinit_done/ret is very strange to me. It makes this
patch seem a bit strained, but that is not it's fault.