From nobody Fri Nov 7 01:01:14 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544679897734437.5727711692107; Wed, 12 Dec 2018 21:44:57 -0800 (PST) Received: from localhost ([::1]:50631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJns-00089Q-Bu for importer@patchew.org; Thu, 13 Dec 2018 00:44:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXJCz-0007zf-Ru for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXJCw-000292-NR for qemu-devel@nongnu.org; Thu, 13 Dec 2018 00:06:49 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:38553) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXJCw-00015E-BE; Thu, 13 Dec 2018 00:06:46 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E37DE221DC; Thu, 13 Dec 2018 00:05:42 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 13 Dec 2018 00:05:42 -0500 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 5595D1045B; Thu, 13 Dec 2018 00:05:42 -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=cwgQsFEO7bZ4btMdICO5/HtuYHxLOUX5qbmf4++QLBs=; b=OaWXWo0sY7+V 1JuqWD3PZ4+ti5wiLzWJkPfk/3Bq5pp8tokXszgireejvtK5PrkWJKv81NP7IHyo kMp0roVM6bn3lB5SEn4jU9fS3kM36q2wMQxY+qFoIy+XLTX9c6HsY9rGpIxVaYFy nXs/lGaYovkw0JiJICFkg6TpDzOScuw= 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=cwgQsFEO7bZ4btMdICO5/HtuYHxLOUX5qbmf4++QL Bs=; b=PNdesKkxic+ts7B2t51rdzjkabtXyc60Z+pxiwpsahJrSgo5Mj4p0xcGe iH+QjfkJM2mVYESCemqxxefXx3ldSl+kWtNgqwQjRqPjkMpuoDBS95x8+hVQIoOR CJ4FwY26zSUtku02ZM06xAXRqdzainZJengpbj6yWa6TKNFYsrgcPb28s+4fQQP8 xlp5Oxs5a1MGpnE/x6drJKewEO1pec2vYyXWlRVcMQWs6n4yH3Uf3Egvf4K8/Xp+ wnpm6EIYYu0Dc33X8pJwh73ZO26kh+Rd2dXryptzgF8e3p9GOp7OvN/rFY5b5Ewm qpNRqi1g8LJpuONvfRoCk4joejrfw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehuddgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkof gjfhggtgfgsehtkeertdertdejnecuhfhrohhmpedfgfhmihhlihhoucfirdcuvehothgr fdcuoegtohhtrgessghrrggrphdrohhrgheqnecukfhppeduvdekrdehledrvddtrddvud einecurfgrrhgrmhepmhgrihhlfhhrohhmpegtohhtrgessghrrggrphdrohhrghenucev lhhushhtvghrufhiiigvpeeg X-ME-Proxy: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 00:04:05 -0500 Message-Id: <20181213050453.9677-26-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213050453.9677-1-cota@braap.org> References: <20181213050453.9677-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] [fuzzy] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v5 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 , Alexander Graf , Christian Borntraeger , qemu-s390x@nongnu.org, Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Cc: Cornelia Huck Cc: Christian Borntraeger Cc: Alexander Graf Cc: David Hildenbrand Cc: qemu-s390x@nongnu.org Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- 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