On 07/30/2013 09:27 PM, Paolo Bonzini wrote: > Il 30/07/2013 15:02, Xiao Guangrong ha scritto: >> kvm_vm_ioctl_get_dirty_log() write-protects the spte based on the dirty >> bitmap, we should ensure the writable spte can be found in rmap before the >> dirty bitmap is visible. Otherwise, we cleared the dirty bitmap and failed >> to write-protect the page >> >> It need the memory barrier to prevent out-of-order that will be added in the >> later patch > > Do you mean that the later patch will also introduce a memory barrier? No. Sorry for the confusion. I mean we miss the memory barrier in this patch and will fix it in the latter patch where we introduce the lockless write-protection. The memory barrier is added in [PATCH 11/12] KVM: MMU: locklessly write-protect the page: + /* + * We should put the sptep into rmap before dirty log + * otherwise the lockless spte write-protect path will + * clear the dirty bit map but fail to find the spte. + * + * See the comments in kvm_vm_ioctl_get_dirty_log(). + */ + smp_wmb(); + if (pte_access & ACC_WRITE_MASK) and the barrier in the another side is: + /* + * xchg acts as a full barrier that ensures + * clearing dirty bitmap before read rmap. + * + * See the comments in set_spte(). + */ mask = xchg(&dirty_bitmap[i], 0); -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html