From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ull3j-0007kr-KD for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:13:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ull3h-0000Lk-1V for qemu-devel@nongnu.org; Sun, 09 Jun 2013 15:13:47 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 9 Jun 2013 21:12:29 +0200 Message-Id: <1370805206-26574-3-git-send-email-afaerber@suse.de> In-Reply-To: <1370805206-26574-1-git-send-email-afaerber@suse.de> References: <1370805206-26574-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu 02/59] kvm: Change cpu_synchronize_state() argument to CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexander Graf , "open list:X86" , Gleb Natapov , Marcelo Tosatti , Markus Armbruster , Luiz Capitulino , "open list:PowerPC" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson Change Monitor::mon_cpu to CPUState as well. In cpu_sychronize_all_states() use qemu_for_each_cpu() now. In dump_init() use cpu_synchronize_all_states(). Signed-off-by: Andreas F=C3=A4rber --- cpus.c | 13 +++++++------ gdbstub.c | 8 ++++---- hw/i386/kvm/apic.c | 2 +- hw/i386/kvmvapic.c | 4 ++-- hw/misc/vmport.c | 2 +- hw/ppc/ppce500_spin.c | 2 +- include/sysemu/kvm.h | 4 ++-- monitor.c | 6 +++--- target-i386/helper.c | 4 ++-- target-i386/kvm.c | 2 +- target-ppc/mmu-hash64.c | 2 +- target-ppc/translate.c | 2 +- target-s390x/kvm.c | 9 +++++---- 13 files changed, 31 insertions(+), 29 deletions(-) diff --git a/cpus.c b/cpus.c index c232265..8ff66c3 100644 --- a/cpus.c +++ b/cpus.c @@ -405,13 +405,14 @@ void hw_error(const char *fmt, ...) abort(); } =20 -void cpu_synchronize_all_states(void) +static void cpu_synchronize_one_state(CPUState *cpu, void *data) { - CPUArchState *cpu; + cpu_synchronize_state(cpu); +} =20 - for (cpu =3D first_cpu; cpu; cpu =3D cpu->next_cpu) { - cpu_synchronize_state(cpu); - } +void cpu_synchronize_all_states(void) +{ + qemu_for_each_cpu(cpu_synchronize_one_state, NULL); } =20 void cpu_synchronize_all_post_reset(void) @@ -1219,7 +1220,7 @@ CpuInfoList *qmp_query_cpus(Error **errp) CPUState *cpu =3D ENV_GET_CPU(env); CpuInfoList *info; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(cpu); =20 info =3D g_malloc0(sizeof(*info)); info->value =3D g_malloc0(sizeof(*info->value)); diff --git a/gdbstub.c b/gdbstub.c index 90e54cb..fb6c6a5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2030,7 +2030,7 @@ static void gdb_breakpoint_remove_all(void) =20 static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { - cpu_synchronize_state(s->c_cpu); + cpu_synchronize_state(ENV_GET_CPU(s->c_cpu)); #if defined(TARGET_I386) s->c_cpu->eip =3D pc; #elif defined (TARGET_PPC) @@ -2229,7 +2229,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) } break; case 'g': - cpu_synchronize_state(s->g_cpu); + cpu_synchronize_state(ENV_GET_CPU(s->g_cpu)); env =3D s->g_cpu; len =3D 0; for (addr =3D 0; addr < num_g_regs; addr++) { @@ -2240,7 +2240,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) put_packet(s, buf); break; case 'G': - cpu_synchronize_state(s->g_cpu); + cpu_synchronize_state(ENV_GET_CPU(s->g_cpu)); env =3D s->g_cpu; registers =3D mem_buf; len =3D strlen(p) / 2; @@ -2408,7 +2408,7 @@ static int gdb_handle_packet(GDBState *s, const cha= r *line_buf) env =3D find_cpu(thread); if (env !=3D NULL) { CPUState *cpu =3D ENV_GET_CPU(env); - cpu_synchronize_state(env); + cpu_synchronize_state(cpu); len =3D snprintf((char *)mem_buf, sizeof(mem_buf), "CPU#%d [%s]", cpu->cpu_index, cpu->halted ? "halted " : "running"); diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c index 8f80425..bd0bdd8 100644 --- a/hw/i386/kvm/apic.c +++ b/hw/i386/kvm/apic.c @@ -129,7 +129,7 @@ static void do_inject_external_nmi(void *data) uint32_t lvt; int ret; =20 - cpu_synchronize_state(&s->cpu->env); + cpu_synchronize_state(cpu); =20 lvt =3D s->lvt[APIC_LVT_LINT1]; if (!(lvt & APIC_LVT_MASKED) && ((lvt >> 8) & 7) =3D=3D APIC_DM_NMI)= { diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 655483b..f93629f 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -456,7 +456,7 @@ void vapic_report_tpr_access(DeviceState *dev, CPUSta= te *cs, target_ulong ip, X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(cs); =20 if (evaluate_tpr_instruction(s, env, &ip, access) < 0) { if (s->state =3D=3D VAPIC_ACTIVE) { @@ -627,7 +627,7 @@ static void vapic_write(void *opaque, hwaddr addr, ui= nt64_t data, hwaddr rom_paddr; VAPICROMState *s =3D opaque; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(CPU(x86_env_get_cpu(env))); =20 /* * The VAPIC supports two PIO-based hypercalls, both via port 0x7E. diff --git a/hw/misc/vmport.c b/hw/misc/vmport.c index c146129..7026481 100644 --- a/hw/misc/vmport.c +++ b/hw/misc/vmport.c @@ -66,7 +66,7 @@ static uint64_t vmport_ioport_read(void *opaque, hwaddr= addr, unsigned char command; uint32_t eax; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(CPU(x86_env_get_cpu(env))); =20 eax =3D env->regs[R_EAX]; if (eax !=3D VMPORT_MAGIC) diff --git a/hw/ppc/ppce500_spin.c b/hw/ppc/ppce500_spin.c index 1290d37..ea65414 100644 --- a/hw/ppc/ppce500_spin.c +++ b/hw/ppc/ppce500_spin.c @@ -98,7 +98,7 @@ static void spin_kick(void *data) hwaddr map_size =3D 64 * 1024 * 1024; hwaddr map_start; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(cpu); stl_p(&curspin->pir, env->spr[SPR_PIR]); env->nip =3D ldq_p(&curspin->addr) & (map_size - 1); env->gpr[3] =3D ldq_p(&curspin->r3); diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 3e1db28..06da2b3 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -263,10 +263,10 @@ void kvm_cpu_synchronize_state(CPUState *cpu); =20 /* generic hooks - to be moved/refactored once there are more users */ =20 -static inline void cpu_synchronize_state(CPUArchState *env) +static inline void cpu_synchronize_state(CPUState *cpu) { if (kvm_enabled()) { - kvm_cpu_synchronize_state(ENV_GET_CPU(env)); + kvm_cpu_synchronize_state(cpu); } } =20 diff --git a/monitor.c b/monitor.c index 017411f..6e22d15 100644 --- a/monitor.c +++ b/monitor.c @@ -191,7 +191,7 @@ struct Monitor { QString *outbuf; ReadLineState *rs; MonitorControl *mc; - CPUArchState *mon_cpu; + CPUState *mon_cpu; BlockDriverCompletionFunc *password_completion_cb; void *password_opaque; QError *error; @@ -900,7 +900,7 @@ int monitor_set_cpu(int cpu_index) if (cpu =3D=3D NULL) { return -1; } - cur_mon->mon_cpu =3D cpu->env_ptr; + cur_mon->mon_cpu =3D cpu; return 0; } =20 @@ -910,7 +910,7 @@ static CPUArchState *mon_get_cpu(void) monitor_set_cpu(0); } cpu_synchronize_state(cur_mon->mon_cpu); - return cur_mon->mon_cpu; + return cur_mon->mon_cpu->env_ptr; } =20 int monitor_get_cpu_index(void) diff --git a/target-i386/helper.c b/target-i386/helper.c index 158710a..803945d 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -187,7 +187,7 @@ void cpu_dump_state(CPUX86State *env, FILE *f, fprint= f_function cpu_fprintf, char cc_op_name[32]; static const char *seg_name[6] =3D { "ES", "CS", "SS", "DS", "FS", "= GS" }; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(cs); =20 eflags =3D cpu_compute_eflags(env); #ifdef TARGET_X86_64 @@ -1116,7 +1116,7 @@ static void do_inject_x86_mce(void *data) CPUState *cpu =3D CPU(params->cpu); uint64_t *banks =3D cenv->mce_banks + 4 * params->bank; =20 - cpu_synchronize_state(cenv); + cpu_synchronize_state(cpu); =20 /* * If there is an MCE exception being processed, ignore this SRAO MC= E diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 0b0adfd..39f4fbb 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2079,7 +2079,7 @@ static int kvm_handle_debug(X86CPU *cpu, ret =3D EXCP_DEBUG; } if (ret =3D=3D 0) { - cpu_synchronize_state(env); + cpu_synchronize_state(CPU(cpu)); assert(env->exception_injected =3D=3D -1); =20 /* pass to guest */ diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c index 43ccf45..5c67ec3 100644 --- a/target-ppc/mmu-hash64.c +++ b/target-ppc/mmu-hash64.c @@ -78,7 +78,7 @@ void dump_slb(FILE *f, fprintf_function cpu_fprintf, CP= UPPCState *env) int i; uint64_t slbe, slbv; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(CPU(ppc_env_get_cpu(env))); =20 cpu_fprintf(f, "SLB\tESID\t\t\tVSID\n"); for (i =3D 0; i < env->slb_nr; i++) { diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 4590c6f..076cdac 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -9534,7 +9534,7 @@ void cpu_dump_state (CPUPPCState *env, FILE *f, fpr= intf_function cpu_fprintf, =20 int i; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(CPU(ppc_env_get_cpu(env))); =20 cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " TARGET_FMT_lx " XER " TARGET_FMT_lx "\n", diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 862fb12..167dd7d 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -450,7 +450,7 @@ static int kvm_sclp_service_call(S390CPU *cpu, struct= kvm_run *run, uint64_t code; int r =3D 0; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(CPU(cpu)); sccb =3D env->regs[ipbh0 & 0xf]; code =3D env->regs[(ipbh0 & 0xf0) >> 4]; =20 @@ -656,16 +656,17 @@ static int s390_store_status(CPUS390XState *env, ui= nt32_t parameter) =20 static int s390_cpu_initial_reset(S390CPU *cpu) { + CPUState *cs =3D CPU(cpu); CPUS390XState *env =3D &cpu->env; int i; =20 s390_del_running_cpu(cpu); - if (kvm_vcpu_ioctl(CPU(cpu), KVM_S390_INITIAL_RESET, NULL) < 0) { + if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL) < 0) { perror("cannot init reset vcpu"); } =20 /* Manually zero out all registers */ - cpu_synchronize_state(env); + cpu_synchronize_state(cs); for (i =3D 0; i < 16; i++) { env->regs[i] =3D 0; } @@ -685,7 +686,7 @@ static int handle_sigp(S390CPU *cpu, struct kvm_run *= run, uint8_t ipa1) S390CPU *target_cpu; CPUS390XState *target_env; =20 - cpu_synchronize_state(env); + cpu_synchronize_state(CPU(cpu)); =20 /* get order code */ order_code =3D run->s390_sieic.ipb >> 28; --=20 1.8.1.4