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

From: Isaku Yamahata
Date: Wed Mar 15 2023 - 20:27:11 EST


On Wed, Mar 15, 2023 at 09:46:00AM +0000,
"Huang, Kai" <kai.huang@xxxxxxxxx> wrote:

>
> > >
> > > I think you should use hardware_enable_all(), and just do something similar to
> > > below in vmx_hardware_enable():
> >
> > The use of hardware_enable_all() make us circle back to refactoring KVM
> > hardware initialization topic. I'd like to stay away from it for now for TDX.
>
> Sean's series to improve hardware enable has been merged to upstream already.

I revised the patch and I can use hardware_enable_all().

> > + for_each_online_cpu(cpu) {
> > + if (smp_call_on_cpu(cpu, tdx_cpu_enable_cpu, NULL, false)) {
> > + r = -EIO;
> > + break;
> > + }
> > + }
> > + if (!r)
> > + r = tdx_module_setup();
> > + on_each_cpu(tdx_vmxoff_cpu, NULL, 1);
> > + cpus_read_unlock();
> > +
> > + return r;
> > +}
>
> I think you can merge next patch with this one because they are kinda related.  
>
> Putting them together allows people to review more easily.

Finally I come up with the version that uses kvm_hardware_enable_all().
that doesn't issue cpus_read_lock().
I had to patch tdx_cpu_enable(). I'll reply to the patch itself.