]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: VMX: Reset eVMCS controls in VP assist page during hardware disabling
authorSean Christopherson <seanjc@google.com>
Wed, 30 Nov 2022 23:08:54 +0000 (23:08 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 07:50:17 +0000 (08:50 +0100)
commitd63f5c4802099265d046b988c4fcc6466aa39cc9
tree4e706c31e1df408bb072e2b93092917c39d16afb
parent05ccf50e2bc59f7ea4480d7cb9542da1a46b04d4
KVM: VMX: Reset eVMCS controls in VP assist page during hardware disabling

[ Upstream commit a4f13dc0ce94f93eb5bb6f0a2614b70b5010dd16 ]

Reset the eVMCS controls in the per-CPU VP assist page during hardware
disabling instead of waiting until kvm-intel's module exit.  The controls
are activated if and only if KVM creates a VM, i.e. don't need to be
reset if hardware is never enabled.

Doing the reset during hardware disabling will naturally fix a potential
NULL pointer deref bug once KVM disables CPU hotplug while enabling and
disabling hardware (which is necessary to fix a variety of bugs).  If the
kernel is running as the root partition, the VP assist page is unmapped
during CPU hot unplug, and so KVM's clearing of the eVMCS controls needs
to occur with CPU hot(un)plug disabled, otherwise KVM could attempt to
write to a CPU's VP assist page after it's unmapped.

Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20221130230934.1014142-11-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Stable-dep-of: 3c3b35a745e3 ("KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace")
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kvm/vmx/vmx.c