qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Scott Wood" <scottwood@freescale.com>,
	"open list:ppce500" <qemu-ppc@nongnu.org>,
	"Andreas Färber" <afaerber@suse.de>,
	anthony@codemonkey.ws, "Alexander Graf" <agraf@suse.de>
Subject: [Qemu-devel] [PATCH 12/35] cpu: Move stopped field to CPUState
Date: Wed, 31 Oct 2012 01:59:43 +0100	[thread overview]
Message-ID: <1351645206-3041-13-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1351645206-3041-1-git-send-email-afaerber@suse.de>

Change its type to bool.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 cpu-defs.h         |    1 -
 cpus.c             |   30 ++++++++++++++++++------------
 hw/ppce500_spin.c  |    3 ++-
 include/qemu/cpu.h |    2 ++
 4 Dateien geändert, 22 Zeilen hinzugefügt(+), 14 Zeilen entfernt(-)

diff --git a/cpu-defs.h b/cpu-defs.h
index 7a6378c..83bf108 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 2341ebb..4654f08 100644
--- a/cpus.c
+++ b/cpus.c
@@ -69,7 +69,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) ||
@@ -432,7 +432,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)
@@ -455,7 +457,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;
@@ -463,9 +465,11 @@ static int cpu_can_run(CPUArchState *env)
 
 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)
@@ -693,7 +697,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);
@@ -829,7 +833,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 */
@@ -930,7 +934,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;
@@ -957,7 +962,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;
@@ -982,7 +987,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;
     }
@@ -1045,10 +1050,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()) {
@@ -1063,7 +1069,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);
     }
@@ -1155,7 +1161,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 04e7e65..fb5461d 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;
     hwaddr 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. */
 };
-- 
1.7.10.4

  parent reply	other threads:[~2012-10-31  1:00 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31  0:59 [Qemu-devel] [PULL] QOM CPUState patch queue 2012-10-31 Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 01/35] target-i386: cpu_x86_register(): report error from property setter Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 02/35] target-i386: If x86_cpu_realize() failed, report error and do cleanup Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 03/35] target-i386: Initialize APIC at CPU level Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 04/35] target-i386: Inline APIC cpu_env property setting Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 05/35] apic: Store X86CPU in APICCommonState Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 06/35] target-i386: Pass X86CPU to cpu_x86_load_seg_cache_sipi() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 07/35] cpus: Pass CPUState to qemu_cpu_is_self() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 08/35] cpus: Pass CPUState to qemu_cpu_kick_thread() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 09/35] cpu: Move created field to CPUState Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 10/35] cpu: Move stop " Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 11/35] ppce500_spin: Store PowerPCCPU in SpinKick Andreas Färber
2012-10-31  0:59 ` Andreas Färber [this message]
2012-10-31  0:59 ` [Qemu-devel] [PATCH 13/35] cpus: Pass CPUState to cpu_is_stopped() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 14/35] cpus: Pass CPUState to cpu_can_run() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 15/35] cpu: Move halt_cond to CPUState Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 16/35] cpus: Pass CPUState to qemu_tcg_cpu_thread_fn Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 17/35] cpus: Pass CPUState to qemu_tcg_init_vcpu() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 18/35] ppc: Pass PowerPCCPU to {ppc6xx, ppc970, power7, ppc40x, ppce500}_set_irq() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 19/35] target-ppc: Rename kvm_kick_{env => cpu} and pass PowerPCCPU Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 20/35] cpus: Pass CPUState to qemu_cpu_kick() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 21/35] cpu: Move queued_work_{first, last} to CPUState Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 22/35] cpus: Pass CPUState to flush_queued_work() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 23/35] cpus: Pass CPUState to qemu_wait_io_event_common() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 24/35] xtensa_pic: Pass XtensaCPU to xtensa_ccompare_cb() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 25/35] target-ppc: Pass PowerPCCPU to powerpc_excp() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 26/35] target-ppc: Pass PowerPCCPU to cpu_ppc_hypercall Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 27/35] spapr: Pass PowerPCCPU to spapr_hypercall() Andreas Färber
2012-10-31  0:59 ` [Qemu-devel] [PATCH 28/35] spapr: Pass PowerPCCPU to hypercalls Andreas Färber
2012-10-31  1:00 ` [Qemu-devel] [PATCH 29/35] cpus: Pass CPUState to [qemu_]cpu_has_work() Andreas Färber
2012-10-31  1:29   ` Richard Henderson
2012-10-31 21:05   ` Aurelien Jarno
2012-10-31 21:37     ` Andreas Färber
2012-10-31 21:47       ` Aurelien Jarno
2012-10-31  1:00 ` [Qemu-devel] [PATCH 30/35] target-i386: Pass X86CPU to kvm_mce_inject() Andreas Färber
2012-10-31  1:00 ` [Qemu-devel] [PATCH 31/35] target-i386: Pass X86CPU to cpu_x86_inject_mce() Andreas Färber
2012-10-31  1:00 ` [Qemu-devel] [PATCH 32/35] cpus: Pass CPUState to run_on_cpu() Andreas Färber
2012-10-31  1:00 ` [Qemu-devel] [PATCH 33/35] cpu: Move thread_id to CPUState Andreas Färber
2012-10-31  1:00 ` [Qemu-devel] [PATCH 34/35] target-i386: Pass X86CPU to kvm_get_mp_state() Andreas Färber
2012-10-31  1:00 ` [Qemu-devel] [PATCH 35/35] target-i386: Pass X86CPU to kvm_handle_halt() Andreas Färber
2012-10-31  3:15 ` [Qemu-devel] [PULL] QOM CPUState patch queue 2012-10-31 Andreas Färber
2012-11-01 19:32 ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351645206-3041-13-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=scottwood@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).