Skip to contentSkip to conversation

Add "qemu_reset_vcpu"

PATCH In review Lluís Vilanova 2 participants 5 messages Sep 16, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Add "qemu_reset_vcpu"

Mimics the already-existing "qemu_init_vcpu".

---
 qemu-common.h                 |    2 ++
 target-arm/helper.c           |    2 ++
 target-cris/translate.c       |    2 ++
 target-i386/helper.c          |    2 ++
 target-lm32/helper.c          |    2 ++
 target-m68k/helper.c          |    2 ++
 target-microblaze/translate.c |    2 ++
 target-mips/translate.c       |    2 ++
 target-ppc/helper.c           |    2 ++
 target-s390x/helper.c         |    2 ++
 target-sh4/translate.c        |    2 ++
 target-sparc/helper.c         |    2 ++
 12 files changed, 24 insertions(+), 0 deletions(-)
qemu-common.h +2 -0
index 404c421..d848f4a 100644
@@ -302,6 +302,8 @@ struct qemu_work_item {
 void qemu_init_vcpu(void *env);
 #endif
 
+#define qemu_reset_vcpu(env) do { } while (0)
+
 typedef struct QEMUIOVector {
     struct iovec *iov;
     int niov;
target-arm/helper.c +2 -0
index d3a3ba2..1bc96e4 100644
@@ -321,6 +321,8 @@ void cpu_reset(CPUARMState *env)
     set_float_detect_tininess(float_tininess_before_rounding,
                               &env->vfp.standard_fp_status);
     tlb_flush(env, 1);
+
+    qemu_reset_vcpu(env);
 }
 
 static int vfp_gdb_get_reg(CPUState *env, uint8_t *buf, int reg)
target-cris/translate.c +2 -0
index 70abf8a..95c28d9 100644
@@ -3601,6 +3601,8 @@ void cpu_reset (CPUCRISState *env)
 	cris_mmu_init(env);
 	env->pregs[PR_CCS] = 0;
 #endif
+
+    qemu_reset_vcpu(env);
 }
 
 void restore_state_to_opc(CPUState *env, TranslationBlock *tb, int pc_pos)
target-i386/helper.c +2 -0
index 5df40d4..4ed179d 100644
@@ -104,6 +104,8 @@ void cpu_reset(CPUX86State *env)
     env->dr[7] = DR7_FIXED_1;
     cpu_breakpoint_remove_all(env, BP_CPU);
     cpu_watchpoint_remove_all(env, BP_CPU);
+
+    qemu_reset_vcpu(env);
 }
 
 void cpu_x86_close(CPUX86State *env)
target-lm32/helper.c +2 -0
index 014fd8d..627c464 100644
@@ -250,5 +250,7 @@ void cpu_reset(CPUState *env)
 
     /* reset cpu state */
     memset(env, 0, offsetof(CPULM32State, breakpoints));
+
+    qemu_reset_vcpu(env);
 }
 
target-m68k/helper.c +2 -0
index 123e1d9..f2ce52a 100644
@@ -165,6 +165,8 @@ void cpu_reset(CPUM68KState *env)
     /* TODO: We should set PC from the interrupt vector.  */
     env->pc = 0;
     tlb_flush(env, 1);
+
+    qemu_reset_vcpu(env);
 }
 
 CPUM68KState *cpu_m68k_init(const char *cpu_model)
target-microblaze/translate.c +2 -0
index 366fd3e..649486f 100644
@@ -1943,6 +1943,8 @@ void cpu_reset (CPUState *env)
     env->mmu.c_mmu_tlb_access = 3;
     env->mmu.c_mmu_zones = 16;
 #endif
+
+    qemu_reset_vcpu(env);
 }
 
 void restore_state_to_opc(CPUState *env, TranslationBlock *tb, int pc_pos)
target-mips/translate.c +2 -0
index d5b1c76..480791d 100644
@@ -12846,6 +12846,8 @@ void cpu_reset (CPUMIPSState *env)
     }
 #endif
     env->exception_index = EXCP_NONE;
+
+    qemu_reset_vcpu(env);
 }
 
 void restore_state_to_opc(CPUState *env, TranslationBlock *tb, int pc_pos)
target-ppc/helper.c +2 -0
index 96ea464..7f92671 100644
@@ -3084,6 +3084,8 @@ void cpu_reset(CPUPPCState *env)
     env->error_code = 0;
     /* Flush all TLBs */
     tlb_flush(env, 1);
+
+    qemu_reset_vcpu(env);
 }
 
 CPUPPCState *cpu_ppc_init (const char *cpu_model)
