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