History

KVM: Provide common implementation for generic dirty log functions

Move the implementations of KVM_GET_DIRTY_LOG and KVM_CLEAR_DIRTY_LOG for CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT into common KVM code. The arch specific implemenations are extremely similar, differing only in whether the dirty log needs to be sync'd from hardware (x86) and how the TLBs are flushed. Add new arch hooks to handle sync and TLB flush; the sync will also be used for non-generic dirty log support in a future patch (s390). The ulterior motive for providing a common implementation is to eliminate the dependency between arch and common code with respect to the memslot referenced by the dirty log, i.e. to make it obvious in the code that the validity of the memslot is guaranteed, as a future patch will rework memslot handling such that id_to_memslot() can return NULL.

Sean Christopherson committed 6 years ago

Commit 0dff0841 parent 163da378 files · +106 −195Browse files

Showing the changes to include/linux (1 of 8 files). Show all

Unified · Split

include/linux/kvm_host.h+10−13
@@ -816,23 +816,20 @@ vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf); · 815 unmodified lines
816 816
817int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext);817int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext);
818 818
819int kvm_get_dirty_log(struct kvm *kvm,
820 struct kvm_dirty_log *log, int *is_dirty);
821
822int kvm_get_dirty_log_protect(struct kvm *kvm,
823 struct kvm_dirty_log *log, bool *flush);
824int kvm_clear_dirty_log_protect(struct kvm *kvm,
825 struct kvm_clear_dirty_log *log, bool *flush);
826
827void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,819void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
828 struct kvm_memory_slot *slot,820 struct kvm_memory_slot *slot,
829 gfn_t gfn_offset,821 gfn_t gfn_offset,
830 unsigned long mask);822 unsigned long mask);
831 823void kvm_arch_sync_dirty_log(struct kvm *kvm, struct kvm_memory_slot *memslot);
832int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,824
833 struct kvm_dirty_log *log);825#ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
834int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm,826void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm,
835 struct kvm_clear_dirty_log *log);827 struct kvm_memory_slot *memslot);
828#else /* !CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT */
829int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log);
830int kvm_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log,
831 int *is_dirty);
832#endif
836 833
837int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,834int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
838 bool line_status);835 bool line_status);