From patchwork Fri Feb 1 01:03:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 217322 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 317C12C0095 for ; Fri, 1 Feb 2013 12:26:51 +1100 (EST) Received: from localhost ([::1]:54455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U152f-0002xt-EX for incoming@patchwork.ozlabs.org; Thu, 31 Jan 2013 20:03:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U152D-0002db-5P for qemu-devel@nongnu.org; Thu, 31 Jan 2013 20:03:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U152A-0002Qc-Bt for qemu-devel@nongnu.org; Thu, 31 Jan 2013 20:03:16 -0500 Received: from cantor2.suse.de ([195.135.220.15]:34833 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1529-0002Q9-SE for qemu-devel@nongnu.org; Thu, 31 Jan 2013 20:03:14 -0500 Received: from relay2.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 591C8A4386; Fri, 1 Feb 2013 02:03:13 +0100 (CET) From: Alexander Graf To: qemu-devel Date: Fri, 1 Feb 2013 02:03:01 +0100 Message-Id: <1359680581-6091-5-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1359680581-6091-1-git-send-email-agraf@suse.de> References: <1359680581-6091-1-git-send-email-agraf@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Blue Swirl , Anthony Liguori , =?utf-8?q?Aur=C3=A9lien=20Jarno?= , =?utf-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH 4/4] target-s390x: Pass S390CPU to s390_{add, del}_running_cpu() 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 From: Andreas Färber This prepares for moving the halted field to CPUState. Most call sites can already supply S390CPU, for some env becomes unused. Signed-off-by: Andreas Färber Acked-by: Cornelia Huck Signed-off-by: Alexander Graf --- hw/s390x/ipl.c | 6 ++++-- hw/s390x/s390-virtio.c | 8 ++++++-- target-s390x/cpu.c | 2 +- target-s390x/cpu.h | 8 ++++---- target-s390x/helper.c | 5 +++-- target-s390x/kvm.c | 13 +++++-------- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 86e8415..206d552 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -58,10 +58,12 @@ typedef struct S390IPLState { static void s390_ipl_cpu(uint64_t pswaddr) { - CPUS390XState *env = &S390_CPU(qemu_get_cpu(0))->env; + S390CPU *cpu = S390_CPU(qemu_get_cpu(0)); + CPUS390XState *env = &cpu->env; + env->psw.addr = pswaddr; env->psw.mask = IPL_PSW_MASK; - s390_add_running_cpu(env); + s390_add_running_cpu(cpu); } static int s390_ipl_init(SysBusDevice *dev) diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index 2a1d9ac..e25c330 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -130,8 +130,10 @@ static void s390_virtio_register_hcalls(void) */ static unsigned s390_running_cpus; -void s390_add_running_cpu(CPUS390XState *env) +void s390_add_running_cpu(S390CPU *cpu) { + CPUS390XState *env = &cpu->env; + if (env->halted) { s390_running_cpus++; env->halted = 0; @@ -139,8 +141,10 @@ void s390_add_running_cpu(CPUS390XState *env) } } -unsigned s390_del_running_cpu(CPUS390XState *env) +unsigned s390_del_running_cpu(S390CPU *cpu) { + CPUS390XState *env = &cpu->env; + if (env->halted == 0) { assert(s390_running_cpus >= 1); s390_running_cpus--; diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 0b68db8..c250091 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -70,7 +70,7 @@ static void s390_cpu_reset(CPUState *s) log_cpu_state(env, 0); } - s390_del_running_cpu(env); + s390_del_running_cpu(cpu); scc->parent_reset(s); diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 41b2d92..01e59b9 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -375,8 +375,8 @@ static inline void kvm_s390_interrupt_internal(S390CPU *cpu, int type, } #endif S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); -void s390_add_running_cpu(CPUS390XState *env); -unsigned s390_del_running_cpu(CPUS390XState *env); +void s390_add_running_cpu(S390CPU *cpu); +unsigned s390_del_running_cpu(S390CPU *cpu); /* service interrupts are floating therefore we must not pass an cpustate */ void s390_sclp_extint(uint32_t parm); @@ -385,11 +385,11 @@ void s390_sclp_extint(uint32_t parm); extern const hwaddr virtio_size; #else -static inline void s390_add_running_cpu(CPUS390XState *env) +static inline void s390_add_running_cpu(S390CPU *cpu) { } -static inline unsigned s390_del_running_cpu(CPUS390XState *env) +static inline unsigned s390_del_running_cpu(S390CPU *cpu) { return 0; } diff --git a/target-s390x/helper.c b/target-s390x/helper.c index a5ce56b..3180b90 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -441,8 +441,9 @@ hwaddr cpu_get_phys_page_debug(CPUS390XState *env, void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr) { if (mask & PSW_MASK_WAIT) { + S390CPU *cpu = s390_env_get_cpu(env); if (!(mask & (PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK))) { - if (s390_del_running_cpu(env) == 0) { + if (s390_del_running_cpu(cpu) == 0) { #ifndef CONFIG_USER_ONLY qemu_system_shutdown_request(); #endif @@ -742,7 +743,7 @@ void do_interrupt(CPUS390XState *env) qemu_log_mask(CPU_LOG_INT, "%s: %d at pc=%" PRIx64 "\n", __func__, env->exception_index, env->psw.addr); - s390_add_running_cpu(env); + s390_add_running_cpu(cpu); /* handle machine checks */ if ((env->psw.mask & PSW_MASK_MCHECK) && (env->exception_index == -1)) { diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 2c24182..3929771 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -570,12 +570,10 @@ static int handle_diag(CPUS390XState *env, struct kvm_run *run, int ipb_code) static int s390_cpu_restart(S390CPU *cpu) { - CPUS390XState *env = &cpu->env; - kvm_s390_interrupt(cpu, KVM_S390_RESTART, 0); - s390_add_running_cpu(env); + s390_add_running_cpu(cpu); qemu_cpu_kick(CPU(cpu)); - dprintf("DONE: SIGP cpu restart: %p\n", env); + dprintf("DONE: SIGP cpu restart: %p\n", &cpu->env); return 0; } @@ -591,7 +589,7 @@ static int s390_cpu_initial_reset(S390CPU *cpu) CPUS390XState *env = &cpu->env; int i; - s390_del_running_cpu(env); + s390_del_running_cpu(cpu); if (kvm_vcpu_ioctl(CPU(cpu), KVM_S390_INITIAL_RESET, NULL) < 0) { perror("cannot init reset vcpu"); } @@ -701,7 +699,6 @@ static bool is_special_wait_psw(CPUState *cs) static int handle_intercept(S390CPU *cpu) { - CPUS390XState *env = &cpu->env; CPUState *cs = CPU(cpu); struct kvm_run *run = cs->kvm_run; int icpt_code = run->s390_sieic.icptcode; @@ -714,14 +711,14 @@ static int handle_intercept(S390CPU *cpu) r = handle_instruction(cpu, run); break; case ICPT_WAITPSW: - if (s390_del_running_cpu(env) == 0 && + if (s390_del_running_cpu(cpu) == 0 && is_special_wait_psw(cs)) { qemu_system_shutdown_request(); } r = EXCP_HALTED; break; case ICPT_CPU_STOP: - if (s390_del_running_cpu(env) == 0) { + if (s390_del_running_cpu(cpu) == 0) { qemu_system_shutdown_request(); } r = EXCP_HALTED;