Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 467

kvm-83-270.el5_11.src.rpm

From 255739a30a476a626514766eba889df11a7b8c20 Mon Sep 17 00:00:00 2001
From: Eduardo Habkost <ehabkost@redhat.com>
Date: Thu, 27 Aug 2009 10:13:29 -0300
Subject: [PATCH] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list

Message-id: <20090826131557.GA618@amt.cnet>
Patchwork-id: 3313
O-Subject: KVM: MMU: make __kvm_mmu_free_some_pages handle empty list
Bugzilla:
CVE:
RH-Acked-by: Avi Kivity <avi@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Izik Eidus <ieidus@redhat.com>

From: Izik Eidus <ieidus@redhat.com>

First check if the list is empty before attempting to look at list
entries.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
(cherry picked from commit 25ed49c02cc195d437bf5832df123fe5a8583271)
Bugzilla: 519397

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 arch/x86/kvm/mmu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 8700a20..f21b3e6 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2694,7 +2694,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page_virt);
 
 void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu)
 {
-	while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES) {
+	while (vcpu->kvm->arch.n_free_mmu_pages < KVM_REFILL_PAGES &&
+	       !list_empty(&vcpu->kvm->arch.active_mmu_pages)) {
 		struct kvm_mmu_page *sp;
 
 		sp = container_of(vcpu->kvm->arch.active_mmu_pages.prev,
-- 
1.6.3.rc4.29.g8146