Branch is here: https://github.com/xzpeter/linux/tree/kvm-dirty-ring (based on kvm/queue) Please refer to either the previous cover letters, or documentation update in patch 12 for the big picture. Previous posts: V1: https://lore.kernel.org/kvm/20191129213505.18472-1-peterx@xxxxxxxxxx V2: https://lore.kernel.org/kvm/20191221014938.58831-1-peterx@xxxxxxxxxx The major change in V3 is that we dropped the whole waitqueue and the global lock. With that, we have clean per-vcpu ring and no default ring any more. The two kvmgt refactoring patches were also included to show the dependency of the works. Patchset layout: Patch 1-2: Picked up from kvmgt refactoring Patch 3-6: Small patches that are not directly related, (So can be acked/nacked/picked as standalone) Patch 7-11: Prepares for the dirty ring interface Patch 12: Major implementation Patch 13-14: Quick follow-ups for patch 8 Patch 15-21: Test cases V3 changelog: - fail userspace writable maps on dirty ring ranges [Jason] - commit message fixups [Paolo] - change __x86_set_memory_region to return hva [Paolo] - cacheline align for indices [Paolo, Jason] - drop waitqueue, global lock, etc., include kvmgt rework patchset - take lock for __x86_set_memory_region() (otherwise it triggers a lockdep in latest kvm/queue) [Paolo] - check KVM_DIRTY_LOG_PAGE_OFFSET in kvm_vm_ioctl_enable_dirty_log_ring - one more patch to drop x86_set_memory_region [Paolo] - one more patch to remove extra srcu usage in init_rmode_identity_map() - add some r-bs for Paolo Please review, thanks. Paolo Bonzini (1): KVM: Move running VCPU from ARM to common code Peter Xu (18): KVM: Remove kvm_read_guest_atomic() KVM: Add build-time error check on kvm_run size KVM: X86: Change parameter for fast_page_fault tracepoint KVM: X86: Don't take srcu lock in init_rmode_identity_map() KVM: Cache as_id in kvm_memory_slot KVM: X86: Drop x86_set_memory_region() KVM: X86: Don't track dirty for KVM_SET_[TSS_ADDR|IDENTITY_MAP_ADDR] KVM: Pass in kvm pointer into mark_page_dirty_in_slot() KVM: X86: Implement ring-based dirty memory tracking KVM: Make dirty ring exclusive to dirty bitmap log KVM: Don't allocate dirty bitmap if dirty ring is enabled KVM: selftests: Always clear dirty bitmap after iteration KVM: selftests: Sync uapi/linux/kvm.h to tools/ KVM: selftests: Use a single binary for dirty/clear log test KVM: selftests: Introduce after_vcpu_run hook for dirty log test KVM: selftests: Add dirty ring buffer test KVM: selftests: Let dirty_log_test async for dirty ring test KVM: selftests: Add "-c" parameter to dirty log test Yan Zhao (2): vfio: introduce vfio_iova_rw to read/write a range of IOVAs drm/i915/gvt: subsitute kvm_read/write_guest with vfio_iova_rw Documentation/virt/kvm/api.txt | 96 ++++ arch/arm/include/asm/kvm_host.h | 2 - arch/arm64/include/asm/kvm_host.h | 2 - arch/x86/include/asm/kvm_host.h | 7 +- arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/kvm/Makefile | 3 +- arch/x86/kvm/mmu/mmu.c | 6 + arch/x86/kvm/mmutrace.h | 9 +- arch/x86/kvm/svm.c | 3 +- arch/x86/kvm/vmx/vmx.c | 86 ++-- arch/x86/kvm/x86.c | 43 +- drivers/gpu/drm/i915/gvt/kvmgt.c | 25 +- drivers/vfio/vfio.c | 45 ++ drivers/vfio/vfio_iommu_type1.c | 81 ++++ include/linux/kvm_dirty_ring.h | 55 +++ include/linux/kvm_host.h | 37 +- include/linux/vfio.h | 5 + include/trace/events/kvm.h | 78 ++++ include/uapi/linux/kvm.h | 33 ++ tools/include/uapi/linux/kvm.h | 38 ++ tools/testing/selftests/kvm/Makefile | 2 - .../selftests/kvm/clear_dirty_log_test.c | 2 - tools/testing/selftests/kvm/dirty_log_test.c | 420 ++++++++++++++++-- .../testing/selftests/kvm/include/kvm_util.h | 4 + tools/testing/selftests/kvm/lib/kvm_util.c | 72 +++ .../selftests/kvm/lib/kvm_util_internal.h | 3 + virt/kvm/arm/arch_timer.c | 2 +- virt/kvm/arm/arm.c | 29 -- virt/kvm/arm/perf.c | 6 +- virt/kvm/arm/vgic/vgic-mmio.c | 15 +- virt/kvm/dirty_ring.c | 162 +++++++ virt/kvm/kvm_main.c | 215 +++++++-- 32 files changed, 1379 insertions(+), 208 deletions(-) create mode 100644 include/linux/kvm_dirty_ring.h delete mode 100644 tools/testing/selftests/kvm/clear_dirty_log_test.c create mode 100644 virt/kvm/dirty_ring.c -- 2.24.1