]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: Register cpuhp and syscore callbacks when enabling hardware
authorSean Christopherson <seanjc@google.com>
Fri, 30 Aug 2024 04:35:52 +0000 (21:35 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 4 Sep 2024 15:02:33 +0000 (11:02 -0400)
commit9a798b1337afe4fdcce53efa77953b068d8614f5
tree55b7abe12928ec95cbb8065c47644fade159524a
parent44d17459626052a2390457e550a12cb973506b2f
KVM: Register cpuhp and syscore callbacks when enabling hardware

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 the 0=>1 transition of
VM creation.  And even that can be mitigated, e.g. by letting userspace
force virtualization to be enabled when KVM is initialized.

Cc: Chao Gao <chao.gao@intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Acked-by: Kai Huang <kai.huang@intel.com>
Tested-by: Farrah Chen <farrah.chen@intel.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20240830043600.127750-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Documentation/virt/kvm/locking.rst
virt/kvm/kvm_main.c