KVM will need to consult some essential TDX global information to create
and run TDX guests. Get the global information after initializing TDX.
Signed-off-by: Kai Huang <kai.huang@intel.com>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Message-ID: <
20241030190039.77971-3-rick.p.edgecombe@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
static enum cpuhp_state tdx_cpuhp_state;
+static const struct tdx_sys_info *tdx_sysinfo;
+
static int tdx_online_cpu(unsigned int cpu)
{
unsigned long flags;
if (r)
goto tdx_bringup_err;
+ /* Get TDX global information for later use */
+ tdx_sysinfo = tdx_get_sysinfo();
+ if (WARN_ON_ONCE(!tdx_sysinfo)) {
+ r = -EINVAL;
+ goto get_sysinfo_err;
+ }
+
/*
* Leave hardware virtualization enabled after TDX is enabled
* successfully. TDX CPU hotplug depends on this.
*/
return 0;
+get_sysinfo_err:
+ __tdx_cleanup();
tdx_bringup_err:
kvm_disable_virtualization();
return r;