root / kvm-all.c @ 452e4751
History | View | Annotate | Download (27.1 kB)
1 | 05330448 | aliguori | /*
|
---|---|---|---|
2 | 05330448 | aliguori | * QEMU KVM support
|
3 | 05330448 | aliguori | *
|
4 | 05330448 | aliguori | * Copyright IBM, Corp. 2008
|
5 | 5832d1f2 | aliguori | * Red Hat, Inc. 2008
|
6 | 05330448 | aliguori | *
|
7 | 05330448 | aliguori | * Authors:
|
8 | 05330448 | aliguori | * Anthony Liguori <aliguori@us.ibm.com>
|
9 | 5832d1f2 | aliguori | * Glauber Costa <gcosta@redhat.com>
|
10 | 05330448 | aliguori | *
|
11 | 05330448 | aliguori | * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
12 | 05330448 | aliguori | * See the COPYING file in the top-level directory.
|
13 | 05330448 | aliguori | *
|
14 | 05330448 | aliguori | */
|
15 | 05330448 | aliguori | |
16 | 05330448 | aliguori | #include <sys/types.h> |
17 | 05330448 | aliguori | #include <sys/ioctl.h> |
18 | 05330448 | aliguori | #include <sys/mman.h> |
19 | 984b5181 | aliguori | #include <stdarg.h> |
20 | 05330448 | aliguori | |
21 | 05330448 | aliguori | #include <linux/kvm.h> |
22 | 05330448 | aliguori | |
23 | 05330448 | aliguori | #include "qemu-common.h" |
24 | 05330448 | aliguori | #include "sysemu.h" |
25 | d33a1810 | Jan Kiszka | #include "hw/hw.h" |
26 | e22a25c9 | aliguori | #include "gdbstub.h" |
27 | 05330448 | aliguori | #include "kvm.h" |
28 | 05330448 | aliguori | |
29 | f65ed4c1 | aliguori | /* KVM uses PAGE_SIZE in it's definition of COALESCED_MMIO_MAX */
|
30 | f65ed4c1 | aliguori | #define PAGE_SIZE TARGET_PAGE_SIZE
|
31 | f65ed4c1 | aliguori | |
32 | 05330448 | aliguori | //#define DEBUG_KVM
|
33 | 05330448 | aliguori | |
34 | 05330448 | aliguori | #ifdef DEBUG_KVM
|
35 | 05330448 | aliguori | #define dprintf(fmt, ...) \
|
36 | 05330448 | aliguori | do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) |
37 | 05330448 | aliguori | #else
|
38 | 05330448 | aliguori | #define dprintf(fmt, ...) \
|
39 | 05330448 | aliguori | do { } while (0) |
40 | 05330448 | aliguori | #endif
|
41 | 05330448 | aliguori | |
42 | 34fc643f | aliguori | typedef struct KVMSlot |
43 | 34fc643f | aliguori | { |
44 | 34fc643f | aliguori | target_phys_addr_t start_addr; |
45 | 34fc643f | aliguori | ram_addr_t memory_size; |
46 | 34fc643f | aliguori | ram_addr_t phys_offset; |
47 | 34fc643f | aliguori | int slot;
|
48 | 34fc643f | aliguori | int flags;
|
49 | 34fc643f | aliguori | } KVMSlot; |
50 | 05330448 | aliguori | |
51 | 5832d1f2 | aliguori | typedef struct kvm_dirty_log KVMDirtyLog; |
52 | 5832d1f2 | aliguori | |
53 | 05330448 | aliguori | int kvm_allowed = 0; |
54 | 05330448 | aliguori | |
55 | 05330448 | aliguori | struct KVMState
|
56 | 05330448 | aliguori | { |
57 | 05330448 | aliguori | KVMSlot slots[32];
|
58 | 05330448 | aliguori | int fd;
|
59 | 05330448 | aliguori | int vmfd;
|
60 | f65ed4c1 | aliguori | int coalesced_mmio;
|
61 | e69917e2 | Jan Kiszka | int broken_set_mem_region;
|
62 | 4495d6a7 | Jan Kiszka | int migration_log;
|
63 | e22a25c9 | aliguori | #ifdef KVM_CAP_SET_GUEST_DEBUG
|
64 | e22a25c9 | aliguori | struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
|
65 | e22a25c9 | aliguori | #endif
|
66 | 05330448 | aliguori | }; |
67 | 05330448 | aliguori | |
68 | 05330448 | aliguori | static KVMState *kvm_state;
|
69 | 05330448 | aliguori | |
70 | 05330448 | aliguori | static KVMSlot *kvm_alloc_slot(KVMState *s)
|
71 | 05330448 | aliguori | { |
72 | 05330448 | aliguori | int i;
|
73 | 05330448 | aliguori | |
74 | 05330448 | aliguori | for (i = 0; i < ARRAY_SIZE(s->slots); i++) { |
75 | 62d60e8c | aliguori | /* KVM private memory slots */
|
76 | 62d60e8c | aliguori | if (i >= 8 && i < 12) |
77 | 62d60e8c | aliguori | continue;
|
78 | 05330448 | aliguori | if (s->slots[i].memory_size == 0) |
79 | 05330448 | aliguori | return &s->slots[i];
|
80 | 05330448 | aliguori | } |
81 | 05330448 | aliguori | |
82 | d3f8d37f | aliguori | fprintf(stderr, "%s: no free slot available\n", __func__);
|
83 | d3f8d37f | aliguori | abort(); |
84 | d3f8d37f | aliguori | } |
85 | d3f8d37f | aliguori | |
86 | d3f8d37f | aliguori | static KVMSlot *kvm_lookup_matching_slot(KVMState *s,
|
87 | d3f8d37f | aliguori | target_phys_addr_t start_addr, |
88 | d3f8d37f | aliguori | target_phys_addr_t end_addr) |
89 | d3f8d37f | aliguori | { |
90 | d3f8d37f | aliguori | int i;
|
91 | d3f8d37f | aliguori | |
92 | d3f8d37f | aliguori | for (i = 0; i < ARRAY_SIZE(s->slots); i++) { |
93 | d3f8d37f | aliguori | KVMSlot *mem = &s->slots[i]; |
94 | d3f8d37f | aliguori | |
95 | d3f8d37f | aliguori | if (start_addr == mem->start_addr &&
|
96 | d3f8d37f | aliguori | end_addr == mem->start_addr + mem->memory_size) { |
97 | d3f8d37f | aliguori | return mem;
|
98 | d3f8d37f | aliguori | } |
99 | d3f8d37f | aliguori | } |
100 | d3f8d37f | aliguori | |
101 | 05330448 | aliguori | return NULL; |
102 | 05330448 | aliguori | } |
103 | 05330448 | aliguori | |
104 | 6152e2ae | aliguori | /*
|
105 | 6152e2ae | aliguori | * Find overlapping slot with lowest start address
|
106 | 6152e2ae | aliguori | */
|
107 | 6152e2ae | aliguori | static KVMSlot *kvm_lookup_overlapping_slot(KVMState *s,
|
108 | 6152e2ae | aliguori | target_phys_addr_t start_addr, |
109 | 6152e2ae | aliguori | target_phys_addr_t end_addr) |
110 | 05330448 | aliguori | { |
111 | 6152e2ae | aliguori | KVMSlot *found = NULL;
|
112 | 05330448 | aliguori | int i;
|
113 | 05330448 | aliguori | |
114 | 05330448 | aliguori | for (i = 0; i < ARRAY_SIZE(s->slots); i++) { |
115 | 05330448 | aliguori | KVMSlot *mem = &s->slots[i]; |
116 | 05330448 | aliguori | |
117 | 6152e2ae | aliguori | if (mem->memory_size == 0 || |
118 | 6152e2ae | aliguori | (found && found->start_addr < mem->start_addr)) { |
119 | 6152e2ae | aliguori | continue;
|
120 | 6152e2ae | aliguori | } |
121 | 6152e2ae | aliguori | |
122 | 6152e2ae | aliguori | if (end_addr > mem->start_addr &&
|
123 | 6152e2ae | aliguori | start_addr < mem->start_addr + mem->memory_size) { |
124 | 6152e2ae | aliguori | found = mem; |
125 | 6152e2ae | aliguori | } |
126 | 05330448 | aliguori | } |
127 | 05330448 | aliguori | |
128 | 6152e2ae | aliguori | return found;
|
129 | 05330448 | aliguori | } |
130 | 05330448 | aliguori | |
131 | 5832d1f2 | aliguori | static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot) |
132 | 5832d1f2 | aliguori | { |
133 | 5832d1f2 | aliguori | struct kvm_userspace_memory_region mem;
|
134 | 5832d1f2 | aliguori | |
135 | 5832d1f2 | aliguori | mem.slot = slot->slot; |
136 | 5832d1f2 | aliguori | mem.guest_phys_addr = slot->start_addr; |
137 | 5832d1f2 | aliguori | mem.memory_size = slot->memory_size; |
138 | 5579c7f3 | pbrook | mem.userspace_addr = (unsigned long)qemu_get_ram_ptr(slot->phys_offset); |
139 | 5832d1f2 | aliguori | mem.flags = slot->flags; |
140 | 4495d6a7 | Jan Kiszka | if (s->migration_log) {
|
141 | 4495d6a7 | Jan Kiszka | mem.flags |= KVM_MEM_LOG_DIRTY_PAGES; |
142 | 4495d6a7 | Jan Kiszka | } |
143 | 5832d1f2 | aliguori | return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem);
|
144 | 5832d1f2 | aliguori | } |
145 | 5832d1f2 | aliguori | |
146 | 8d2ba1fb | Jan Kiszka | static void kvm_reset_vcpu(void *opaque) |
147 | 8d2ba1fb | Jan Kiszka | { |
148 | 8d2ba1fb | Jan Kiszka | CPUState *env = opaque; |
149 | 8d2ba1fb | Jan Kiszka | |
150 | 8d2ba1fb | Jan Kiszka | if (kvm_arch_put_registers(env)) {
|
151 | 8d2ba1fb | Jan Kiszka | fprintf(stderr, "Fatal: kvm vcpu reset failed\n");
|
152 | 8d2ba1fb | Jan Kiszka | abort(); |
153 | 8d2ba1fb | Jan Kiszka | } |
154 | 8d2ba1fb | Jan Kiszka | } |
155 | 5832d1f2 | aliguori | |
156 | 452e4751 | Glauber Costa | static void on_vcpu(CPUState *env, void (*func)(void *data), void *data) |
157 | 452e4751 | Glauber Costa | { |
158 | 452e4751 | Glauber Costa | if (env == cpu_single_env) {
|
159 | 452e4751 | Glauber Costa | func(data); |
160 | 452e4751 | Glauber Costa | return;
|
161 | 452e4751 | Glauber Costa | } |
162 | 452e4751 | Glauber Costa | abort(); |
163 | 452e4751 | Glauber Costa | } |
164 | 452e4751 | Glauber Costa | |
165 | 05330448 | aliguori | int kvm_init_vcpu(CPUState *env)
|
166 | 05330448 | aliguori | { |
167 | 05330448 | aliguori | KVMState *s = kvm_state; |
168 | 05330448 | aliguori | long mmap_size;
|
169 | 05330448 | aliguori | int ret;
|
170 | 05330448 | aliguori | |
171 | 05330448 | aliguori | dprintf("kvm_init_vcpu\n");
|
172 | 05330448 | aliguori | |
173 | 984b5181 | aliguori | ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index); |
174 | 05330448 | aliguori | if (ret < 0) { |
175 | 05330448 | aliguori | dprintf("kvm_create_vcpu failed\n");
|
176 | 05330448 | aliguori | goto err;
|
177 | 05330448 | aliguori | } |
178 | 05330448 | aliguori | |
179 | 05330448 | aliguori | env->kvm_fd = ret; |
180 | 05330448 | aliguori | env->kvm_state = s; |
181 | 05330448 | aliguori | |
182 | 05330448 | aliguori | mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
|
183 | 05330448 | aliguori | if (mmap_size < 0) { |
184 | 05330448 | aliguori | dprintf("KVM_GET_VCPU_MMAP_SIZE failed\n");
|
185 | 05330448 | aliguori | goto err;
|
186 | 05330448 | aliguori | } |
187 | 05330448 | aliguori | |
188 | 05330448 | aliguori | env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
189 | 05330448 | aliguori | env->kvm_fd, 0);
|
190 | 05330448 | aliguori | if (env->kvm_run == MAP_FAILED) {
|
191 | 05330448 | aliguori | ret = -errno; |
192 | 05330448 | aliguori | dprintf("mmap'ing vcpu state failed\n");
|
193 | 05330448 | aliguori | goto err;
|
194 | 05330448 | aliguori | } |
195 | 05330448 | aliguori | |
196 | 05330448 | aliguori | ret = kvm_arch_init_vcpu(env); |
197 | 8d2ba1fb | Jan Kiszka | if (ret == 0) { |
198 | a08d4367 | Jan Kiszka | qemu_register_reset(kvm_reset_vcpu, env); |
199 | 8d2ba1fb | Jan Kiszka | ret = kvm_arch_put_registers(env); |
200 | 8d2ba1fb | Jan Kiszka | } |
201 | 05330448 | aliguori | err:
|
202 | 05330448 | aliguori | return ret;
|
203 | 05330448 | aliguori | } |
204 | 05330448 | aliguori | |
205 | f8d926e9 | Jan Kiszka | int kvm_put_mp_state(CPUState *env)
|
206 | f8d926e9 | Jan Kiszka | { |
207 | f8d926e9 | Jan Kiszka | struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
|
208 | f8d926e9 | Jan Kiszka | |
209 | f8d926e9 | Jan Kiszka | return kvm_vcpu_ioctl(env, KVM_SET_MP_STATE, &mp_state);
|
210 | f8d926e9 | Jan Kiszka | } |
211 | f8d926e9 | Jan Kiszka | |
212 | f8d926e9 | Jan Kiszka | int kvm_get_mp_state(CPUState *env)
|
213 | f8d926e9 | Jan Kiszka | { |
214 | f8d926e9 | Jan Kiszka | struct kvm_mp_state mp_state;
|
215 | f8d926e9 | Jan Kiszka | int ret;
|
216 | f8d926e9 | Jan Kiszka | |
217 | f8d926e9 | Jan Kiszka | ret = kvm_vcpu_ioctl(env, KVM_GET_MP_STATE, &mp_state); |
218 | f8d926e9 | Jan Kiszka | if (ret < 0) { |
219 | f8d926e9 | Jan Kiszka | return ret;
|
220 | f8d926e9 | Jan Kiszka | } |
221 | f8d926e9 | Jan Kiszka | env->mp_state = mp_state.mp_state; |
222 | f8d926e9 | Jan Kiszka | return 0; |
223 | f8d926e9 | Jan Kiszka | } |
224 | f8d926e9 | Jan Kiszka | |
225 | 5832d1f2 | aliguori | /*
|
226 | 5832d1f2 | aliguori | * dirty pages logging control
|
227 | 5832d1f2 | aliguori | */
|
228 | d3f8d37f | aliguori | static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr, |
229 | 4495d6a7 | Jan Kiszka | ram_addr_t size, int flags, int mask) |
230 | 5832d1f2 | aliguori | { |
231 | 5832d1f2 | aliguori | KVMState *s = kvm_state; |
232 | d3f8d37f | aliguori | KVMSlot *mem = kvm_lookup_matching_slot(s, phys_addr, phys_addr + size); |
233 | 4495d6a7 | Jan Kiszka | int old_flags;
|
234 | 4495d6a7 | Jan Kiszka | |
235 | 5832d1f2 | aliguori | if (mem == NULL) { |
236 | d3f8d37f | aliguori | fprintf(stderr, "BUG: %s: invalid parameters " TARGET_FMT_plx "-" |
237 | d3f8d37f | aliguori | TARGET_FMT_plx "\n", __func__, phys_addr,
|
238 | b80a55e6 | Alexander Graf | (target_phys_addr_t)(phys_addr + size - 1));
|
239 | 5832d1f2 | aliguori | return -EINVAL;
|
240 | 5832d1f2 | aliguori | } |
241 | 5832d1f2 | aliguori | |
242 | 4495d6a7 | Jan Kiszka | old_flags = mem->flags; |
243 | 5832d1f2 | aliguori | |
244 | 4495d6a7 | Jan Kiszka | flags = (mem->flags & ~mask) | flags; |
245 | 5832d1f2 | aliguori | mem->flags = flags; |
246 | 5832d1f2 | aliguori | |
247 | 4495d6a7 | Jan Kiszka | /* If nothing changed effectively, no need to issue ioctl */
|
248 | 4495d6a7 | Jan Kiszka | if (s->migration_log) {
|
249 | 4495d6a7 | Jan Kiszka | flags |= KVM_MEM_LOG_DIRTY_PAGES; |
250 | 4495d6a7 | Jan Kiszka | } |
251 | 4495d6a7 | Jan Kiszka | if (flags == old_flags) {
|
252 | 4495d6a7 | Jan Kiszka | return 0; |
253 | 4495d6a7 | Jan Kiszka | } |
254 | 4495d6a7 | Jan Kiszka | |
255 | 5832d1f2 | aliguori | return kvm_set_user_memory_region(s, mem);
|
256 | 5832d1f2 | aliguori | } |
257 | 5832d1f2 | aliguori | |
258 | d3f8d37f | aliguori | int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size)
|
259 | 5832d1f2 | aliguori | { |
260 | d3f8d37f | aliguori | return kvm_dirty_pages_log_change(phys_addr, size,
|
261 | 5832d1f2 | aliguori | KVM_MEM_LOG_DIRTY_PAGES, |
262 | 5832d1f2 | aliguori | KVM_MEM_LOG_DIRTY_PAGES); |
263 | 5832d1f2 | aliguori | } |
264 | 5832d1f2 | aliguori | |
265 | d3f8d37f | aliguori | int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size)
|
266 | 5832d1f2 | aliguori | { |
267 | d3f8d37f | aliguori | return kvm_dirty_pages_log_change(phys_addr, size,
|
268 | 5832d1f2 | aliguori | 0,
|
269 | 5832d1f2 | aliguori | KVM_MEM_LOG_DIRTY_PAGES); |
270 | 5832d1f2 | aliguori | } |
271 | 5832d1f2 | aliguori | |
272 | 4495d6a7 | Jan Kiszka | int kvm_set_migration_log(int enable) |
273 | 4495d6a7 | Jan Kiszka | { |
274 | 4495d6a7 | Jan Kiszka | KVMState *s = kvm_state; |
275 | 4495d6a7 | Jan Kiszka | KVMSlot *mem; |
276 | 4495d6a7 | Jan Kiszka | int i, err;
|
277 | 4495d6a7 | Jan Kiszka | |
278 | 4495d6a7 | Jan Kiszka | s->migration_log = enable; |
279 | 4495d6a7 | Jan Kiszka | |
280 | 4495d6a7 | Jan Kiszka | for (i = 0; i < ARRAY_SIZE(s->slots); i++) { |
281 | 4495d6a7 | Jan Kiszka | mem = &s->slots[i]; |
282 | 4495d6a7 | Jan Kiszka | |
283 | 4495d6a7 | Jan Kiszka | if (!!(mem->flags & KVM_MEM_LOG_DIRTY_PAGES) == enable) {
|
284 | 4495d6a7 | Jan Kiszka | continue;
|
285 | 4495d6a7 | Jan Kiszka | } |
286 | 4495d6a7 | Jan Kiszka | err = kvm_set_user_memory_region(s, mem); |
287 | 4495d6a7 | Jan Kiszka | if (err) {
|
288 | 4495d6a7 | Jan Kiszka | return err;
|
289 | 4495d6a7 | Jan Kiszka | } |
290 | 4495d6a7 | Jan Kiszka | } |
291 | 4495d6a7 | Jan Kiszka | return 0; |
292 | 4495d6a7 | Jan Kiszka | } |
293 | 4495d6a7 | Jan Kiszka | |
294 | 5832d1f2 | aliguori | /**
|
295 | 5832d1f2 | aliguori | * kvm_physical_sync_dirty_bitmap - Grab dirty bitmap from kernel space
|
296 | 5832d1f2 | aliguori | * This function updates qemu's dirty bitmap using cpu_physical_memory_set_dirty().
|
297 | 5832d1f2 | aliguori | * This means all bits are set to dirty.
|
298 | 5832d1f2 | aliguori | *
|
299 | d3f8d37f | aliguori | * @start_add: start of logged region.
|
300 | 5832d1f2 | aliguori | * @end_addr: end of logged region.
|
301 | 5832d1f2 | aliguori | */
|
302 | 151f7749 | Jan Kiszka | int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
|
303 | 151f7749 | Jan Kiszka | target_phys_addr_t end_addr) |
304 | 5832d1f2 | aliguori | { |
305 | 5832d1f2 | aliguori | KVMState *s = kvm_state; |
306 | 151f7749 | Jan Kiszka | unsigned long size, allocated_size = 0; |
307 | 151f7749 | Jan Kiszka | target_phys_addr_t phys_addr; |
308 | 5832d1f2 | aliguori | ram_addr_t addr; |
309 | 151f7749 | Jan Kiszka | KVMDirtyLog d; |
310 | 151f7749 | Jan Kiszka | KVMSlot *mem; |
311 | 151f7749 | Jan Kiszka | int ret = 0; |
312 | bd836776 | Alexander Graf | int r;
|
313 | 5832d1f2 | aliguori | |
314 | 151f7749 | Jan Kiszka | d.dirty_bitmap = NULL;
|
315 | 151f7749 | Jan Kiszka | while (start_addr < end_addr) {
|
316 | 151f7749 | Jan Kiszka | mem = kvm_lookup_overlapping_slot(s, start_addr, end_addr); |
317 | 151f7749 | Jan Kiszka | if (mem == NULL) { |
318 | 151f7749 | Jan Kiszka | break;
|
319 | 151f7749 | Jan Kiszka | } |
320 | 5832d1f2 | aliguori | |
321 | bd836776 | Alexander Graf | /* We didn't activate dirty logging? Don't care then. */
|
322 | bd836776 | Alexander Graf | if(!(mem->flags & KVM_MEM_LOG_DIRTY_PAGES)) {
|
323 | bd836776 | Alexander Graf | continue;
|
324 | bd836776 | Alexander Graf | } |
325 | bd836776 | Alexander Graf | |
326 | 151f7749 | Jan Kiszka | size = ((mem->memory_size >> TARGET_PAGE_BITS) + 7) / 8; |
327 | 151f7749 | Jan Kiszka | if (!d.dirty_bitmap) {
|
328 | 151f7749 | Jan Kiszka | d.dirty_bitmap = qemu_malloc(size); |
329 | 151f7749 | Jan Kiszka | } else if (size > allocated_size) { |
330 | 151f7749 | Jan Kiszka | d.dirty_bitmap = qemu_realloc(d.dirty_bitmap, size); |
331 | 151f7749 | Jan Kiszka | } |
332 | 151f7749 | Jan Kiszka | allocated_size = size; |
333 | 151f7749 | Jan Kiszka | memset(d.dirty_bitmap, 0, allocated_size);
|
334 | 5832d1f2 | aliguori | |
335 | 151f7749 | Jan Kiszka | d.slot = mem->slot; |
336 | 5832d1f2 | aliguori | |
337 | bd836776 | Alexander Graf | r = kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d); |
338 | bd836776 | Alexander Graf | if (r == -EINVAL) {
|
339 | 151f7749 | Jan Kiszka | dprintf("ioctl failed %d\n", errno);
|
340 | 151f7749 | Jan Kiszka | ret = -1;
|
341 | 151f7749 | Jan Kiszka | break;
|
342 | 151f7749 | Jan Kiszka | } |
343 | 5832d1f2 | aliguori | |
344 | 151f7749 | Jan Kiszka | for (phys_addr = mem->start_addr, addr = mem->phys_offset;
|
345 | 151f7749 | Jan Kiszka | phys_addr < mem->start_addr + mem->memory_size; |
346 | 151f7749 | Jan Kiszka | phys_addr += TARGET_PAGE_SIZE, addr += TARGET_PAGE_SIZE) { |
347 | 151f7749 | Jan Kiszka | unsigned long *bitmap = (unsigned long *)d.dirty_bitmap; |
348 | 151f7749 | Jan Kiszka | unsigned nr = (phys_addr - mem->start_addr) >> TARGET_PAGE_BITS;
|
349 | 151f7749 | Jan Kiszka | unsigned word = nr / (sizeof(*bitmap) * 8); |
350 | 151f7749 | Jan Kiszka | unsigned bit = nr % (sizeof(*bitmap) * 8); |
351 | 151f7749 | Jan Kiszka | |
352 | 151f7749 | Jan Kiszka | if ((bitmap[word] >> bit) & 1) { |
353 | 151f7749 | Jan Kiszka | cpu_physical_memory_set_dirty(addr); |
354 | bd836776 | Alexander Graf | } else if (r < 0) { |
355 | bd836776 | Alexander Graf | /* When our KVM implementation doesn't know about dirty logging
|
356 | bd836776 | Alexander Graf | * we can just assume it's always dirty and be fine. */
|
357 | bd836776 | Alexander Graf | cpu_physical_memory_set_dirty(addr); |
358 | 151f7749 | Jan Kiszka | } |
359 | 151f7749 | Jan Kiszka | } |
360 | 151f7749 | Jan Kiszka | start_addr = phys_addr; |
361 | 5832d1f2 | aliguori | } |
362 | 5832d1f2 | aliguori | qemu_free(d.dirty_bitmap); |
363 | 151f7749 | Jan Kiszka | |
364 | 151f7749 | Jan Kiszka | return ret;
|
365 | 5832d1f2 | aliguori | } |
366 | 5832d1f2 | aliguori | |
367 | f65ed4c1 | aliguori | int kvm_coalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
|
368 | f65ed4c1 | aliguori | { |
369 | f65ed4c1 | aliguori | int ret = -ENOSYS;
|
370 | f65ed4c1 | aliguori | #ifdef KVM_CAP_COALESCED_MMIO
|
371 | f65ed4c1 | aliguori | KVMState *s = kvm_state; |
372 | f65ed4c1 | aliguori | |
373 | f65ed4c1 | aliguori | if (s->coalesced_mmio) {
|
374 | f65ed4c1 | aliguori | struct kvm_coalesced_mmio_zone zone;
|
375 | f65ed4c1 | aliguori | |
376 | f65ed4c1 | aliguori | zone.addr = start; |
377 | f65ed4c1 | aliguori | zone.size = size; |
378 | f65ed4c1 | aliguori | |
379 | f65ed4c1 | aliguori | ret = kvm_vm_ioctl(s, KVM_REGISTER_COALESCED_MMIO, &zone); |
380 | f65ed4c1 | aliguori | } |
381 | f65ed4c1 | aliguori | #endif
|
382 | f65ed4c1 | aliguori | |
383 | f65ed4c1 | aliguori | return ret;
|
384 | f65ed4c1 | aliguori | } |
385 | f65ed4c1 | aliguori | |
386 | f65ed4c1 | aliguori | int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
|
387 | f65ed4c1 | aliguori | { |
388 | f65ed4c1 | aliguori | int ret = -ENOSYS;
|
389 | f65ed4c1 | aliguori | #ifdef KVM_CAP_COALESCED_MMIO
|
390 | f65ed4c1 | aliguori | KVMState *s = kvm_state; |
391 | f65ed4c1 | aliguori | |
392 | f65ed4c1 | aliguori | if (s->coalesced_mmio) {
|
393 | f65ed4c1 | aliguori | struct kvm_coalesced_mmio_zone zone;
|
394 | f65ed4c1 | aliguori | |
395 | f65ed4c1 | aliguori | zone.addr = start; |
396 | f65ed4c1 | aliguori | zone.size = size; |
397 | f65ed4c1 | aliguori | |
398 | f65ed4c1 | aliguori | ret = kvm_vm_ioctl(s, KVM_UNREGISTER_COALESCED_MMIO, &zone); |
399 | f65ed4c1 | aliguori | } |
400 | f65ed4c1 | aliguori | #endif
|
401 | f65ed4c1 | aliguori | |
402 | f65ed4c1 | aliguori | return ret;
|
403 | f65ed4c1 | aliguori | } |
404 | f65ed4c1 | aliguori | |
405 | ad7b8b33 | Anthony Liguori | int kvm_check_extension(KVMState *s, unsigned int extension) |
406 | ad7b8b33 | Anthony Liguori | { |
407 | ad7b8b33 | Anthony Liguori | int ret;
|
408 | ad7b8b33 | Anthony Liguori | |
409 | ad7b8b33 | Anthony Liguori | ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, extension); |
410 | ad7b8b33 | Anthony Liguori | if (ret < 0) { |
411 | ad7b8b33 | Anthony Liguori | ret = 0;
|
412 | ad7b8b33 | Anthony Liguori | } |
413 | ad7b8b33 | Anthony Liguori | |
414 | ad7b8b33 | Anthony Liguori | return ret;
|
415 | ad7b8b33 | Anthony Liguori | } |
416 | ad7b8b33 | Anthony Liguori | |
417 | 05330448 | aliguori | int kvm_init(int smp_cpus) |
418 | 05330448 | aliguori | { |
419 | 168ccc11 | Jan Kiszka | static const char upgrade_note[] = |
420 | 168ccc11 | Jan Kiszka | "Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
|
421 | 168ccc11 | Jan Kiszka | "(see http://sourceforge.net/projects/kvm).\n";
|
422 | 05330448 | aliguori | KVMState *s; |
423 | 05330448 | aliguori | int ret;
|
424 | 05330448 | aliguori | int i;
|
425 | 05330448 | aliguori | |
426 | 9f8fd694 | Mark McLoughlin | if (smp_cpus > 1) { |
427 | 9f8fd694 | Mark McLoughlin | fprintf(stderr, "No SMP KVM support, use '-smp 1'\n");
|
428 | 05330448 | aliguori | return -EINVAL;
|
429 | 9f8fd694 | Mark McLoughlin | } |
430 | 05330448 | aliguori | |
431 | 05330448 | aliguori | s = qemu_mallocz(sizeof(KVMState));
|
432 | 05330448 | aliguori | |
433 | e22a25c9 | aliguori | #ifdef KVM_CAP_SET_GUEST_DEBUG
|
434 | e22a25c9 | aliguori | TAILQ_INIT(&s->kvm_sw_breakpoints); |
435 | e22a25c9 | aliguori | #endif
|
436 | 05330448 | aliguori | for (i = 0; i < ARRAY_SIZE(s->slots); i++) |
437 | 05330448 | aliguori | s->slots[i].slot = i; |
438 | 05330448 | aliguori | |
439 | 05330448 | aliguori | s->vmfd = -1;
|
440 | 05330448 | aliguori | s->fd = open("/dev/kvm", O_RDWR);
|
441 | 05330448 | aliguori | if (s->fd == -1) { |
442 | 05330448 | aliguori | fprintf(stderr, "Could not access KVM kernel module: %m\n");
|
443 | 05330448 | aliguori | ret = -errno; |
444 | 05330448 | aliguori | goto err;
|
445 | 05330448 | aliguori | } |
446 | 05330448 | aliguori | |
447 | 05330448 | aliguori | ret = kvm_ioctl(s, KVM_GET_API_VERSION, 0);
|
448 | 05330448 | aliguori | if (ret < KVM_API_VERSION) {
|
449 | 05330448 | aliguori | if (ret > 0) |
450 | 05330448 | aliguori | ret = -EINVAL; |
451 | 05330448 | aliguori | fprintf(stderr, "kvm version too old\n");
|
452 | 05330448 | aliguori | goto err;
|
453 | 05330448 | aliguori | } |
454 | 05330448 | aliguori | |
455 | 05330448 | aliguori | if (ret > KVM_API_VERSION) {
|
456 | 05330448 | aliguori | ret = -EINVAL; |
457 | 05330448 | aliguori | fprintf(stderr, "kvm version not supported\n");
|
458 | 05330448 | aliguori | goto err;
|
459 | 05330448 | aliguori | } |
460 | 05330448 | aliguori | |
461 | 05330448 | aliguori | s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
|
462 | 05330448 | aliguori | if (s->vmfd < 0) |
463 | 05330448 | aliguori | goto err;
|
464 | 05330448 | aliguori | |
465 | 05330448 | aliguori | /* initially, KVM allocated its own memory and we had to jump through
|
466 | 05330448 | aliguori | * hooks to make phys_ram_base point to this. Modern versions of KVM
|
467 | 5579c7f3 | pbrook | * just use a user allocated buffer so we can use regular pages
|
468 | 05330448 | aliguori | * unmodified. Make sure we have a sufficiently modern version of KVM.
|
469 | 05330448 | aliguori | */
|
470 | ad7b8b33 | Anthony Liguori | if (!kvm_check_extension(s, KVM_CAP_USER_MEMORY)) {
|
471 | ad7b8b33 | Anthony Liguori | ret = -EINVAL; |
472 | 168ccc11 | Jan Kiszka | fprintf(stderr, "kvm does not support KVM_CAP_USER_MEMORY\n%s",
|
473 | 168ccc11 | Jan Kiszka | upgrade_note); |
474 | 05330448 | aliguori | goto err;
|
475 | 05330448 | aliguori | } |
476 | 05330448 | aliguori | |
477 | d85dc283 | aliguori | /* There was a nasty bug in < kvm-80 that prevents memory slots from being
|
478 | d85dc283 | aliguori | * destroyed properly. Since we rely on this capability, refuse to work
|
479 | d85dc283 | aliguori | * with any kernel without this capability. */
|
480 | ad7b8b33 | Anthony Liguori | if (!kvm_check_extension(s, KVM_CAP_DESTROY_MEMORY_REGION_WORKS)) {
|
481 | ad7b8b33 | Anthony Liguori | ret = -EINVAL; |
482 | d85dc283 | aliguori | |
483 | d85dc283 | aliguori | fprintf(stderr, |
484 | 168ccc11 | Jan Kiszka | "KVM kernel module broken (DESTROY_MEMORY_REGION).\n%s",
|
485 | 168ccc11 | Jan Kiszka | upgrade_note); |
486 | d85dc283 | aliguori | goto err;
|
487 | d85dc283 | aliguori | } |
488 | d85dc283 | aliguori | |
489 | f65ed4c1 | aliguori | #ifdef KVM_CAP_COALESCED_MMIO
|
490 | ad7b8b33 | Anthony Liguori | s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO); |
491 | ad7b8b33 | Anthony Liguori | #else
|
492 | ad7b8b33 | Anthony Liguori | s->coalesced_mmio = 0;
|
493 | f65ed4c1 | aliguori | #endif
|
494 | f65ed4c1 | aliguori | |
495 | e69917e2 | Jan Kiszka | s->broken_set_mem_region = 1;
|
496 | e69917e2 | Jan Kiszka | #ifdef KVM_CAP_JOIN_MEMORY_REGIONS_WORKS
|
497 | e69917e2 | Jan Kiszka | ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS); |
498 | e69917e2 | Jan Kiszka | if (ret > 0) { |
499 | e69917e2 | Jan Kiszka | s->broken_set_mem_region = 0;
|
500 | e69917e2 | Jan Kiszka | } |
501 | e69917e2 | Jan Kiszka | #endif
|
502 | e69917e2 | Jan Kiszka | |
503 | 05330448 | aliguori | ret = kvm_arch_init(s, smp_cpus); |
504 | 05330448 | aliguori | if (ret < 0) |
505 | 05330448 | aliguori | goto err;
|
506 | 05330448 | aliguori | |
507 | 05330448 | aliguori | kvm_state = s; |
508 | 05330448 | aliguori | |
509 | 05330448 | aliguori | return 0; |
510 | 05330448 | aliguori | |
511 | 05330448 | aliguori | err:
|
512 | 05330448 | aliguori | if (s) {
|
513 | 05330448 | aliguori | if (s->vmfd != -1) |
514 | 05330448 | aliguori | close(s->vmfd); |
515 | 05330448 | aliguori | if (s->fd != -1) |
516 | 05330448 | aliguori | close(s->fd); |
517 | 05330448 | aliguori | } |
518 | 05330448 | aliguori | qemu_free(s); |
519 | 05330448 | aliguori | |
520 | 05330448 | aliguori | return ret;
|
521 | 05330448 | aliguori | } |
522 | 05330448 | aliguori | |
523 | 05330448 | aliguori | static int kvm_handle_io(CPUState *env, uint16_t port, void *data, |
524 | 05330448 | aliguori | int direction, int size, uint32_t count) |
525 | 05330448 | aliguori | { |
526 | 05330448 | aliguori | int i;
|
527 | 05330448 | aliguori | uint8_t *ptr = data; |
528 | 05330448 | aliguori | |
529 | 05330448 | aliguori | for (i = 0; i < count; i++) { |
530 | 05330448 | aliguori | if (direction == KVM_EXIT_IO_IN) {
|
531 | 05330448 | aliguori | switch (size) {
|
532 | 05330448 | aliguori | case 1: |
533 | 05330448 | aliguori | stb_p(ptr, cpu_inb(env, port)); |
534 | 05330448 | aliguori | break;
|
535 | 05330448 | aliguori | case 2: |
536 | 05330448 | aliguori | stw_p(ptr, cpu_inw(env, port)); |
537 | 05330448 | aliguori | break;
|
538 | 05330448 | aliguori | case 4: |
539 | 05330448 | aliguori | stl_p(ptr, cpu_inl(env, port)); |
540 | 05330448 | aliguori | break;
|
541 | 05330448 | aliguori | } |
542 | 05330448 | aliguori | } else {
|
543 | 05330448 | aliguori | switch (size) {
|
544 | 05330448 | aliguori | case 1: |
545 | 05330448 | aliguori | cpu_outb(env, port, ldub_p(ptr)); |
546 | 05330448 | aliguori | break;
|
547 | 05330448 | aliguori | case 2: |
548 | 05330448 | aliguori | cpu_outw(env, port, lduw_p(ptr)); |
549 | 05330448 | aliguori | break;
|
550 | 05330448 | aliguori | case 4: |
551 | 05330448 | aliguori | cpu_outl(env, port, ldl_p(ptr)); |
552 | 05330448 | aliguori | break;
|
553 | 05330448 | aliguori | } |
554 | 05330448 | aliguori | } |
555 | 05330448 | aliguori | |
556 | 05330448 | aliguori | ptr += size; |
557 | 05330448 | aliguori | } |
558 | 05330448 | aliguori | |
559 | 05330448 | aliguori | return 1; |
560 | 05330448 | aliguori | } |
561 | 05330448 | aliguori | |
562 | f65ed4c1 | aliguori | static void kvm_run_coalesced_mmio(CPUState *env, struct kvm_run *run) |
563 | f65ed4c1 | aliguori | { |
564 | f65ed4c1 | aliguori | #ifdef KVM_CAP_COALESCED_MMIO
|
565 | f65ed4c1 | aliguori | KVMState *s = kvm_state; |
566 | f65ed4c1 | aliguori | if (s->coalesced_mmio) {
|
567 | f65ed4c1 | aliguori | struct kvm_coalesced_mmio_ring *ring;
|
568 | f65ed4c1 | aliguori | |
569 | f65ed4c1 | aliguori | ring = (void *)run + (s->coalesced_mmio * TARGET_PAGE_SIZE);
|
570 | f65ed4c1 | aliguori | while (ring->first != ring->last) {
|
571 | f65ed4c1 | aliguori | struct kvm_coalesced_mmio *ent;
|
572 | f65ed4c1 | aliguori | |
573 | f65ed4c1 | aliguori | ent = &ring->coalesced_mmio[ring->first]; |
574 | f65ed4c1 | aliguori | |
575 | f65ed4c1 | aliguori | cpu_physical_memory_write(ent->phys_addr, ent->data, ent->len); |
576 | f65ed4c1 | aliguori | /* FIXME smp_wmb() */
|
577 | f65ed4c1 | aliguori | ring->first = (ring->first + 1) % KVM_COALESCED_MMIO_MAX;
|
578 | f65ed4c1 | aliguori | } |
579 | f65ed4c1 | aliguori | } |
580 | f65ed4c1 | aliguori | #endif
|
581 | f65ed4c1 | aliguori | } |
582 | f65ed4c1 | aliguori | |
583 | 05330448 | aliguori | int kvm_cpu_exec(CPUState *env)
|
584 | 05330448 | aliguori | { |
585 | 05330448 | aliguori | struct kvm_run *run = env->kvm_run;
|
586 | 05330448 | aliguori | int ret;
|
587 | 05330448 | aliguori | |
588 | 05330448 | aliguori | dprintf("kvm_cpu_exec()\n");
|
589 | 05330448 | aliguori | |
590 | 05330448 | aliguori | do {
|
591 | be214e6c | aurel32 | if (env->exit_request) {
|
592 | 05330448 | aliguori | dprintf("interrupt exit requested\n");
|
593 | 05330448 | aliguori | ret = 0;
|
594 | 05330448 | aliguori | break;
|
595 | 05330448 | aliguori | } |
596 | 05330448 | aliguori | |
597 | 8c14c173 | Jan Kiszka | kvm_arch_pre_run(env, run); |
598 | 05330448 | aliguori | ret = kvm_vcpu_ioctl(env, KVM_RUN, 0);
|
599 | 05330448 | aliguori | kvm_arch_post_run(env, run); |
600 | 05330448 | aliguori | |
601 | 05330448 | aliguori | if (ret == -EINTR || ret == -EAGAIN) {
|
602 | 05330448 | aliguori | dprintf("io window exit\n");
|
603 | 05330448 | aliguori | ret = 0;
|
604 | 05330448 | aliguori | break;
|
605 | 05330448 | aliguori | } |
606 | 05330448 | aliguori | |
607 | 05330448 | aliguori | if (ret < 0) { |
608 | 05330448 | aliguori | dprintf("kvm run failed %s\n", strerror(-ret));
|
609 | 05330448 | aliguori | abort(); |
610 | 05330448 | aliguori | } |
611 | 05330448 | aliguori | |
612 | f65ed4c1 | aliguori | kvm_run_coalesced_mmio(env, run); |
613 | f65ed4c1 | aliguori | |
614 | 05330448 | aliguori | ret = 0; /* exit loop */ |
615 | 05330448 | aliguori | switch (run->exit_reason) {
|
616 | 05330448 | aliguori | case KVM_EXIT_IO:
|
617 | 05330448 | aliguori | dprintf("handle_io\n");
|
618 | 05330448 | aliguori | ret = kvm_handle_io(env, run->io.port, |
619 | 05330448 | aliguori | (uint8_t *)run + run->io.data_offset, |
620 | 05330448 | aliguori | run->io.direction, |
621 | 05330448 | aliguori | run->io.size, |
622 | 05330448 | aliguori | run->io.count); |
623 | 05330448 | aliguori | break;
|
624 | 05330448 | aliguori | case KVM_EXIT_MMIO:
|
625 | 05330448 | aliguori | dprintf("handle_mmio\n");
|
626 | 05330448 | aliguori | cpu_physical_memory_rw(run->mmio.phys_addr, |
627 | 05330448 | aliguori | run->mmio.data, |
628 | 05330448 | aliguori | run->mmio.len, |
629 | 05330448 | aliguori | run->mmio.is_write); |
630 | 05330448 | aliguori | ret = 1;
|
631 | 05330448 | aliguori | break;
|
632 | 05330448 | aliguori | case KVM_EXIT_IRQ_WINDOW_OPEN:
|
633 | 05330448 | aliguori | dprintf("irq_window_open\n");
|
634 | 05330448 | aliguori | break;
|
635 | 05330448 | aliguori | case KVM_EXIT_SHUTDOWN:
|
636 | 05330448 | aliguori | dprintf("shutdown\n");
|
637 | 05330448 | aliguori | qemu_system_reset_request(); |
638 | 05330448 | aliguori | ret = 1;
|
639 | 05330448 | aliguori | break;
|
640 | 05330448 | aliguori | case KVM_EXIT_UNKNOWN:
|
641 | 05330448 | aliguori | dprintf("kvm_exit_unknown\n");
|
642 | 05330448 | aliguori | break;
|
643 | 05330448 | aliguori | case KVM_EXIT_FAIL_ENTRY:
|
644 | 05330448 | aliguori | dprintf("kvm_exit_fail_entry\n");
|
645 | 05330448 | aliguori | break;
|
646 | 05330448 | aliguori | case KVM_EXIT_EXCEPTION:
|
647 | 05330448 | aliguori | dprintf("kvm_exit_exception\n");
|
648 | 05330448 | aliguori | break;
|
649 | 05330448 | aliguori | case KVM_EXIT_DEBUG:
|
650 | 05330448 | aliguori | dprintf("kvm_exit_debug\n");
|
651 | e22a25c9 | aliguori | #ifdef KVM_CAP_SET_GUEST_DEBUG
|
652 | e22a25c9 | aliguori | if (kvm_arch_debug(&run->debug.arch)) {
|
653 | e22a25c9 | aliguori | gdb_set_stop_cpu(env); |
654 | e22a25c9 | aliguori | vm_stop(EXCP_DEBUG); |
655 | e22a25c9 | aliguori | env->exception_index = EXCP_DEBUG; |
656 | e22a25c9 | aliguori | return 0; |
657 | e22a25c9 | aliguori | } |
658 | e22a25c9 | aliguori | /* re-enter, this exception was guest-internal */
|
659 | e22a25c9 | aliguori | ret = 1;
|
660 | e22a25c9 | aliguori | #endif /* KVM_CAP_SET_GUEST_DEBUG */ |
661 | 05330448 | aliguori | break;
|
662 | 05330448 | aliguori | default:
|
663 | 05330448 | aliguori | dprintf("kvm_arch_handle_exit\n");
|
664 | 05330448 | aliguori | ret = kvm_arch_handle_exit(env, run); |
665 | 05330448 | aliguori | break;
|
666 | 05330448 | aliguori | } |
667 | 05330448 | aliguori | } while (ret > 0); |
668 | 05330448 | aliguori | |
669 | be214e6c | aurel32 | if (env->exit_request) {
|
670 | be214e6c | aurel32 | env->exit_request = 0;
|
671 | becfc390 | aliguori | env->exception_index = EXCP_INTERRUPT; |
672 | becfc390 | aliguori | } |
673 | becfc390 | aliguori | |
674 | 05330448 | aliguori | return ret;
|
675 | 05330448 | aliguori | } |
676 | 05330448 | aliguori | |
677 | 05330448 | aliguori | void kvm_set_phys_mem(target_phys_addr_t start_addr,
|
678 | 05330448 | aliguori | ram_addr_t size, |
679 | 05330448 | aliguori | ram_addr_t phys_offset) |
680 | 05330448 | aliguori | { |
681 | 05330448 | aliguori | KVMState *s = kvm_state; |
682 | 05330448 | aliguori | ram_addr_t flags = phys_offset & ~TARGET_PAGE_MASK; |
683 | 6152e2ae | aliguori | KVMSlot *mem, old; |
684 | 6152e2ae | aliguori | int err;
|
685 | 05330448 | aliguori | |
686 | d3f8d37f | aliguori | if (start_addr & ~TARGET_PAGE_MASK) {
|
687 | e6f4afe0 | Jan Kiszka | if (flags >= IO_MEM_UNASSIGNED) {
|
688 | e6f4afe0 | Jan Kiszka | if (!kvm_lookup_overlapping_slot(s, start_addr,
|
689 | e6f4afe0 | Jan Kiszka | start_addr + size)) { |
690 | e6f4afe0 | Jan Kiszka | return;
|
691 | e6f4afe0 | Jan Kiszka | } |
692 | e6f4afe0 | Jan Kiszka | fprintf(stderr, "Unaligned split of a KVM memory slot\n");
|
693 | e6f4afe0 | Jan Kiszka | } else {
|
694 | e6f4afe0 | Jan Kiszka | fprintf(stderr, "Only page-aligned memory slots supported\n");
|
695 | e6f4afe0 | Jan Kiszka | } |
696 | d3f8d37f | aliguori | abort(); |
697 | d3f8d37f | aliguori | } |
698 | d3f8d37f | aliguori | |
699 | 05330448 | aliguori | /* KVM does not support read-only slots */
|
700 | 05330448 | aliguori | phys_offset &= ~IO_MEM_ROM; |
701 | 05330448 | aliguori | |
702 | 6152e2ae | aliguori | while (1) { |
703 | 6152e2ae | aliguori | mem = kvm_lookup_overlapping_slot(s, start_addr, start_addr + size); |
704 | 6152e2ae | aliguori | if (!mem) {
|
705 | 6152e2ae | aliguori | break;
|
706 | 6152e2ae | aliguori | } |
707 | 62d60e8c | aliguori | |
708 | 6152e2ae | aliguori | if (flags < IO_MEM_UNASSIGNED && start_addr >= mem->start_addr &&
|
709 | 6152e2ae | aliguori | (start_addr + size <= mem->start_addr + mem->memory_size) && |
710 | 6152e2ae | aliguori | (phys_offset - start_addr == mem->phys_offset - mem->start_addr)) { |
711 | 6152e2ae | aliguori | /* The new slot fits into the existing one and comes with
|
712 | 6152e2ae | aliguori | * identical parameters - nothing to be done. */
|
713 | 05330448 | aliguori | return;
|
714 | 6152e2ae | aliguori | } |
715 | 6152e2ae | aliguori | |
716 | 6152e2ae | aliguori | old = *mem; |
717 | 6152e2ae | aliguori | |
718 | 6152e2ae | aliguori | /* unregister the overlapping slot */
|
719 | 6152e2ae | aliguori | mem->memory_size = 0;
|
720 | 6152e2ae | aliguori | err = kvm_set_user_memory_region(s, mem); |
721 | 6152e2ae | aliguori | if (err) {
|
722 | 6152e2ae | aliguori | fprintf(stderr, "%s: error unregistering overlapping slot: %s\n",
|
723 | 6152e2ae | aliguori | __func__, strerror(-err)); |
724 | 62d60e8c | aliguori | abort(); |
725 | 62d60e8c | aliguori | } |
726 | 6152e2ae | aliguori | |
727 | 6152e2ae | aliguori | /* Workaround for older KVM versions: we can't join slots, even not by
|
728 | 6152e2ae | aliguori | * unregistering the previous ones and then registering the larger
|
729 | 6152e2ae | aliguori | * slot. We have to maintain the existing fragmentation. Sigh.
|
730 | 6152e2ae | aliguori | *
|
731 | 6152e2ae | aliguori | * This workaround assumes that the new slot starts at the same
|
732 | 6152e2ae | aliguori | * address as the first existing one. If not or if some overlapping
|
733 | 6152e2ae | aliguori | * slot comes around later, we will fail (not seen in practice so far)
|
734 | 6152e2ae | aliguori | * - and actually require a recent KVM version. */
|
735 | e69917e2 | Jan Kiszka | if (s->broken_set_mem_region &&
|
736 | e69917e2 | Jan Kiszka | old.start_addr == start_addr && old.memory_size < size && |
737 | 6152e2ae | aliguori | flags < IO_MEM_UNASSIGNED) { |
738 | 6152e2ae | aliguori | mem = kvm_alloc_slot(s); |
739 | 6152e2ae | aliguori | mem->memory_size = old.memory_size; |
740 | 6152e2ae | aliguori | mem->start_addr = old.start_addr; |
741 | 6152e2ae | aliguori | mem->phys_offset = old.phys_offset; |
742 | 6152e2ae | aliguori | mem->flags = 0;
|
743 | 6152e2ae | aliguori | |
744 | 6152e2ae | aliguori | err = kvm_set_user_memory_region(s, mem); |
745 | 6152e2ae | aliguori | if (err) {
|
746 | 6152e2ae | aliguori | fprintf(stderr, "%s: error updating slot: %s\n", __func__,
|
747 | 6152e2ae | aliguori | strerror(-err)); |
748 | 6152e2ae | aliguori | abort(); |
749 | 6152e2ae | aliguori | } |
750 | 6152e2ae | aliguori | |
751 | 6152e2ae | aliguori | start_addr += old.memory_size; |
752 | 6152e2ae | aliguori | phys_offset += old.memory_size; |
753 | 6152e2ae | aliguori | size -= old.memory_size; |
754 | 6152e2ae | aliguori | continue;
|
755 | 6152e2ae | aliguori | } |
756 | 6152e2ae | aliguori | |
757 | 6152e2ae | aliguori | /* register prefix slot */
|
758 | 6152e2ae | aliguori | if (old.start_addr < start_addr) {
|
759 | 6152e2ae | aliguori | mem = kvm_alloc_slot(s); |
760 | 6152e2ae | aliguori | mem->memory_size = start_addr - old.start_addr; |
761 | 6152e2ae | aliguori | mem->start_addr = old.start_addr; |
762 | 6152e2ae | aliguori | mem->phys_offset = old.phys_offset; |
763 | 6152e2ae | aliguori | mem->flags = 0;
|
764 | 6152e2ae | aliguori | |
765 | 6152e2ae | aliguori | err = kvm_set_user_memory_region(s, mem); |
766 | 6152e2ae | aliguori | if (err) {
|
767 | 6152e2ae | aliguori | fprintf(stderr, "%s: error registering prefix slot: %s\n",
|
768 | 6152e2ae | aliguori | __func__, strerror(-err)); |
769 | 6152e2ae | aliguori | abort(); |
770 | 6152e2ae | aliguori | } |
771 | 6152e2ae | aliguori | } |
772 | 6152e2ae | aliguori | |
773 | 6152e2ae | aliguori | /* register suffix slot */
|
774 | 6152e2ae | aliguori | if (old.start_addr + old.memory_size > start_addr + size) {
|
775 | 6152e2ae | aliguori | ram_addr_t size_delta; |
776 | 6152e2ae | aliguori | |
777 | 6152e2ae | aliguori | mem = kvm_alloc_slot(s); |
778 | 6152e2ae | aliguori | mem->start_addr = start_addr + size; |
779 | 6152e2ae | aliguori | size_delta = mem->start_addr - old.start_addr; |
780 | 6152e2ae | aliguori | mem->memory_size = old.memory_size - size_delta; |
781 | 6152e2ae | aliguori | mem->phys_offset = old.phys_offset + size_delta; |
782 | 6152e2ae | aliguori | mem->flags = 0;
|
783 | 6152e2ae | aliguori | |
784 | 6152e2ae | aliguori | err = kvm_set_user_memory_region(s, mem); |
785 | 6152e2ae | aliguori | if (err) {
|
786 | 6152e2ae | aliguori | fprintf(stderr, "%s: error registering suffix slot: %s\n",
|
787 | 6152e2ae | aliguori | __func__, strerror(-err)); |
788 | 6152e2ae | aliguori | abort(); |
789 | 6152e2ae | aliguori | } |
790 | 6152e2ae | aliguori | } |
791 | 05330448 | aliguori | } |
792 | 6152e2ae | aliguori | |
793 | 6152e2ae | aliguori | /* in case the KVM bug workaround already "consumed" the new slot */
|
794 | 6152e2ae | aliguori | if (!size)
|
795 | 6152e2ae | aliguori | return;
|
796 | 6152e2ae | aliguori | |
797 | 05330448 | aliguori | /* KVM does not need to know about this memory */
|
798 | 05330448 | aliguori | if (flags >= IO_MEM_UNASSIGNED)
|
799 | 05330448 | aliguori | return;
|
800 | 05330448 | aliguori | |
801 | 05330448 | aliguori | mem = kvm_alloc_slot(s); |
802 | 05330448 | aliguori | mem->memory_size = size; |
803 | 34fc643f | aliguori | mem->start_addr = start_addr; |
804 | 34fc643f | aliguori | mem->phys_offset = phys_offset; |
805 | 05330448 | aliguori | mem->flags = 0;
|
806 | 05330448 | aliguori | |
807 | 6152e2ae | aliguori | err = kvm_set_user_memory_region(s, mem); |
808 | 6152e2ae | aliguori | if (err) {
|
809 | 6152e2ae | aliguori | fprintf(stderr, "%s: error registering slot: %s\n", __func__,
|
810 | 6152e2ae | aliguori | strerror(-err)); |
811 | 6152e2ae | aliguori | abort(); |
812 | 6152e2ae | aliguori | } |
813 | 05330448 | aliguori | } |
814 | 05330448 | aliguori | |
815 | 984b5181 | aliguori | int kvm_ioctl(KVMState *s, int type, ...) |
816 | 05330448 | aliguori | { |
817 | 05330448 | aliguori | int ret;
|
818 | 984b5181 | aliguori | void *arg;
|
819 | 984b5181 | aliguori | va_list ap; |
820 | 05330448 | aliguori | |
821 | 984b5181 | aliguori | va_start(ap, type); |
822 | 984b5181 | aliguori | arg = va_arg(ap, void *);
|
823 | 984b5181 | aliguori | va_end(ap); |
824 | 984b5181 | aliguori | |
825 | 984b5181 | aliguori | ret = ioctl(s->fd, type, arg); |
826 | 05330448 | aliguori | if (ret == -1) |
827 | 05330448 | aliguori | ret = -errno; |
828 | 05330448 | aliguori | |
829 | 05330448 | aliguori | return ret;
|
830 | 05330448 | aliguori | } |
831 | 05330448 | aliguori | |
832 | 984b5181 | aliguori | int kvm_vm_ioctl(KVMState *s, int type, ...) |
833 | 05330448 | aliguori | { |
834 | 05330448 | aliguori | int ret;
|
835 | 984b5181 | aliguori | void *arg;
|
836 | 984b5181 | aliguori | va_list ap; |
837 | 984b5181 | aliguori | |
838 | 984b5181 | aliguori | va_start(ap, type); |
839 | 984b5181 | aliguori | arg = va_arg(ap, void *);
|
840 | 984b5181 | aliguori | va_end(ap); |
841 | 05330448 | aliguori | |
842 | 984b5181 | aliguori | ret = ioctl(s->vmfd, type, arg); |
843 | 05330448 | aliguori | if (ret == -1) |
844 | 05330448 | aliguori | ret = -errno; |
845 | 05330448 | aliguori | |
846 | 05330448 | aliguori | return ret;
|
847 | 05330448 | aliguori | } |
848 | 05330448 | aliguori | |
849 | 984b5181 | aliguori | int kvm_vcpu_ioctl(CPUState *env, int type, ...) |
850 | 05330448 | aliguori | { |
851 | 05330448 | aliguori | int ret;
|
852 | 984b5181 | aliguori | void *arg;
|
853 | 984b5181 | aliguori | va_list ap; |
854 | 984b5181 | aliguori | |
855 | 984b5181 | aliguori | va_start(ap, type); |
856 | 984b5181 | aliguori | arg = va_arg(ap, void *);
|
857 | 984b5181 | aliguori | va_end(ap); |
858 | 05330448 | aliguori | |
859 | 984b5181 | aliguori | ret = ioctl(env->kvm_fd, type, arg); |
860 | 05330448 | aliguori | if (ret == -1) |
861 | 05330448 | aliguori | ret = -errno; |
862 | 05330448 | aliguori | |
863 | 05330448 | aliguori | return ret;
|
864 | 05330448 | aliguori | } |
865 | bd322087 | aliguori | |
866 | bd322087 | aliguori | int kvm_has_sync_mmu(void) |
867 | bd322087 | aliguori | { |
868 | a9c11522 | aurel32 | #ifdef KVM_CAP_SYNC_MMU
|
869 | bd322087 | aliguori | KVMState *s = kvm_state; |
870 | bd322087 | aliguori | |
871 | ad7b8b33 | Anthony Liguori | return kvm_check_extension(s, KVM_CAP_SYNC_MMU);
|
872 | ad7b8b33 | Anthony Liguori | #else
|
873 | bd322087 | aliguori | return 0; |
874 | ad7b8b33 | Anthony Liguori | #endif
|
875 | bd322087 | aliguori | } |
876 | e22a25c9 | aliguori | |
877 | 6f0437e8 | Jan Kiszka | void kvm_setup_guest_memory(void *start, size_t size) |
878 | 6f0437e8 | Jan Kiszka | { |
879 | 6f0437e8 | Jan Kiszka | if (!kvm_has_sync_mmu()) {
|
880 | 6f0437e8 | Jan Kiszka | #ifdef MADV_DONTFORK
|
881 | 6f0437e8 | Jan Kiszka | int ret = madvise(start, size, MADV_DONTFORK);
|
882 | 6f0437e8 | Jan Kiszka | |
883 | 6f0437e8 | Jan Kiszka | if (ret) {
|
884 | 6f0437e8 | Jan Kiszka | perror("madvice");
|
885 | 6f0437e8 | Jan Kiszka | exit(1);
|
886 | 6f0437e8 | Jan Kiszka | } |
887 | 6f0437e8 | Jan Kiszka | #else
|
888 | 6f0437e8 | Jan Kiszka | fprintf(stderr, |
889 | 6f0437e8 | Jan Kiszka | "Need MADV_DONTFORK in absence of synchronous KVM MMU\n");
|
890 | 6f0437e8 | Jan Kiszka | exit(1);
|
891 | 6f0437e8 | Jan Kiszka | #endif
|
892 | 6f0437e8 | Jan Kiszka | } |
893 | 6f0437e8 | Jan Kiszka | } |
894 | 6f0437e8 | Jan Kiszka | |
895 | e22a25c9 | aliguori | #ifdef KVM_CAP_SET_GUEST_DEBUG
|
896 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
|
897 | e22a25c9 | aliguori | target_ulong pc) |
898 | e22a25c9 | aliguori | { |
899 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp;
|
900 | e22a25c9 | aliguori | |
901 | e22a25c9 | aliguori | TAILQ_FOREACH(bp, &env->kvm_state->kvm_sw_breakpoints, entry) { |
902 | e22a25c9 | aliguori | if (bp->pc == pc)
|
903 | e22a25c9 | aliguori | return bp;
|
904 | e22a25c9 | aliguori | } |
905 | e22a25c9 | aliguori | return NULL; |
906 | e22a25c9 | aliguori | } |
907 | e22a25c9 | aliguori | |
908 | e22a25c9 | aliguori | int kvm_sw_breakpoints_active(CPUState *env)
|
909 | e22a25c9 | aliguori | { |
910 | e22a25c9 | aliguori | return !TAILQ_EMPTY(&env->kvm_state->kvm_sw_breakpoints);
|
911 | e22a25c9 | aliguori | } |
912 | e22a25c9 | aliguori | |
913 | 452e4751 | Glauber Costa | struct kvm_set_guest_debug_data {
|
914 | 452e4751 | Glauber Costa | struct kvm_guest_debug dbg;
|
915 | 452e4751 | Glauber Costa | CPUState *env; |
916 | 452e4751 | Glauber Costa | int err;
|
917 | 452e4751 | Glauber Costa | }; |
918 | 452e4751 | Glauber Costa | |
919 | 452e4751 | Glauber Costa | static void kvm_invoke_set_guest_debug(void *data) |
920 | 452e4751 | Glauber Costa | { |
921 | 452e4751 | Glauber Costa | struct kvm_set_guest_debug_data *dbg_data = data;
|
922 | 452e4751 | Glauber Costa | dbg_data->err = kvm_vcpu_ioctl(dbg_data->env, KVM_SET_GUEST_DEBUG, &dbg_data->dbg); |
923 | 452e4751 | Glauber Costa | } |
924 | 452e4751 | Glauber Costa | |
925 | e22a25c9 | aliguori | int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap) |
926 | e22a25c9 | aliguori | { |
927 | 452e4751 | Glauber Costa | struct kvm_set_guest_debug_data data;
|
928 | e22a25c9 | aliguori | |
929 | 452e4751 | Glauber Costa | data.dbg.control = 0;
|
930 | e22a25c9 | aliguori | if (env->singlestep_enabled)
|
931 | 452e4751 | Glauber Costa | data.dbg.control = KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP; |
932 | e22a25c9 | aliguori | |
933 | 452e4751 | Glauber Costa | kvm_arch_update_guest_debug(env, &data.dbg); |
934 | 452e4751 | Glauber Costa | data.dbg.control |= reinject_trap; |
935 | 452e4751 | Glauber Costa | data.env = env; |
936 | e22a25c9 | aliguori | |
937 | 452e4751 | Glauber Costa | on_vcpu(env, kvm_invoke_set_guest_debug, &data); |
938 | 452e4751 | Glauber Costa | return data.err;
|
939 | e22a25c9 | aliguori | } |
940 | e22a25c9 | aliguori | |
941 | e22a25c9 | aliguori | int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
|
942 | e22a25c9 | aliguori | target_ulong len, int type)
|
943 | e22a25c9 | aliguori | { |
944 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp;
|
945 | e22a25c9 | aliguori | CPUState *env; |
946 | e22a25c9 | aliguori | int err;
|
947 | e22a25c9 | aliguori | |
948 | e22a25c9 | aliguori | if (type == GDB_BREAKPOINT_SW) {
|
949 | e22a25c9 | aliguori | bp = kvm_find_sw_breakpoint(current_env, addr); |
950 | e22a25c9 | aliguori | if (bp) {
|
951 | e22a25c9 | aliguori | bp->use_count++; |
952 | e22a25c9 | aliguori | return 0; |
953 | e22a25c9 | aliguori | } |
954 | e22a25c9 | aliguori | |
955 | e22a25c9 | aliguori | bp = qemu_malloc(sizeof(struct kvm_sw_breakpoint)); |
956 | e22a25c9 | aliguori | if (!bp)
|
957 | e22a25c9 | aliguori | return -ENOMEM;
|
958 | e22a25c9 | aliguori | |
959 | e22a25c9 | aliguori | bp->pc = addr; |
960 | e22a25c9 | aliguori | bp->use_count = 1;
|
961 | e22a25c9 | aliguori | err = kvm_arch_insert_sw_breakpoint(current_env, bp); |
962 | e22a25c9 | aliguori | if (err) {
|
963 | e22a25c9 | aliguori | free(bp); |
964 | e22a25c9 | aliguori | return err;
|
965 | e22a25c9 | aliguori | } |
966 | e22a25c9 | aliguori | |
967 | e22a25c9 | aliguori | TAILQ_INSERT_HEAD(¤t_env->kvm_state->kvm_sw_breakpoints, |
968 | e22a25c9 | aliguori | bp, entry); |
969 | e22a25c9 | aliguori | } else {
|
970 | e22a25c9 | aliguori | err = kvm_arch_insert_hw_breakpoint(addr, len, type); |
971 | e22a25c9 | aliguori | if (err)
|
972 | e22a25c9 | aliguori | return err;
|
973 | e22a25c9 | aliguori | } |
974 | e22a25c9 | aliguori | |
975 | e22a25c9 | aliguori | for (env = first_cpu; env != NULL; env = env->next_cpu) { |
976 | e22a25c9 | aliguori | err = kvm_update_guest_debug(env, 0);
|
977 | e22a25c9 | aliguori | if (err)
|
978 | e22a25c9 | aliguori | return err;
|
979 | e22a25c9 | aliguori | } |
980 | e22a25c9 | aliguori | return 0; |
981 | e22a25c9 | aliguori | } |
982 | e22a25c9 | aliguori | |
983 | e22a25c9 | aliguori | int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
|
984 | e22a25c9 | aliguori | target_ulong len, int type)
|
985 | e22a25c9 | aliguori | { |
986 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp;
|
987 | e22a25c9 | aliguori | CPUState *env; |
988 | e22a25c9 | aliguori | int err;
|
989 | e22a25c9 | aliguori | |
990 | e22a25c9 | aliguori | if (type == GDB_BREAKPOINT_SW) {
|
991 | e22a25c9 | aliguori | bp = kvm_find_sw_breakpoint(current_env, addr); |
992 | e22a25c9 | aliguori | if (!bp)
|
993 | e22a25c9 | aliguori | return -ENOENT;
|
994 | e22a25c9 | aliguori | |
995 | e22a25c9 | aliguori | if (bp->use_count > 1) { |
996 | e22a25c9 | aliguori | bp->use_count--; |
997 | e22a25c9 | aliguori | return 0; |
998 | e22a25c9 | aliguori | } |
999 | e22a25c9 | aliguori | |
1000 | e22a25c9 | aliguori | err = kvm_arch_remove_sw_breakpoint(current_env, bp); |
1001 | e22a25c9 | aliguori | if (err)
|
1002 | e22a25c9 | aliguori | return err;
|
1003 | e22a25c9 | aliguori | |
1004 | e22a25c9 | aliguori | TAILQ_REMOVE(¤t_env->kvm_state->kvm_sw_breakpoints, bp, entry); |
1005 | e22a25c9 | aliguori | qemu_free(bp); |
1006 | e22a25c9 | aliguori | } else {
|
1007 | e22a25c9 | aliguori | err = kvm_arch_remove_hw_breakpoint(addr, len, type); |
1008 | e22a25c9 | aliguori | if (err)
|
1009 | e22a25c9 | aliguori | return err;
|
1010 | e22a25c9 | aliguori | } |
1011 | e22a25c9 | aliguori | |
1012 | e22a25c9 | aliguori | for (env = first_cpu; env != NULL; env = env->next_cpu) { |
1013 | e22a25c9 | aliguori | err = kvm_update_guest_debug(env, 0);
|
1014 | e22a25c9 | aliguori | if (err)
|
1015 | e22a25c9 | aliguori | return err;
|
1016 | e22a25c9 | aliguori | } |
1017 | e22a25c9 | aliguori | return 0; |
1018 | e22a25c9 | aliguori | } |
1019 | e22a25c9 | aliguori | |
1020 | e22a25c9 | aliguori | void kvm_remove_all_breakpoints(CPUState *current_env)
|
1021 | e22a25c9 | aliguori | { |
1022 | e22a25c9 | aliguori | struct kvm_sw_breakpoint *bp, *next;
|
1023 | e22a25c9 | aliguori | KVMState *s = current_env->kvm_state; |
1024 | e22a25c9 | aliguori | CPUState *env; |
1025 | e22a25c9 | aliguori | |
1026 | e22a25c9 | aliguori | TAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { |
1027 | e22a25c9 | aliguori | if (kvm_arch_remove_sw_breakpoint(current_env, bp) != 0) { |
1028 | e22a25c9 | aliguori | /* Try harder to find a CPU that currently sees the breakpoint. */
|
1029 | e22a25c9 | aliguori | for (env = first_cpu; env != NULL; env = env->next_cpu) { |
1030 | e22a25c9 | aliguori | if (kvm_arch_remove_sw_breakpoint(env, bp) == 0) |
1031 | e22a25c9 | aliguori | break;
|
1032 | e22a25c9 | aliguori | } |
1033 | e22a25c9 | aliguori | } |
1034 | e22a25c9 | aliguori | } |
1035 | e22a25c9 | aliguori | kvm_arch_remove_all_hw_breakpoints(); |
1036 | e22a25c9 | aliguori | |
1037 | e22a25c9 | aliguori | for (env = first_cpu; env != NULL; env = env->next_cpu) |
1038 | e22a25c9 | aliguori | kvm_update_guest_debug(env, 0);
|
1039 | e22a25c9 | aliguori | } |
1040 | e22a25c9 | aliguori | |
1041 | e22a25c9 | aliguori | #else /* !KVM_CAP_SET_GUEST_DEBUG */ |
1042 | e22a25c9 | aliguori | |
1043 | e22a25c9 | aliguori | int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap) |
1044 | e22a25c9 | aliguori | { |
1045 | e22a25c9 | aliguori | return -EINVAL;
|
1046 | e22a25c9 | aliguori | } |
1047 | e22a25c9 | aliguori | |
1048 | e22a25c9 | aliguori | int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
|
1049 | e22a25c9 | aliguori | target_ulong len, int type)
|
1050 | e22a25c9 | aliguori | { |
1051 | e22a25c9 | aliguori | return -EINVAL;
|
1052 | e22a25c9 | aliguori | } |
1053 | e22a25c9 | aliguori | |
1054 | e22a25c9 | aliguori | int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
|
1055 | e22a25c9 | aliguori | target_ulong len, int type)
|
1056 | e22a25c9 | aliguori | { |
1057 | e22a25c9 | aliguori | return -EINVAL;
|
1058 | e22a25c9 | aliguori | } |
1059 | e22a25c9 | aliguori | |
1060 | e22a25c9 | aliguori | void kvm_remove_all_breakpoints(CPUState *current_env)
|
1061 | e22a25c9 | aliguori | { |
1062 | e22a25c9 | aliguori | } |
1063 | e22a25c9 | aliguori | #endif /* !KVM_CAP_SET_GUEST_DEBUG */ |