root / kvm.h @ ddde095c
History | View | Annotate | Download (3.9 kB)
1 | 05330448 | aliguori | /*
|
---|---|---|---|
2 | 05330448 | aliguori | * QEMU KVM support
|
3 | 05330448 | aliguori | *
|
4 | 05330448 | aliguori | * Copyright IBM, Corp. 2008
|
5 | 05330448 | aliguori | *
|
6 | 05330448 | aliguori | * Authors:
|
7 | 05330448 | aliguori | * Anthony Liguori <aliguori@us.ibm.com>
|
8 | 05330448 | aliguori | *
|
9 | 05330448 | aliguori | * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
10 | 05330448 | aliguori | * See the COPYING file in the top-level directory.
|
11 | 05330448 | aliguori | *
|
12 | 05330448 | aliguori | */
|
13 | 05330448 | aliguori | |
14 | 05330448 | aliguori | #ifndef QEMU_KVM_H
|
15 | 05330448 | aliguori | #define QEMU_KVM_H
|
16 | 05330448 | aliguori | |
17 | 05330448 | aliguori | #include "config.h" |
18 | e22a25c9 | aliguori | #include "sys-queue.h" |
19 | 05330448 | aliguori | |
20 | 05330448 | aliguori | #ifdef CONFIG_KVM
|
21 | 05330448 | aliguori | extern int kvm_allowed; |
22 | 05330448 | aliguori | |
23 | 05330448 | aliguori | #define kvm_enabled() (kvm_allowed)
|
24 | 05330448 | aliguori | #else
|
25 | 05330448 | aliguori | #define kvm_enabled() (0) |
26 | 05330448 | aliguori | #endif
|
27 | 05330448 | aliguori | |
28 | 05330448 | aliguori | struct kvm_run;
|
29 | 05330448 | aliguori | |
30 | 05330448 | aliguori | /* external API */
|
31 | 05330448 | aliguori | |
32 | 05330448 | aliguori | int kvm_init(int smp_cpus); |
33 | 05330448 | aliguori | |
34 | 05330448 | aliguori | int kvm_init_vcpu(CPUState *env);
|
35 | 05330448 | aliguori | |
36 | 05330448 | aliguori | int kvm_cpu_exec(CPUState *env);
|
37 | 05330448 | aliguori | |
38 | 05330448 | aliguori | void kvm_set_phys_mem(target_phys_addr_t start_addr,
|
39 | 05330448 | aliguori | ram_addr_t size, |
40 | 05330448 | aliguori | ram_addr_t phys_offset); |
41 | 05330448 | aliguori | |
42 | 151f7749 | Jan Kiszka | int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
|
43 | 151f7749 | Jan Kiszka | target_phys_addr_t end_addr); |
44 | 5832d1f2 | aliguori | |
45 | d3f8d37f | aliguori | int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size);
|
46 | d3f8d37f | aliguori | int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size);
|
47 | 4495d6a7 | Jan Kiszka | int kvm_set_migration_log(int enable); |
48 | bd322087 | aliguori | |
49 | bd322087 | aliguori | int kvm_has_sync_mmu(void); |
50 | bd322087 | aliguori | |
51 | 6f0437e8 | Jan Kiszka | void kvm_setup_guest_memory(void *start, size_t size); |
52 | 6f0437e8 | Jan Kiszka | |
53 | f65ed4c1 | aliguori | int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
|
54 | f65ed4c1 | aliguori | int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size);
|
55 | f65ed4c1 | aliguori | |
56 | e22a25c9 | aliguori | int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
|
57 | e22a25c9 | aliguori | target_ulong len, int type);
|
58 | e22a25c9 | aliguori | int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
|
59 | e22a25c9 | aliguori | target_ulong len, int type);
|
60 | e22a25c9 | aliguori | void kvm_remove_all_breakpoints(CPUState *current_env);
|
61 | e22a25c9 | aliguori | int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap); |
62 | e22a25c9 | aliguori | |
63 | 6f725c13 | Glauber Costa | int kvm_pit_in_kernel(void); |
64 | 6f725c13 | Glauber Costa | int kvm_irqchip_in_kernel(void); |
65 | 6f725c13 | Glauber Costa | |
66 | 05330448 | aliguori | /* internal API */
|
67 | 05330448 | aliguori | |
68 | 05330448 | aliguori | struct KVMState;
|
69 | 05330448 | aliguori | typedef struct KVMState KVMState; |
70 | 05330448 | aliguori | |
71 | 984b5181 | aliguori | int kvm_ioctl(KVMState *s, int type, ...); |
72 | 05330448 | aliguori | |
73 | 984b5181 | aliguori | int kvm_vm_ioctl(KVMState *s, int type, ...); |
74 | 05330448 | aliguori | |
75 | 984b5181 | aliguori | int kvm_vcpu_ioctl(CPUState *env, int type, ...); |
76 | 05330448 | aliguori | |
77 | f8d926e9 | Jan Kiszka | int kvm_get_mp_state(CPUState *env);
|
78 | f8d926e9 | Jan Kiszka | int kvm_put_mp_state(CPUState *env);
|
79 | f8d926e9 | Jan Kiszka | |
80 | 05330448 | aliguori | /* Arch specific hooks */
|
81 | 05330448 | aliguori | |
82 | 05330448 | aliguori | int kvm_arch_post_run(CPUState *env, struct kvm_run *run); |
83 | 05330448 | aliguori | |
84 | 05330448 | aliguori | int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run); |
85 | 05330448 | aliguori | |
86 | 05330448 | aliguori | int kvm_arch_pre_run(CPUState *env, struct kvm_run *run); |
87 | 05330448 | aliguori | |
88 | 05330448 | aliguori | int kvm_arch_get_registers(CPUState *env);
|
89 | 05330448 | aliguori | |
90 | 05330448 | aliguori | int kvm_arch_put_registers(CPUState *env);
|
91 | 05330448 | aliguori | |
92 | 05330448 | aliguori | int kvm_arch_init(KVMState *s, int smp_cpus); |
93 | 05330448 | aliguori | |
94 | 05330448 | aliguori | int kvm_arch_init_vcpu(CPUState *env);
|
95 | 05330448 | aliguori | |
96 | e22a25c9 | aliguori | struct kvm_guest_debug;
|
97 | e22a25c9 | aliguori | struct kvm_debug_exit_arch;
|
98 | e22a25c9 | aliguori | |
99 | e22a25c9 | aliguori | struct kvm_sw_breakpoint {
|
100 | e22a25c9 | aliguori | target_ulong pc; |
101 | e22a25c9 | aliguori | target_ulong saved_insn; |
102 | e22a25c9 | aliguori | int use_count;
|
103 | e22a25c9 | aliguori | TAILQ_ENTRY(kvm_sw_breakpoint) entry; |
104 | e22a25c9 | aliguori | }; |
105 | e22a25c9 | aliguori | |
106 | e22a25c9 | aliguori | TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint); |
107 | e22a25c9 | aliguori | |
108 | e22a25c9 | aliguori | int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info); |
109 | e22a25c9 | aliguori | |
110 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
|
111 | e22a25c9 | aliguori | target_ulong pc); |
112 | e22a25c9 | aliguori | |
113 | e22a25c9 | aliguori | int kvm_sw_breakpoints_active(CPUState *env);
|
114 | e22a25c9 | aliguori | |
115 | e22a25c9 | aliguori | int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
|
116 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp);
|
117 | e22a25c9 | aliguori | int kvm_arch_remove_sw_breakpoint(CPUState *current_env,
|
118 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp);
|
119 | e22a25c9 | aliguori | int kvm_arch_insert_hw_breakpoint(target_ulong addr,
|
120 | e22a25c9 | aliguori | target_ulong len, int type);
|
121 | e22a25c9 | aliguori | int kvm_arch_remove_hw_breakpoint(target_ulong addr,
|
122 | e22a25c9 | aliguori | target_ulong len, int type);
|
123 | e22a25c9 | aliguori | void kvm_arch_remove_all_hw_breakpoints(void); |
124 | e22a25c9 | aliguori | |
125 | e22a25c9 | aliguori | void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg); |
126 | e22a25c9 | aliguori | |
127 | ad7b8b33 | Anthony Liguori | int kvm_check_extension(KVMState *s, unsigned int extension); |
128 | ad7b8b33 | Anthony Liguori | |
129 | b827df58 | Avi Kivity | uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, |
130 | b827df58 | Avi Kivity | int reg);
|
131 | b827df58 | Avi Kivity | |
132 | e22a25c9 | aliguori | /* generic hooks - to be moved/refactored once there are more users */
|
133 | e22a25c9 | aliguori | |
134 | e22a25c9 | aliguori | static inline void cpu_synchronize_state(CPUState *env, int modified) |
135 | e22a25c9 | aliguori | { |
136 | e22a25c9 | aliguori | if (kvm_enabled()) {
|
137 | e22a25c9 | aliguori | if (modified)
|
138 | e22a25c9 | aliguori | kvm_arch_put_registers(env); |
139 | e22a25c9 | aliguori | else
|
140 | e22a25c9 | aliguori | kvm_arch_get_registers(env); |
141 | e22a25c9 | aliguori | } |
142 | e22a25c9 | aliguori | } |
143 | e22a25c9 | aliguori | |
144 | 05330448 | aliguori | #endif |