root / kvm.h @ 636aa70a
History | View | Annotate | Download (3.8 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 | 05330448 | aliguori | /* internal API */
|
64 | 05330448 | aliguori | |
65 | 05330448 | aliguori | struct KVMState;
|
66 | 05330448 | aliguori | typedef struct KVMState KVMState; |
67 | 05330448 | aliguori | |
68 | 984b5181 | aliguori | int kvm_ioctl(KVMState *s, int type, ...); |
69 | 05330448 | aliguori | |
70 | 984b5181 | aliguori | int kvm_vm_ioctl(KVMState *s, int type, ...); |
71 | 05330448 | aliguori | |
72 | 984b5181 | aliguori | int kvm_vcpu_ioctl(CPUState *env, int type, ...); |
73 | 05330448 | aliguori | |
74 | f8d926e9 | Jan Kiszka | int kvm_get_mp_state(CPUState *env);
|
75 | f8d926e9 | Jan Kiszka | int kvm_put_mp_state(CPUState *env);
|
76 | f8d926e9 | Jan Kiszka | |
77 | 05330448 | aliguori | /* Arch specific hooks */
|
78 | 05330448 | aliguori | |
79 | 05330448 | aliguori | int kvm_arch_post_run(CPUState *env, struct kvm_run *run); |
80 | 05330448 | aliguori | |
81 | 05330448 | aliguori | int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run); |
82 | 05330448 | aliguori | |
83 | 05330448 | aliguori | int kvm_arch_pre_run(CPUState *env, struct kvm_run *run); |
84 | 05330448 | aliguori | |
85 | 05330448 | aliguori | int kvm_arch_get_registers(CPUState *env);
|
86 | 05330448 | aliguori | |
87 | 05330448 | aliguori | int kvm_arch_put_registers(CPUState *env);
|
88 | 05330448 | aliguori | |
89 | 05330448 | aliguori | int kvm_arch_init(KVMState *s, int smp_cpus); |
90 | 05330448 | aliguori | |
91 | 05330448 | aliguori | int kvm_arch_init_vcpu(CPUState *env);
|
92 | 05330448 | aliguori | |
93 | e22a25c9 | aliguori | struct kvm_guest_debug;
|
94 | e22a25c9 | aliguori | struct kvm_debug_exit_arch;
|
95 | e22a25c9 | aliguori | |
96 | e22a25c9 | aliguori | struct kvm_sw_breakpoint {
|
97 | e22a25c9 | aliguori | target_ulong pc; |
98 | e22a25c9 | aliguori | target_ulong saved_insn; |
99 | e22a25c9 | aliguori | int use_count;
|
100 | e22a25c9 | aliguori | TAILQ_ENTRY(kvm_sw_breakpoint) entry; |
101 | e22a25c9 | aliguori | }; |
102 | e22a25c9 | aliguori | |
103 | e22a25c9 | aliguori | TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint); |
104 | e22a25c9 | aliguori | |
105 | e22a25c9 | aliguori | int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info); |
106 | e22a25c9 | aliguori | |
107 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
|
108 | e22a25c9 | aliguori | target_ulong pc); |
109 | e22a25c9 | aliguori | |
110 | e22a25c9 | aliguori | int kvm_sw_breakpoints_active(CPUState *env);
|
111 | e22a25c9 | aliguori | |
112 | e22a25c9 | aliguori | int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
|
113 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp);
|
114 | e22a25c9 | aliguori | int kvm_arch_remove_sw_breakpoint(CPUState *current_env,
|
115 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp);
|
116 | e22a25c9 | aliguori | int kvm_arch_insert_hw_breakpoint(target_ulong addr,
|
117 | e22a25c9 | aliguori | target_ulong len, int type);
|
118 | e22a25c9 | aliguori | int kvm_arch_remove_hw_breakpoint(target_ulong addr,
|
119 | e22a25c9 | aliguori | target_ulong len, int type);
|
120 | e22a25c9 | aliguori | void kvm_arch_remove_all_hw_breakpoints(void); |
121 | e22a25c9 | aliguori | |
122 | e22a25c9 | aliguori | void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg); |
123 | e22a25c9 | aliguori | |
124 | ad7b8b33 | Anthony Liguori | int kvm_check_extension(KVMState *s, unsigned int extension); |
125 | ad7b8b33 | Anthony Liguori | |
126 | b827df58 | Avi Kivity | uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, |
127 | b827df58 | Avi Kivity | int reg);
|
128 | b827df58 | Avi Kivity | |
129 | e22a25c9 | aliguori | /* generic hooks - to be moved/refactored once there are more users */
|
130 | e22a25c9 | aliguori | |
131 | e22a25c9 | aliguori | static inline void cpu_synchronize_state(CPUState *env, int modified) |
132 | e22a25c9 | aliguori | { |
133 | e22a25c9 | aliguori | if (kvm_enabled()) {
|
134 | e22a25c9 | aliguori | if (modified)
|
135 | e22a25c9 | aliguori | kvm_arch_put_registers(env); |
136 | e22a25c9 | aliguori | else
|
137 | e22a25c9 | aliguori | kvm_arch_get_registers(env); |
138 | e22a25c9 | aliguori | } |
139 | e22a25c9 | aliguori | } |
140 | e22a25c9 | aliguori | |
141 | 05330448 | aliguori | #endif |