[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <cbfadff812dd3e25a485b867025cde4ba39d16f1.1647167475.git.kai.huang@intel.com>
Date: Sun, 13 Mar 2022 23:49:48 +1300
From: Kai Huang <kai.huang@...el.com>
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc: dave.hansen@...el.com, seanjc@...gle.com, pbonzini@...hat.com,
kirill.shutemov@...ux.intel.com,
sathyanarayanan.kuppuswamy@...ux.intel.com, peterz@...radead.org,
tony.luck@...el.com, ak@...ux.intel.com, dan.j.williams@...el.com,
isaku.yamahata@...el.com, kai.huang@...el.com
Subject: [PATCH v2 08/21] x86/virt/tdx: Do logical-cpu scope TDX module initialization
Logical-cpu scope initialization requires calling TDH.SYS.LP.INIT on all
BIOS-enabled cpus, otherwise the TDH.SYS.CONFIG SEAMCALL will fail.
TDH.SYS.LP.INIT can be called concurrently on all cpus.
Following global initialization, do the logical-cpu scope initialization
by calling TDH.SYS.LP.INIT on all online cpus. Whether all BIOS-enabled
cpus are online is not checked here for simplicity. The user of TDX
should guarantee all BIOS-enabled cpus are online.
Signed-off-by: Kai Huang <kai.huang@...el.com>
---
arch/x86/virt/vmx/tdx.c | 12 ++++++++++++
arch/x86/virt/vmx/tdx.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/arch/x86/virt/vmx/tdx.c b/arch/x86/virt/vmx/tdx.c
index 45e7404b5d81..4b0c285d844b 100644
--- a/arch/x86/virt/vmx/tdx.c
+++ b/arch/x86/virt/vmx/tdx.c
@@ -461,6 +461,13 @@ static int __tdx_detect(void)
return -ENODEV;
}
+static int tdx_module_init_cpus(void)
+{
+ struct seamcall_ctx sc = { .fn = TDH_SYS_LP_INIT };
+
+ return seamcall_on_each_cpu(&sc);
+}
+
static int init_tdx_module(void)
{
int ret;
@@ -470,6 +477,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 -EFAULT until all steps of TDX module
* initialization are done.
diff --git a/arch/x86/virt/vmx/tdx.h b/arch/x86/virt/vmx/tdx.h
index f0983b1936d8..b8cfdd6e12f3 100644
--- a/arch/x86/virt/vmx/tdx.h
+++ b/arch/x86/virt/vmx/tdx.h
@@ -39,6 +39,7 @@ struct p_seamldr_info {
* TDX module SEAMCALL leaf functions
*/
#define TDH_SYS_INIT 33
+#define TDH_SYS_LP_INIT 35
#define TDH_SYS_LP_SHUTDOWN 44
struct tdx_module_output;
--
2.35.1
Powered by blists - more mailing lists