s390x/tcg: Don't ignore content in r0 when not specified via "b" or "x"
[qemu/ar7.git] / target / i386 / hax / hax-cpus.c
blobf72c85bd49f80f21576270f985f0aa65974af57f
1 /*
2 * QEMU HAX support
4 * Copyright IBM, Corp. 2008
5 * Red Hat, Inc. 2008
7 * Authors:
8 * Anthony Liguori <aliguori@us.ibm.com>
9 * Glauber Costa <gcosta@redhat.com>
11 * Copyright (c) 2011 Intel Corporation
12 * Written by:
13 * Jiang Yunhong<yunhong.jiang@intel.com>
14 * Xin Xiaohui<xiaohui.xin@intel.com>
15 * Zhang Xiantao<xiantao.zhang@intel.com>
17 * This work is licensed under the terms of the GNU GPL, version 2 or later.
18 * See the COPYING file in the top-level directory.
22 #include "qemu/osdep.h"
23 #include "qemu/error-report.h"
24 #include "qemu/main-loop.h"
25 #include "sysemu/runstate.h"
26 #include "sysemu/cpus.h"
27 #include "qemu/guest-random.h"
29 #include "hax-cpus.h"
31 static void *hax_cpu_thread_fn(void *arg)
33 CPUState *cpu = arg;
34 int r;
36 rcu_register_thread();
37 qemu_mutex_lock_iothread();
38 qemu_thread_get_self(cpu->thread);
40 cpu->thread_id = qemu_get_thread_id();
41 current_cpu = cpu;
42 hax_init_vcpu(cpu);
43 cpu_thread_signal_created(cpu);
44 qemu_guest_random_seed_thread_part2(cpu->random_seed);
46 do {
47 if (cpu_can_run(cpu)) {
48 r = hax_smp_cpu_exec(cpu);
49 if (r == EXCP_DEBUG) {
50 cpu_handle_guest_debug(cpu);
54 qemu_wait_io_event(cpu);
55 } while (!cpu->unplug || cpu_can_run(cpu));
56 rcu_unregister_thread();
57 return NULL;
60 static void hax_start_vcpu_thread(CPUState *cpu)
62 char thread_name[VCPU_THREAD_NAME_SIZE];
64 cpu->thread = g_malloc0(sizeof(QemuThread));
65 cpu->halt_cond = g_malloc0(sizeof(QemuCond));
66 qemu_cond_init(cpu->halt_cond);
68 snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HAX",
69 cpu->cpu_index);
70 qemu_thread_create(cpu->thread, thread_name, hax_cpu_thread_fn,
71 cpu, QEMU_THREAD_JOINABLE);
72 #ifdef _WIN32
73 cpu->hThread = qemu_thread_get_handle(cpu->thread);
74 #endif
77 const CpusAccel hax_cpus = {
78 .create_vcpu_thread = hax_start_vcpu_thread,
79 .kick_vcpu_thread = hax_kick_vcpu_thread,
81 .synchronize_post_reset = hax_cpu_synchronize_post_reset,
82 .synchronize_post_init = hax_cpu_synchronize_post_init,
83 .synchronize_state = hax_cpu_synchronize_state,
84 .synchronize_pre_loadvm = hax_cpu_synchronize_pre_loadvm,