libkvm: remove ppc functions from callbacks
[qemu-kvm/fedora.git] / qemu-kvm.h
blob68a5b400fdf3c5ebddb79b1e7bfb3b63d260c3ed
1 /*
2 * qemu/kvm integration
4 * Copyright (C) 2006-2008 Qumranet Technologies
6 * Licensed under the terms of the GNU GPL version 2 or higher.
7 */
8 #ifndef THE_ORIGINAL_AND_TRUE_QEMU_KVM_H
9 #define THE_ORIGINAL_AND_TRUE_QEMU_KVM_H
11 #include "cpu.h"
13 #include <signal.h>
15 int kvm_main_loop(void);
16 int kvm_qemu_init(void);
17 int kvm_qemu_create_context(void);
18 int kvm_init_ap(void);
19 int kvm_vcpu_inited(CPUState *env);
20 void kvm_qemu_destroy(void);
21 void kvm_load_registers(CPUState *env);
22 void kvm_save_registers(CPUState *env);
23 void kvm_load_mpstate(CPUState *env);
24 void kvm_save_mpstate(CPUState *env);
25 int kvm_cpu_exec(CPUState *env);
26 int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
27 target_ulong len, int type);
28 int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
29 target_ulong len, int type);
30 void kvm_remove_all_breakpoints(CPUState *current_env);
31 int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap);
32 int kvm_qemu_init_env(CPUState *env);
33 int kvm_qemu_check_extension(int ext);
34 void kvm_apic_init(CPUState *env);
35 /* called from vcpu initialization */
36 void qemu_kvm_load_lapic(CPUState *env);
38 int kvm_set_irq(int irq, int level, int *status);
40 int kvm_physical_memory_set_dirty_tracking(int enable);
41 int kvm_update_dirty_pages_log(void);
42 int kvm_get_phys_ram_page_bitmap(unsigned char *bitmap);
44 void qemu_kvm_call_with_env(void (*func)(void *), void *data, CPUState *env);
45 void qemu_kvm_cpuid_on_env(CPUState *env);
46 void kvm_inject_interrupt(CPUState *env, int mask);
47 void kvm_update_after_sipi(CPUState *env);
48 void kvm_update_interrupt_request(CPUState *env);
49 void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
50 unsigned long size,
51 unsigned long phys_offset);
52 void kvm_cpu_unregister_physical_memory(target_phys_addr_t start_addr,
53 target_phys_addr_t size,
54 unsigned long phys_offset);
55 void *kvm_cpu_create_phys_mem(target_phys_addr_t start_addr,
56 unsigned long size, int log, int writable);
58 void kvm_cpu_destroy_phys_mem(target_phys_addr_t start_addr,
59 unsigned long size);
60 void kvm_qemu_log_memory(target_phys_addr_t start, target_phys_addr_t size,
61 int log);
62 int kvm_setup_guest_memory(void *area, unsigned long size);
63 int kvm_qemu_create_memory_alias(uint64_t phys_start,
64 uint64_t len,
65 uint64_t target_phys);
66 int kvm_qemu_destroy_memory_alias(uint64_t phys_start);
68 int kvm_arch_qemu_create_context(void);
70 void kvm_arch_save_regs(CPUState *env);
71 void kvm_arch_load_regs(CPUState *env);
72 void kvm_arch_load_mpstate(CPUState *env);
73 void kvm_arch_save_mpstate(CPUState *env);
74 int kvm_arch_qemu_init_env(CPUState *cenv);
75 void kvm_arch_pre_kvm_run(void *opaque, CPUState *env);
76 void kvm_arch_post_kvm_run(void *opaque, CPUState *env);
77 int kvm_arch_has_work(CPUState *env);
78 int kvm_arch_try_push_interrupts(void *opaque);
79 void kvm_arch_push_nmi(void *opaque);
80 void kvm_arch_update_regs_for_sipi(CPUState *env);
81 void kvm_arch_cpu_reset(CPUState *env);
83 struct kvm_guest_debug;
84 struct kvm_debug_exit_arch;
86 struct kvm_sw_breakpoint {
87 target_ulong pc;
88 target_ulong saved_insn;
89 int use_count;
90 TAILQ_ENTRY(kvm_sw_breakpoint) entry;
92 TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint);
94 extern struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
96 int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info);
97 struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(target_ulong pc);
98 int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
99 struct kvm_sw_breakpoint *bp);
100 int kvm_arch_remove_sw_breakpoint(CPUState *current_env,
101 struct kvm_sw_breakpoint *bp);
102 int kvm_arch_insert_hw_breakpoint(target_ulong addr,
103 target_ulong len, int type);
104 int kvm_arch_remove_hw_breakpoint(target_ulong addr,
105 target_ulong len, int type);
106 void kvm_arch_remove_all_hw_breakpoints(void);
107 void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg);
109 void qemu_kvm_aio_wait_start(void);
110 void qemu_kvm_aio_wait(void);
111 void qemu_kvm_aio_wait_end(void);
113 void qemu_kvm_notify_work(void);
115 void kvm_tpr_opt_setup(void);
116 void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write);
117 void kvm_tpr_vcpu_start(CPUState *env);
119 int qemu_kvm_get_dirty_pages(unsigned long phys_addr, void *buf);
120 int qemu_kvm_register_coalesced_mmio(target_phys_addr_t addr,
121 unsigned int size);
122 int qemu_kvm_unregister_coalesced_mmio(target_phys_addr_t addr,
123 unsigned int size);
125 int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
126 int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
128 int kvm_arch_init_irq_routing(void);
130 #ifdef USE_KVM_DEVICE_ASSIGNMENT
131 struct ioperm_data;
133 void kvm_ioperm(CPUState *env, void *data);
134 void kvm_add_ioperm_data(struct ioperm_data *data);
135 void kvm_remove_ioperm_data(unsigned long start_port, unsigned long num);
136 void kvm_arch_do_ioperm(void *_data);
137 #endif
139 #define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1))
140 #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8)
142 #ifdef USE_KVM
143 #include "libkvm-all.h"
144 #include "sys-queue.h"
146 extern int kvm_allowed;
147 extern int kvm_irqchip;
148 extern int kvm_pit;
149 extern int kvm_pit_reinject;
150 extern int kvm_nested;
151 extern kvm_context_t kvm_context;
153 struct ioperm_data {
154 unsigned long start_port;
155 unsigned long num;
156 int turn_on;
157 LIST_ENTRY(ioperm_data) entries;
160 void qemu_kvm_cpu_stop(CPUState *env);
161 int kvm_arch_halt(void *opaque, kvm_vcpu_context_t vcpu);
162 int handle_tpr_access(void *opaque, kvm_vcpu_context_t vcpu,
163 uint64_t rip, int is_write);
164 int kvm_has_sync_mmu(void);
166 #define kvm_enabled() (kvm_allowed)
167 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
168 #define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
169 void kvm_init_vcpu(CPUState *env);
170 void kvm_load_tsc(CPUState *env);
171 #else
172 #define kvm_enabled() (0)
173 #define kvm_nested 0
174 #define qemu_kvm_irqchip_in_kernel() (0)
175 #define qemu_kvm_pit_in_kernel() (0)
176 #define kvm_load_registers(env) do {} while(0)
177 #define kvm_save_registers(env) do {} while(0)
178 #define qemu_kvm_cpu_stop(env) do {} while(0)
179 static inline void kvm_init_vcpu(CPUState *env) { }
180 static inline void kvm_load_tsc(CPUState *env) {}
181 #endif
183 void kvm_mutex_unlock(void);
184 void kvm_mutex_lock(void);
186 static inline void kvm_sleep_begin(void)
188 if (kvm_enabled())
189 kvm_mutex_unlock();
192 static inline void kvm_sleep_end(void)
194 if (kvm_enabled())
195 kvm_mutex_lock();
198 static inline void kvm_set_phys_mem(target_phys_addr_t start_addr,
199 ram_addr_t size,
200 ram_addr_t phys_offset)
202 kvm_cpu_register_physical_memory(start_addr, size, phys_offset);
206 int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, target_phys_addr_t end_addr);
208 int kvm_log_start(target_phys_addr_t phys_addr, target_phys_addr_t len);
209 int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t len);
212 static inline int kvm_sync_vcpus(void) { return 0; }
214 static inline void kvm_arch_get_registers(CPUState *env)
216 kvm_save_registers(env);
217 kvm_save_mpstate(env);
220 static inline void kvm_arch_put_registers(CPUState *env)
222 kvm_load_registers(env);
223 kvm_load_mpstate(env);
226 static inline void cpu_synchronize_state(CPUState *env, int modified)
228 if (kvm_enabled()) {
229 if (modified)
230 kvm_arch_put_registers(env);
231 else
232 kvm_arch_get_registers(env);
236 uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
237 int reg);
240 static inline int kvm_set_migration_log(int enable)
242 return kvm_physical_memory_set_dirty_tracking(enable);
245 #endif