Back to home page

OSCL-LXR

 
 

    


0001 #ifndef KVM_DIRTY_RING_H
0002 #define KVM_DIRTY_RING_H
0003 
0004 #include <linux/kvm.h>
0005 
0006 /**
0007  * kvm_dirty_ring: KVM internal dirty ring structure
0008  *
0009  * @dirty_index: free running counter that points to the next slot in
0010  *               dirty_ring->dirty_gfns, where a new dirty page should go
0011  * @reset_index: free running counter that points to the next dirty page
0012  *               in dirty_ring->dirty_gfns for which dirty trap needs to
0013  *               be reenabled
0014  * @size:        size of the compact list, dirty_ring->dirty_gfns
0015  * @soft_limit:  when the number of dirty pages in the list reaches this
0016  *               limit, vcpu that owns this ring should exit to userspace
0017  *               to allow userspace to harvest all the dirty pages
0018  * @dirty_gfns:  the array to keep the dirty gfns
0019  * @index:       index of this dirty ring
0020  */
0021 struct kvm_dirty_ring {
0022     u32 dirty_index;
0023     u32 reset_index;
0024     u32 size;
0025     u32 soft_limit;
0026     struct kvm_dirty_gfn *dirty_gfns;
0027     int index;
0028 };
0029 
0030 #ifndef CONFIG_HAVE_KVM_DIRTY_RING
0031 /*
0032  * If CONFIG_HAVE_HVM_DIRTY_RING not defined, kvm_dirty_ring.o should
0033  * not be included as well, so define these nop functions for the arch.
0034  */
0035 static inline u32 kvm_dirty_ring_get_rsvd_entries(void)
0036 {
0037     return 0;
0038 }
0039 
0040 static inline int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring,
0041                        int index, u32 size)
0042 {
0043     return 0;
0044 }
0045 
0046 static inline int kvm_dirty_ring_reset(struct kvm *kvm,
0047                        struct kvm_dirty_ring *ring)
0048 {
0049     return 0;
0050 }
0051 
0052 static inline void kvm_dirty_ring_push(struct kvm_dirty_ring *ring,
0053                        u32 slot, u64 offset)
0054 {
0055 }
0056 
0057 static inline struct page *kvm_dirty_ring_get_page(struct kvm_dirty_ring *ring,
0058                            u32 offset)
0059 {
0060     return NULL;
0061 }
0062 
0063 static inline void kvm_dirty_ring_free(struct kvm_dirty_ring *ring)
0064 {
0065 }
0066 
0067 static inline bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring)
0068 {
0069     return true;
0070 }
0071 
0072 #else /* CONFIG_HAVE_KVM_DIRTY_RING */
0073 
0074 u32 kvm_dirty_ring_get_rsvd_entries(void);
0075 int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring, int index, u32 size);
0076 
0077 /*
0078  * called with kvm->slots_lock held, returns the number of
0079  * processed pages.
0080  */
0081 int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_dirty_ring *ring);
0082 
0083 /*
0084  * returns =0: successfully pushed
0085  *         <0: unable to push, need to wait
0086  */
0087 void kvm_dirty_ring_push(struct kvm_dirty_ring *ring, u32 slot, u64 offset);
0088 
0089 /* for use in vm_operations_struct */
0090 struct page *kvm_dirty_ring_get_page(struct kvm_dirty_ring *ring, u32 offset);
0091 
0092 void kvm_dirty_ring_free(struct kvm_dirty_ring *ring);
0093 bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring);
0094 
0095 #endif /* CONFIG_HAVE_KVM_DIRTY_RING */
0096 
0097 #endif  /* KVM_DIRTY_RING_H */