From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM swapping with mmu notifiers Date: Mon, 14 Jan 2008 16:09:03 +0200 Message-ID: <478B6CFF.9070801@qumranet.com> References: <20080113133244.GC8736@v2.random> <20080114134539.GB15200@dmt> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Andrea Arcangeli To: Marcelo Tosatti Return-path: In-Reply-To: <20080114134539.GB15200@dmt> 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 Marcelo Tosatti wrote: >> >> +static void unmap_spte(struct kvm *kvm, u64 *spte) >> +{ >> + struct page *page = pfn_to_page((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT); >> + get_page(page); >> + rmap_remove(kvm, spte); >> + set_shadow_pte(spte, shadow_trap_nonpresent_pte); >> + kvm_flush_remote_tlbs(kvm); >> + __free_page(page); >> +} >> + >> +void kvm_rmap_unmap_gfn(struct kvm *kvm, gfn_t gfn) >> +{ >> + unsigned long *rmapp; >> + u64 *spte, *curr_spte; >> + >> + spin_lock(&kvm->mmu_lock); >> + gfn = unalias_gfn(kvm, gfn); >> + rmapp = gfn_to_rmap(kvm, gfn); >> > > The alias and memslot maps are protected only by mmap_sem, so you > should make kvm_set_memory_region/set_memory_alias grab the mmu spinlock > in addition to mmap_sem in write mode. > > kvm_mmu_zap_all() grabs the mmu lock.. that should probably move up into > the caller. > > Aren't mmu notifiers called with mmap_sem held for read? Maybe not from the swap path? -- error compiling committee.c: too many arguments to function ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace