1
2
3
4
5
6
7
8
9#ifndef QEMU_KVM_INT_H
10#define QEMU_KVM_INT_H
11
12#include "exec/memory.h"
13#include "qapi/qapi-types-common.h"
14#include "qemu/accel.h"
15#include "sysemu/kvm.h"
16
17typedef struct KVMSlot
18{
19 hwaddr start_addr;
20 ram_addr_t memory_size;
21 void *ram;
22 int slot;
23 int flags;
24 int old_flags;
25
26 unsigned long *dirty_bmap;
27 unsigned long dirty_bmap_size;
28
29 int as_id;
30
31 ram_addr_t ram_start_offset;
32} KVMSlot;
33
34typedef struct KVMMemoryListener {
35 MemoryListener listener;
36 KVMSlot *slots;
37 int as_id;
38} KVMMemoryListener;
39
40#define KVM_MSI_HASHTAB_SIZE 256
41
42enum KVMDirtyRingReaperState {
43 KVM_DIRTY_RING_REAPER_NONE = 0,
44
45 KVM_DIRTY_RING_REAPER_WAIT,
46
47 KVM_DIRTY_RING_REAPER_REAPING,
48};
49
50
51
52
53
54struct KVMDirtyRingReaper {
55
56 QemuThread reaper_thr;
57 volatile uint64_t reaper_iteration;
58 volatile enum KVMDirtyRingReaperState reaper_state;
59};
60struct KVMState
61{
62 AccelState parent_obj;
63
64 int nr_slots;
65 int fd;
66 int vmfd;
67 int coalesced_mmio;
68 int coalesced_pio;
69 struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
70 bool coalesced_flush_in_progress;
71 int vcpu_events;
72 int robust_singlestep;
73 int debugregs;
74#ifdef KVM_CAP_SET_GUEST_DEBUG
75 QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
76#endif
77 int max_nested_state_len;
78 int many_ioeventfds;
79 int intx_set_mask;
80 int kvm_shadow_mem;
81 bool kernel_irqchip_allowed;
82 bool kernel_irqchip_required;
83 OnOffAuto kernel_irqchip_split;
84 bool sync_mmu;
85 uint64_t manual_dirty_log_protect;
86
87
88
89 unsigned irq_set_ioctl;
90 unsigned int sigmask_len;
91 GHashTable *gsimap;
92#ifdef KVM_CAP_IRQ_ROUTING
93 struct kvm_irq_routing *irq_routes;
94 int nr_allocated_irq_routes;
95 unsigned long *used_gsi_bitmap;
96 unsigned int gsi_count;
97 QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];
98#endif
99 KVMMemoryListener memory_listener;
100 QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus;
101
102
103 int nr_as;
104 struct KVMAs {
105 KVMMemoryListener *ml;
106 AddressSpace *as;
107 } *as;
108 uint64_t kvm_dirty_ring_bytes;
109 uint32_t kvm_dirty_ring_size;
110 struct KVMDirtyRingReaper reaper;
111 NotifyVmexitOption notify_vmexit;
112 uint32_t notify_window;
113};
114
115void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
116 AddressSpace *as, int as_id, const char *name);
117
118void kvm_set_max_memslot_size(hwaddr max_slot_size);
119
120
121
122
123
124
125
126
127
128
129
130void kvm_hwpoison_page_add(ram_addr_t ram_addr);
131#endif
132