On Thu, Mar 14, 2024 at 10:05:35AM +0800,
Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx> wrote:
Correct.diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.cHow about if there are some LPs that are offline.
index 18cecf12c7c8..18aef6e23aab 100644
--- a/arch/x86/kvm/vmx/main.c
+++ b/arch/x86/kvm/vmx/main.c
@@ -6,6 +6,22 @@
#include "nested.h"
#include "pmu.h"
+static bool enable_tdx __ro_after_init;
+module_param_named(tdx, enable_tdx, bool, 0444);
+
+static __init int vt_hardware_setup(void)
+{
+ int ret;
+
+ ret = vmx_hardware_setup();
+ if (ret)
+ return ret;
+
+ enable_tdx = enable_tdx && !tdx_hardware_setup(&vt_x86_ops);
+
+ return 0;
+}
+
#define VMX_REQUIRED_APICV_INHIBITS \
(BIT(APICV_INHIBIT_REASON_DISABLE)| \
BIT(APICV_INHIBIT_REASON_ABSENT) | \
@@ -22,6 +38,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
.hardware_unsetup = vmx_hardware_unsetup,
+ /* TDX cpu enablement is done by tdx_hardware_setup(). */
In tdx_hardware_setup(), only online LPs are initialed for TDX, right?
Then when an offline LP becoming online, it doesn't have a chance to callKVM registers kvm_online/offline_cpu() @ kvm_main.c as cpu hotplug callbacks.
tdx_cpu_enable()?
Eventually x86 kvm hardware_enable() is called on online/offline event.