Re: [RFC PATCH 3/4] KVM: x86/tdx: Do VMXON and TDX-Module initialization during tdx_init()
From: Chao Gao
Date: Mon Oct 13 2025 - 08:49:51 EST
>-static int __tdx_enable(void)
>+static __init int tdx_enable(void)
> {
>+ enum cpuhp_state state;
> int ret;
>
>+ if (!cpu_feature_enabled(X86_FEATURE_XSAVE)) {
>+ pr_err("XSAVE is required for TDX\n");
>+ return -EINVAL;
>+ }
>+
>+ if (!cpu_feature_enabled(X86_FEATURE_MOVDIR64B)) {
>+ pr_err("MOVDIR64B is required for TDX\n");
>+ return -EINVAL;
>+ }
>+
>+ if (!cpu_feature_enabled(X86_FEATURE_SELFSNOOP)) {
>+ pr_err("Self-snoop is required for TDX\n");
>+ return -ENODEV;
>+ }
>+
>+ state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "virt/tdx:online",
>+ tdx_online_cpu, tdx_offline_cpu);
>+ if (state < 0)
>+ return state;
>+
> ret = init_tdx_module();
...
>@@ -1445,11 +1462,6 @@ void __init tdx_init(void)
> return;
> }
>
>-#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND)
>- pr_info("Disable ACPI S3. Turn off TDX in the BIOS to use ACPI S3.\n");
>- acpi_suspend_lowlevel = NULL;
>-#endif
>-
> /*
> * Just use the first TDX KeyID as the 'global KeyID' and
> * leave the rest for TDX guests.
>@@ -1458,22 +1470,30 @@ void __init tdx_init(void)
> tdx_guest_keyid_start = tdx_keyid_start + 1;
> tdx_nr_guest_keyids = nr_tdx_keyids - 1;
>
>+ err = tdx_enable();
>+ if (err)
>+ goto err_enable;
IIRC, existing TDX modules require all CPUs to have completed per-CPU
initialization before TDMR/PAMT initialization.
But at this point, APs are not online, so tdx_enable() will fail here.