On Wed, Aug 14, 2024, Paolo Bonzini wrote: > On 6/8/24 02:06, Sean Christopherson wrote: > > Register KVM's cpuhp and syscore callback when enabling virtualization > > in hardware instead of registering the callbacks during initialization, > > and let the CPU up/down framework invoke the inner enable/disable > > functions. Registering the callbacks during initialization makes things > > more complex than they need to be, as KVM needs to be very careful about > > handling races between enabling CPUs being onlined/offlined and hardware > > being enabled/disabled. > > > > Intel TDX support will require KVM to enable virtualization during KVM > > initialization, i.e. will add another wrinkle to things, at which point > > sorting out the potential races with kvm_usage_count would become even > > more complex. > > > > Note, using the cpuhp framework has a subtle behavioral change: enabling > > will be done serially across all CPUs, whereas KVM currently sends an IPI > > to all CPUs in parallel. While serializing virtualization enabling could > > create undesirable latency, the issue is limited to creation of KVM's > > first VM, > > Isn't that "limited to when kvm_usage_count goes from 0 to 1", so every time > a VM is started if you never run two? Yes, "first" isn't the correct word/phrase.