Re: [PATCH v14 004/113] KVM: TDX: Initialize the TDX module when loading the KVM intel kernel module

From: Sean Christopherson
Date: Tue May 30 2023 - 13:14:24 EST


On Tue, May 30, 2023, Zhi Wang wrote:
> On Sun, 28 May 2023 21:18:46 -0700 isaku.yamahata@xxxxxxxxx wrote:
> > + /* tdx_enable() in tdx_module_setup() requires cpus lock. */
> > + cpus_read_lock();
> > + on_each_cpu(vmx_tdx_on, &err, true); /* TDX requires vmxon. */
> > + r = atomic_read(&err);
> > + if (!r)
> > + r = tdx_module_setup();
> > + on_each_cpu(vmx_off, NULL, true);
>
> Out of curiosity, why VMX has to be turned off after tdx_module_setup()?

KVM has historically enabled VMX if and only if KVM has active VMs. Whether or
not it still makes sense to do dynamic enabling is debatable, but that's a
discussion for another day.