On Tue, Jun 28, 2022 at 04:31:35PM +1200, Kai Huang <kai.huang@xxxxxxxxx> wrote: > On Mon, 2022-06-27 at 14:53 -0700, isaku.yamahata@xxxxxxxxx wrote: > > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > > > > To use TDX functionality, TDX module needs to be loaded and initialized. > > A TDX host patch series[1] implements the detection of the TDX module, > > tdx_detect() and its initialization, tdx_init(). > > "A TDX host patch series[1]" really isn't a commit message material. You can > put it to the cover letter, but not here. > > Also tdx_detect() is removed in latest code. How about the followings? KVM: TDX: Initialize TDX module when loading kvm_intel.ko To use TDX functionality, TDX module needs to be loaded and initialized. This patch is to call a function, tdx_init(), when loading kvm_intel.ko. Add a hook, kvm_arch_post_hardware_enable_setup, to module initialization while hardware is enabled, i.e. after hardware_enable_all() and before hardware_disable_all(). Because TDX requires all present CPUs to enable VMX (VMXON). > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 30af2bd0b4d5..fb7a33fbc136 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -11792,6 +11792,14 @@ int kvm_arch_hardware_setup(void *opaque) > > return 0; > > } > > > > +int kvm_arch_post_hardware_enable_setup(void *opaque) > > +{ > > + struct kvm_x86_init_ops *ops = opaque; > > + if (ops->post_hardware_enable_setup) > > + return ops->post_hardware_enable_setup(); > > + return 0; > > +} > > + > > Where is this kvm_arch_post_hardware_enable_setup() called? > > Shouldn't the code change which calls it be part of this patch? The patch of "4/102 KVM: Refactor CPU compatibility check on module initialiization" introduces it. Because the patch affects multiple archs (mips, x86, poerpc, s390, and arm), I deliberately put it in early. -- Isaku Yamahata <isaku.yamahata@xxxxxxxxx>