target-s390x/helper.c +2 -0
index 96dd867..5bc24ab 100644
@@ -131,6 +131,8 @@ void cpu_reset(CPUS390XState *env)
     memset(env, 0, offsetof(CPUS390XState, breakpoints));
     /* FIXME: reset vector? */
     tlb_flush(env, 1);
+
+    qemu_reset_vcpu(env);
 }
 
 #ifndef CONFIG_USER_ONLY
target-sh4/translate.c +2 -0
index bad3577..88f0eec 100644
@@ -205,6 +205,8 @@ void cpu_reset(CPUSH4State * env)
     set_flush_to_zero(1, &env->fp_status);
 #endif
     set_default_nan_mode(1, &env->fp_status);
+
+    qemu_reset_vcpu(env);
 }
 
 typedef struct {
target-sparc/helper.c +2 -0
index c80531a..7601969 100644
@@ -1166,6 +1166,8 @@ void cpu_reset(CPUSPARCState *env)
     env->npc = env->pc + 4;
 #endif
     env->cache_control = 0;
+
+    qemu_reset_vcpu(env);
 }
 
 static int cpu_sparc_register(CPUSPARCState *env, const char *cpu_model)
#1 lore raw

PATCH 2/3 trace: Add "qemu_init_vcpu" event

---
 cpus.c        |    1 +
 qemu-common.h |    4 +++-
 trace-events  |    3 +++
 3 files changed, 7 insertions(+), 1 deletions(-)
cpus.c +1 -0
index 54c188c..8f7ce15 100644
@@ -861,6 +861,7 @@ void qemu_init_vcpu(void *_env)
     } else {
         qemu_tcg_init_vcpu(env);
     }
+    trace_qemu_init_vcpu(env);
 }
 
 void qemu_notify_event(void)
qemu-common.h +3 -1
index d848f4a..cdb6b3b 100644
@@ -296,8 +296,10 @@ struct qemu_work_item {
     int done;
 };
 
+#include "trace.h"
+
 #ifdef CONFIG_USER_ONLY
-#define qemu_init_vcpu(env) do { } while (0)
+#define qemu_init_vcpu(env) do { trace_qemu_init_vcpu(env); } while (0)
 #else
 void qemu_init_vcpu(void *env);
 #endif
trace-events +3 -0
index 7b2e619..53add77 100644
@@ -501,3 +501,6 @@ escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x"
 escc_sunkbd_event_out(int ch) "Translated keycode %2.2x"
 escc_kbd_command(int val) "Command %d"
 escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=%01x"
+
+# qemu-common.h
+qemu_init_vcpu(void *vcpu) "%p"
#2 lore raw

PATCH 3/3 trace: Add "qemu_reset_vcpu" event

In reply to Lluís Vilanova
---
 qemu-common.h |    2 +-
 trace-events  |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)
qemu-common.h +1 -1
index cdb6b3b..2915ccf 100644
@@ -304,7 +304,7 @@ struct qemu_work_item {
 void qemu_init_vcpu(void *env);
 #endif
 
-#define qemu_reset_vcpu(env) do { } while (0)
+#define qemu_reset_vcpu(env) do { trace_qemu_reset_vcpu(env); } while (0)
 
 typedef struct QEMUIOVector {
     struct iovec *iov;
trace-events +1 -0
index 53add77..0b9f834 100644
@@ -504,3 +504,4 @@ escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=%01x
 
 # qemu-common.h
 qemu_init_vcpu(void *vcpu) "%p"
+qemu_reset_vcpu(void *vcpu) "%p"
#3 lore raw
In reply to Lluís Vilanova
Quoted 1 line · Lluís Vilanova

Mimics the already-existing "qemu_init_vcpu".

Bad name as it implies something important happens inside. Call it trace_reset_vcpu because that is what it will do.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#4 lore raw
Quoted 5 lines · Jan Kiszka
Quoted 1 line · Lluís Vilanova

Mimics the already-existing "qemu_init_vcpu".

Bad name as it implies something important happens inside. Call it trace_reset_vcpu because that is what it will do.

I just thought it is much cleaner to call a generic "qemu_reset_vcpu" function that _might_ do something related to resetting the vCPU state, regardless of whether there is a tracing event for it or not.

Otherwise if someone wants to add some generic vCPU-resetting code in the future, the tracing function might end up in the target-specific code instead of the generic qemu code.

If you still think this is a bad idea I'll resend a patch with both events renamed into trace_vcpu_init/trace_vcpu_reset.

Thanks,
Lluis

Signature · 4 lines
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth