Skip to content

Commit 45154fb

Browse files
kaihuangbonzini
authored andcommitted
KVM: TDX: Get TDX global information
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>
1 parent fcdbdf6 commit 45154fb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arch/x86/kvm/vmx/tdx.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module_param_named(tdx, enable_tdx, bool, 0444);
1313

1414
static enum cpuhp_state tdx_cpuhp_state;
1515

16+
static const struct tdx_sys_info *tdx_sysinfo;
17+
1618
static int tdx_online_cpu(unsigned int cpu)
1719
{
1820
unsigned long flags;
@@ -92,11 +94,20 @@ static int __init __tdx_bringup(void)
9294
if (r)
9395
goto tdx_bringup_err;
9496

97+
/* Get TDX global information for later use */
98+
tdx_sysinfo = tdx_get_sysinfo();
99+
if (WARN_ON_ONCE(!tdx_sysinfo)) {
100+
r = -EINVAL;
101+
goto get_sysinfo_err;
102+
}
103+
95104
/*
96105
* Leave hardware virtualization enabled after TDX is enabled
97106
* successfully. TDX CPU hotplug depends on this.
98107
*/
99108
return 0;
109+
get_sysinfo_err:
110+
__tdx_cleanup();
100111
tdx_bringup_err:
101112
kvm_disable_virtualization();
102113
return r;

0 commit comments

Comments
 (0)