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, 17 Mar 2023 07:48:49 +0000 (08:48 +0100)
commit45bcf4a4f2b1e9cf73fb05e0383f2492c5cd53ba
tree70f3609a8521be3a08828627e9a21099df2bdb2c
parent0a0ecaf0988b079d65b8c5e00976b2a930309bff
KVM: Register /dev/kvm as the _very_ last thing during initialization

[ Upstream commit 2b01281273738bf2d6551da48d65db2df3f28998 ]

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: Sasha Levin <sashal@kernel.org>
virt/kvm/kvm_main.c