22 typedef struct kvm_context
*kvm_context_t
;
24 struct kvm_msr_list
*kvm_get_msr_list(kvm_context_t
);
26 struct kvm_callbacks
{
27 int (*inb
)(void *opaque
, uint16_t addr
, uint8_t *data
);
28 int (*inw
)(void *opaque
, uint16_t addr
, uint16_t *data
);
29 int (*inl
)(void *opaque
, uint16_t addr
, uint32_t *data
);
30 int (*outb
)(void *opaque
, uint16_t addr
, uint8_t data
);
31 int (*outw
)(void *opaque
, uint16_t addr
, uint16_t data
);
32 int (*outl
)(void *opaque
, uint16_t addr
, uint32_t data
);
33 int (*mmio_read
)(void *opaque
, uint64_t addr
, uint8_t *data
, int len
);
34 int (*mmio_write
)(void *opaque
, uint64_t addr
, uint8_t *data
, int len
);
35 int (*debug
)(void *opaque
, int vcpu
);
36 int (*halt
)(void *opaque
, int vcpu
);
37 int (*shutdown
)(void *opaque
, int vcpu
);
38 int (*io_window
)(void *opaque
);
39 int (*try_push_interrupts
)(void *opaque
);
40 int (*try_push_nmi
)(void *opaque
);
41 void (*post_kvm_run
)(void *opaque
, int vcpu
);
42 int (*pre_kvm_run
)(void *opaque
, int vcpu
);
43 int (*tpr_access
)(void *opaque
, int vcpu
, uint64_t rip
, int is_write
);
46 int kvm_get_msrs(kvm_context_t
, int vcpu
, struct kvm_msr_entry
*msrs
, int n
);
47 int kvm_set_msrs(kvm_context_t
, int vcpu
, struct kvm_msr_entry
*msrs
, int n
);
48 kvm_context_t
kvm_init(struct kvm_callbacks
*callbacks
, void *opaque
);
49 void kvm_finalize(kvm_context_t kvm
);
50 void kvm_disable_irqchip_creation(kvm_context_t
);
51 void kvm_disable_pit_creation(kvm_context_t
);
52 int kvm_create(kvm_context_t
, unsigned long phys_mem_bytes
, void **phys_mem
);
53 int kvm_create_vm(kvm_context_t
);
54 int kvm_check_extension(kvm_context_t
, int ext
);
55 void kvm_create_irqchip(kvm_context_t
);
56 int kvm_create_vcpu(kvm_context_t
, int slot
);
57 int kvm_run(kvm_context_t
, int vcpu
);
58 int kvm_get_interrupt_flag(kvm_context_t
, int vcpu
);
59 uint64_t kvm_get_apic_base(kvm_context_t
, int vcpu
);
60 int kvm_is_ready_for_interrupt_injection(kvm_context_t
, int vcpu
);
61 int kvm_is_ready_for_nmi_injection(kvm_context_t
, int vcpu
);
62 int kvm_get_regs(kvm_context_t
, int vcpu
, struct kvm_regs
*regs
);
63 int kvm_set_regs(kvm_context_t
, int vcpu
, struct kvm_regs
*regs
);
64 int kvm_get_fpu(kvm_context_t
, int vcpu
, struct kvm_fpu
*fpu
);
65 int kvm_set_fpu(kvm_context_t
, int vcpu
, struct kvm_fpu
*fpu
);
66 int kvm_get_sregs(kvm_context_t
, int vcpu
, struct kvm_sregs
*regs
);
67 int kvm_set_sregs(kvm_context_t
, int vcpu
, struct kvm_sregs
*regs
);
68 int kvm_inject_irq(kvm_context_t
, int vcpu
, unsigned irq
);
69 int kvm_guest_debug(kvm_context_t
, int vcpu
, struct kvm_debug_guest
*dbg
);
70 int kvm_setup_cpuid(kvm_context_t
, int vcpu
, int nent
, const struct kvm_cpuid_entry
*entries
);
71 int kvm_set_shadow_pages(kvm_context_t
, unsigned int nrshadow_pages
);
72 int kvm_get_shadow_pages(kvm_context_t
, unsigned int *nrshadow_pages
);
73 void kvm_set_cr8(kvm_context_t
, int vcpu
, uint64_t cr8
);
74 __u64
kvm_get_cr8(kvm_context_t
, int vcpu
);
75 int kvm_set_signal_mask(kvm_context_t
, int vcpu
, const sigset_t
*sigset
);
76 int kvm_dump_vcpu(kvm_context_t
, int vcpu
);
77 void kvm_show_regs(kvm_context_t
, int vcpu
);
78 void *kvm_create_phys_mem(kvm_context_t
, unsigned long phys_start
, unsigned long len
, int log
, int writable
);
79 void kvm_destroy_phys_mem(kvm_context_t
, unsigned long phys_start
, unsigned long len
);
80 void kvm_unregister_memory_area(kvm_context_t
, uint64_t phys_start
, unsigned long len
);
81 int kvm_is_containing_region(kvm_context_t
, unsigned long phys_start
, unsigned long size
);
82 int kvm_register_phys_mem(kvm_context_t
, unsigned long phys_start
, void *userspace_addr
, unsigned long len
, int log
);
83 int kvm_get_dirty_pages(kvm_context_t
, unsigned long phys_addr
, void *buf
);
84 int kvm_get_dirty_pages_range(kvm_context_t
, unsigned long phys_addr
, unsigned long end_addr
, void *buf
, void*opaque
, int (*cb
)(unsigned long start
, unsigned long len
, void*bitmap
, void *opaque
));
85 int kvm_register_coalesced_mmio(kvm_context_t
, uint64_t addr
, uint32_t size
);
86 int kvm_unregister_coalesced_mmio(kvm_context_t
, uint64_t addr
, uint32_t size
);
87 int kvm_create_memory_alias(kvm_context_t
, uint64_t phys_start
, uint64_t len
, uint64_t target_phys
);
88 int kvm_destroy_memory_alias(kvm_context_t
, uint64_t phys_start
);
89 int kvm_get_mem_map(kvm_context_t
, unsigned long phys_addr
, void *bitmap
);
90 int kvm_get_mem_map_range(kvm_context_t
, unsigned long phys_addr
, unsigned long len
, void *buf
, void *opaque
, int (*cb
)(unsigned long start
,unsigned long len
, void* bitmap
, void* opaque
));
91 int kvm_set_irq_level(kvm_context_t
, int irq
, int level
);
92 int kvm_dirty_pages_log_enable_slot(kvm_context_t
, uint64_t phys_start
, uint64_t len
);
93 int kvm_dirty_pages_log_disable_slot(kvm_context_t
, uint64_t phys_start
, uint64_t len
);
94 int kvm_dirty_pages_log_enable_all(kvm_context_t
);
95 int kvm_dirty_pages_log_reset(kvm_context_t
);
96 int kvm_irqchip_in_kernel(kvm_context_t
);
97 int kvm_has_sync_mmu(kvm_context_t
);
98 int kvm_pit_in_kernel(kvm_context_t
);
99 int kvm_init_coalesced_mmio(kvm_context_t
);
101 #ifdef KVM_CAP_MP_STATE
102 int kvm_get_mpstate(kvm_context_t
, int vcpu
, struct kvm_mp_state
*mp_state
);
103 int kvm_set_mpstate(kvm_context_t
, int vcpu
, struct kvm_mp_state
*mp_state
);
104 static inline int kvm_reset_mpstate(kvm_context_t
, int vcpu
)
106 struct kvm_mp_state mp_state
= {.mp_state
= KVM_MP_STATE_UNINITIALIZED
};
107 return kvm_set_mpstate(kvm
, vcpu
, &mp_state
);
111 #ifdef KVM_CAP_IRQCHIP
112 int kvm_get_irqchip(kvm_context_t
, struct kvm_irqchip
*chip
);
113 int kvm_set_irqchip(kvm_context_t
, struct kvm_irqchip
*chip
);
114 int kvm_get_lapic(kvm_context_t
, int vcpu
, struct kvm_lapic_state
*s
);
115 int kvm_set_lapic(kvm_context_t
, int vcpu
, struct kvm_lapic_state
*s
);
116 int kvm_inject_nmi(kvm_context_t
, int vcpu
);
121 int kvm_get_pit(kvm_context_t kvm
, struct kvm_pit_state
*s
);
122 int kvm_set_pit(kvm_context_t kvm
, struct kvm_pit_state
*s
);
126 int kvm_enable_tpr_access_reporting(kvm_context_t kvm
, int vcpu
);
127 int kvm_disable_tpr_access_reporting(kvm_context_t kvm
, int vcpu
);
128 int kvm_enable_vapic(kvm_context_t kvm
, int vcpu
, uint64_t vapic
);