]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: WARN if is_unsync_root() is called on a root without a shadow page
authorSean Christopherson <seanjc@google.com>
Fri, 25 Feb 2022 18:22:48 +0000 (18:22 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 1 Mar 2022 13:58:26 +0000 (08:58 -0500)
WARN and bail if is_unsync_root() is passed a root for which there is no
shadow page, i.e. is passed the physical address of one of the special
roots, which do not have an associated shadow page.  The current usage
squeaks by without bug reports because neither kvm_mmu_sync_roots() nor
kvm_mmu_sync_prev_roots() calls the helper with pae_root or pml4_root,
and 5-level AMD CPUs are not generally available, i.e. no one can coerce
KVM into calling is_unsync_root() on pml5_root.

Note, this doesn't fix the mess with 5-level nNPT, it just (hopefully)
prevents KVM from crashing.

Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220225182248.3812651-8-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c

index 825996408465b3fb049959e462c0847f9cd509a1..3e7c8ad5bed908f5a1324d8ae693ac4fd16a2333 100644 (file)
@@ -3634,6 +3634,14 @@ static bool is_unsync_root(hpa_t root)
         */
        smp_rmb();
        sp = to_shadow_page(root);
+
+       /*
+        * PAE roots (somewhat arbitrarily) aren't backed by shadow pages, the
+        * PDPTEs for a given PAE root need to be synchronized individually.
+        */
+       if (WARN_ON_ONCE(!sp))
+               return false;
+
        if (sp->unsync || sp->unsync_children)
                return true;