1 #ifndef KVM_DIRTY_RING_H
2 #define KVM_DIRTY_RING_H
7 * kvm_dirty_ring: KVM internal dirty ring structure
9 * @dirty_index: free running counter that points to the next slot in
10 * dirty_ring->dirty_gfns, where a new dirty page should go
11 * @reset_index: free running counter that points to the next dirty page
12 * in dirty_ring->dirty_gfns for which dirty trap needs to
14 * @size: size of the compact list, dirty_ring->dirty_gfns
15 * @soft_limit: when the number of dirty pages in the list reaches this
16 * limit, vcpu that owns this ring should exit to userspace
17 * to allow userspace to harvest all the dirty pages
18 * @dirty_gfns: the array to keep the dirty gfns
19 * @index: index of this dirty ring
21 struct kvm_dirty_ring {
26 struct kvm_dirty_gfn *dirty_gfns;
30 #ifndef CONFIG_HAVE_KVM_DIRTY_RING
32 * If CONFIG_HAVE_HVM_DIRTY_RING not defined, kvm_dirty_ring.o should
33 * not be included as well, so define these nop functions for the arch.
35 static inline u32 kvm_dirty_ring_get_rsvd_entries(void)
40 static inline int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring,
46 static inline struct kvm_dirty_ring *kvm_dirty_ring_get(struct kvm *kvm)
51 static inline int kvm_dirty_ring_reset(struct kvm *kvm,
52 struct kvm_dirty_ring *ring)
57 static inline void kvm_dirty_ring_push(struct kvm_dirty_ring *ring,
62 static inline struct page *kvm_dirty_ring_get_page(struct kvm_dirty_ring *ring,
68 static inline void kvm_dirty_ring_free(struct kvm_dirty_ring *ring)
72 static inline bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring)
77 #else /* CONFIG_HAVE_KVM_DIRTY_RING */
79 u32 kvm_dirty_ring_get_rsvd_entries(void);
80 int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring, int index, u32 size);
81 struct kvm_dirty_ring *kvm_dirty_ring_get(struct kvm *kvm);
84 * called with kvm->slots_lock held, returns the number of
87 int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_dirty_ring *ring);
90 * returns =0: successfully pushed
91 * <0: unable to push, need to wait
93 void kvm_dirty_ring_push(struct kvm_dirty_ring *ring, u32 slot, u64 offset);
95 /* for use in vm_operations_struct */
96 struct page *kvm_dirty_ring_get_page(struct kvm_dirty_ring *ring, u32 offset);
98 void kvm_dirty_ring_free(struct kvm_dirty_ring *ring);
99 bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring);
101 #endif /* CONFIG_HAVE_KVM_DIRTY_RING */
103 #endif /* KVM_DIRTY_RING_H */