kvm: x86: add mce support
[qemu/ar7.git] / cpus.c
blob38756572d993a0700678f35be6ec711e5d37ce48
1 /*
2 * QEMU System Emulator
4 * Copyright (c) 2003-2008 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 /* Needed early for CONFIG_BSD etc. */
26 #include "config-host.h"
28 #include "monitor.h"
29 #include "sysemu.h"
30 #include "gdbstub.h"
31 #include "dma.h"
32 #include "kvm.h"
33 #include "exec-all.h"
35 #include "cpus.h"
36 #include "compatfd.h"
38 #ifdef SIGRTMIN
39 #define SIG_IPI (SIGRTMIN+4)
40 #else
41 #define SIG_IPI SIGUSR1
42 #endif
44 static CPUState *next_cpu;
46 /***********************************************************/
47 void hw_error(const char *fmt, ...)
49 va_list ap;
50 CPUState *env;
52 va_start(ap, fmt);
53 fprintf(stderr, "qemu: hardware error: ");
54 vfprintf(stderr, fmt, ap);
55 fprintf(stderr, "\n");
56 for(env = first_cpu; env != NULL; env = env->next_cpu) {
57 fprintf(stderr, "CPU #%d:\n", env->cpu_index);
58 #ifdef TARGET_I386
59 cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU);
60 #else
61 cpu_dump_state(env, stderr, fprintf, 0);
62 #endif
64 va_end(ap);
65 abort();
68 void cpu_synchronize_all_states(void)
70 CPUState *cpu;
72 for (cpu = first_cpu; cpu; cpu = cpu->next_cpu) {
73 cpu_synchronize_state(cpu);
77 void cpu_synchronize_all_post_reset(void)
79 CPUState *cpu;
81 for (cpu = first_cpu; cpu; cpu = cpu->next_cpu) {
82 cpu_synchronize_post_reset(cpu);
86 void cpu_synchronize_all_post_init(void)
88 CPUState *cpu;
90 for (cpu = first_cpu; cpu; cpu = cpu->next_cpu) {
91 cpu_synchronize_post_init(cpu);
95 int cpu_is_stopped(CPUState *env)
97 return !vm_running || env->stopped;
100 static void do_vm_stop(int reason)
102 if (vm_running) {
103 cpu_disable_ticks();
104 vm_running = 0;
105 pause_all_vcpus();
106 vm_state_notify(0, reason);
107 monitor_protocol_event(QEVENT_STOP, NULL);
111 static int cpu_can_run(CPUState *env)
113 if (env->stop)
114 return 0;
115 if (env->stopped || !vm_running)
116 return 0;
117 return 1;
120 static int cpu_has_work(CPUState *env)
122 if (env->stop)
123 return 1;
124 if (env->queued_work_first)
125 return 1;
126 if (env->stopped || !vm_running)
127 return 0;
128 if (!env->halted)
129 return 1;
130 if (qemu_cpu_has_work(env))
131 return 1;
132 return 0;
135 static int any_cpu_has_work(void)
137 CPUState *env;
139 for (env = first_cpu; env != NULL; env = env->next_cpu)
140 if (cpu_has_work(env))
141 return 1;
142 return 0;
145 static void cpu_debug_handler(CPUState *env)
147 gdb_set_stop_cpu(env);
148 debug_requested = EXCP_DEBUG;
149 vm_stop(EXCP_DEBUG);
152 #ifndef _WIN32
153 static int io_thread_fd = -1;
155 static void qemu_event_increment(void)
157 /* Write 8 bytes to be compatible with eventfd. */
158 static const uint64_t val = 1;
159 ssize_t ret;
161 if (io_thread_fd == -1)
162 return;
164 do {
165 ret = write(io_thread_fd, &val, sizeof(val));
166 } while (ret < 0 && errno == EINTR);
168 /* EAGAIN is fine, a read must be pending. */
169 if (ret < 0 && errno != EAGAIN) {
170 fprintf(stderr, "qemu_event_increment: write() filed: %s\n",
171 strerror(errno));
172 exit (1);
176 static void qemu_event_read(void *opaque)
178 int fd = (unsigned long)opaque;
179 ssize_t len;
180 char buffer[512];
182 /* Drain the notify pipe. For eventfd, only 8 bytes will be read. */
183 do {
184 len = read(fd, buffer, sizeof(buffer));
185 } while ((len == -1 && errno == EINTR) || len == sizeof(buffer));
188 static int qemu_event_init(void)
190 int err;
191 int fds[2];
193 err = qemu_eventfd(fds);
194 if (err == -1)
195 return -errno;
197 err = fcntl_setfl(fds[0], O_NONBLOCK);
198 if (err < 0)
199 goto fail;
201 err = fcntl_setfl(fds[1], O_NONBLOCK);
202 if (err < 0)
203 goto fail;
205 qemu_set_fd_handler2(fds[0], NULL, qemu_event_read, NULL,
206 (void *)(unsigned long)fds[0]);
208 io_thread_fd = fds[1];
209 return 0;
211 fail:
212 close(fds[0]);
213 close(fds[1]);
214 return err;
216 #else
217 HANDLE qemu_event_handle;
219 static void dummy_event_handler(void *opaque)
223 static int qemu_event_init(void)
225 qemu_event_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
226 if (!qemu_event_handle) {
227 fprintf(stderr, "Failed CreateEvent: %ld\n", GetLastError());
228 return -1;
230 qemu_add_wait_object(qemu_event_handle, dummy_event_handler, NULL);
231 return 0;
234 static void qemu_event_increment(void)
236 if (!SetEvent(qemu_event_handle)) {
237 fprintf(stderr, "qemu_event_increment: SetEvent failed: %ld\n",
238 GetLastError());
239 exit (1);
242 #endif
244 #ifndef CONFIG_IOTHREAD
245 int qemu_init_main_loop(void)
247 cpu_set_debug_excp_handler(cpu_debug_handler);
249 return qemu_event_init();
252 void qemu_main_loop_start(void)
256 void qemu_init_vcpu(void *_env)
258 CPUState *env = _env;
260 env->nr_cores = smp_cores;
261 env->nr_threads = smp_threads;
262 if (kvm_enabled())
263 kvm_init_vcpu(env);
264 return;
267 int qemu_cpu_self(void *env)
269 return 1;
272 void run_on_cpu(CPUState *env, void (*func)(void *data), void *data)
274 func(data);
277 void resume_all_vcpus(void)
281 void pause_all_vcpus(void)
285 void qemu_cpu_kick(void *env)
287 return;
290 void qemu_notify_event(void)
292 CPUState *env = cpu_single_env;
294 qemu_event_increment ();
295 if (env) {
296 cpu_exit(env);
298 if (next_cpu && env != next_cpu) {
299 cpu_exit(next_cpu);
303 void qemu_mutex_lock_iothread(void) {}
304 void qemu_mutex_unlock_iothread(void) {}
306 void vm_stop(int reason)
308 do_vm_stop(reason);
311 #else /* CONFIG_IOTHREAD */
313 #include "qemu-thread.h"
315 QemuMutex qemu_global_mutex;
316 static QemuMutex qemu_fair_mutex;
318 static QemuThread io_thread;
320 static QemuThread *tcg_cpu_thread;
321 static QemuCond *tcg_halt_cond;
323 static int qemu_system_ready;
324 /* cpu creation */
325 static QemuCond qemu_cpu_cond;
326 /* system init */
327 static QemuCond qemu_system_cond;
328 static QemuCond qemu_pause_cond;
329 static QemuCond qemu_work_cond;
331 static void tcg_init_ipi(void);
332 static void kvm_init_ipi(CPUState *env);
333 static sigset_t block_io_signals(void);
335 /* If we have signalfd, we mask out the signals we want to handle and then
336 * use signalfd to listen for them. We rely on whatever the current signal
337 * handler is to dispatch the signals when we receive them.
339 static void sigfd_handler(void *opaque)
341 int fd = (unsigned long) opaque;
342 struct qemu_signalfd_siginfo info;
343 struct sigaction action;
344 ssize_t len;
346 while (1) {
347 do {
348 len = read(fd, &info, sizeof(info));
349 } while (len == -1 && errno == EINTR);
351 if (len == -1 && errno == EAGAIN) {
352 break;
355 if (len != sizeof(info)) {
356 printf("read from sigfd returned %zd: %m\n", len);
357 return;
360 sigaction(info.ssi_signo, NULL, &action);
361 if ((action.sa_flags & SA_SIGINFO) && action.sa_sigaction) {
362 action.sa_sigaction(info.ssi_signo,
363 (siginfo_t *)&info, NULL);
364 } else if (action.sa_handler) {
365 action.sa_handler(info.ssi_signo);
370 static int qemu_signalfd_init(sigset_t mask)
372 int sigfd;
374 sigfd = qemu_signalfd(&mask);
375 if (sigfd == -1) {
376 fprintf(stderr, "failed to create signalfd\n");
377 return -errno;
380 fcntl_setfl(sigfd, O_NONBLOCK);
382 qemu_set_fd_handler2(sigfd, NULL, sigfd_handler, NULL,
383 (void *)(unsigned long) sigfd);
385 return 0;
388 int qemu_init_main_loop(void)
390 int ret;
391 sigset_t blocked_signals;
393 cpu_set_debug_excp_handler(cpu_debug_handler);
395 blocked_signals = block_io_signals();
397 ret = qemu_signalfd_init(blocked_signals);
398 if (ret)
399 return ret;
401 /* Note eventfd must be drained before signalfd handlers run */
402 ret = qemu_event_init();
403 if (ret)
404 return ret;
406 qemu_cond_init(&qemu_pause_cond);
407 qemu_cond_init(&qemu_system_cond);
408 qemu_mutex_init(&qemu_fair_mutex);
409 qemu_mutex_init(&qemu_global_mutex);
410 qemu_mutex_lock(&qemu_global_mutex);
412 qemu_thread_self(&io_thread);
414 return 0;
417 void qemu_main_loop_start(void)
419 qemu_system_ready = 1;
420 qemu_cond_broadcast(&qemu_system_cond);
423 void run_on_cpu(CPUState *env, void (*func)(void *data), void *data)
425 struct qemu_work_item wi;
427 if (qemu_cpu_self(env)) {
428 func(data);
429 return;
432 wi.func = func;
433 wi.data = data;
434 if (!env->queued_work_first)
435 env->queued_work_first = &wi;
436 else
437 env->queued_work_last->next = &wi;
438 env->queued_work_last = &wi;
439 wi.next = NULL;
440 wi.done = false;
442 qemu_cpu_kick(env);
443 while (!wi.done) {
444 CPUState *self_env = cpu_single_env;
446 qemu_cond_wait(&qemu_work_cond, &qemu_global_mutex);
447 cpu_single_env = self_env;
451 static void flush_queued_work(CPUState *env)
453 struct qemu_work_item *wi;
455 if (!env->queued_work_first)
456 return;
458 while ((wi = env->queued_work_first)) {
459 env->queued_work_first = wi->next;
460 wi->func(wi->data);
461 wi->done = true;
463 env->queued_work_last = NULL;
464 qemu_cond_broadcast(&qemu_work_cond);
467 static void qemu_wait_io_event_common(CPUState *env)
469 if (env->stop) {
470 env->stop = 0;
471 env->stopped = 1;
472 qemu_cond_signal(&qemu_pause_cond);
474 flush_queued_work(env);
477 static void qemu_tcg_wait_io_event(void)
479 CPUState *env;
481 while (!any_cpu_has_work())
482 qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000);
484 qemu_mutex_unlock(&qemu_global_mutex);
487 * Users of qemu_global_mutex can be starved, having no chance
488 * to acquire it since this path will get to it first.
489 * So use another lock to provide fairness.
491 qemu_mutex_lock(&qemu_fair_mutex);
492 qemu_mutex_unlock(&qemu_fair_mutex);
494 qemu_mutex_lock(&qemu_global_mutex);
496 for (env = first_cpu; env != NULL; env = env->next_cpu) {
497 qemu_wait_io_event_common(env);
501 static void qemu_kvm_eat_signal(CPUState *env, int timeout)
503 struct timespec ts;
504 int r, e;
505 siginfo_t siginfo;
506 sigset_t waitset;
508 ts.tv_sec = timeout / 1000;
509 ts.tv_nsec = (timeout % 1000) * 1000000;
511 sigemptyset(&waitset);
512 sigaddset(&waitset, SIG_IPI);
514 qemu_mutex_unlock(&qemu_global_mutex);
515 r = sigtimedwait(&waitset, &siginfo, &ts);
516 e = errno;
517 qemu_mutex_lock(&qemu_global_mutex);
519 if (r == -1 && !(e == EAGAIN || e == EINTR)) {
520 fprintf(stderr, "sigtimedwait: %s\n", strerror(e));
521 exit(1);
525 static void qemu_kvm_wait_io_event(CPUState *env)
527 while (!cpu_has_work(env))
528 qemu_cond_timedwait(env->halt_cond, &qemu_global_mutex, 1000);
530 qemu_kvm_eat_signal(env, 0);
531 qemu_wait_io_event_common(env);
534 static int qemu_cpu_exec(CPUState *env);
536 static void *kvm_cpu_thread_fn(void *arg)
538 CPUState *env = arg;
540 qemu_mutex_lock(&qemu_global_mutex);
541 qemu_thread_self(env->thread);
542 if (kvm_enabled())
543 kvm_init_vcpu(env);
545 kvm_init_ipi(env);
547 /* signal CPU creation */
548 env->created = 1;
549 qemu_cond_signal(&qemu_cpu_cond);
551 /* and wait for machine initialization */
552 while (!qemu_system_ready)
553 qemu_cond_timedwait(&qemu_system_cond, &qemu_global_mutex, 100);
555 while (1) {
556 if (cpu_can_run(env))
557 qemu_cpu_exec(env);
558 qemu_kvm_wait_io_event(env);
561 return NULL;
564 static void *tcg_cpu_thread_fn(void *arg)
566 CPUState *env = arg;
568 tcg_init_ipi();
569 qemu_thread_self(env->thread);
571 /* signal CPU creation */
572 qemu_mutex_lock(&qemu_global_mutex);
573 for (env = first_cpu; env != NULL; env = env->next_cpu)
574 env->created = 1;
575 qemu_cond_signal(&qemu_cpu_cond);
577 /* and wait for machine initialization */
578 while (!qemu_system_ready)
579 qemu_cond_timedwait(&qemu_system_cond, &qemu_global_mutex, 100);
581 while (1) {
582 cpu_exec_all();
583 qemu_tcg_wait_io_event();
586 return NULL;
589 void qemu_cpu_kick(void *_env)
591 CPUState *env = _env;
592 qemu_cond_broadcast(env->halt_cond);
593 qemu_thread_signal(env->thread, SIG_IPI);
596 int qemu_cpu_self(void *_env)
598 CPUState *env = _env;
599 QemuThread this;
601 qemu_thread_self(&this);
603 return qemu_thread_equal(&this, env->thread);
606 static void cpu_signal(int sig)
608 if (cpu_single_env)
609 cpu_exit(cpu_single_env);
610 exit_request = 1;
613 static void tcg_init_ipi(void)
615 sigset_t set;
616 struct sigaction sigact;
618 memset(&sigact, 0, sizeof(sigact));
619 sigact.sa_handler = cpu_signal;
620 sigaction(SIG_IPI, &sigact, NULL);
622 sigemptyset(&set);
623 sigaddset(&set, SIG_IPI);
624 pthread_sigmask(SIG_UNBLOCK, &set, NULL);
627 static void dummy_signal(int sig)
631 static void kvm_init_ipi(CPUState *env)
633 int r;
634 sigset_t set;
635 struct sigaction sigact;
637 memset(&sigact, 0, sizeof(sigact));
638 sigact.sa_handler = dummy_signal;
639 sigaction(SIG_IPI, &sigact, NULL);
641 pthread_sigmask(SIG_BLOCK, NULL, &set);
642 sigdelset(&set, SIG_IPI);
643 r = kvm_set_signal_mask(env, &set);
644 if (r) {
645 fprintf(stderr, "kvm_set_signal_mask: %s\n", strerror(r));
646 exit(1);
650 static sigset_t block_io_signals(void)
652 sigset_t set;
654 /* SIGUSR2 used by posix-aio-compat.c */
655 sigemptyset(&set);
656 sigaddset(&set, SIGUSR2);
657 pthread_sigmask(SIG_UNBLOCK, &set, NULL);
659 sigemptyset(&set);
660 sigaddset(&set, SIGIO);
661 sigaddset(&set, SIGALRM);
662 sigaddset(&set, SIG_IPI);
663 pthread_sigmask(SIG_BLOCK, &set, NULL);
665 return set;
668 void qemu_mutex_lock_iothread(void)
670 if (kvm_enabled()) {
671 qemu_mutex_lock(&qemu_fair_mutex);
672 qemu_mutex_lock(&qemu_global_mutex);
673 qemu_mutex_unlock(&qemu_fair_mutex);
674 } else {
675 qemu_mutex_lock(&qemu_fair_mutex);
676 if (qemu_mutex_trylock(&qemu_global_mutex)) {
677 qemu_thread_signal(tcg_cpu_thread, SIG_IPI);
678 qemu_mutex_lock(&qemu_global_mutex);
680 qemu_mutex_unlock(&qemu_fair_mutex);
684 void qemu_mutex_unlock_iothread(void)
686 qemu_mutex_unlock(&qemu_global_mutex);
689 static int all_vcpus_paused(void)
691 CPUState *penv = first_cpu;
693 while (penv) {
694 if (!penv->stopped)
695 return 0;
696 penv = (CPUState *)penv->next_cpu;
699 return 1;
702 void pause_all_vcpus(void)
704 CPUState *penv = first_cpu;
706 while (penv) {
707 penv->stop = 1;
708 qemu_cpu_kick(penv);
709 penv = (CPUState *)penv->next_cpu;
712 while (!all_vcpus_paused()) {
713 qemu_cond_timedwait(&qemu_pause_cond, &qemu_global_mutex, 100);
714 penv = first_cpu;
715 while (penv) {
716 qemu_cpu_kick(penv);
717 penv = (CPUState *)penv->next_cpu;
722 void resume_all_vcpus(void)
724 CPUState *penv = first_cpu;
726 while (penv) {
727 penv->stop = 0;
728 penv->stopped = 0;
729 qemu_cpu_kick(penv);
730 penv = (CPUState *)penv->next_cpu;
734 static void tcg_init_vcpu(void *_env)
736 CPUState *env = _env;
737 /* share a single thread for all cpus with TCG */
738 if (!tcg_cpu_thread) {
739 env->thread = qemu_mallocz(sizeof(QemuThread));
740 env->halt_cond = qemu_mallocz(sizeof(QemuCond));
741 qemu_cond_init(env->halt_cond);
742 qemu_thread_create(env->thread, tcg_cpu_thread_fn, env);
743 while (env->created == 0)
744 qemu_cond_timedwait(&qemu_cpu_cond, &qemu_global_mutex, 100);
745 tcg_cpu_thread = env->thread;
746 tcg_halt_cond = env->halt_cond;
747 } else {
748 env->thread = tcg_cpu_thread;
749 env->halt_cond = tcg_halt_cond;
753 static void kvm_start_vcpu(CPUState *env)
755 env->thread = qemu_mallocz(sizeof(QemuThread));
756 env->halt_cond = qemu_mallocz(sizeof(QemuCond));
757 qemu_cond_init(env->halt_cond);
758 qemu_thread_create(env->thread, kvm_cpu_thread_fn, env);
759 while (env->created == 0)
760 qemu_cond_timedwait(&qemu_cpu_cond, &qemu_global_mutex, 100);
763 void qemu_init_vcpu(void *_env)
765 CPUState *env = _env;
767 env->nr_cores = smp_cores;
768 env->nr_threads = smp_threads;
769 if (kvm_enabled())
770 kvm_start_vcpu(env);
771 else
772 tcg_init_vcpu(env);
775 void qemu_notify_event(void)
777 qemu_event_increment();
780 static void qemu_system_vmstop_request(int reason)
782 vmstop_requested = reason;
783 qemu_notify_event();
786 void vm_stop(int reason)
788 QemuThread me;
789 qemu_thread_self(&me);
791 if (!qemu_thread_equal(&me, &io_thread)) {
792 qemu_system_vmstop_request(reason);
794 * FIXME: should not return to device code in case
795 * vm_stop() has been requested.
797 if (cpu_single_env) {
798 cpu_exit(cpu_single_env);
799 cpu_single_env->stop = 1;
801 return;
803 do_vm_stop(reason);
806 #endif
808 static int qemu_cpu_exec(CPUState *env)
810 int ret;
811 #ifdef CONFIG_PROFILER
812 int64_t ti;
813 #endif
815 #ifdef CONFIG_PROFILER
816 ti = profile_getclock();
817 #endif
818 if (use_icount) {
819 int64_t count;
820 int decr;
821 qemu_icount -= (env->icount_decr.u16.low + env->icount_extra);
822 env->icount_decr.u16.low = 0;
823 env->icount_extra = 0;
824 count = qemu_icount_round (qemu_next_deadline());
825 qemu_icount += count;
826 decr = (count > 0xffff) ? 0xffff : count;
827 count -= decr;
828 env->icount_decr.u16.low = decr;
829 env->icount_extra = count;
831 ret = cpu_exec(env);
832 #ifdef CONFIG_PROFILER
833 qemu_time += profile_getclock() - ti;
834 #endif
835 if (use_icount) {
836 /* Fold pending instructions back into the
837 instruction counter, and clear the interrupt flag. */
838 qemu_icount -= (env->icount_decr.u16.low
839 + env->icount_extra);
840 env->icount_decr.u32 = 0;
841 env->icount_extra = 0;
843 return ret;
846 bool cpu_exec_all(void)
848 if (next_cpu == NULL)
849 next_cpu = first_cpu;
850 for (; next_cpu != NULL && !exit_request; next_cpu = next_cpu->next_cpu) {
851 CPUState *env = next_cpu;
853 qemu_clock_enable(vm_clock,
854 (env->singlestep_enabled & SSTEP_NOTIMER) == 0);
856 if (qemu_alarm_pending())
857 break;
858 if (cpu_can_run(env)) {
859 if (qemu_cpu_exec(env) == EXCP_DEBUG) {
860 break;
862 } else if (env->stop) {
863 break;
866 exit_request = 0;
867 return any_cpu_has_work();
870 void set_numa_modes(void)
872 CPUState *env;
873 int i;
875 for (env = first_cpu; env != NULL; env = env->next_cpu) {
876 for (i = 0; i < nb_numa_nodes; i++) {
877 if (node_cpumask[i] & (1 << env->cpu_index)) {
878 env->numa_node = i;
884 void set_cpu_log(const char *optarg)
886 int mask;
887 const CPULogItem *item;
889 mask = cpu_str_to_log_mask(optarg);
890 if (!mask) {
891 printf("Log items (comma separated):\n");
892 for (item = cpu_log_items; item->mask != 0; item++) {
893 printf("%-10s %s\n", item->name, item->help);
895 exit(1);
897 cpu_set_log(mask);
900 /* Return the virtual CPU time, based on the instruction counter. */
901 int64_t cpu_get_icount(void)
903 int64_t icount;
904 CPUState *env = cpu_single_env;;
906 icount = qemu_icount;
907 if (env) {
908 if (!can_do_io(env)) {
909 fprintf(stderr, "Bad clock read\n");
911 icount -= (env->icount_decr.u16.low + env->icount_extra);
913 return qemu_icount_bias + (icount << icount_time_shift);
916 void list_cpus(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
917 const char *optarg)
919 /* XXX: implement xxx_cpu_list for targets that still miss it */
920 #if defined(cpu_list_id)
921 cpu_list_id(f, cpu_fprintf, optarg);
922 #elif defined(cpu_list)
923 cpu_list(f, cpu_fprintf); /* deprecated */
924 #endif