]>
Commit | Line | Data |
---|---|---|
8571ed35 PB |
1 | /* |
2 | * Internal definitions for a target's KVM support | |
3 | * | |
4 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
5 | * See the COPYING file in the top-level directory. | |
6 | * | |
7 | */ | |
8 | ||
9 | #ifndef QEMU_KVM_INT_H | |
10 | #define QEMU_KVM_INT_H | |
11 | ||
ec150c7e | 12 | #include "exec/memory.h" |
5f8a6bce | 13 | #include "qapi/qapi-types-common.h" |
940e43aa | 14 | #include "qemu/accel.h" |
f39b7d2b | 15 | #include "qemu/queue.h" |
8571ed35 PB |
16 | #include "sysemu/kvm.h" |
17 | ||
18 | typedef struct KVMSlot | |
19 | { | |
20 | hwaddr start_addr; | |
21 | ram_addr_t memory_size; | |
22 | void *ram; | |
23 | int slot; | |
24 | int flags; | |
6c090d4a | 25 | int old_flags; |
9f4bf4ba PX |
26 | /* Dirty bitmap cache for the slot */ |
27 | unsigned long *dirty_bmap; | |
563d32ba | 28 | unsigned long dirty_bmap_size; |
e65e5f50 PX |
29 | /* Cache of the address space ID */ |
30 | int as_id; | |
2c20b27e PX |
31 | /* Cache of the offset in ram address space */ |
32 | ram_addr_t ram_start_offset; | |
8571ed35 PB |
33 | } KVMSlot; |
34 | ||
f39b7d2b DH |
35 | typedef struct KVMMemoryUpdate { |
36 | QSIMPLEQ_ENTRY(KVMMemoryUpdate) next; | |
37 | MemoryRegionSection section; | |
38 | } KVMMemoryUpdate; | |
39 | ||
7bbda04c PB |
40 | typedef struct KVMMemoryListener { |
41 | MemoryListener listener; | |
42 | KVMSlot *slots; | |
5b23186a | 43 | unsigned int nr_used_slots; |
38bfe691 | 44 | int as_id; |
f39b7d2b DH |
45 | QSIMPLEQ_HEAD(, KVMMemoryUpdate) transaction_add; |
46 | QSIMPLEQ_HEAD(, KVMMemoryUpdate) transaction_del; | |
7bbda04c PB |
47 | } KVMMemoryListener; |
48 | ||
5f8a6bce CQ |
49 | #define KVM_MSI_HASHTAB_SIZE 256 |
50 | ||
51 | enum KVMDirtyRingReaperState { | |
52 | KVM_DIRTY_RING_REAPER_NONE = 0, | |
53 | /* The reaper is sleeping */ | |
54 | KVM_DIRTY_RING_REAPER_WAIT, | |
55 | /* The reaper is reaping for dirty pages */ | |
56 | KVM_DIRTY_RING_REAPER_REAPING, | |
57 | }; | |
58 | ||
59 | /* | |
60 | * KVM reaper instance, responsible for collecting the KVM dirty bits | |
61 | * via the dirty ring. | |
62 | */ | |
63 | struct KVMDirtyRingReaper { | |
64 | /* The reaper thread */ | |
65 | QemuThread reaper_thr; | |
66 | volatile uint64_t reaper_iteration; /* iteration number of reaper thr */ | |
67 | volatile enum KVMDirtyRingReaperState reaper_state; /* reap thr state */ | |
68 | }; | |
69 | struct KVMState | |
70 | { | |
71 | AccelState parent_obj; | |
72 | ||
73 | int nr_slots; | |
74 | int fd; | |
75 | int vmfd; | |
76 | int coalesced_mmio; | |
77 | int coalesced_pio; | |
78 | struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; | |
79 | bool coalesced_flush_in_progress; | |
80 | int vcpu_events; | |
81 | int robust_singlestep; | |
82 | int debugregs; | |
83 | #ifdef KVM_CAP_SET_GUEST_DEBUG | |
84 | QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; | |
85 | #endif | |
86 | int max_nested_state_len; | |
87 | int many_ioeventfds; | |
88 | int intx_set_mask; | |
89 | int kvm_shadow_mem; | |
90 | bool kernel_irqchip_allowed; | |
91 | bool kernel_irqchip_required; | |
92 | OnOffAuto kernel_irqchip_split; | |
93 | bool sync_mmu; | |
94 | uint64_t manual_dirty_log_protect; | |
95 | /* The man page (and posix) say ioctl numbers are signed int, but | |
96 | * they're not. Linux, glibc and *BSD all treat ioctl numbers as | |
97 | * unsigned, and treating them as signed here can break things */ | |
98 | unsigned irq_set_ioctl; | |
99 | unsigned int sigmask_len; | |
100 | GHashTable *gsimap; | |
101 | #ifdef KVM_CAP_IRQ_ROUTING | |
102 | struct kvm_irq_routing *irq_routes; | |
103 | int nr_allocated_irq_routes; | |
104 | unsigned long *used_gsi_bitmap; | |
105 | unsigned int gsi_count; | |
5f8a6bce CQ |
106 | #endif |
107 | KVMMemoryListener memory_listener; | |
108 | QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus; | |
109 | ||
110 | /* For "info mtree -f" to tell if an MR is registered in KVM */ | |
111 | int nr_as; | |
112 | struct KVMAs { | |
113 | KVMMemoryListener *ml; | |
114 | AddressSpace *as; | |
115 | } *as; | |
116 | uint64_t kvm_dirty_ring_bytes; /* Size of the per-vcpu dirty ring */ | |
117 | uint32_t kvm_dirty_ring_size; /* Number of dirty GFNs per ring */ | |
b20cc776 | 118 | bool kvm_dirty_ring_with_bitmap; |
c8f2eb5d | 119 | uint64_t kvm_eager_split_size; /* Eager Page Splitting chunk size */ |
5f8a6bce CQ |
120 | struct KVMDirtyRingReaper reaper; |
121 | NotifyVmexitOption notify_vmexit; | |
122 | uint32_t notify_window; | |
61491cf4 DW |
123 | uint32_t xen_version; |
124 | uint32_t xen_caps; | |
6f43f2ee | 125 | uint16_t xen_gnttab_max_frames; |
e16aff4c | 126 | uint16_t xen_evtchn_max_pirq; |
5f8a6bce CQ |
127 | }; |
128 | ||
38bfe691 | 129 | void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, |
142518bd | 130 | AddressSpace *as, int as_id, const char *name); |
38bfe691 | 131 | |
023ae9a8 | 132 | void kvm_set_max_memslot_size(hwaddr max_slot_size); |
6b552b9b DG |
133 | |
134 | /** | |
135 | * kvm_hwpoison_page_add: | |
136 | * | |
137 | * Parameters: | |
138 | * @ram_addr: the address in the RAM for the poisoned page | |
139 | * | |
140 | * Add a poisoned page to the list | |
141 | * | |
142 | * Return: None. | |
143 | */ | |
144 | void kvm_hwpoison_page_add(ram_addr_t ram_addr); | |
8571ed35 | 145 | #endif |