summaryrefslogtreecommitdiff
path: root/cpus.c
diff options
context:
space:
mode:
authorSeokYeon Hwang <syeon.hwang@samsung.com>2014-04-21 15:32:27 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2014-04-21 15:57:17 +0900
commitc38a355e67e966e447e3b58b897daffda70e2801 (patch)
tree3a90ebbaf8bf89014212325e374e5073f074b014 /cpus.c
parent3d8e749baf4b053639581bc11e5664dc182e621d (diff)
parenta9e8aeb3755bccb7b51174adcf4a3fc427e0d147 (diff)
downloadqemu-c38a355e67e966e447e3b58b897daffda70e2801.tar.gz
qemu-c38a355e67e966e447e3b58b897daffda70e2801.tar.bz2
qemu-c38a355e67e966e447e3b58b897daffda70e2801.zip
Merge branch 'upstream_qemu_2.0' into tizen
Initial merge Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com> Conflicts: .gitignore Makefile.target block/raw-win32.c configure cpu-exec.c cpus.c hw/9pfs/virtio-9p-device.c hw/i386/pc_piix.c include/exec/cpu-defs.h include/qemu-common.h include/sysemu/sysemu.h include/ui/console.h tcg/i386/tcg-target.c tcg/tcg.h ui/console.c ui/input.c util/oslib-posix.c vl.c Change-Id: I52df9052942eea8d541bde75fd936e58a9f2f8ff
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c57
1 files changed, 36 insertions, 21 deletions
diff --git a/cpus.c b/cpus.c
index ea0d68466e..7d86bddc43 100644
--- a/cpus.c
+++ b/cpus.c
@@ -77,7 +77,7 @@ static bool cpu_thread_is_idle(CPUState *cpu)
if (cpu_is_stopped(cpu)) {
return true;
}
- if (!cpu->halted || qemu_cpu_has_work(cpu) ||
+ if (!cpu->halted || cpu_has_work(cpu) ||
kvm_halt_in_kernel()) {
return false;
}
@@ -140,11 +140,10 @@ static int64_t cpu_get_icount_locked(void)
icount = qemu_icount;
if (cpu) {
- CPUArchState *env = cpu->env_ptr;
- if (!can_do_io(env)) {
+ if (!cpu_can_do_io(cpu)) {
fprintf(stderr, "Bad clock read\n");
}
- icount -= (env->icount_decr.u16.low + env->icount_extra);
+ icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
}
return qemu_icount_bias + (icount << icount_time_shift);
}
@@ -1125,20 +1124,29 @@ void resume_all_vcpus(void)
}
}
+/* For temporary buffers for forming a name */
+#define VCPU_THREAD_NAME_SIZE 16
+
static void qemu_tcg_init_vcpu(CPUState *cpu)
{
#ifdef CONFIG_HAX
if (hax_enabled())
hax_init_vcpu(cpu->env_ptr);
#endif
+ char thread_name[VCPU_THREAD_NAME_SIZE];
+
+ tcg_cpu_address_space_init(cpu, cpu->as);
+
/* share a single thread for all cpus with TCG */
if (!tcg_cpu_thread) {
cpu->thread = g_malloc0(sizeof(QemuThread));
cpu->halt_cond = g_malloc0(sizeof(QemuCond));
qemu_cond_init(cpu->halt_cond);
tcg_halt_cond = cpu->halt_cond;
- qemu_thread_create(cpu->thread, qemu_tcg_cpu_thread_fn, cpu,
- QEMU_THREAD_JOINABLE);
+ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/TCG",
+ cpu->cpu_index);
+ qemu_thread_create(cpu->thread, thread_name, qemu_tcg_cpu_thread_fn,
+ cpu, QEMU_THREAD_JOINABLE);
#ifdef _WIN32
cpu->hThread = qemu_thread_get_handle(cpu->thread);
#endif
@@ -1154,11 +1162,15 @@ static void qemu_tcg_init_vcpu(CPUState *cpu)
static void qemu_kvm_start_vcpu(CPUState *cpu)
{
+ char thread_name[VCPU_THREAD_NAME_SIZE];
+
cpu->thread = g_malloc0(sizeof(QemuThread));
cpu->halt_cond = g_malloc0(sizeof(QemuCond));
qemu_cond_init(cpu->halt_cond);
- qemu_thread_create(cpu->thread, qemu_kvm_cpu_thread_fn, cpu,
- QEMU_THREAD_JOINABLE);
+ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/KVM",
+ cpu->cpu_index);
+ qemu_thread_create(cpu->thread, thread_name, qemu_kvm_cpu_thread_fn,
+ cpu, QEMU_THREAD_JOINABLE);
while (!cpu->created) {
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
}
@@ -1166,10 +1178,14 @@ static void qemu_kvm_start_vcpu(CPUState *cpu)
static void qemu_dummy_start_vcpu(CPUState *cpu)
{
+ char thread_name[VCPU_THREAD_NAME_SIZE];
+
cpu->thread = g_malloc0(sizeof(QemuThread));
cpu->halt_cond = g_malloc0(sizeof(QemuCond));
qemu_cond_init(cpu->halt_cond);
- qemu_thread_create(cpu->thread, qemu_dummy_cpu_thread_fn, cpu,
+ snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY",
+ cpu->cpu_index);
+ qemu_thread_create(cpu->thread, thread_name, qemu_dummy_cpu_thread_fn, cpu,
QEMU_THREAD_JOINABLE);
while (!cpu->created) {
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
@@ -1231,6 +1247,7 @@ int vm_stop_force_state(RunState state)
static int tcg_cpu_exec(CPUArchState *env)
{
+ CPUState *cpu = ENV_GET_CPU(env);
int ret;
#ifdef CONFIG_PROFILER
int64_t ti;
@@ -1243,9 +1260,9 @@ static int tcg_cpu_exec(CPUArchState *env)
int64_t count;
int64_t deadline;
int decr;
- qemu_icount -= (env->icount_decr.u16.low + env->icount_extra);
- env->icount_decr.u16.low = 0;
- env->icount_extra = 0;
+ qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
+ cpu->icount_decr.u16.low = 0;
+ cpu->icount_extra = 0;
deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);
/* Maintain prior (possibly buggy) behaviour where if no deadline
@@ -1261,8 +1278,8 @@ static int tcg_cpu_exec(CPUArchState *env)
qemu_icount += count;
decr = (count > 0xffff) ? 0xffff : count;
count -= decr;
- env->icount_decr.u16.low = decr;
- env->icount_extra = count;
+ cpu->icount_decr.u16.low = decr;
+ cpu->icount_extra = count;
}
ret = cpu_exec(env);
#ifdef CONFIG_PROFILER
@@ -1271,10 +1288,9 @@ static int tcg_cpu_exec(CPUArchState *env)
if (use_icount) {
/* Fold pending instructions back into the
instruction counter, and clear the interrupt flag. */
- qemu_icount -= (env->icount_decr.u16.low
- + env->icount_extra);
- env->icount_decr.u32 = 0;
- env->icount_extra = 0;
+ qemu_icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
+ cpu->icount_decr.u32 = 0;
+ cpu->icount_extra = 0;
}
return ret;
}
@@ -1470,12 +1486,11 @@ void qmp_inject_nmi(Error **errp)
CPU_FOREACH(cs) {
X86CPU *cpu = X86_CPU(cs);
- CPUX86State *env = &cpu->env;
- if (!env->apic_state) {
+ if (!cpu->apic_state) {
cpu_interrupt(cs, CPU_INTERRUPT_NMI);
} else {
- apic_deliver_nmi(env->apic_state);
+ apic_deliver_nmi(cpu->apic_state);
}
}
#elif defined(TARGET_S390X)