]> git.proxmox.com Git - qemu.git/blame - kvm.h
qcow2: Reject too large header extensions
[qemu.git] / kvm.h
CommitLineData
05330448
AL
1/*
2 * QEMU KVM support
3 *
4 * Copyright IBM, Corp. 2008
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef QEMU_KVM_H
15#define QEMU_KVM_H
16
ca821806 17#include <errno.h>
1c14f162 18#include "config-host.h"
72cf2d4f 19#include "qemu-queue.h"
05330448 20
ca821806
MT
21#ifdef CONFIG_KVM
22#include <linux/kvm.h>
23#endif
05330448 24
ca821806 25extern int kvm_allowed;
3d4b2649 26extern bool kvm_kernel_irqchip;
98c8573e
PB
27
28#if defined CONFIG_KVM || !defined NEED_CPU_H
3d4b2649
JK
29#define kvm_enabled() (kvm_allowed)
30#define kvm_irqchip_in_kernel() (kvm_kernel_irqchip)
05330448 31#else
3d4b2649
JK
32#define kvm_enabled() (0)
33#define kvm_irqchip_in_kernel() (false)
05330448
AL
34#endif
35
36struct kvm_run;
680c1c6f 37struct kvm_lapic_state;
05330448 38
94a8d39a
JK
39typedef struct KVMCapabilityInfo {
40 const char *name;
41 int value;
42} KVMCapabilityInfo;
43
44#define KVM_CAP_INFO(CAP) { "KVM_CAP_" stringify(CAP), KVM_CAP_##CAP }
45#define KVM_CAP_LAST_INFO { NULL, 0 }
46
05330448
AL
47/* external API */
48
cad1e282 49int kvm_init(void);
05330448 50
00a1555e
PB
51int kvm_has_sync_mmu(void);
52int kvm_has_vcpu_events(void);
53int kvm_has_robust_singlestep(void);
ff44f1a3 54int kvm_has_debugregs(void);
f1665b21
SY
55int kvm_has_xsave(void);
56int kvm_has_xcrs(void);
d2f2b8a7 57int kvm_has_many_ioeventfds(void);
84b058d7 58int kvm_has_gsi_routing(void);
00a1555e 59
9b5b76d4
JK
60int kvm_allows_irq0_override(void);
61
1c14f162 62#ifdef NEED_CPU_H
05330448
AL
63int kvm_init_vcpu(CPUState *env);
64
65int kvm_cpu_exec(CPUState *env);
66
b3755a91 67#if !defined(CONFIG_USER_ONLY)
6f0437e8
JK
68void kvm_setup_guest_memory(void *start, size_t size);
69
c227f099
AL
70int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
71int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
62a2744c 72void kvm_flush_coalesced_mmio_buffer(void);
b3755a91 73#endif
f65ed4c1 74
e22a25c9
AL
75int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
76 target_ulong len, int type);
77int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
78 target_ulong len, int type);
79void kvm_remove_all_breakpoints(CPUState *current_env);
80int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap);
20c20526 81#ifndef _WIN32
cc84de95 82int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset);
20c20526 83#endif
e22a25c9 84
6f725c13 85int kvm_pit_in_kernel(void);
6f725c13 86
a1b87fe0
JK
87int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr);
88int kvm_on_sigbus(int code, void *addr);
89
05330448
AL
90/* internal API */
91
92struct KVMState;
93typedef struct KVMState KVMState;
6a7af8cb 94extern KVMState *kvm_state;
05330448 95
984b5181 96int kvm_ioctl(KVMState *s, int type, ...);
05330448 97
984b5181 98int kvm_vm_ioctl(KVMState *s, int type, ...);
05330448 99
984b5181 100int kvm_vcpu_ioctl(CPUState *env, int type, ...);
05330448
AL
101
102/* Arch specific hooks */
103
94a8d39a
JK
104extern const KVMCapabilityInfo kvm_arch_required_capabilities[];
105
7a39fe58
JK
106void kvm_arch_pre_run(CPUState *env, struct kvm_run *run);
107void kvm_arch_post_run(CPUState *env, struct kvm_run *run);
05330448
AL
108
109int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run);
110
99036865 111int kvm_arch_process_async_events(CPUState *env);
0af691d7 112
05330448
AL
113int kvm_arch_get_registers(CPUState *env);
114
ea375f9a
JK
115/* state subset only touched by the VCPU itself during runtime */
116#define KVM_PUT_RUNTIME_STATE 1
117/* state subset modified during VCPU reset */
118#define KVM_PUT_RESET_STATE 2
119/* full state set, modified during initialization or on vmload */
120#define KVM_PUT_FULL_STATE 3
121
122int kvm_arch_put_registers(CPUState *env, int level);
05330448 123
cad1e282 124int kvm_arch_init(KVMState *s);
05330448
AL
125
126int kvm_arch_init_vcpu(CPUState *env);
127
caa5af0f
JK
128void kvm_arch_reset_vcpu(CPUState *env);
129
a1b87fe0
JK
130int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr);
131int kvm_arch_on_sigbus(int code, void *addr);
c0532a76 132
84b058d7
JK
133void kvm_arch_init_irq_routing(KVMState *s);
134
135int kvm_irqchip_set_irq(KVMState *s, int irq, int level);
136
137void kvm_irqchip_add_route(KVMState *s, int gsi, int irqchip, int pin);
138int kvm_irqchip_commit_routes(KVMState *s);
139
680c1c6f
JK
140void kvm_put_apic_state(DeviceState *d, struct kvm_lapic_state *kapic);
141void kvm_get_apic_state(DeviceState *d, struct kvm_lapic_state *kapic);
142
e22a25c9
AL
143struct kvm_guest_debug;
144struct kvm_debug_exit_arch;
145
146struct kvm_sw_breakpoint {
147 target_ulong pc;
148 target_ulong saved_insn;
149 int use_count;
72cf2d4f 150 QTAILQ_ENTRY(kvm_sw_breakpoint) entry;
e22a25c9
AL
151};
152
72cf2d4f 153QTAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint);
e22a25c9 154
e22a25c9
AL
155struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
156 target_ulong pc);
157
158int kvm_sw_breakpoints_active(CPUState *env);
159
160int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
161 struct kvm_sw_breakpoint *bp);
162int kvm_arch_remove_sw_breakpoint(CPUState *current_env,
163 struct kvm_sw_breakpoint *bp);
164int kvm_arch_insert_hw_breakpoint(target_ulong addr,
165 target_ulong len, int type);
166int kvm_arch_remove_hw_breakpoint(target_ulong addr,
167 target_ulong len, int type);
168void kvm_arch_remove_all_hw_breakpoints(void);
169
170void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg);
171
4513d923
GN
172bool kvm_arch_stop_on_emulation_error(CPUState *env);
173
ad7b8b33
AL
174int kvm_check_extension(KVMState *s, unsigned int extension);
175
ba9bc59e 176uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
c958a8bd 177 uint32_t index, int reg);
4c0960c0 178void kvm_cpu_synchronize_state(CPUState *env);
ea375f9a
JK
179void kvm_cpu_synchronize_post_reset(CPUState *env);
180void kvm_cpu_synchronize_post_init(CPUState *env);
b827df58 181
e22a25c9
AL
182/* generic hooks - to be moved/refactored once there are more users */
183
4c0960c0 184static inline void cpu_synchronize_state(CPUState *env)
e22a25c9
AL
185{
186 if (kvm_enabled()) {
4c0960c0 187 kvm_cpu_synchronize_state(env);
e22a25c9
AL
188 }
189}
190
ea375f9a
JK
191static inline void cpu_synchronize_post_reset(CPUState *env)
192{
193 if (kvm_enabled()) {
194 kvm_cpu_synchronize_post_reset(env);
195 }
196}
197
198static inline void cpu_synchronize_post_init(CPUState *env)
199{
200 if (kvm_enabled()) {
201 kvm_cpu_synchronize_post_init(env);
202 }
203}
ca821806 204
983dfc3b
HY
205
206#if !defined(CONFIG_USER_ONLY)
9f213ed9
AK
207int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
208 target_phys_addr_t *phys_addr);
983dfc3b
HY
209#endif
210
ca821806 211#endif
44f1a3d8 212int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign);
ca821806 213
98c8573e 214int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign);
05330448 215#endif