Re: [PATCH v10 02/25] x86/virt/tdx: Move TDX global initialization states to file scope

From: Kiryl Shutsemau

Date: Wed May 27 2026 - 06:47:45 EST


On Wed, May 20, 2026 at 06:38:05AM -0700, Chao Gao wrote:
> TDX module global initialization is executed only once. The first call
> caches both the result and the "done" state, and later callers reuse the
> saved result. A lock protects that cached states.
>
> Those states and the lock are currently kept as function-local statics
> because they are used only by try_init_module_global().
>
> TDX module updates need to reset the cached states so TDX global
> initialization can be run again after an update. That will add another
> access site in the same file.
>
> Move the cached states to file scope so it is accessible outside
> try_init_module_global(), and move the lock along with the states it
> protects.
>
> No functional change intended.
>
> Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>

Reviewed-by: Kiryl Shutsemau <kas@xxxxxxxxxx>

--
Kiryl Shutsemau / Kirill A. Shutemov