#include "qemu/guest-random.h"
#include "exec/exec-all.h"
#include "hw/boards.h"
-#include "tcg/tcg.h"
+#include "tcg/startup.h"
#include "tcg-accel-ops.h"
#include "tcg-accel-ops-mttcg.h"
rcu_add_force_rcu_notifier(&force_rcu.notifier);
tcg_register_thread();
- qemu_mutex_lock_iothread();
+ bql_lock();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
- cpu->can_do_io = 1;
+ cpu->neg.can_do_io = true;
current_cpu = cpu;
cpu_thread_signal_created(cpu);
qemu_guest_random_seed_thread_part2(cpu->random_seed);
do {
if (cpu_can_run(cpu)) {
int r;
- qemu_mutex_unlock_iothread();
- r = tcg_cpus_exec(cpu);
- qemu_mutex_lock_iothread();
+ bql_unlock();
+ r = tcg_cpu_exec(cpu);
+ bql_lock();
switch (r) {
case EXCP_DEBUG:
cpu_handle_guest_debug(cpu);
break;
case EXCP_HALTED:
/*
- * during start-up the vCPU is reset and the thread is
- * kicked several times. If we don't ensure we go back
- * to sleep in the halted state we won't cleanly
- * start-up when the vCPU is enabled.
- *
- * cpu->halted should ensure we sleep in wait_io_event
+ * Usually cpu->halted is set, but may have already been
+ * reset by another thread by the time we arrive here.
*/
- g_assert(cpu->halted);
break;
case EXCP_ATOMIC:
- qemu_mutex_unlock_iothread();
+ bql_unlock();
cpu_exec_step_atomic(cpu);
- qemu_mutex_lock_iothread();
+ bql_lock();
default:
/* Ignore everything else? */
break;
qemu_wait_io_event(cpu);
} while (!cpu->unplug || cpu_can_run(cpu));
- tcg_cpus_destroy(cpu);
- qemu_mutex_unlock_iothread();
+ tcg_cpu_destroy(cpu);
+ bql_unlock();
rcu_remove_force_rcu_notifier(&force_rcu.notifier);
rcu_unregister_thread();
return NULL;