From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [patch] kvm: make cr3 loading more robust Date: Wed, 3 Jan 2007 13:32:53 +0100 Message-ID: <20070103123253.GA8822@elte.hu> References: <20070103021057.GA11316@elte.hu> <459B695C.5090004@qumranet.com> <20070103115911.GA2786@elte.hu> <459B9C5C.9060008@qumranet.com> <20070103122114.GD2786@elte.hu> <459BA194.8070305@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel Return-path: To: Avi Kivity Content-Disposition: inline In-Reply-To: <459BA194.8070305-atKUWr5tajBWk0Htik3J/w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org * Avi Kivity wrote: > Right not the list is not LRU, so a zap can kill your parent page > table. I'm also worried about preserving invariants, as the page > tables are linked through a variety of data structures. Calling > zap_page() while another operation is in progress could cause > corruption if zap_page() kills one of your parents or children. ok. How about the patch below then? This only addresses the OOM scenario, not the !memslot case. Ingo Signed-off-by: Ingo Molnar Index: linux/drivers/kvm/mmu.c =================================================================== --- linux.orig/drivers/kvm/mmu.c +++ linux/drivers/kvm/mmu.c @@ -903,6 +903,8 @@ static void paging_new_cr3(struct kvm_vc { 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); ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV