Skip to contentSkip to conversation

mmu fixes

PATCH Applied Marcelo Tosatti 3 participants 6 messages Jul 28, 2009 – Jul 29, 2009

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH 1/2 KVM: MMU: make __kvm_mmu_free_some_pages handle empty list

From: Izik Eidus <[email protected]>

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

arch/x86/kvm/mmu.c +2 -1
Index: kvm/arch/x86/kvm/mmu.c
===================================================================
@@ -2625,7 +2625,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page
 
 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,
#2 lore raw

Re: [patch 1/2] KVM: MMU: make __kvm_mmu_free_some_pages handle empty list

Quoted 16 lines · Marcelo Tosatti

From: Izik Eidus <[email protected]>

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

Index: kvm/arch/x86/kvm/mmu.c
===================================================================

arch/x86/kvm/mmu.c EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page · line 2632

Quoted 9 lines
arch/x86/kvm/mmu.c +2 -1
@@ -2625,7 +2625,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_unprotect_page
 
 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,

ack

#3 lore raw

PATCH 2/2 KVM: MMU: fix bogus alloc_mmu_pages assignment

In reply to Marcelo Tosatti

Remove the bogus n_free_mmu_pages assignment from alloc_mmu_pages.

It breaks accounting of mmu pages, since n_free_mmu_pages is modified but the real number of pages remains the same.

arch/x86/kvm/mmu.c +0 -8
Index: kvm/arch/x86/kvm/mmu.c
===================================================================
@@ -2706,14 +2706,6 @@ static int alloc_mmu_pages(struct kvm_vc
 
 	ASSERT(vcpu);
 
-	spin_lock(&vcpu->kvm->mmu_lock);
-	if (vcpu->kvm->arch.n_requested_mmu_pages)
-		vcpu->kvm->arch.n_free_mmu_pages =
-					vcpu->kvm->arch.n_requested_mmu_pages;
-	else
-		vcpu->kvm->arch.n_free_mmu_pages =
-					vcpu->kvm->arch.n_alloc_mmu_pages;
-	spin_unlock(&vcpu->kvm->mmu_lock);
 	/*
 	 * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64.
 	 * Therefore we need to allocate shadow page tables in the first
#4 lore raw

Re: [patch 2/2] KVM: MMU: fix bogus alloc_mmu_pages assignment

Quoted 19 lines · Marcelo Tosatti

Remove the bogus n_free_mmu_pages assignment from alloc_mmu_pages.

It breaks accounting of mmu pages, since n_free_mmu_pages is modified but the real number of pages remains the same.

Index: kvm/arch/x86/kvm/mmu.c
===================================================================

arch/x86/kvm/mmu.c +0 -1
@@ -2706,14 +2706,6 @@ static int alloc_mmu_pages(struct kvm_vc
 
 	ASSERT(vcpu);
 
-	spin_lock(&vcpu->kvm->mmu_lock);

arch/x86/kvm/mmu.c static int alloc_mmu_pages(struct kvm_vc · line 2711

Quoted 10 lines
arch/x86/kvm/mmu.c +0 -7
-	if (vcpu->kvm->arch.n_requested_mmu_pages)
-		vcpu->kvm->arch.n_free_mmu_pages =
-					vcpu->kvm->arch.n_requested_mmu_pages;
-	else
-		vcpu->kvm->arch.n_free_mmu_pages =
-					vcpu->kvm->arch.n_alloc_mmu_pages;
-	spin_unlock(&vcpu->kvm->mmu_lock);
 	/*
 	 * When emulating 32-bit mode, cr3 is only 32 bits even on x86_64.
 	 * Therefore we need to allocate shadow page tables in the first

ack

Applied
#5 lore raw
In reply to Marcelo Tosatti
Quoted 3 lines · Marcelo Tosatti

See patches for details.

Applied, thanks.

Please add the failure scenario to the changelog in the future.

Signature · 1 line
error compiling committee.c: too many arguments to function