Re: KVM swapping with mmu notifiers

Avi Kivity
2008-01-14T14:09:03Z

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.