Register KVM's cpuhp and syscore callbacks when enabling virtualization in hardware, as the sole purpose of said callbacks is to disable and re-enable virtualization as needed. The primary motivation for this series is to simplify dealing with enabling virtualization for Intel's TDX, which needs to temporarily enable virtualization when kvm-intek.ko is loaded, i.e. long before the first VM is created. That said, this is a nice cleanup on its own, assuming I haven't broken something. By registering the callbacks on-demand, the callbacks themselves don't need to check kvm_usage_count, because their very existence implies a non-zero count. The meat is in patch 3, patches 1 and 2 are tangentially related x86 cleanups, patch 4 renames helpers to further pave the way for TDX. Moderately well tested on x86, though I haven't (yet) done due dilegence on the suspend/resume and cphup paths. I ran selftests on arm64 and nothing exploded. Sean Christopherson (4): x86/reboot: Unconditionally define cpu_emergency_virt_cb typedef KVM: x86: Register emergency virt callback in common code, via kvm_x86_ops KVM: Register cpuhp and syscore callbacks when enabling hardware KVM: Rename functions related to enabling virtualization hardware arch/x86/include/asm/kvm_host.h | 3 + arch/x86/include/asm/reboot.h | 2 +- arch/x86/kvm/svm/svm.c | 5 +- arch/x86/kvm/vmx/main.c | 2 + arch/x86/kvm/vmx/vmx.c | 6 +- arch/x86/kvm/vmx/x86_ops.h | 1 + arch/x86/kvm/x86.c | 5 + virt/kvm/kvm_main.c | 186 +++++++++++--------------------- 8 files changed, 78 insertions(+), 132 deletions(-) base-commit: 7b076c6a308ec5bce9fc96e2935443ed228b9148 -- 2.44.0.769.g3c40516874-goog