OSDN Git Service

KVM: x86/mmu: WARN on NULL pae_root or lm_root, or bad shadow root level
authorSean Christopherson <seanjc@google.com>
Fri, 5 Mar 2021 01:11:01 +0000 (17:11 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 15 Mar 2021 08:42:25 +0000 (04:42 -0400)
commit73ad160693dc3baf230d76cf44c3207defad6e21
treef695a81b8403ecff524e06a3ea158bbeae808ff6
parenta91f387b4bfedab595a987ad41e75d8839a958bf
KVM: x86/mmu: WARN on NULL pae_root or lm_root, or bad shadow root level

WARN if KVM is about to dereference a NULL pae_root or lm_root when
loading an MMU, and convert the BUG() on a bad shadow_root_level into a
WARN (now that errors are handled cleanly).  With nested NPT, botching
the level and sending KVM down the wrong path is all too easy, and the
on-demand allocation of pae_root and lm_root means bugs crash the host.
Obviously, KVM could unconditionally allocate the roots, but that's
arguably a worse failure mode as it would potentially corrupt the guest
instead of crashing it.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210305011101.3597423-18-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c