From patchwork Wed May 23 03:07:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 160835 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B121EB7017 for ; Wed, 23 May 2012 15:13:22 +1000 (EST) Received: from localhost ([::1]:35604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1xX-00022t-7M for incoming@patchwork.ozlabs.org; Tue, 22 May 2012 23:09:59 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1wg-0000KQ-JF for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SX1wd-0005ba-QD for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35569 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1wd-0005af-GO for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:03 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 730C7978B8 for ; Wed, 23 May 2012 05:09:02 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 23 May 2012 05:07:37 +0200 Message-Id: <1337742502-28565-15-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1337742502-28565-1-git-send-email-afaerber@suse.de> References: <1337742502-28565-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH qom-next 14/59] cpu: Move stopped field to CPUState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Change its type to bool. Signed-off-by: Andreas Färber --- cpu-defs.h | 1 - cpus.c | 30 ++++++++++++++++++------------ hw/ppce500_spin.c | 3 ++- include/qemu/cpu.h | 2 ++ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index c93371e..43af2ba 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -205,7 +205,6 @@ typedef struct CPUWatchpoint { /* user data */ \ void *opaque; \ \ - uint32_t stopped; /* Artificially stopped */ \ struct QemuCond *halt_cond; \ struct qemu_work_item *queued_work_first, *queued_work_last; \ const char *cpu_model_str; \ diff --git a/cpus.c b/cpus.c index e26ef39..fca4eb2 100644 --- a/cpus.c +++ b/cpus.c @@ -406,7 +406,9 @@ void cpu_synchronize_all_post_init(void) int cpu_is_stopped(CPUArchState *env) { - return !runstate_is_running() || env->stopped; + CPUState *cpu = ENV_GET_CPU(env); + + return !runstate_is_running() || cpu->stopped; } static void do_vm_stop(RunState state) @@ -429,7 +431,7 @@ static int cpu_can_run(CPUArchState *env) if (cpu->stop) { return 0; } - if (env->stopped || !runstate_is_running()) { + if (cpu->stopped || !runstate_is_running()) { return 0; } return 1; @@ -442,7 +444,7 @@ static bool cpu_thread_is_idle(CPUArchState *env) if (cpu->stop || env->queued_work_first) { return false; } - if (env->stopped || !runstate_is_running()) { + if (cpu->stopped || !runstate_is_running()) { return true; } if (!env->halted || qemu_cpu_has_work(env) || kvm_irqchip_in_kernel()) { @@ -465,9 +467,11 @@ bool all_cpu_threads_idle(void) static void cpu_handle_guest_debug(CPUArchState *env) { + CPUState *cpu = ENV_GET_CPU(env); + gdb_set_stop_cpu(env); qemu_system_debug_request(); - env->stopped = 1; + cpu->stopped = true; } static void cpu_signal(int sig) @@ -695,7 +699,7 @@ static void qemu_wait_io_event_common(CPUArchState *env) if (cpu->stop) { cpu->stop = false; - env->stopped = 1; + cpu->stopped = true; qemu_cond_signal(&qemu_pause_cond); } flush_queued_work(env); @@ -831,7 +835,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) qemu_cond_signal(&qemu_cpu_cond); /* wait for initial kick-off after machine start */ - while (first_cpu->stopped) { + while (ENV_GET_CPU(first_cpu)->stopped) { qemu_cond_wait(tcg_halt_cond, &qemu_global_mutex); /* process any pending work */ @@ -927,7 +931,8 @@ static int all_vcpus_paused(void) CPUArchState *penv = first_cpu; while (penv) { - if (!penv->stopped) { + CPUState *pcpu = ENV_GET_CPU(penv); + if (!pcpu->stopped) { return 0; } penv = penv->next_cpu; @@ -954,7 +959,7 @@ void pause_all_vcpus(void) while (penv) { CPUState *pcpu = ENV_GET_CPU(penv); pcpu->stop = 0; - penv->stopped = 1; + pcpu->stopped = true; penv = penv->next_cpu; } return; @@ -979,7 +984,7 @@ void resume_all_vcpus(void) while (penv) { CPUState *pcpu = ENV_GET_CPU(penv); pcpu->stop = false; - penv->stopped = 0; + pcpu->stopped = false; qemu_cpu_kick(penv); penv = penv->next_cpu; } @@ -1042,10 +1047,11 @@ static void qemu_dummy_start_vcpu(CPUArchState *env) void qemu_init_vcpu(void *_env) { CPUArchState *env = _env; + CPUState *cpu = ENV_GET_CPU(env); env->nr_cores = smp_cores; env->nr_threads = smp_threads; - env->stopped = 1; + cpu->stopped = true; if (kvm_enabled()) { qemu_kvm_start_vcpu(env); } else if (tcg_enabled()) { @@ -1060,7 +1066,7 @@ void cpu_stop_current(void) if (cpu_single_env) { CPUState *cpu_single_cpu = ENV_GET_CPU(cpu_single_env); cpu_single_cpu->stop = false; - cpu_single_env->stopped = 1; + cpu_single_cpu->stopped = true; cpu_exit(cpu_single_env); qemu_cond_signal(&qemu_pause_cond); } @@ -1152,7 +1158,7 @@ static void tcg_exec_all(void) cpu_handle_guest_debug(env); break; } - } else if (cpu->stop || env->stopped) { + } else if (cpu->stop || cpu->stopped) { break; } } diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c index 4c4a456..a03a4d3 100644 --- a/hw/ppce500_spin.c +++ b/hw/ppce500_spin.c @@ -92,6 +92,7 @@ static void mmubooke_create_initial_mapping(CPUPPCState *env, static void spin_kick(void *data) { SpinKick *kick = data; + CPUState *cpu = CPU(kick->cpu); CPUPPCState *env = &kick->cpu->env; SpinInfo *curspin = kick->spin; target_phys_addr_t map_size = 64 * 1024 * 1024; @@ -113,7 +114,7 @@ static void spin_kick(void *data) env->halted = 0; env->exception_index = -1; - env->stopped = 0; + cpu->stopped = false; qemu_cpu_kick(env); } diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h index 04c7848..83378c5 100644 --- a/include/qemu/cpu.h +++ b/include/qemu/cpu.h @@ -56,6 +56,7 @@ typedef struct CPUClass { * CPUState: * @created: Indicates whether the CPU thread has been successfully created. * @stop: Indicates a pending stop request. + * @stopped: Indicates the CPU has been artificially stopped. * * State of one CPU core or thread. */ @@ -71,6 +72,7 @@ struct CPUState { bool thread_kicked; bool created; bool stop; + bool stopped; /* TODO Move common fields from CPUArchState here. */ };