]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
KVM: x86/mmu: Skip invalid pages during zapping iff root_count is zero
authorSean Christopherson <sean.j.christopherson@intel.com>
Fri, 13 Sep 2019 02:46:12 +0000 (19:46 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 24 Sep 2019 12:36:06 +0000 (14:36 +0200)
Do not skip invalid shadow pages when zapping obsolete pages if the
pages' root_count has reached zero, in which case the page can be
immediately zapped and freed.

Update the comment accordingly.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c

index 5f086400036032dbba6de5c2597e32aaeb06b3b1..5269aa057dfa609341b4afa5ac9bb3ada7748855 100644 (file)
@@ -5693,11 +5693,12 @@ static void kvm_zap_obsolete_pages(struct kvm *kvm)
                        break;
 
                /*
-                * Since we are reversely walking the list and the invalid
-                * list will be moved to the head, skip the invalid page
-                * can help us to avoid the infinity list walking.
+                * Skip invalid pages with a non-zero root count, zapping pages
+                * with a non-zero root count will never succeed, i.e. the page
+                * will get thrown back on active_mmu_pages and we'll get stuck
+                * in an infinite loop.
                 */
-               if (sp->role.invalid)
+               if (sp->role.invalid && sp->root_count)
                        continue;
 
                /*