[v7,08/20] x86/virt/tdx: Do logical-cpu scope TDX module initialization
Commit Message
After the global module initialization, the next step is logical-cpu
scope module initialization. Logical-cpu initialization requires
calling TDH.SYS.LP.INIT on all BIOS-enabled CPUs. This SEAMCALL can run
concurrently on all CPUs.
Use the helper introduced for shutting down the module to do logical-cpu
scope initialization.
Signed-off-by: Kai Huang <kai.huang@intel.com>
---
arch/x86/virt/vmx/tdx/tdx.c | 14 ++++++++++++++
arch/x86/virt/vmx/tdx/tdx.h | 1 +
2 files changed, 15 insertions(+)
@@ -199,6 +199,15 @@ static void seamcall_on_each_cpu(struct seamcall_ctx *sc)
on_each_cpu(seamcall_smp_call_function, sc, true);
}
+static int tdx_module_init_cpus(void)
+{
+ struct seamcall_ctx sc = { .fn = TDH_SYS_LP_INIT };
+
+ seamcall_on_each_cpu(&sc);
+
+ return atomic_read(&sc.err);
+}
+
/*
* Detect and initialize the TDX module.
*
@@ -218,6 +227,11 @@ static int init_tdx_module(void)
if (ret)
goto out;
+ /* Logical-cpu scope initialization */
+ ret = tdx_module_init_cpus();
+ if (ret)
+ goto out;
+
/*
* Return -EINVAL until all steps of TDX module initialization
* process are done.
@@ -16,6 +16,7 @@
* TDX module SEAMCALL leaf functions
*/
#define TDH_SYS_INIT 33
+#define TDH_SYS_LP_INIT 35
#define TDH_SYS_LP_SHUTDOWN 44
/*