On Thu, Feb 20, 2020 at 12:28:28PM +0800, Jay Zhou wrote: > @@ -5865,8 +5865,12 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, > bool flush; > > spin_lock(&kvm->mmu_lock); > - flush = slot_handle_all_level(kvm, memslot, slot_rmap_write_protect, > - false); > + if (kvm->manual_dirty_log_protect & KVM_DIRTY_LOG_INITIALLY_SET) > + flush = slot_handle_large_level(kvm, memslot, > + slot_rmap_write_protect, false); > + else > + flush = slot_handle_all_level(kvm, memslot, > + slot_rmap_write_protect, false); Another extra comment: I think we should still keep the old behavior for KVM_MEM_READONLY (in kvm_mmu_slot_apply_flags())) for this... Say, instead of doing this, maybe we want kvm_mmu_slot_remove_write_access() to take a new parameter to decide to which level we do the wr-protect. Thanks, > spin_unlock(&kvm->mmu_lock); > > /* -- Peter Xu