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 "sysemu/kvm.h"
17 typedef struct KVMSlot
20 ram_addr_t memory_size
;
25 /* Dirty bitmap cache for the slot */
26 unsigned long *dirty_bmap
;
27 unsigned long dirty_bmap_size
;
28 /* Cache of the address space ID */
30 /* Cache of the offset in ram address space */
31 ram_addr_t ram_start_offset
;
34 typedef struct KVMMemoryListener
{
35 MemoryListener listener
;
40 #define KVM_MSI_HASHTAB_SIZE 256
42 enum KVMDirtyRingReaperState
{
43 KVM_DIRTY_RING_REAPER_NONE
= 0,
44 /* The reaper is sleeping */
45 KVM_DIRTY_RING_REAPER_WAIT
,
46 /* The reaper is reaping for dirty pages */
47 KVM_DIRTY_RING_REAPER_REAPING
,
51 * KVM reaper instance, responsible for collecting the KVM dirty bits
54 struct KVMDirtyRingReaper
{
55 /* The reaper thread */
56 QemuThread reaper_thr
;
57 volatile uint64_t reaper_iteration
; /* iteration number of reaper thr */
58 volatile enum KVMDirtyRingReaperState reaper_state
; /* reap thr state */
62 AccelState parent_obj
;
69 struct kvm_coalesced_mmio_ring
*coalesced_mmio_ring
;
70 bool coalesced_flush_in_progress
;
72 int robust_singlestep
;
74 #ifdef KVM_CAP_SET_GUEST_DEBUG
75 QTAILQ_HEAD(, kvm_sw_breakpoint
) kvm_sw_breakpoints
;
77 int max_nested_state_len
;
81 bool kernel_irqchip_allowed
;
82 bool kernel_irqchip_required
;
83 OnOffAuto kernel_irqchip_split
;
85 uint64_t manual_dirty_log_protect
;
86 /* The man page (and posix) say ioctl numbers are signed int, but
87 * they're not. Linux, glibc and *BSD all treat ioctl numbers as
88 * unsigned, and treating them as signed here can break things */
89 unsigned irq_set_ioctl
;
90 unsigned int sigmask_len
;
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
];
99 KVMMemoryListener memory_listener
;
100 QLIST_HEAD(, KVMParkedVcpu
) kvm_parked_vcpus
;
102 /* For "info mtree -f" to tell if an MR is registered in KVM */
105 KVMMemoryListener
*ml
;
108 uint64_t kvm_dirty_ring_bytes
; /* Size of the per-vcpu dirty ring */
109 uint32_t kvm_dirty_ring_size
; /* Number of dirty GFNs per ring */
110 struct KVMDirtyRingReaper reaper
;
111 NotifyVmexitOption notify_vmexit
;
112 uint32_t notify_window
;
115 void kvm_memory_listener_register(KVMState
*s
, KVMMemoryListener
*kml
,
116 AddressSpace
*as
, int as_id
, const char *name
);
118 void kvm_set_max_memslot_size(hwaddr max_slot_size
);
121 * kvm_hwpoison_page_add:
124 * @ram_addr: the address in the RAM for the poisoned page
126 * Add a poisoned page to the list
130 void kvm_hwpoison_page_add(ram_addr_t ram_addr
);