KVM: Register /dev/kvm as the _very_ last thing during initialization
authorSean Christopherson <seanjc@google.com>
Wed, 30 Nov 2022 23:08:45 +0000 (23:08 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:11 +0000 (09:34 +0100)
commit59320074afa4f572057c47bb55cf781bb37abefe
tree76cb06de440b899889f5c7df7b63d3fa7e1ce7af
parentb2de2b4d4e007f9add46ea8dc06f781835e3ea9f
KVM: Register /dev/kvm as the _very_ last thing during initialization

commit 2b01281273738bf2d6551da48d65db2df3f28998 upstream.

Register /dev/kvm, i.e. expose KVM to userspace, only after all other
setup has completed.  Once /dev/kvm is exposed, userspace can start
invoking KVM ioctls, creating VMs, etc...  If userspace creates a VM
before KVM is done with its configuration, bad things may happen, e.g.
KVM will fail to properly migrate vCPU state if a VM is created before
KVM has registered preemption notifiers.

Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221130230934.1014142-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/kvm_main.c