From: Ingo Molnar Date: Sat, 6 Jan 2007 00:36:57 +0000 (-0800) Subject: [PATCH] KVM: Avoid oom on cr3 switch X-Git-Tag: v2.6.20-rc4~21 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f7417d67ea6c1538469e3ea005484e807642c0a;p=linux-2.6 [PATCH] KVM: Avoid oom on cr3 switch Signed-off-by: Ingo Molnar Signed-off-by: Avi Kivity Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index 6e7381bc22..4118e504e6 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c @@ -905,6 +905,8 @@ static void paging_new_cr3(struct kvm_vcpu *vcpu) { pgprintk("%s: cr3 %lx\n", __FUNCTION__, vcpu->cr3); mmu_free_roots(vcpu); + if (unlikely(vcpu->kvm->n_free_mmu_pages < KVM_MIN_FREE_MMU_PAGES)) + kvm_mmu_free_some_pages(vcpu); mmu_alloc_roots(vcpu); kvm_mmu_flush_tlb(vcpu); kvm_arch_ops->set_cr3(vcpu, vcpu->mmu.root_hpa);