root / kvm.h @ e3b42536
History | View | Annotate | Download (3.7 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 | f5d6f51b | aliguori | int kvm_sync_vcpus(void); |
36 | 05330448 | aliguori | |
37 | 05330448 | aliguori | int kvm_cpu_exec(CPUState *env);
|
38 | 05330448 | aliguori | |
39 | 05330448 | aliguori | void kvm_set_phys_mem(target_phys_addr_t start_addr,
|
40 | 05330448 | aliguori | ram_addr_t size, |
41 | 05330448 | aliguori | ram_addr_t phys_offset); |
42 | 05330448 | aliguori | |
43 | d3f8d37f | aliguori | void kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
|
44 | d3f8d37f | aliguori | target_phys_addr_t end_addr); |
45 | 5832d1f2 | aliguori | |
46 | d3f8d37f | aliguori | int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size);
|
47 | d3f8d37f | aliguori | int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size);
|
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 | 05330448 | aliguori | /* Arch specific hooks */
|
75 | 05330448 | aliguori | |
76 | 05330448 | aliguori | int kvm_arch_post_run(CPUState *env, struct kvm_run *run); |
77 | 05330448 | aliguori | |
78 | 05330448 | aliguori | int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run); |
79 | 05330448 | aliguori | |
80 | 05330448 | aliguori | int kvm_arch_pre_run(CPUState *env, struct kvm_run *run); |
81 | 05330448 | aliguori | |
82 | 05330448 | aliguori | int kvm_arch_get_registers(CPUState *env);
|
83 | 05330448 | aliguori | |
84 | 05330448 | aliguori | int kvm_arch_put_registers(CPUState *env);
|
85 | 05330448 | aliguori | |
86 | 05330448 | aliguori | int kvm_arch_init(KVMState *s, int smp_cpus); |
87 | 05330448 | aliguori | |
88 | 05330448 | aliguori | int kvm_arch_init_vcpu(CPUState *env);
|
89 | 05330448 | aliguori | |
90 | e22a25c9 | aliguori | struct kvm_guest_debug;
|
91 | e22a25c9 | aliguori | struct kvm_debug_exit_arch;
|
92 | e22a25c9 | aliguori | |
93 | e22a25c9 | aliguori | struct kvm_sw_breakpoint {
|
94 | e22a25c9 | aliguori | target_ulong pc; |
95 | e22a25c9 | aliguori | target_ulong saved_insn; |
96 | e22a25c9 | aliguori | int use_count;
|
97 | e22a25c9 | aliguori | TAILQ_ENTRY(kvm_sw_breakpoint) entry; |
98 | e22a25c9 | aliguori | }; |
99 | e22a25c9 | aliguori | |
100 | e22a25c9 | aliguori | TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint); |
101 | e22a25c9 | aliguori | |
102 | e22a25c9 | aliguori | int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info); |
103 | e22a25c9 | aliguori | |
104 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
|
105 | e22a25c9 | aliguori | target_ulong pc); |
106 | e22a25c9 | aliguori | |
107 | e22a25c9 | aliguori | int kvm_sw_breakpoints_active(CPUState *env);
|
108 | e22a25c9 | aliguori | |
109 | e22a25c9 | aliguori | int kvm_arch_insert_sw_breakpoint(CPUState *current_env,
|
110 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp);
|
111 | e22a25c9 | aliguori | int kvm_arch_remove_sw_breakpoint(CPUState *current_env,
|
112 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp);
|
113 | e22a25c9 | aliguori | int kvm_arch_insert_hw_breakpoint(target_ulong addr,
|
114 | e22a25c9 | aliguori | target_ulong len, int type);
|
115 | e22a25c9 | aliguori | int kvm_arch_remove_hw_breakpoint(target_ulong addr,
|
116 | e22a25c9 | aliguori | target_ulong len, int type);
|
117 | e22a25c9 | aliguori | void kvm_arch_remove_all_hw_breakpoints(void); |
118 | e22a25c9 | aliguori | |
119 | e22a25c9 | aliguori | void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg); |
120 | e22a25c9 | aliguori | |
121 | ad7b8b33 | Anthony Liguori | int kvm_check_extension(KVMState *s, unsigned int extension); |
122 | ad7b8b33 | Anthony Liguori | |
123 | b827df58 | Avi Kivity | uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, |
124 | b827df58 | Avi Kivity | int reg);
|
125 | b827df58 | Avi Kivity | |
126 | e22a25c9 | aliguori | /* generic hooks - to be moved/refactored once there are more users */
|
127 | e22a25c9 | aliguori | |
128 | e22a25c9 | aliguori | static inline void cpu_synchronize_state(CPUState *env, int modified) |
129 | e22a25c9 | aliguori | { |
130 | e22a25c9 | aliguori | if (kvm_enabled()) {
|
131 | e22a25c9 | aliguori | if (modified)
|
132 | e22a25c9 | aliguori | kvm_arch_put_registers(env); |
133 | e22a25c9 | aliguori | else
|
134 | e22a25c9 | aliguori | kvm_arch_get_registers(env); |
135 | e22a25c9 | aliguori | } |
136 | e22a25c9 | aliguori | } |
137 | e22a25c9 | aliguori | |
138 | 05330448 | aliguori | #endif |