4 * Copyright (C) 2006-2008 Qumranet Technologies
6 * Licensed under the terms of the GNU GPL version 2 or higher.
9 #include "config-host.h"
19 #include "qemu-common.h"
27 #include <sys/utsname.h>
28 #include <sys/syscall.h>
34 extern void perror(const char *s
);
36 kvm_context_t kvm_context
;
40 pthread_mutex_t qemu_mutex
= PTHREAD_MUTEX_INITIALIZER
;
41 pthread_cond_t qemu_vcpu_cond
= PTHREAD_COND_INITIALIZER
;
42 pthread_cond_t qemu_system_cond
= PTHREAD_COND_INITIALIZER
;
43 pthread_cond_t qemu_pause_cond
= PTHREAD_COND_INITIALIZER
;
44 pthread_cond_t qemu_work_cond
= PTHREAD_COND_INITIALIZER
;
45 __thread
struct CPUState
*current_env
;
47 static int qemu_system_ready
;
49 #define SIG_IPI (SIGRTMIN+4)
52 static int io_thread_fd
= -1;
53 static int io_thread_sigfd
= -1;
55 static int kvm_debug_stop_requested
;
57 /* The list of ioperm_data */
58 static LIST_HEAD(, ioperm_data
) ioperm_head
;
60 static inline unsigned long kvm_get_thread_id(void)
62 return syscall(SYS_gettid
);
65 static void qemu_cond_wait(pthread_cond_t
*cond
)
67 CPUState
*env
= cpu_single_env
;
68 static const struct timespec ts
= {
73 pthread_cond_timedwait(cond
, &qemu_mutex
, &ts
);
77 static void sig_ipi_handler(int n
)
81 static void on_vcpu(CPUState
*env
, void (*func
)(void *data
), void *data
)
83 struct qemu_work_item wi
;
85 if (env
== current_env
) {
92 if (!env
->kvm_cpu_state
.queued_work_first
)
93 env
->kvm_cpu_state
.queued_work_first
= &wi
;
95 env
->kvm_cpu_state
.queued_work_last
->next
= &wi
;
96 env
->kvm_cpu_state
.queued_work_last
= &wi
;
100 pthread_kill(env
->kvm_cpu_state
.thread
, SIG_IPI
);
102 qemu_cond_wait(&qemu_work_cond
);
105 static void inject_interrupt(void *data
)
107 cpu_interrupt(current_env
, (int)data
);
110 void kvm_inject_interrupt(CPUState
*env
, int mask
)
112 on_vcpu(env
, inject_interrupt
, (void *)mask
);
115 void kvm_update_interrupt_request(CPUState
*env
)
120 if (current_env
&& !current_env
->kvm_cpu_state
.created
)
123 * Testing for created here is really redundant
125 if (current_env
&& current_env
->kvm_cpu_state
.created
&&
126 env
!= current_env
&& !env
->kvm_cpu_state
.signalled
)
130 env
->kvm_cpu_state
.signalled
= 1;
131 if (env
->kvm_cpu_state
.thread
)
132 pthread_kill(env
->kvm_cpu_state
.thread
, SIG_IPI
);
137 void kvm_update_after_sipi(CPUState
*env
)
139 env
->kvm_cpu_state
.sipi_needed
= 1;
140 kvm_update_interrupt_request(env
);
143 void kvm_apic_init(CPUState
*env
)
145 if (env
->cpu_index
!= 0)
146 env
->kvm_cpu_state
.init
= 1;
147 kvm_update_interrupt_request(env
);
152 static int try_push_interrupts(void *opaque
)
154 return kvm_arch_try_push_interrupts(opaque
);
157 static int try_push_nmi(void *opaque
)
159 return kvm_arch_try_push_nmi(opaque
);
162 static void post_kvm_run(void *opaque
, void *data
)
164 CPUState
*env
= (CPUState
*)data
;
166 pthread_mutex_lock(&qemu_mutex
);
167 kvm_arch_post_kvm_run(opaque
, env
);
170 static int pre_kvm_run(void *opaque
, void *data
)
172 CPUState
*env
= (CPUState
*)data
;
174 kvm_arch_pre_kvm_run(opaque
, env
);
176 if (env
->interrupt_request
& CPU_INTERRUPT_EXIT
)
178 pthread_mutex_unlock(&qemu_mutex
);
182 static void kvm_do_load_registers(void *_env
)
184 CPUState
*env
= _env
;
186 kvm_arch_load_regs(env
);
189 void kvm_load_registers(CPUState
*env
)
191 if (kvm_enabled() && qemu_system_ready
)
192 on_vcpu(env
, kvm_do_load_registers
, env
);
195 static void kvm_do_save_registers(void *_env
)
197 CPUState
*env
= _env
;
199 kvm_arch_save_regs(env
);
202 void kvm_save_registers(CPUState
*env
)
205 on_vcpu(env
, kvm_do_save_registers
, env
);
208 int kvm_cpu_exec(CPUState
*env
)
212 r
= kvm_run(kvm_context
, env
->cpu_index
, env
);
214 printf("kvm_run returned %d\n", r
);
221 extern int vm_running
;
223 static int has_work(CPUState
*env
)
225 if (!vm_running
|| (env
&& env
->kvm_cpu_state
.stopped
))
229 return kvm_arch_has_work(env
);
232 static void flush_queued_work(CPUState
*env
)
234 struct qemu_work_item
*wi
;
236 if (!env
->kvm_cpu_state
.queued_work_first
)
239 while ((wi
= env
->kvm_cpu_state
.queued_work_first
)) {
240 env
->kvm_cpu_state
.queued_work_first
= wi
->next
;
244 env
->kvm_cpu_state
.queued_work_last
= NULL
;
245 pthread_cond_broadcast(&qemu_work_cond
);
248 static void kvm_main_loop_wait(CPUState
*env
, int timeout
)
255 pthread_mutex_unlock(&qemu_mutex
);
257 ts
.tv_sec
= timeout
/ 1000;
258 ts
.tv_nsec
= (timeout
% 1000) * 1000000;
259 sigemptyset(&waitset
);
260 sigaddset(&waitset
, SIG_IPI
);
262 r
= sigtimedwait(&waitset
, &siginfo
, &ts
);
265 pthread_mutex_lock(&qemu_mutex
);
267 if (r
== -1 && !(e
== EAGAIN
|| e
== EINTR
)) {
268 printf("sigtimedwait: %s\n", strerror(e
));
272 cpu_single_env
= env
;
273 flush_queued_work(env
);
275 if (env
->kvm_cpu_state
.stop
) {
276 env
->kvm_cpu_state
.stop
= 0;
277 env
->kvm_cpu_state
.stopped
= 1;
278 pthread_cond_signal(&qemu_pause_cond
);
281 env
->kvm_cpu_state
.signalled
= 0;
284 static int all_threads_paused(void)
286 CPUState
*penv
= first_cpu
;
289 if (penv
->kvm_cpu_state
.stop
)
291 penv
= (CPUState
*)penv
->next_cpu
;
297 static void pause_all_threads(void)
299 CPUState
*penv
= first_cpu
;
301 assert(!cpu_single_env
);
304 penv
->kvm_cpu_state
.stop
= 1;
305 pthread_kill(penv
->kvm_cpu_state
.thread
, SIG_IPI
);
306 penv
= (CPUState
*)penv
->next_cpu
;
309 while (!all_threads_paused())
310 qemu_cond_wait(&qemu_pause_cond
);
313 static void resume_all_threads(void)
315 CPUState
*penv
= first_cpu
;
317 assert(!cpu_single_env
);
320 penv
->kvm_cpu_state
.stop
= 0;
321 penv
->kvm_cpu_state
.stopped
= 0;
322 pthread_kill(penv
->kvm_cpu_state
.thread
, SIG_IPI
);
323 penv
= (CPUState
*)penv
->next_cpu
;
327 static void kvm_vm_state_change_handler(void *context
, int running
)
330 resume_all_threads();
335 static void update_regs_for_sipi(CPUState
*env
)
337 kvm_arch_update_regs_for_sipi(env
);
338 env
->kvm_cpu_state
.sipi_needed
= 0;
341 static void update_regs_for_init(CPUState
*env
)
344 SegmentCache cs
= env
->segs
[R_CS
];
350 /* restore SIPI vector */
351 if(env
->kvm_cpu_state
.sipi_needed
)
352 env
->segs
[R_CS
] = cs
;
355 env
->kvm_cpu_state
.init
= 0;
356 kvm_arch_load_regs(env
);
359 static void setup_kernel_sigmask(CPUState
*env
)
364 sigaddset(&set
, SIGUSR2
);
365 sigaddset(&set
, SIGIO
);
366 sigaddset(&set
, SIGALRM
);
367 sigprocmask(SIG_BLOCK
, &set
, NULL
);
369 sigprocmask(SIG_BLOCK
, NULL
, &set
);
370 sigdelset(&set
, SIG_IPI
);
372 kvm_set_signal_mask(kvm_context
, env
->cpu_index
, &set
);
375 void qemu_kvm_system_reset(void)
377 CPUState
*penv
= first_cpu
;
384 kvm_arch_cpu_reset(penv
);
385 penv
= (CPUState
*)penv
->next_cpu
;
388 resume_all_threads();
391 static int kvm_main_loop_cpu(CPUState
*env
)
393 setup_kernel_sigmask(env
);
395 pthread_mutex_lock(&qemu_mutex
);
396 if (kvm_irqchip_in_kernel(kvm_context
))
399 kvm_qemu_init_env(env
);
401 kvm_tpr_vcpu_start(env
);
404 cpu_single_env
= env
;
405 kvm_load_registers(env
);
408 while (!has_work(env
))
409 kvm_main_loop_wait(env
, 1000);
410 if (env
->interrupt_request
& (CPU_INTERRUPT_HARD
| CPU_INTERRUPT_NMI
))
412 if (!kvm_irqchip_in_kernel(kvm_context
)) {
413 if (env
->kvm_cpu_state
.init
)
414 update_regs_for_init(env
);
415 if (env
->kvm_cpu_state
.sipi_needed
)
416 update_regs_for_sipi(env
);
418 if (!env
->halted
&& !env
->kvm_cpu_state
.init
)
420 env
->interrupt_request
&= ~CPU_INTERRUPT_EXIT
;
421 kvm_main_loop_wait(env
, 0);
423 pthread_mutex_unlock(&qemu_mutex
);
427 static void *ap_main_loop(void *_env
)
429 CPUState
*env
= _env
;
431 struct ioperm_data
*data
= NULL
;
434 env
->thread_id
= kvm_get_thread_id();
435 sigfillset(&signals
);
436 sigprocmask(SIG_BLOCK
, &signals
, NULL
);
437 kvm_create_vcpu(kvm_context
, env
->cpu_index
);
438 kvm_qemu_init_env(env
);
440 #ifdef USE_KVM_DEVICE_ASSIGNMENT
441 /* do ioperm for io ports of assigned devices */
442 LIST_FOREACH(data
, &ioperm_head
, entries
)
443 on_vcpu(env
, kvm_arch_do_ioperm
, data
);
446 /* signal VCPU creation */
447 pthread_mutex_lock(&qemu_mutex
);
448 current_env
->kvm_cpu_state
.created
= 1;
449 pthread_cond_signal(&qemu_vcpu_cond
);
451 /* and wait for machine initialization */
452 while (!qemu_system_ready
)
453 qemu_cond_wait(&qemu_system_cond
);
454 pthread_mutex_unlock(&qemu_mutex
);
456 kvm_main_loop_cpu(env
);
460 void kvm_init_vcpu(CPUState
*env
)
462 int cpu
= env
->cpu_index
;
463 pthread_create(&env
->kvm_cpu_state
.thread
, NULL
, ap_main_loop
, env
);
465 while (env
->kvm_cpu_state
.created
== 0)
466 qemu_cond_wait(&qemu_vcpu_cond
);
469 int kvm_init_ap(void)
474 qemu_add_vm_change_state_handler(kvm_vm_state_change_handler
, NULL
);
476 signal(SIG_IPI
, sig_ipi_handler
);
480 void qemu_kvm_notify_work(void)
486 if (io_thread_fd
== -1)
489 memcpy(buffer
, &value
, sizeof(value
));
494 len
= write(io_thread_fd
, buffer
+ offset
, 8 - offset
);
495 if (len
== -1 && errno
== EINTR
)
505 fprintf(stderr
, "failed to notify io thread\n");
508 /* If we have signalfd, we mask out the signals we want to handle and then
509 * use signalfd to listen for them. We rely on whatever the current signal
510 * handler is to dispatch the signals when we receive them.
513 static void sigfd_handler(void *opaque
)
515 int fd
= (unsigned long)opaque
;
516 struct qemu_signalfd_siginfo info
;
517 struct sigaction action
;
522 len
= read(fd
, &info
, sizeof(info
));
523 } while (len
== -1 && errno
== EINTR
);
525 if (len
== -1 && errno
== EAGAIN
)
528 if (len
!= sizeof(info
)) {
529 printf("read from sigfd returned %ld: %m\n", len
);
533 sigaction(info
.ssi_signo
, NULL
, &action
);
534 if (action
.sa_handler
)
535 action
.sa_handler(info
.ssi_signo
);
540 /* Used to break IO thread out of select */
541 static void io_thread_wakeup(void *opaque
)
543 int fd
= (unsigned long)opaque
;
550 len
= read(fd
, buffer
+ offset
, 8 - offset
);
551 if (len
== -1 && errno
== EINTR
)
561 int kvm_main_loop(void)
567 io_thread
= pthread_self();
568 qemu_system_ready
= 1;
570 if (qemu_eventfd(fds
) == -1) {
571 fprintf(stderr
, "failed to create eventfd\n");
575 qemu_set_fd_handler2(fds
[0], NULL
, io_thread_wakeup
, NULL
,
576 (void *)(unsigned long)fds
[0]);
578 io_thread_fd
= fds
[1];
581 sigaddset(&mask
, SIGIO
);
582 sigaddset(&mask
, SIGALRM
);
583 sigprocmask(SIG_BLOCK
, &mask
, NULL
);
585 sigfd
= qemu_signalfd(&mask
);
587 fprintf(stderr
, "failed to create signalfd\n");
591 fcntl(sigfd
, F_SETFL
, O_NONBLOCK
);
593 qemu_set_fd_handler2(sigfd
, NULL
, sigfd_handler
, NULL
,
594 (void *)(unsigned long)sigfd
);
596 pthread_cond_broadcast(&qemu_system_cond
);
598 io_thread_sigfd
= sigfd
;
599 cpu_single_env
= NULL
;
602 main_loop_wait(1000);
603 if (qemu_shutdown_requested())
605 else if (qemu_powerdown_requested())
606 qemu_system_powerdown();
607 else if (qemu_reset_requested())
608 qemu_kvm_system_reset();
609 else if (kvm_debug_stop_requested
) {
611 kvm_debug_stop_requested
= 0;
616 pthread_mutex_unlock(&qemu_mutex
);
621 static int kvm_debug(void *opaque
, void *data
)
623 struct CPUState
*env
= (struct CPUState
*)data
;
625 kvm_debug_stop_requested
= 1;
626 env
->kvm_cpu_state
.stopped
= 1;
630 static int kvm_inb(void *opaque
, uint16_t addr
, uint8_t *data
)
632 *data
= cpu_inb(0, addr
);
636 static int kvm_inw(void *opaque
, uint16_t addr
, uint16_t *data
)
638 *data
= cpu_inw(0, addr
);
642 static int kvm_inl(void *opaque
, uint16_t addr
, uint32_t *data
)
644 *data
= cpu_inl(0, addr
);
648 #define PM_IO_BASE 0xb000
650 static int kvm_outb(void *opaque
, uint16_t addr
, uint8_t data
)
655 cpu_outb(0, 0xb3, 0);
662 x
= cpu_inw(0, PM_IO_BASE
+ 4);
664 cpu_outw(0, PM_IO_BASE
+ 4, x
);
671 x
= cpu_inw(0, PM_IO_BASE
+ 4);
673 cpu_outw(0, PM_IO_BASE
+ 4, x
);
681 cpu_outb(0, addr
, data
);
685 static int kvm_outw(void *opaque
, uint16_t addr
, uint16_t data
)
687 cpu_outw(0, addr
, data
);
691 static int kvm_outl(void *opaque
, uint16_t addr
, uint32_t data
)
693 cpu_outl(0, addr
, data
);
697 static int kvm_mmio_read(void *opaque
, uint64_t addr
, uint8_t *data
, int len
)
699 cpu_physical_memory_rw(addr
, data
, len
, 0);
703 static int kvm_mmio_write(void *opaque
, uint64_t addr
, uint8_t *data
, int len
)
705 cpu_physical_memory_rw(addr
, data
, len
, 1);
709 static int kvm_io_window(void *opaque
)
715 static int kvm_halt(void *opaque
, int vcpu
)
717 return kvm_arch_halt(opaque
, vcpu
);
720 static int kvm_shutdown(void *opaque
, void *data
)
722 struct CPUState
*env
= (struct CPUState
*)data
;
724 /* stop the current vcpu from going back to guest mode */
725 env
->kvm_cpu_state
.stopped
= 1;
727 qemu_system_reset_request();
731 static struct kvm_callbacks qemu_kvm_ops
= {
739 .mmio_read
= kvm_mmio_read
,
740 .mmio_write
= kvm_mmio_write
,
742 .shutdown
= kvm_shutdown
,
743 .io_window
= kvm_io_window
,
744 .try_push_interrupts
= try_push_interrupts
,
745 .try_push_nmi
= try_push_nmi
,
746 .post_kvm_run
= post_kvm_run
,
747 .pre_kvm_run
= pre_kvm_run
,
749 .tpr_access
= handle_tpr_access
,
752 .powerpc_dcr_read
= handle_powerpc_dcr_read
,
753 .powerpc_dcr_write
= handle_powerpc_dcr_write
,
759 /* Try to initialize kvm */
760 kvm_context
= kvm_init(&qemu_kvm_ops
, cpu_single_env
);
764 pthread_mutex_lock(&qemu_mutex
);
769 int kvm_qemu_create_context(void)
773 kvm_disable_irqchip_creation(kvm_context
);
776 kvm_disable_pit_creation(kvm_context
);
778 if (kvm_create(kvm_context
, phys_ram_size
, (void**)&phys_ram_base
) < 0) {
782 r
= kvm_arch_qemu_create_context();
788 void kvm_qemu_destroy(void)
790 kvm_finalize(kvm_context
);
793 void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr
,
795 unsigned long phys_offset
)
798 unsigned long area_flags
= phys_offset
& ~TARGET_PAGE_MASK
;
800 phys_offset
&= ~IO_MEM_ROM
;
802 if (area_flags
== IO_MEM_UNASSIGNED
) {
803 kvm_unregister_memory_area(kvm_context
, start_addr
, size
);
807 r
= kvm_is_containing_region(kvm_context
, start_addr
, size
);
811 if (area_flags
>= TLB_MMIO
)
814 r
= kvm_register_phys_mem(kvm_context
, start_addr
,
815 phys_ram_base
+ phys_offset
,
818 printf("kvm_cpu_register_physical_memory: failed\n");
824 void kvm_cpu_unregister_physical_memory(target_phys_addr_t start_addr
,
825 target_phys_addr_t size
,
826 unsigned long phys_offset
)
828 kvm_unregister_memory_area(kvm_context
, start_addr
, size
);
831 int kvm_setup_guest_memory(void *area
, unsigned long size
)
836 if (kvm_enabled() && !kvm_has_sync_mmu(kvm_context
))
837 ret
= madvise(area
, size
, MADV_DONTFORK
);
846 int kvm_qemu_check_extension(int ext
)
848 return kvm_check_extension(kvm_context
, ext
);
851 int kvm_qemu_init_env(CPUState
*cenv
)
853 return kvm_arch_qemu_init_env(cenv
);
856 struct kvm_guest_debug_data
{
857 struct kvm_debug_guest dbg
;
861 void kvm_invoke_guest_debug(void *data
)
863 struct kvm_guest_debug_data
*dbg_data
= data
;
865 dbg_data
->err
= kvm_guest_debug(kvm_context
, cpu_single_env
->cpu_index
,
869 int kvm_update_debugger(CPUState
*env
)
871 struct kvm_guest_debug_data data
;
874 memset(data
.dbg
.breakpoints
, 0, sizeof(data
.dbg
.breakpoints
));
876 data
.dbg
.enabled
= 0;
877 if (env
->nb_breakpoints
|| env
->singlestep_enabled
) {
878 data
.dbg
.enabled
= 1;
879 for (i
= 0; i
< 4 && i
< env
->nb_breakpoints
; ++i
) {
880 data
.dbg
.breakpoints
[i
].enabled
= 1;
881 data
.dbg
.breakpoints
[i
].address
= env
->breakpoints
[i
];
883 data
.dbg
.singlestep
= env
->singlestep_enabled
;
885 on_vcpu(env
, kvm_invoke_guest_debug
, &data
);
891 * dirty pages logging
893 /* FIXME: use unsigned long pointer instead of unsigned char */
894 unsigned char *kvm_dirty_bitmap
= NULL
;
895 int kvm_physical_memory_set_dirty_tracking(int enable
)
903 if (!kvm_dirty_bitmap
) {
904 unsigned bitmap_size
= BITMAP_SIZE(phys_ram_size
);
905 kvm_dirty_bitmap
= qemu_malloc(bitmap_size
);
906 if (kvm_dirty_bitmap
== NULL
) {
907 perror("Failed to allocate dirty pages bitmap");
911 r
= kvm_dirty_pages_log_enable_all(kvm_context
);
916 if (kvm_dirty_bitmap
) {
917 r
= kvm_dirty_pages_log_reset(kvm_context
);
918 qemu_free(kvm_dirty_bitmap
);
919 kvm_dirty_bitmap
= NULL
;
925 /* get kvm's dirty pages bitmap and update qemu's */
926 int kvm_get_dirty_pages_log_range(unsigned long start_addr
,
927 unsigned char *bitmap
,
929 unsigned long mem_size
)
931 unsigned int i
, j
, n
=0;
933 unsigned page_number
, addr
, addr1
;
934 unsigned int len
= ((mem_size
/TARGET_PAGE_SIZE
) + 7) / 8;
937 * bitmap-traveling is faster than memory-traveling (for addr...)
938 * especially when most of the memory is not dirty.
940 for (i
=0; i
<len
; i
++) {
945 page_number
= i
* 8 + j
;
946 addr1
= page_number
* TARGET_PAGE_SIZE
;
947 addr
= offset
+ addr1
;
948 cpu_physical_memory_set_dirty(addr
);
954 int kvm_get_dirty_bitmap_cb(unsigned long start
, unsigned long len
,
955 void *bitmap
, void *opaque
)
957 return kvm_get_dirty_pages_log_range(start
, bitmap
, start
, len
);
961 * get kvm's dirty pages bitmap and update qemu's
962 * we only care about physical ram, which resides in slots 0 and 3
964 int kvm_update_dirty_pages_log(void)
969 r
= kvm_get_dirty_pages_range(kvm_context
, 0, phys_ram_size
,
970 kvm_dirty_bitmap
, NULL
,
971 kvm_get_dirty_bitmap_cb
);
975 void kvm_qemu_log_memory(target_phys_addr_t start
, target_phys_addr_t size
,
979 kvm_dirty_pages_log_enable_slot(kvm_context
, start
, size
);
981 kvm_dirty_pages_log_disable_slot(kvm_context
, start
, size
);
984 int kvm_get_phys_ram_page_bitmap(unsigned char *bitmap
)
986 unsigned int bsize
= BITMAP_SIZE(phys_ram_size
);
987 unsigned int brsize
= BITMAP_SIZE(ram_size
);
988 unsigned int extra_pages
= (phys_ram_size
- ram_size
) / TARGET_PAGE_SIZE
;
989 unsigned int extra_bytes
= (extra_pages
+7)/8;
990 unsigned int hole_start
= BITMAP_SIZE(0xa0000);
991 unsigned int hole_end
= BITMAP_SIZE(0xc0000);
993 memset(bitmap
, 0xFF, brsize
+ extra_bytes
);
994 memset(bitmap
+ hole_start
, 0, hole_end
- hole_start
);
995 memset(bitmap
+ brsize
+ extra_bytes
, 0, bsize
- brsize
- extra_bytes
);
1000 #ifdef KVM_CAP_IRQCHIP
1002 int kvm_set_irq(int irq
, int level
)
1004 return kvm_set_irq_level(kvm_context
, irq
, level
);
1009 int qemu_kvm_get_dirty_pages(unsigned long phys_addr
, void *buf
)
1011 return kvm_get_dirty_pages(kvm_context
, phys_addr
, buf
);
1014 void *kvm_cpu_create_phys_mem(target_phys_addr_t start_addr
,
1015 unsigned long size
, int log
, int writable
)
1017 return kvm_create_phys_mem(kvm_context
, start_addr
, size
, log
, writable
);
1020 void kvm_cpu_destroy_phys_mem(target_phys_addr_t start_addr
,
1023 kvm_destroy_phys_mem(kvm_context
, start_addr
, size
);
1026 void kvm_mutex_unlock(void)
1028 assert(!cpu_single_env
);
1029 pthread_mutex_unlock(&qemu_mutex
);
1032 void kvm_mutex_lock(void)
1034 pthread_mutex_lock(&qemu_mutex
);
1035 cpu_single_env
= NULL
;
1038 int qemu_kvm_register_coalesced_mmio(target_phys_addr_t addr
, unsigned int size
)
1040 return kvm_register_coalesced_mmio(kvm_context
, addr
, size
);
1043 int qemu_kvm_unregister_coalesced_mmio(target_phys_addr_t addr
,
1046 return kvm_unregister_coalesced_mmio(kvm_context
, addr
, size
);
1049 #ifdef USE_KVM_DEVICE_ASSIGNMENT
1050 void kvm_add_ioperm_data(struct ioperm_data
*data
)
1052 LIST_INSERT_HEAD(&ioperm_head
, data
, entries
);
1055 void kvm_ioperm(CPUState
*env
, void *data
)
1057 if (kvm_enabled() && qemu_system_ready
)
1058 on_vcpu(env
, kvm_arch_do_ioperm
, data
);