Re: [PATCH v9 07/18] x86/virt/tdx: Do TDX module per-cpu initialization
From: Dave Hansen
Date: Mon Feb 13 2023 - 13:09:41 EST
On 2/13/23 03:59, Kai Huang wrote:
> @@ -247,8 +395,17 @@ int tdx_enable(void)
> ret = __tdx_enable();
> break;
> case TDX_MODULE_INITIALIZED:
> - /* Already initialized, great, tell the caller. */
> - ret = 0;
> + /*
> + * The previous call of __tdx_enable() may only have
> + * initialized part of present cpus during module
> + * initialization, and new cpus may have become online
> + * since then.
> + *
> + * To make sure all online cpus are TDX-runnable, always
> + * do per-cpu initialization for all online cpus here
> + * even the module has been initialized.
> + */
> + ret = __tdx_enable_online_cpus();
I'm missing something here. CPUs get initialized through either:
1. __tdx_enable(), for the CPUs around at the time
2. tdx_cpu_online(), for hotplugged CPUs after __tdx_enable()
But, this is a third class. CPUs that came online after #1, but which
got missed by #2. How can that happen?