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>
35 extern void perror(const char *s
);
37 kvm_context_t kvm_context
;
41 pthread_mutex_t qemu_mutex
= PTHREAD_MUTEX_INITIALIZER
;
42 pthread_cond_t qemu_vcpu_cond
= PTHREAD_COND_INITIALIZER
;
43 pthread_cond_t qemu_system_cond
= PTHREAD_COND_INITIALIZER
;
44 pthread_cond_t qemu_pause_cond
= PTHREAD_COND_INITIALIZER
;
45 pthread_cond_t qemu_work_cond
= PTHREAD_COND_INITIALIZER
;
46 __thread
struct vcpu_info
*vcpu
;
48 static int qemu_system_ready
;
50 #define SIG_IPI (SIGRTMIN+4)
52 struct qemu_kvm_work_item
{
53 struct qemu_kvm_work_item
*next
;
54 void (*func
)(void *data
);
68 struct qemu_kvm_work_item
*queued_work_first
, *queued_work_last
;
72 static int io_thread_fd
= -1;
73 static int io_thread_sigfd
= -1;
75 static int kvm_debug_stop_requested
;
77 /* The list of ioperm_data */
78 static LIST_HEAD(, ioperm_data
) ioperm_head
;
80 static inline unsigned long kvm_get_thread_id(void)
82 return syscall(SYS_gettid
);
85 static void qemu_cond_wait(pthread_cond_t
*cond
)
87 CPUState
*env
= cpu_single_env
;
88 static const struct timespec ts
= {
93 pthread_cond_timedwait(cond
, &qemu_mutex
, &ts
);
97 CPUState
*qemu_kvm_cpu_env(int index
)
99 return vcpu_info
[index
].env
;
102 static void sig_ipi_handler(int n
)
106 static void on_vcpu(CPUState
*env
, void (*func
)(void *data
), void *data
)
108 struct vcpu_info
*vi
= &vcpu_info
[env
->cpu_index
];
109 struct qemu_kvm_work_item wi
;
118 if (!vi
->queued_work_first
)
119 vi
->queued_work_first
= &wi
;
121 vi
->queued_work_last
->next
= &wi
;
122 vi
->queued_work_last
= &wi
;
126 pthread_kill(vi
->thread
, SIG_IPI
);
128 qemu_cond_wait(&qemu_work_cond
);
131 static void inject_interrupt(void *data
)
133 cpu_interrupt(vcpu
->env
, (int)data
);
136 void kvm_inject_interrupt(CPUState
*env
, int mask
)
138 on_vcpu(env
, inject_interrupt
, (void *)mask
);
141 void kvm_update_interrupt_request(CPUState
*env
)
148 if (vcpu
&& env
!= vcpu
->env
&& !vcpu_info
[env
->cpu_index
].signalled
)
152 vcpu_info
[env
->cpu_index
].signalled
= 1;
153 if (vcpu_info
[env
->cpu_index
].thread
)
154 pthread_kill(vcpu_info
[env
->cpu_index
].thread
, SIG_IPI
);
159 void kvm_update_after_sipi(CPUState
*env
)
161 vcpu_info
[env
->cpu_index
].sipi_needed
= 1;
162 kvm_update_interrupt_request(env
);
165 void kvm_apic_init(CPUState
*env
)
167 if (env
->cpu_index
!= 0)
168 vcpu_info
[env
->cpu_index
].init
= 1;
169 kvm_update_interrupt_request(env
);
174 static int try_push_interrupts(void *opaque
)
176 return kvm_arch_try_push_interrupts(opaque
);
179 static int try_push_nmi(void *opaque
)
181 return kvm_arch_try_push_nmi(opaque
);
184 static void post_kvm_run(void *opaque
, int vcpu
)
187 pthread_mutex_lock(&qemu_mutex
);
188 kvm_arch_post_kvm_run(opaque
, vcpu
);
191 static int pre_kvm_run(void *opaque
, int vcpu
)
193 CPUState
*env
= qemu_kvm_cpu_env(vcpu
);
195 kvm_arch_pre_kvm_run(opaque
, vcpu
);
197 if (env
->interrupt_request
& CPU_INTERRUPT_EXIT
)
199 pthread_mutex_unlock(&qemu_mutex
);
203 static void kvm_do_load_registers(void *_env
)
205 CPUState
*env
= _env
;
207 kvm_arch_load_regs(env
);
210 void kvm_load_registers(CPUState
*env
)
212 if (kvm_enabled() && qemu_system_ready
)
213 on_vcpu(env
, kvm_do_load_registers
, env
);
216 static void kvm_do_save_registers(void *_env
)
218 CPUState
*env
= _env
;
220 kvm_arch_save_regs(env
);
223 void kvm_save_registers(CPUState
*env
)
226 on_vcpu(env
, kvm_do_save_registers
, env
);
229 int kvm_cpu_exec(CPUState
*env
)
233 r
= kvm_run(kvm_context
, env
->cpu_index
);
235 printf("kvm_run returned %d\n", r
);
242 extern int vm_running
;
244 static int has_work(CPUState
*env
)
246 if (!vm_running
|| (env
&& vcpu_info
[env
->cpu_index
].stopped
))
250 return kvm_arch_has_work(env
);
253 static void flush_queued_work(CPUState
*env
)
255 struct vcpu_info
*vi
= &vcpu_info
[env
->cpu_index
];
256 struct qemu_kvm_work_item
*wi
;
258 if (!vi
->queued_work_first
)
261 while ((wi
= vi
->queued_work_first
)) {
262 vi
->queued_work_first
= wi
->next
;
266 vi
->queued_work_last
= NULL
;
267 pthread_cond_broadcast(&qemu_work_cond
);
270 static void kvm_main_loop_wait(CPUState
*env
, int timeout
)
277 pthread_mutex_unlock(&qemu_mutex
);
279 ts
.tv_sec
= timeout
/ 1000;
280 ts
.tv_nsec
= (timeout
% 1000) * 1000000;
281 sigemptyset(&waitset
);
282 sigaddset(&waitset
, SIG_IPI
);
284 r
= sigtimedwait(&waitset
, &siginfo
, &ts
);
287 pthread_mutex_lock(&qemu_mutex
);
289 if (r
== -1 && !(e
== EAGAIN
|| e
== EINTR
)) {
290 printf("sigtimedwait: %s\n", strerror(e
));
294 cpu_single_env
= env
;
295 flush_queued_work(env
);
297 if (vcpu_info
[env
->cpu_index
].stop
) {
298 vcpu_info
[env
->cpu_index
].stop
= 0;
299 vcpu_info
[env
->cpu_index
].stopped
= 1;
300 pthread_cond_signal(&qemu_pause_cond
);
303 vcpu_info
[env
->cpu_index
].signalled
= 0;
306 static int all_threads_paused(void)
310 for (i
= 0; i
< smp_cpus
; ++i
)
311 if (vcpu_info
[i
].stop
)
316 static void pause_all_threads(void)
320 assert(!cpu_single_env
);
322 for (i
= 0; i
< smp_cpus
; ++i
) {
323 vcpu_info
[i
].stop
= 1;
324 pthread_kill(vcpu_info
[i
].thread
, SIG_IPI
);
326 while (!all_threads_paused())
327 qemu_cond_wait(&qemu_pause_cond
);
330 static void resume_all_threads(void)
334 assert(!cpu_single_env
);
336 for (i
= 0; i
< smp_cpus
; ++i
) {
337 vcpu_info
[i
].stop
= 0;
338 vcpu_info
[i
].stopped
= 0;
339 pthread_kill(vcpu_info
[i
].thread
, SIG_IPI
);
343 static void kvm_vm_state_change_handler(void *context
, int running
)
346 resume_all_threads();
351 static void update_regs_for_sipi(CPUState
*env
)
353 kvm_arch_update_regs_for_sipi(env
);
354 vcpu_info
[env
->cpu_index
].sipi_needed
= 0;
357 static void update_regs_for_init(CPUState
*env
)
360 SegmentCache cs
= env
->segs
[R_CS
];
366 /* restore SIPI vector */
367 if(vcpu_info
[env
->cpu_index
].sipi_needed
)
368 env
->segs
[R_CS
] = cs
;
370 vcpu_info
[env
->cpu_index
].init
= 0;
372 kvm_arch_load_regs(env
);
375 static void setup_kernel_sigmask(CPUState
*env
)
380 sigaddset(&set
, SIGUSR2
);
381 sigaddset(&set
, SIGIO
);
382 sigaddset(&set
, SIGALRM
);
383 sigprocmask(SIG_BLOCK
, &set
, NULL
);
385 sigprocmask(SIG_BLOCK
, NULL
, &set
);
386 sigdelset(&set
, SIG_IPI
);
388 kvm_set_signal_mask(kvm_context
, env
->cpu_index
, &set
);
391 void qemu_kvm_system_reset(void)
399 for (i
= 0; i
< smp_cpus
; ++i
)
400 kvm_arch_cpu_reset(vcpu_info
[i
].env
);
402 resume_all_threads();
405 static int kvm_main_loop_cpu(CPUState
*env
)
407 struct vcpu_info
*info
= &vcpu_info
[env
->cpu_index
];
409 setup_kernel_sigmask(env
);
411 pthread_mutex_lock(&qemu_mutex
);
412 if (kvm_irqchip_in_kernel(kvm_context
))
415 kvm_qemu_init_env(env
);
417 kvm_tpr_vcpu_start(env
);
420 cpu_single_env
= env
;
421 kvm_load_registers(env
);
424 while (!has_work(env
))
425 kvm_main_loop_wait(env
, 1000);
426 if (env
->interrupt_request
& (CPU_INTERRUPT_HARD
| CPU_INTERRUPT_NMI
))
428 if (!kvm_irqchip_in_kernel(kvm_context
)) {
430 update_regs_for_init(env
);
431 if (info
->sipi_needed
)
432 update_regs_for_sipi(env
);
434 if (!env
->halted
&& !info
->init
)
436 env
->interrupt_request
&= ~CPU_INTERRUPT_EXIT
;
437 kvm_main_loop_wait(env
, 0);
439 pthread_mutex_unlock(&qemu_mutex
);
443 static void *ap_main_loop(void *_env
)
445 CPUState
*env
= _env
;
447 struct ioperm_data
*data
= NULL
;
449 vcpu
= &vcpu_info
[env
->cpu_index
];
451 vcpu
->env
->thread_id
= kvm_get_thread_id();
452 sigfillset(&signals
);
453 sigprocmask(SIG_BLOCK
, &signals
, NULL
);
454 kvm_create_vcpu(kvm_context
, env
->cpu_index
);
455 kvm_qemu_init_env(env
);
457 #ifdef USE_KVM_DEVICE_ASSIGNMENT
458 /* do ioperm for io ports of assigned devices */
459 LIST_FOREACH(data
, &ioperm_head
, entries
)
460 on_vcpu(env
, kvm_arch_do_ioperm
, data
);
463 /* signal VCPU creation */
464 pthread_mutex_lock(&qemu_mutex
);
466 pthread_cond_signal(&qemu_vcpu_cond
);
468 /* and wait for machine initialization */
469 while (!qemu_system_ready
)
470 qemu_cond_wait(&qemu_system_cond
);
471 pthread_mutex_unlock(&qemu_mutex
);
473 kvm_main_loop_cpu(env
);
477 void kvm_init_vcpu(CPUState
*env
)
479 int cpu
= env
->cpu_index
;
480 pthread_create(&vcpu_info
[cpu
].thread
, NULL
, ap_main_loop
, env
);
482 while (vcpu_info
[cpu
].created
== 0)
483 qemu_cond_wait(&qemu_vcpu_cond
);
486 int kvm_init_ap(void)
491 qemu_add_vm_change_state_handler(kvm_vm_state_change_handler
, NULL
);
493 signal(SIG_IPI
, sig_ipi_handler
);
497 void qemu_kvm_notify_work(void)
503 if (io_thread_fd
== -1)
506 memcpy(buffer
, &value
, sizeof(value
));
511 len
= write(io_thread_fd
, buffer
+ offset
, 8 - offset
);
512 if (len
== -1 && errno
== EINTR
)
522 fprintf(stderr
, "failed to notify io thread\n");
525 /* If we have signalfd, we mask out the signals we want to handle and then
526 * use signalfd to listen for them. We rely on whatever the current signal
527 * handler is to dispatch the signals when we receive them.
530 static void sigfd_handler(void *opaque
)
532 int fd
= (unsigned long)opaque
;
533 struct qemu_signalfd_siginfo info
;
534 struct sigaction action
;
539 len
= read(fd
, &info
, sizeof(info
));
540 } while (len
== -1 && errno
== EINTR
);
542 if (len
== -1 && errno
== EAGAIN
)
545 if (len
!= sizeof(info
)) {
546 printf("read from sigfd returned %ld: %m\n", len
);
550 sigaction(info
.ssi_signo
, NULL
, &action
);
551 if (action
.sa_handler
)
552 action
.sa_handler(info
.ssi_signo
);
557 /* Used to break IO thread out of select */
558 static void io_thread_wakeup(void *opaque
)
560 int fd
= (unsigned long)opaque
;
567 len
= read(fd
, buffer
+ offset
, 8 - offset
);
568 if (len
== -1 && errno
== EINTR
)
578 int kvm_main_loop(void)
584 io_thread
= pthread_self();
585 qemu_system_ready
= 1;
587 if (qemu_eventfd(fds
) == -1) {
588 fprintf(stderr
, "failed to create eventfd\n");
592 qemu_set_fd_handler2(fds
[0], NULL
, io_thread_wakeup
, NULL
,
593 (void *)(unsigned long)fds
[0]);
595 io_thread_fd
= fds
[1];
598 sigaddset(&mask
, SIGIO
);
599 sigaddset(&mask
, SIGALRM
);
600 sigprocmask(SIG_BLOCK
, &mask
, NULL
);
602 sigfd
= qemu_signalfd(&mask
);
604 fprintf(stderr
, "failed to create signalfd\n");
608 fcntl(sigfd
, F_SETFL
, O_NONBLOCK
);
610 qemu_set_fd_handler2(sigfd
, NULL
, sigfd_handler
, NULL
,
611 (void *)(unsigned long)sigfd
);
613 pthread_cond_broadcast(&qemu_system_cond
);
615 io_thread_sigfd
= sigfd
;
616 cpu_single_env
= NULL
;
619 main_loop_wait(1000);
620 if (qemu_shutdown_requested())
622 else if (qemu_powerdown_requested())
623 qemu_system_powerdown();
624 else if (qemu_reset_requested())
625 qemu_kvm_system_reset();
626 else if (kvm_debug_stop_requested
) {
628 kvm_debug_stop_requested
= 0;
633 pthread_mutex_unlock(&qemu_mutex
);
638 static int kvm_debug(void *opaque
, int vcpu
)
640 kvm_debug_stop_requested
= 1;
641 vcpu_info
[vcpu
].stopped
= 1;
645 static int kvm_inb(void *opaque
, uint16_t addr
, uint8_t *data
)
647 *data
= cpu_inb(0, addr
);
651 static int kvm_inw(void *opaque
, uint16_t addr
, uint16_t *data
)
653 *data
= cpu_inw(0, addr
);
657 static int kvm_inl(void *opaque
, uint16_t addr
, uint32_t *data
)
659 *data
= cpu_inl(0, addr
);
663 #define PM_IO_BASE 0xb000
665 static int kvm_outb(void *opaque
, uint16_t addr
, uint8_t data
)
670 cpu_outb(0, 0xb3, 0);
677 x
= cpu_inw(0, PM_IO_BASE
+ 4);
679 cpu_outw(0, PM_IO_BASE
+ 4, x
);
686 x
= cpu_inw(0, PM_IO_BASE
+ 4);
688 cpu_outw(0, PM_IO_BASE
+ 4, x
);
696 cpu_outb(0, addr
, data
);
700 static int kvm_outw(void *opaque
, uint16_t addr
, uint16_t data
)
702 cpu_outw(0, addr
, data
);
706 static int kvm_outl(void *opaque
, uint16_t addr
, uint32_t data
)
708 cpu_outl(0, addr
, data
);
712 static int kvm_mmio_read(void *opaque
, uint64_t addr
, uint8_t *data
, int len
)
714 cpu_physical_memory_rw(addr
, data
, len
, 0);
718 static int kvm_mmio_write(void *opaque
, uint64_t addr
, uint8_t *data
, int len
)
720 cpu_physical_memory_rw(addr
, data
, len
, 1);
724 static int kvm_io_window(void *opaque
)
730 static int kvm_halt(void *opaque
, int vcpu
)
732 return kvm_arch_halt(opaque
, vcpu
);
735 static int kvm_shutdown(void *opaque
, int vcpu
)
737 /* stop the current vcpu from going back to guest mode */
738 vcpu_info
[cpu_single_env
->cpu_index
].stopped
= 1;
740 qemu_system_reset_request();
744 static struct kvm_callbacks qemu_kvm_ops
= {
752 .mmio_read
= kvm_mmio_read
,
753 .mmio_write
= kvm_mmio_write
,
755 .shutdown
= kvm_shutdown
,
756 .io_window
= kvm_io_window
,
757 .try_push_interrupts
= try_push_interrupts
,
758 .try_push_nmi
= try_push_nmi
,
759 .post_kvm_run
= post_kvm_run
,
760 .pre_kvm_run
= pre_kvm_run
,
762 .tpr_access
= handle_tpr_access
,
765 .powerpc_dcr_read
= handle_powerpc_dcr_read
,
766 .powerpc_dcr_write
= handle_powerpc_dcr_write
,
772 /* Try to initialize kvm */
773 kvm_context
= kvm_init(&qemu_kvm_ops
, cpu_single_env
);
777 pthread_mutex_lock(&qemu_mutex
);
782 int kvm_qemu_create_context(void)
786 kvm_disable_irqchip_creation(kvm_context
);
789 kvm_disable_pit_creation(kvm_context
);
791 if (kvm_create(kvm_context
, phys_ram_size
, (void**)&phys_ram_base
) < 0) {
795 r
= kvm_arch_qemu_create_context();
801 void kvm_qemu_destroy(void)
803 kvm_finalize(kvm_context
);
806 void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr
,
808 unsigned long phys_offset
)
811 unsigned long area_flags
= phys_offset
& ~TARGET_PAGE_MASK
;
813 phys_offset
&= ~IO_MEM_ROM
;
815 if (area_flags
== IO_MEM_UNASSIGNED
) {
816 kvm_unregister_memory_area(kvm_context
, start_addr
, size
);
820 r
= kvm_is_containing_region(kvm_context
, start_addr
, size
);
824 if (area_flags
>= TLB_MMIO
)
827 r
= kvm_register_phys_mem(kvm_context
, start_addr
,
828 phys_ram_base
+ phys_offset
,
831 printf("kvm_cpu_register_physical_memory: failed\n");
837 void kvm_cpu_unregister_physical_memory(target_phys_addr_t start_addr
,
838 target_phys_addr_t size
,
839 unsigned long phys_offset
)
841 kvm_unregister_memory_area(kvm_context
, start_addr
, size
);
844 int kvm_setup_guest_memory(void *area
, unsigned long size
)
849 if (kvm_enabled() && !kvm_has_sync_mmu(kvm_context
))
850 ret
= madvise(area
, size
, MADV_DONTFORK
);
859 int kvm_qemu_check_extension(int ext
)
861 return kvm_check_extension(kvm_context
, ext
);
864 int kvm_qemu_init_env(CPUState
*cenv
)
866 return kvm_arch_qemu_init_env(cenv
);
869 struct kvm_guest_debug_data
{
870 struct kvm_debug_guest dbg
;
874 void kvm_invoke_guest_debug(void *data
)
876 struct kvm_guest_debug_data
*dbg_data
= data
;
878 dbg_data
->err
= kvm_guest_debug(kvm_context
, cpu_single_env
->cpu_index
,
882 int kvm_update_debugger(CPUState
*env
)
884 struct kvm_guest_debug_data data
;
887 memset(data
.dbg
.breakpoints
, 0, sizeof(data
.dbg
.breakpoints
));
889 data
.dbg
.enabled
= 0;
890 if (env
->nb_breakpoints
|| env
->singlestep_enabled
) {
891 data
.dbg
.enabled
= 1;
892 for (i
= 0; i
< 4 && i
< env
->nb_breakpoints
; ++i
) {
893 data
.dbg
.breakpoints
[i
].enabled
= 1;
894 data
.dbg
.breakpoints
[i
].address
= env
->breakpoints
[i
];
896 data
.dbg
.singlestep
= env
->singlestep_enabled
;
898 on_vcpu(env
, kvm_invoke_guest_debug
, &data
);
904 * dirty pages logging
906 /* FIXME: use unsigned long pointer instead of unsigned char */
907 unsigned char *kvm_dirty_bitmap
= NULL
;
908 int kvm_physical_memory_set_dirty_tracking(int enable
)
916 if (!kvm_dirty_bitmap
) {
917 unsigned bitmap_size
= BITMAP_SIZE(phys_ram_size
);
918 kvm_dirty_bitmap
= qemu_malloc(bitmap_size
);
919 if (kvm_dirty_bitmap
== NULL
) {
920 perror("Failed to allocate dirty pages bitmap");
924 r
= kvm_dirty_pages_log_enable_all(kvm_context
);
929 if (kvm_dirty_bitmap
) {
930 r
= kvm_dirty_pages_log_reset(kvm_context
);
931 qemu_free(kvm_dirty_bitmap
);
932 kvm_dirty_bitmap
= NULL
;
938 /* get kvm's dirty pages bitmap and update qemu's */
939 int kvm_get_dirty_pages_log_range(unsigned long start_addr
,
940 unsigned char *bitmap
,
942 unsigned long mem_size
)
944 unsigned int i
, j
, n
=0;
946 unsigned page_number
, addr
, addr1
;
947 unsigned int len
= ((mem_size
/TARGET_PAGE_SIZE
) + 7) / 8;
950 * bitmap-traveling is faster than memory-traveling (for addr...)
951 * especially when most of the memory is not dirty.
953 for (i
=0; i
<len
; i
++) {
958 page_number
= i
* 8 + j
;
959 addr1
= page_number
* TARGET_PAGE_SIZE
;
960 addr
= offset
+ addr1
;
961 cpu_physical_memory_set_dirty(addr
);
967 int kvm_get_dirty_bitmap_cb(unsigned long start
, unsigned long len
,
968 void *bitmap
, void *opaque
)
970 return kvm_get_dirty_pages_log_range(start
, bitmap
, start
, len
);
974 * get kvm's dirty pages bitmap and update qemu's
975 * we only care about physical ram, which resides in slots 0 and 3
977 int kvm_update_dirty_pages_log(void)
982 r
= kvm_get_dirty_pages_range(kvm_context
, 0, phys_ram_size
,
983 kvm_dirty_bitmap
, NULL
,
984 kvm_get_dirty_bitmap_cb
);
988 void kvm_qemu_log_memory(target_phys_addr_t start
, target_phys_addr_t size
,
992 kvm_dirty_pages_log_enable_slot(kvm_context
, start
, size
);
994 kvm_dirty_pages_log_disable_slot(kvm_context
, start
, size
);
997 int kvm_get_phys_ram_page_bitmap(unsigned char *bitmap
)
999 unsigned int bsize
= BITMAP_SIZE(phys_ram_size
);
1000 unsigned int brsize
= BITMAP_SIZE(ram_size
);
1001 unsigned int extra_pages
= (phys_ram_size
- ram_size
) / TARGET_PAGE_SIZE
;
1002 unsigned int extra_bytes
= (extra_pages
+7)/8;
1003 unsigned int hole_start
= BITMAP_SIZE(0xa0000);
1004 unsigned int hole_end
= BITMAP_SIZE(0xc0000);
1006 memset(bitmap
, 0xFF, brsize
+ extra_bytes
);
1007 memset(bitmap
+ hole_start
, 0, hole_end
- hole_start
);
1008 memset(bitmap
+ brsize
+ extra_bytes
, 0, bsize
- brsize
- extra_bytes
);
1013 #ifdef KVM_CAP_IRQCHIP
1015 int kvm_set_irq(int irq
, int level
)
1017 return kvm_set_irq_level(kvm_context
, irq
, level
);
1022 int qemu_kvm_get_dirty_pages(unsigned long phys_addr
, void *buf
)
1024 return kvm_get_dirty_pages(kvm_context
, phys_addr
, buf
);
1027 void *kvm_cpu_create_phys_mem(target_phys_addr_t start_addr
,
1028 unsigned long size
, int log
, int writable
)
1030 return kvm_create_phys_mem(kvm_context
, start_addr
, size
, log
, writable
);
1033 void kvm_cpu_destroy_phys_mem(target_phys_addr_t start_addr
,
1036 kvm_destroy_phys_mem(kvm_context
, start_addr
, size
);
1039 void kvm_mutex_unlock(void)
1041 assert(!cpu_single_env
);
1042 pthread_mutex_unlock(&qemu_mutex
);
1045 void kvm_mutex_lock(void)
1047 pthread_mutex_lock(&qemu_mutex
);
1048 cpu_single_env
= NULL
;
1051 int qemu_kvm_register_coalesced_mmio(target_phys_addr_t addr
, unsigned int size
)
1053 return kvm_register_coalesced_mmio(kvm_context
, addr
, size
);
1056 int qemu_kvm_unregister_coalesced_mmio(target_phys_addr_t addr
,
1059 return kvm_unregister_coalesced_mmio(kvm_context
, addr
, size
);
1062 #ifdef USE_KVM_DEVICE_ASSIGNMENT
1063 void kvm_add_ioperm_data(struct ioperm_data
*data
)
1065 LIST_INSERT_HEAD(&ioperm_head
, data
, entries
);
1068 void kvm_ioperm(CPUState
*env
, void *data
)
1070 if (kvm_enabled() && qemu_system_ready
)
1071 on_vcpu(env
, kvm_arch_do_ioperm
, data
);