]> git.itanic.dy.fi Git - linux-stable/commitdiff
KVM: x86: change kvm_mmu_page_get_gfn BUG_ON to WARN_ON
authorPaolo Bonzini <pbonzini@redhat.com>
Sun, 30 Jun 2019 12:36:21 +0000 (08:36 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 5 Jul 2019 11:48:48 +0000 (13:48 +0200)
Note that in such a case it is quite likely that KVM will BUG_ON
in __pte_list_remove when the VM is closed.  However, there is no
immediate risk of memory corruption in the host so a WARN_ON is
enough and it lets you gather traces for debugging.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c

index 084c1a0d9f98342e3ae463c915340b3dc9588d65..0629a89bb0703b4548804c6c154f16f7ec18582b 100644 (file)
@@ -1098,10 +1098,16 @@ static gfn_t kvm_mmu_page_get_gfn(struct kvm_mmu_page *sp, int index)
 
 static void kvm_mmu_page_set_gfn(struct kvm_mmu_page *sp, int index, gfn_t gfn)
 {
-       if (sp->role.direct)
-               BUG_ON(gfn != kvm_mmu_page_get_gfn(sp, index));
-       else
+       if (!sp->role.direct) {
                sp->gfns[index] = gfn;
+               return;
+       }
+
+       if (WARN_ON(gfn != kvm_mmu_page_get_gfn(sp, index)))
+               pr_err_ratelimited("gfn mismatch under direct page %llx "
+                                  "(expected %llx, got %llx)\n",
+                                  sp->gfn,
+                                  kvm_mmu_page_get_gfn(sp, index), gfn);
 }
 
 /*