From nobody Fri Nov 7 22:57:20 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548810404155518.9116405760351; Tue, 29 Jan 2019 17:06:44 -0800 (PST) Received: from localhost ([127.0.0.1]:58024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goeKs-0005WM-1Z for importer@patchew.org; Tue, 29 Jan 2019 20:06:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goe3l-0008P9-Dt for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:48:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goe3j-00018B-0g for qemu-devel@nongnu.org; Tue, 29 Jan 2019 19:48:56 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:39351) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goe3i-0000pP-SR; Tue, 29 Jan 2019 19:48:54 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 37C882207D; Tue, 29 Jan 2019 19:48:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 29 Jan 2019 19:48:19 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id A97E0E4596; Tue, 29 Jan 2019 19:48:18 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=dRko9o7UIuv09Hif64QtDzaTNbrbLpVj30v6PONbyhA=; b=LZondVWcqVRk g+ps0jQQ7nddp95HNTZLD1+Is3F5+UcpJ/sARScGtjzwxAnUfwZBjdf6/7QI4qyE WQnoyEExyQYx4WdGvNCM8INVEgsQUr076AI43G3GoL6cMCQDUtJ8ldBvrN1z7OJ5 /R71bb0NlDd5WM/Jy9ecMYwjlPMEuvk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=dRko9o7UIuv09Hif64QtDzaTNbrbLpVj30v6PONby hA=; b=MfdLjfGuFt6/EEuMy+kdsxt0xYELImjQR8xDG8tA3ENLyLRqqTS+1bFnA A4pz19cTfoLP8oetcHC69lN1wGbOl5Yc3aofCvt0ueKpM6AdwGYl+zxphdujGMif 4Z4sG1tCD/icR5NUNbjGzqffP7G5fGjMC2uDlTX+fQygg/cRUXoZC3JD6PIFKkYL fYp60NOY2Y3aW1Dh250iQHGrhhpZwthvjbdDHSk0vn8me4Icv8HRdLIuqAdQzwH6 RqDqQUznxjY5ELI0vGpTwrgVWCmrkhY72TFM606F083JNSE/wbdkAele+9P/1PWz RElWc08S2DaJ/IuvuqRDMMh6V5OOw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrjeefgddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojg hfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohhtrgdf uceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvdduie enucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecuvehl uhhsthgvrhfuihiivgepke X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 19:47:23 -0500 Message-Id: <20190130004811.27372-26-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190130004811.27372-1-cota@braap.org> References: <20190130004811.27372-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v6 25/73] s390x: convert to cpu_halted X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand , Cornelia Huck , Richard Henderson , Christian Borntraeger , qemu-s390x@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Cc: Cornelia Huck Cc: Christian Borntraeger Cc: David Hildenbrand Cc: qemu-s390x@nongnu.org Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Reviewed-by: Cornelia Huck --- hw/intc/s390_flic.c | 2 +- target/s390x/cpu.c | 22 +++++++++++++++------- target/s390x/excp_helper.c | 2 +- target/s390x/kvm.c | 2 +- target/s390x/sigp.c | 8 ++++---- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 5f8168f0f0..bfb5cf1d07 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -198,7 +198,7 @@ static void qemu_s390_flic_notify(uint32_t type) } =20 /* we always kick running CPUs for now, this is tricky */ - if (cs->halted) { + if (cpu_halted(cs)) { /* don't check for subclasses, CPUs double check when waking u= p */ if (type & FLIC_PENDING_SERVICE) { if (!(cpu->env.psw.mask & PSW_MASK_EXT)) { diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 18ba7f85a5..4d70ba785c 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -288,7 +288,7 @@ static void s390_cpu_initfn(Object *obj) CPUS390XState *env =3D &cpu->env; =20 cs->env_ptr =3D env; - cs->halted =3D 1; + cpu_halted_set(cs, 1); cs->exception_index =3D EXCP_HLT; object_property_add(obj, "crash-information", "GuestPanicInformation", s390_cpu_get_crash_info_qom, NULL, NULL, NULL, NUL= L); @@ -313,8 +313,8 @@ static void s390_cpu_finalize(Object *obj) #if !defined(CONFIG_USER_ONLY) static bool disabled_wait(CPUState *cpu) { - return cpu->halted && !(S390_CPU(cpu)->env.psw.mask & - (PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK)= ); + return cpu_halted(cpu) && !(S390_CPU(cpu)->env.psw.mask & + (PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCH= ECK)); } =20 static unsigned s390_count_running_cpus(void) @@ -340,10 +340,16 @@ unsigned int s390_cpu_halt(S390CPU *cpu) CPUState *cs =3D CPU(cpu); trace_cpu_halt(cs->cpu_index); =20 - if (!cs->halted) { - cs->halted =3D 1; + /* + * cpu_halted and cpu_halted_set acquire the cpu lock if it + * isn't already held, so acquire it first. + */ + cpu_mutex_lock(cs); + if (!cpu_halted(cs)) { + cpu_halted_set(cs, 1); cs->exception_index =3D EXCP_HLT; } + cpu_mutex_unlock(cs); =20 return s390_count_running_cpus(); } @@ -353,10 +359,12 @@ void s390_cpu_unhalt(S390CPU *cpu) CPUState *cs =3D CPU(cpu); trace_cpu_unhalt(cs->cpu_index); =20 - if (cs->halted) { - cs->halted =3D 0; + cpu_mutex_lock(cs); + if (cpu_halted(cs)) { + cpu_halted_set(cs, 0); cs->exception_index =3D -1; } + cpu_mutex_unlock(cs); } =20 unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu) diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 2a33222f7e..d22c5b3ce5 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -461,7 +461,7 @@ try_deliver: if ((env->psw.mask & PSW_MASK_WAIT) || stopped) { /* don't trigger a cpu_loop_exit(), use an interrupt instead */ cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HALT); - } else if (cs->halted) { + } else if (cpu_halted(cs)) { /* unhalt if we had a WAIT PSW somehwere in our injection chain */ s390_cpu_unhalt(cpu); } diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 2ebf26adfe..ffb52888c0 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1005,7 +1005,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm= _run *run) =20 int kvm_arch_process_async_events(CPUState *cs) { - return cs->halted; + return cpu_halted(cs); } =20 static int s390_kvm_irq_to_interrupt(struct kvm_s390_irq *irq, diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index c1f9245797..d410da797a 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -115,7 +115,7 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data arg) } =20 /* disabled wait - sleeping in user space */ - if (cs->halted) { + if (cpu_halted(cs)) { s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); } else { /* execute the stop function */ @@ -131,7 +131,7 @@ static void sigp_stop_and_store_status(CPUState *cs, ru= n_on_cpu_data arg) SigpInfo *si =3D arg.host_ptr; =20 /* disabled wait - sleeping in user space */ - if (s390_cpu_get_state(cpu) =3D=3D S390_CPU_STATE_OPERATING && cs->hal= ted) { + if (s390_cpu_get_state(cpu) =3D=3D S390_CPU_STATE_OPERATING && cpu_hal= ted(cs)) { s390_cpu_set_state(S390_CPU_STATE_STOPPED, cpu); } =20 @@ -313,7 +313,7 @@ static void sigp_cond_emergency(S390CPU *src_cpu, S390C= PU *dst_cpu, } =20 /* this looks racy, but these values are only used when STOPPED */ - idle =3D CPU(dst_cpu)->halted; + idle =3D cpu_halted(CPU(dst_cpu)); psw_addr =3D dst_cpu->env.psw.addr; psw_mask =3D dst_cpu->env.psw.mask; asn =3D si->param; @@ -347,7 +347,7 @@ static void sigp_sense_running(S390CPU *dst_cpu, SigpIn= fo *si) } =20 /* If halted (which includes also STOPPED), it is not running */ - if (CPU(dst_cpu)->halted) { + if (cpu_halted(CPU(dst_cpu))) { si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } else { set_sigp_status(si, SIGP_STAT_NOT_RUNNING); --=20 2.17.1