Re: [PATCH v10 01/25] x86/virt/tdx: Clarify try_init_module_global() result caching

From: Xiaoyao Li

Date: Thu May 21 2026 - 06:06:08 EST


On 5/20/2026 9:38 PM, 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 state.

The current code is hard to read because sysinit_done is accessed under
the lock, while sysinit_ret is not.

To improve readability, move sysinit_ret accesses within the lock.

Group sysinit_ret/sysinit_done updates right after initialization so
Caching the result is separate from the initialization itself.

Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
Reviewed-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>