On 03/01/2012 06:33 PM, Takuya Yoshikawa wrote:

> +     spin_lock(&kvm->mmu_lock);
> 
> -             r = -ENOMEM;
> -             slots = kmemdup(kvm->memslots, sizeof(*kvm->memslots), 
> GFP_KERNEL);
> -             if (!slots)
> -                     goto out;
> +     for (i = 0; i < n / sizeof(long); i++) {
> +             unsigned long mask;
> +             gfn_t offset;
> 
> -             memslot = id_to_memslot(slots, log->slot);
> -             memslot->nr_dirty_pages = 0;
> -             memslot->dirty_bitmap = dirty_bitmap_head;
> -             update_memslots(slots, NULL);
> +             if (!dirty_bitmap[i])
> +                     continue;
> 
> -             old_slots = kvm->memslots;
> -             rcu_assign_pointer(kvm->memslots, slots);
> -             synchronize_srcu_expedited(&kvm->srcu);
> -             kfree(old_slots);


For my quickly review, mmu_lock can not protect everything, if the guest page
is written out of the shadow page/ept table, dirty page will be lost.

There is a example:

             CPU A                                   CPU  B
guest page is written by write-emulation

                                                  hold mmu-lock and see 
dirty-bitmap
                                                  is not be changed, then 
migration is
                                                  completed.

call mark_page_dirty() to set dirty_bit map


Right?

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to