2 * Internal definitions for a target's KVM support
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.
10 #define QEMU_KVM_INT_H
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"
18 typedef struct KVMSlot
21 ram_addr_t memory_size
;
26 /* Dirty bitmap cache for the slot */
27 unsigned long *dirty_bmap
;
28 unsigned long dirty_bmap_size
;
29 /* Cache of the address space ID */
31 /* Cache of the offset in ram address space */
32 ram_addr_t ram_start_offset
;
35 typedef struct KVMMemoryUpdate
{
36 QSIMPLEQ_ENTRY(KVMMemoryUpdate
) next
;
37 MemoryRegionSection section
;
40 typedef struct KVMMemoryListener
{
41 MemoryListener listener
;
43 unsigned int nr_used_slots
;
45 QSIMPLEQ_HEAD(, KVMMemoryUpdate
) transaction_add
;
46 QSIMPLEQ_HEAD(, KVMMemoryUpdate
) transaction_del
;
49 #define KVM_MSI_HASHTAB_SIZE 256
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
,
60 * KVM reaper instance, responsible for collecting the KVM dirty bits
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 */
71 AccelState parent_obj
;
78 struct kvm_coalesced_mmio_ring
*coalesced_mmio_ring
;
79 bool coalesced_flush_in_progress
;
81 #ifdef KVM_CAP_SET_GUEST_DEBUG
82 QTAILQ_HEAD(, kvm_sw_breakpoint
) kvm_sw_breakpoints
;
84 int max_nested_state_len
;
86 bool kernel_irqchip_allowed
;
87 bool kernel_irqchip_required
;
88 OnOffAuto kernel_irqchip_split
;
90 uint64_t manual_dirty_log_protect
;
91 /* The man page (and posix) say ioctl numbers are signed int, but
92 * they're not. Linux, glibc and *BSD all treat ioctl numbers as
93 * unsigned, and treating them as signed here can break things */
94 unsigned irq_set_ioctl
;
95 unsigned int sigmask_len
;
97 #ifdef KVM_CAP_IRQ_ROUTING
98 struct kvm_irq_routing
*irq_routes
;
99 int nr_allocated_irq_routes
;
100 unsigned long *used_gsi_bitmap
;
101 unsigned int gsi_count
;
103 KVMMemoryListener memory_listener
;
104 QLIST_HEAD(, KVMParkedVcpu
) kvm_parked_vcpus
;
106 /* For "info mtree -f" to tell if an MR is registered in KVM */
109 KVMMemoryListener
*ml
;
112 uint64_t kvm_dirty_ring_bytes
; /* Size of the per-vcpu dirty ring */
113 uint32_t kvm_dirty_ring_size
; /* Number of dirty GFNs per ring */
114 bool kvm_dirty_ring_with_bitmap
;
115 uint64_t kvm_eager_split_size
; /* Eager Page Splitting chunk size */
116 struct KVMDirtyRingReaper reaper
;
117 NotifyVmexitOption notify_vmexit
;
118 uint32_t notify_window
;
119 uint32_t xen_version
;
121 uint16_t xen_gnttab_max_frames
;
122 uint16_t xen_evtchn_max_pirq
;
125 void kvm_memory_listener_register(KVMState
*s
, KVMMemoryListener
*kml
,
126 AddressSpace
*as
, int as_id
, const char *name
);
128 void kvm_set_max_memslot_size(hwaddr max_slot_size
);
131 * kvm_hwpoison_page_add:
134 * @ram_addr: the address in the RAM for the poisoned page
136 * Add a poisoned page to the list
140 void kvm_hwpoison_page_add(ram_addr_t ram_addr
);