[PATCH] KVM: Avoid oom on cr3 switch
authorIngo Molnar <mingo@elte.hu>
Sat, 6 Jan 2007 00:36:57 +0000 (16:36 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Sat, 6 Jan 2007 07:55:28 +0000 (23:55 -0800)
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/kvm/mmu.c

index 6e7381bc22182bb4150f2fa9666118248854bb5c..4118e504e647041120b3da96f5dc49d3295609e4 100644 (file)
@@ -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);