cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

kvm_dirty_ring.h (2633B)


      1#ifndef KVM_DIRTY_RING_H
      2#define KVM_DIRTY_RING_H
      3
      4#include <linux/kvm.h>
      5
      6/**
      7 * kvm_dirty_ring: KVM internal dirty ring structure
      8 *
      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
     13 *               be reenabled
     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
     20 */
     21struct kvm_dirty_ring {
     22	u32 dirty_index;
     23	u32 reset_index;
     24	u32 size;
     25	u32 soft_limit;
     26	struct kvm_dirty_gfn *dirty_gfns;
     27	int index;
     28};
     29
     30#ifndef CONFIG_HAVE_KVM_DIRTY_RING
     31/*
     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.
     34 */
     35static inline u32 kvm_dirty_ring_get_rsvd_entries(void)
     36{
     37	return 0;
     38}
     39
     40static inline int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring,
     41				       int index, u32 size)
     42{
     43	return 0;
     44}
     45
     46static inline int kvm_dirty_ring_reset(struct kvm *kvm,
     47				       struct kvm_dirty_ring *ring)
     48{
     49	return 0;
     50}
     51
     52static inline void kvm_dirty_ring_push(struct kvm_dirty_ring *ring,
     53				       u32 slot, u64 offset)
     54{
     55}
     56
     57static inline struct page *kvm_dirty_ring_get_page(struct kvm_dirty_ring *ring,
     58						   u32 offset)
     59{
     60	return NULL;
     61}
     62
     63static inline void kvm_dirty_ring_free(struct kvm_dirty_ring *ring)
     64{
     65}
     66
     67static inline bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring)
     68{
     69	return true;
     70}
     71
     72#else /* CONFIG_HAVE_KVM_DIRTY_RING */
     73
     74u32 kvm_dirty_ring_get_rsvd_entries(void);
     75int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring, int index, u32 size);
     76
     77/*
     78 * called with kvm->slots_lock held, returns the number of
     79 * processed pages.
     80 */
     81int kvm_dirty_ring_reset(struct kvm *kvm, struct kvm_dirty_ring *ring);
     82
     83/*
     84 * returns =0: successfully pushed
     85 *         <0: unable to push, need to wait
     86 */
     87void kvm_dirty_ring_push(struct kvm_dirty_ring *ring, u32 slot, u64 offset);
     88
     89/* for use in vm_operations_struct */
     90struct page *kvm_dirty_ring_get_page(struct kvm_dirty_ring *ring, u32 offset);
     91
     92void kvm_dirty_ring_free(struct kvm_dirty_ring *ring);
     93bool kvm_dirty_ring_soft_full(struct kvm_dirty_ring *ring);
     94
     95#endif /* CONFIG_HAVE_KVM_DIRTY_RING */
     96
     97#endif	/* KVM_DIRTY_RING_H */