From nobody Sun Apr 28 00:08:01 2024 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 1505750986599965.3073349313088; Mon, 18 Sep 2017 09:09:46 -0700 (PDT) Received: from localhost ([::1]:37613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyc9-0005fc-Qe for importer@patchew.org; Mon, 18 Sep 2017 12:09:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTe-0006j5-Uf for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTZ-0007iQ-7J for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:00:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52076) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTZ-0007i8-1O for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:00:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF4A32CE918; Mon, 18 Sep 2017 16:00:47 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AAE75D6A8; Mon, 18 Sep 2017 16:00:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF4A32CE918 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:46 +0200 Message-Id: <20170918160012.4317-2-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Sep 2017 16:00:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 01/27] s390x: raise CPU hotplug irq after really hotplugged 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Let's move it into the machine, so we trigger the IRQ after setting ms->possible_cpus (which SCLP uses to construct the list of online CPUs). Signed-off-by: David Hildenbrand Reviewed-by: Christian Borntraeger Reviewed-by: Richard Henderson --- hw/s390x/s390-virtio-ccw.c | 4 ++++ target/s390x/cpu.c | 8 -------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 0471407187..d5a12a2472 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -327,6 +327,10 @@ static void s390_cpu_plug(HotplugHandler *hotplug_dev, =20 g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); ms->possible_cpus->cpus[cpu->env.core_id].cpu =3D OBJECT(dev); + + if (dev->hotplugged) { + raise_irq_cpu_hotplug(); + } } =20 static void s390_machine_reset(void) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 34538c3ab9..4920da3625 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -41,7 +41,6 @@ #include "hw/hw.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" -#include "hw/s390x/sclp.h" #endif =20 #define CR0_RESET 0xE0UL @@ -227,13 +226,6 @@ static void s390_cpu_realizefn(DeviceState *dev, Error= **errp) #endif =20 scc->parent_realize(dev, &err); - -#if !defined(CONFIG_USER_ONLY) - if (dev->hotplugged) { - raise_irq_cpu_hotplug(); - } -#endif - out: error_propagate(errp, err); } --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505750810250358.2309993387993; Mon, 18 Sep 2017 09:06:50 -0700 (PDT) Received: from localhost ([::1]:37604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyZN-00036u-86 for importer@patchew.org; Mon, 18 Sep 2017 12:06:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTe-0006j4-Ug for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:00:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTc-0007jj-DJ for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:00:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTc-0007jR-7A for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:00:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13A90491; Mon, 18 Sep 2017 16:00:51 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D4695D6A8; Mon, 18 Sep 2017 16:00:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13A90491 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:47 +0200 Message-Id: <20170918160012.4317-3-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Sep 2017 16:00:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 02/27] s390x/cpumodel: fix max STFL(E) bit number 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Not that it would matter in the near future, but it is actually 2048 bytes, therefore 16384 possible bits. Signed-off-by: David Hildenbrand Reviewed-by: Christian Borntraeger Reviewed-by: Thomas Huth --- target/s390x/cpu_features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 1d3a036393..31a4676f05 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -381,7 +381,7 @@ void s390_add_from_feat_block(S390FeatBitmap features, = S390FeatType type, =20 switch (type) { case S390_FEAT_TYPE_STFL: - nr_bits =3D 2048; + nr_bits =3D 16384; break; case S390_FEAT_TYPE_PLO: nr_bits =3D 256; --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505750648761348.0684278135883; Mon, 18 Sep 2017 09:04:08 -0700 (PDT) Received: from localhost ([::1]:37549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyWl-0000qg-Tp for importer@patchew.org; Mon, 18 Sep 2017 12:04:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTl-0006ob-8Q for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTf-0007l6-JS for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54322) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTf-0007kf-BL for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:00:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 499B77CE0E; Mon, 18 Sep 2017 16:00:54 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 652875D6A8; Mon, 18 Sep 2017 16:00:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 499B77CE0E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:48 +0200 Message-Id: <20170918160012.4317-4-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 18 Sep 2017 16:00:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 03/27] target/s390x: get rid of next_core_id 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" core_id is not needed by linux-user, as the core_id a.k.a. CPU address is only accessible from kernel space. Therefore, drop next_core_id and make cpu_index get autoassigned again for linux-user. While at it, shield core_id and cpuid completely from linux-user. cpuid can also only be queried from kernel space. Suggested-by: Igor Mammedov Signed-off-by: David Hildenbrand Reviewed-by: Igor Mammedov --- target/s390x/cpu-qom.h | 2 -- target/s390x/cpu.c | 14 +++++++------- target/s390x/cpu.h | 2 ++ target/s390x/cpu_models.c | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h index 2e446fab51..0510c49e07 100644 --- a/target/s390x/cpu-qom.h +++ b/target/s390x/cpu-qom.h @@ -54,8 +54,6 @@ typedef struct S390CPUClass { bool is_migration_safe; const char *desc; =20 - uint32_t next_core_id; - DeviceRealize parent_realize; void (*parent_reset)(CPUState *cpu); void (*load_normal)(CPUState *cpu); diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 4920da3625..f42e28ea25 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -178,8 +178,9 @@ static void s390_cpu_realizefn(DeviceState *dev, Error = **errp) { CPUState *cs =3D CPU(dev); S390CPUClass *scc =3D S390_CPU_GET_CLASS(dev); +#if !defined(CONFIG_USER_ONLY) S390CPU *cpu =3D S390_CPU(dev); - CPUS390XState *env =3D &cpu->env; +#endif Error *err =3D NULL; =20 /* the model has to be realized before qemu_init_vcpu() due to kvm */ @@ -195,11 +196,6 @@ static void s390_cpu_realizefn(DeviceState *dev, Error= **errp) max_cpus - 1); goto out; } -#else - /* implicitly set for linux-user only */ - cpu->env.core_id =3D scc->next_core_id; - scc->next_core_id++; -#endif =20 if (cpu_exists(cpu->env.core_id)) { error_setg(&err, "Unable to add CPU with core-id: %" PRIu32 @@ -208,7 +204,9 @@ static void s390_cpu_realizefn(DeviceState *dev, Error = **errp) } =20 /* sync cs->cpu_index and env->core_id. The latter is needed for TCG. = */ - cs->cpu_index =3D env->core_id; + cs->cpu_index =3D cpu->env.core_id; +#endif + cpu_exec_realizefn(cs, &err); if (err !=3D NULL) { goto out; @@ -440,7 +438,9 @@ static gchar *s390_gdb_arch_name(CPUState *cs) } =20 static Property s390x_cpu_properties[] =3D { +#if !defined(CONFIG_USER_ONLY) DEFINE_PROP_UINT32("core-id", S390CPU, env.core_id, 0), +#endif DEFINE_PROP_END_OF_LIST() }; =20 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 9b549dc491..f13aea3dd8 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -150,8 +150,10 @@ struct CPUS390XState { =20 CPU_COMMON =20 +#if !defined(CONFIG_USER_ONLY) uint32_t core_id; /* PoP "CPU address", same as cpu_index */ uint64_t cpuid; +#endif =20 uint64_t tod_offset; uint64_t tod_basetime; diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 5169379db5..191aee6dd4 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -941,11 +941,13 @@ void s390_realize_cpu_model(CPUState *cs, Error **err= p) =20 apply_cpu_model(cpu->model, errp); =20 +#if !defined(CONFIG_USER_ONLY) cpu->env.cpuid =3D s390_cpuid_from_cpu_model(cpu->model); if (tcg_enabled()) { /* basic mode, write the cpu address into the first 4 bit of the I= D */ cpu->env.cpuid =3D deposit64(cpu->env.cpuid, 54, 4, cpu->env.core_= id); } +#endif } =20 static void get_feature(Object *obj, Visitor *v, const char *name, --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505750868227886.1943115480584; Mon, 18 Sep 2017 09:07:48 -0700 (PDT) Received: from localhost ([::1]:37607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyaJ-000489-Eg for importer@patchew.org; Mon, 18 Sep 2017 12:07:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTo-0006qp-If for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTi-0007mC-Oz for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTi-0007m2-JG for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:00:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 832F27C838; Mon, 18 Sep 2017 16:00:57 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 988A75D6A9; Mon, 18 Sep 2017 16:00:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 832F27C838 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:49 +0200 Message-Id: <20170918160012.4317-5-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 18 Sep 2017 16:00:57 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 04/27] s390x: introduce and use S390_MAX_CPUS 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Will be handy in the next patches. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth --- hw/s390x/s390-virtio-ccw.c | 2 +- target/s390x/cpu.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index d5a12a2472..a57d435cbf 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -443,7 +443,7 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) mc->no_parallel =3D 1; mc->no_sdcard =3D 1; mc->use_sclp =3D 1; - mc->max_cpus =3D 248; + mc->max_cpus =3D S390_MAX_CPUS; mc->has_hotpluggable_cpus =3D true; mc->get_hotplug_handler =3D s390_get_hotplug_handler; mc->cpu_index_to_instance_props =3D s390_cpu_index_to_props; diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index f13aea3dd8..5f539b1057 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -59,6 +59,8 @@ #define PSW_MCHK_MASK 0x0004000000000000 #define PSW_IO_MASK 0x0200000000000000 =20 +#define S390_MAX_CPUS 248 + typedef struct PSW { uint64_t mask; uint64_t addr; --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505750819034817.8935384955233; Mon, 18 Sep 2017 09:06:59 -0700 (PDT) Received: from localhost ([::1]:37606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyZW-0003EK-4x for importer@patchew.org; Mon, 18 Sep 2017 12:06:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTr-0006u7-Od for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTl-0007nr-L4 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47514) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTl-0007nC-DW for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FD107E43B; Mon, 18 Sep 2017 16:01:00 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id D40CC5D6A8; Mon, 18 Sep 2017 16:00:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4FD107E43B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:50 +0200 Message-Id: <20170918160012.4317-6-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 18 Sep 2017 16:01:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 05/27] s390/tcg: turn INTERRUPT_EXT into a mask 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" External interrupts are currently all handled like floating external interrupts, they are queued. Let's prepare for a split of floating and local interrupts by turning INTERRUPT_EXT into a mask. While we can have various floating external interrupts of one kind, there is usually only one (or a fixed number) of the local external interrupts. So turn INTERRUPT_EXT into a mask and properly indicate the kind of external interrupt. Floating interrupts will have to moved out of one CPU instance later once we have SMP support. This get's rid of the ugly special handling for cpu timer and clock comparator interrupts. And we really only store the parameters as defined by the PoP. We'll introduce external calls and emergency signals in the following patches. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 13 ++++++---- target/s390x/excp_helper.c | 65 ++++++++++++++++++++++++------------------= ---- target/s390x/helper.c | 12 ++------- target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 18 ++++++++++++- 5 files changed, 63 insertions(+), 47 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 5f539b1057..d4e2aa2f24 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -400,11 +400,14 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState= * env, target_ulong *pc, #define EXCP_IO 7 /* I/O interrupt */ #define EXCP_MCHK 8 /* machine check */ =20 -#define INTERRUPT_EXT (1 << 0) -#define INTERRUPT_TOD (1 << 1) -#define INTERRUPT_CPUTIMER (1 << 2) -#define INTERRUPT_IO (1 << 3) -#define INTERRUPT_MCHK (1 << 4) +#define INTERRUPT_IO (1 << 0) +#define INTERRUPT_MCHK (1 << 1) +#define INTERRUPT_EXT_FLOATING (1 << 2) +#define INTERRUPT_EXT_CPU_TIMER (1 << 3) +#define INTERRUPT_EXT_CLOCK_COMPARATOR (1 << 4) +#define INTERRUPT_EXT (INTERRUPT_EXT_FLOATING | \ + INTERRUPT_EXT_CPU_TIMER | \ + INTERRUPT_EXT_CLOCK_COMPARATOR) =20 /* Program Status Word. */ #define S390_PSWM_REGNUM 0 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 470cf8f5bc..46d015f260 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -238,29 +238,44 @@ static void do_ext_interrupt(CPUS390XState *env) cpu_abort(CPU(cpu), "Ext int w/o ext mask\n"); } =20 - if (env->ext_index < 0 || env->ext_index >=3D MAX_EXT_QUEUE) { - cpu_abort(CPU(cpu), "Ext queue overrun: %d\n", env->ext_index); - } - - q =3D &env->ext_queue[env->ext_index]; lowcore =3D cpu_map_lowcore(env); =20 - lowcore->ext_int_code =3D cpu_to_be16(q->code); - lowcore->ext_params =3D cpu_to_be32(q->param); - lowcore->ext_params2 =3D cpu_to_be64(q->param64); - lowcore->external_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); - lowcore->external_old_psw.addr =3D cpu_to_be64(env->psw.addr); - lowcore->cpu_addr =3D cpu_to_be16(env->core_id | VIRTIO_SUBCODE_64); + if (env->pending_int & INTERRUPT_EXT_CLOCK_COMPARATOR) { + lowcore->ext_int_code =3D cpu_to_be16(EXT_CLOCK_COMP); + lowcore->cpu_addr =3D 0; + env->pending_int &=3D ~INTERRUPT_EXT_CLOCK_COMPARATOR; + } else if (env->pending_int & INTERRUPT_EXT_CPU_TIMER) { + lowcore->ext_int_code =3D cpu_to_be16(EXT_CPU_TIMER); + lowcore->cpu_addr =3D 0; + env->pending_int &=3D ~INTERRUPT_EXT_CPU_TIMER; + } else if (env->pending_int | INTERRUPT_EXT_FLOATING) { + g_assert(env->ext_index >=3D 0); + /* + * FIXME: floating IRQs should be considered by all CPUs and + * shuld not get cleared by CPU reset. + */ + q =3D &env->ext_queue[env->ext_index]; + lowcore->ext_int_code =3D cpu_to_be16(q->code); + lowcore->ext_params =3D cpu_to_be32(q->param); + lowcore->ext_params2 =3D cpu_to_be64(q->param64); + lowcore->external_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); + lowcore->external_old_psw.addr =3D cpu_to_be64(env->psw.addr); + lowcore->cpu_addr =3D cpu_to_be16(env->core_id | VIRTIO_SUBCODE_64= ); + env->ext_index--; + if (env->ext_index =3D=3D -1) { + env->pending_int &=3D ~INTERRUPT_EXT_FLOATING; + } + } else { + g_assert_not_reached(); + } + mask =3D be64_to_cpu(lowcore->external_new_psw.mask); addr =3D be64_to_cpu(lowcore->external_new_psw.addr); + lowcore->external_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); + lowcore->external_old_psw.addr =3D cpu_to_be64(env->psw.addr); =20 cpu_unmap_lowcore(lowcore); =20 - env->ext_index--; - if (env->ext_index =3D=3D -1) { - env->pending_int &=3D ~INTERRUPT_EXT; - } - DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, env->psw.mask, env->psw.addr); =20 @@ -413,21 +428,9 @@ void s390_cpu_do_interrupt(CPUState *cs) } /* handle external interrupts */ if ((env->psw.mask & PSW_MASK_EXT) && - cs->exception_index =3D=3D -1) { - if (env->pending_int & INTERRUPT_EXT) { - /* code is already in env */ - cs->exception_index =3D EXCP_EXT; - } else if (env->pending_int & INTERRUPT_TOD) { - cpu_inject_ext(cpu, 0x1004, 0, 0); - cs->exception_index =3D EXCP_EXT; - env->pending_int &=3D ~INTERRUPT_EXT; - env->pending_int &=3D ~INTERRUPT_TOD; - } else if (env->pending_int & INTERRUPT_CPUTIMER) { - cpu_inject_ext(cpu, 0x1005, 0, 0); - cs->exception_index =3D EXCP_EXT; - env->pending_int &=3D ~INTERRUPT_EXT; - env->pending_int &=3D ~INTERRUPT_TOD; - } + cs->exception_index =3D=3D -1 && + (env->pending_int & INTERRUPT_EXT)) { + cs->exception_index =3D EXCP_EXT; } /* handle I/O interrupts */ if ((env->psw.mask & PSW_MASK_IO) && diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 97adbcc86d..e22b93258b 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -51,20 +51,12 @@ #ifndef CONFIG_USER_ONLY void s390x_tod_timer(void *opaque) { - S390CPU *cpu =3D opaque; - CPUS390XState *env =3D &cpu->env; - - env->pending_int |=3D INTERRUPT_TOD; - cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + cpu_inject_clock_comparator((S390CPU *) opaque); } =20 void s390x_cpu_timer(void *opaque) { - S390CPU *cpu =3D opaque; - CPUS390XState *env =3D &cpu->env; - - env->pending_int |=3D INTERRUPT_CPUTIMER; - cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + cpu_inject_cpu_timer((S390CPU *) opaque); } #endif =20 diff --git a/target/s390x/internal.h b/target/s390x/internal.h index bc8f83129a..ae4b27a574 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -348,6 +348,8 @@ void cpu_unmap_lowcore(LowCore *lowcore); void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n); void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param, uint64_t param64); +void cpu_inject_clock_comparator(S390CPU *cpu); +void cpu_inject_cpu_timer(S390CPU *cpu); =20 =20 /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 058e219fe5..4ba33c49cb 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -71,7 +71,23 @@ void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_= t param, env->ext_queue[env->ext_index].param =3D param; env->ext_queue[env->ext_index].param64 =3D param64; =20 - env->pending_int |=3D INTERRUPT_EXT; + env->pending_int |=3D INTERRUPT_EXT_FLOATING; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); +} + +void cpu_inject_clock_comparator(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + env->pending_int |=3D INTERRUPT_EXT_CLOCK_COMPARATOR; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); +} + +void cpu_inject_cpu_timer(S390CPU *cpu) +{ + CPUS390XState *env =3D &cpu->env; + + env->pending_int |=3D INTERRUPT_EXT_CPU_TIMER; cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505750991865960.7741543360181; Mon, 18 Sep 2017 09:09:51 -0700 (PDT) Received: from localhost ([::1]:37615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtycJ-0005p2-3p for importer@patchew.org; Mon, 18 Sep 2017 12:09:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTu-0006wT-Tw for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTo-0007p4-M5 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTo-0007oO-E0 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:04 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52813C0050BF; Mon, 18 Sep 2017 16:01:03 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id A08715D6A9; Mon, 18 Sep 2017 16:01:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 52813C0050BF Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:51 +0200 Message-Id: <20170918160012.4317-7-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 18 Sep 2017 16:01:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 06/27] s390x/tcg: injection of emergency signals and extarnal calls 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Preparation for new TCG SIGP code. Especially also prepare for indicating that another external call is already pending. Signed-off-by: David Hildenbrand --- target/s390x/cpu.h | 8 +++++++- target/s390x/excp_helper.c | 14 ++++++++++++++ target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 26 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index d4e2aa2f24..857af21d06 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -132,6 +132,8 @@ struct CPUS390XState { MchkQueue mchk_queue[MAX_MCHK_QUEUE]; =20 int pending_int; + uint16_t external_call_addr; + DECLARE_BITMAP(emergency_signals, S390_MAX_CPUS); int ext_index; int io_index[8]; int mchk_index; @@ -405,9 +407,13 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState*= env, target_ulong *pc, #define INTERRUPT_EXT_FLOATING (1 << 2) #define INTERRUPT_EXT_CPU_TIMER (1 << 3) #define INTERRUPT_EXT_CLOCK_COMPARATOR (1 << 4) +#define INTERRUPT_EXTERNAL_CALL (1 << 5) +#define INTERRUPT_EMERGENCY_SIGNAL (1 << 6) #define INTERRUPT_EXT (INTERRUPT_EXT_FLOATING | \ INTERRUPT_EXT_CPU_TIMER | \ - INTERRUPT_EXT_CLOCK_COMPARATOR) + INTERRUPT_EXT_CLOCK_COMPARATOR |= \ + INTERRUPT_EXTERNAL_CALL | \ + INTERRUPT_EMERGENCY_SIGNAL) =20 /* Program Status Word. */ #define S390_PSWM_REGNUM 0 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 46d015f260..ff257ba72e 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -231,6 +231,7 @@ static void do_ext_interrupt(CPUS390XState *env) { S390CPU *cpu =3D s390_env_get_cpu(env); uint64_t mask, addr; + uint16_t cpu_addr; LowCore *lowcore; ExtQueue *q; =20 @@ -248,6 +249,19 @@ static void do_ext_interrupt(CPUS390XState *env) lowcore->ext_int_code =3D cpu_to_be16(EXT_CPU_TIMER); lowcore->cpu_addr =3D 0; env->pending_int &=3D ~INTERRUPT_EXT_CPU_TIMER; + } else if (env->pending_int & INTERRUPT_EMERGENCY_SIGNAL) { + lowcore->ext_int_code =3D cpu_to_be16(EXT_EMERGENCY); + cpu_addr =3D find_first_bit(env->emergency_signals, S390_MAX_CPUS); + g_assert(cpu_addr < S390_MAX_CPUS); + lowcore->cpu_addr =3D cpu_to_be16(cpu_addr); + clear_bit(cpu_addr, env->emergency_signals); + if (bitmap_empty(env->emergency_signals, max_cpus)) { + env->pending_int &=3D ~INTERRUPT_EMERGENCY_SIGNAL; + } + } else if (env->pending_int & INTERRUPT_EXTERNAL_CALL) { + lowcore->ext_int_code =3D cpu_to_be16(EXT_EXTERNAL_CALL); + lowcore->cpu_addr =3D cpu_to_be16(env->external_call_addr); + env->pending_int &=3D ~INTERRUPT_EXTERNAL_CALL; } else if (env->pending_int | INTERRUPT_EXT_FLOATING) { g_assert(env->ext_index >=3D 0); /* diff --git a/target/s390x/internal.h b/target/s390x/internal.h index ae4b27a574..15743ec40f 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -350,6 +350,8 @@ void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32= _t param, uint64_t param64); void cpu_inject_clock_comparator(S390CPU *cpu); void cpu_inject_cpu_timer(S390CPU *cpu); +void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr); +int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr); =20 =20 /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 4ba33c49cb..462316be8e 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -91,6 +91,32 @@ void cpu_inject_cpu_timer(S390CPU *cpu) cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 +void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr) +{ + CPUS390XState *env =3D &cpu->env; + + g_assert(src_cpu_addr < S390_MAX_CPUS); + set_bit(src_cpu_addr, env->emergency_signals); + + env->pending_int |=3D INTERRUPT_EMERGENCY_SIGNAL; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); +} + +int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr) +{ + CPUS390XState *env =3D &cpu->env; + + g_assert(src_cpu_addr < S390_MAX_CPUS); + if (env->pending_int & INTERRUPT_EXTERNAL_CALL) { + return -EBUSY; + } + env->external_call_addr =3D src_cpu_addr; + + env->pending_int |=3D INTERRUPT_EXTERNAL_CALL; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); + return 0; +} + static void cpu_inject_io(S390CPU *cpu, uint16_t subchannel_id, uint16_t subchannel_number, uint32_t io_int_parm, uint32_t io_int_word) --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751144823521.9367410956472; Mon, 18 Sep 2017 09:12:24 -0700 (PDT) Received: from localhost ([::1]:37627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyel-000812-PW for importer@patchew.org; Mon, 18 Sep 2017 12:12:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTw-0006yU-QY for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTt-0007rd-2T for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43622) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTs-0007rE-TC for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D16DA3B752; Mon, 18 Sep 2017 16:01:07 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id A35505D6A8; Mon, 18 Sep 2017 16:01:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D16DA3B752 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:52 +0200 Message-Id: <20170918160012.4317-8-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 18 Sep 2017 16:01:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 07/27] s390x/tcg: STOPPED cpus can never wake up 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Interrupts can't wake such CPUs up. SIGP from other CPUs has to be used to toggle the state. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index f42e28ea25..64db086702 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -58,6 +58,12 @@ static bool s390_cpu_has_work(CPUState *cs) S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; =20 + /* STOPPED cpus can never wake up */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_LOAD && + s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { + return false; + } + return (cs->interrupt_request & CPU_INTERRUPT_HARD) && (env->psw.mask & PSW_MASK_EXT); } --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751048003508.6342601285122; Mon, 18 Sep 2017 09:10:48 -0700 (PDT) Received: from localhost ([::1]:37622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtydD-0006d1-31 for importer@patchew.org; Mon, 18 Sep 2017 12:10:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyTz-00072L-Oc for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTw-0007u5-2L for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTv-0007t5-Sn for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C62427E9EB; Mon, 18 Sep 2017 16:01:10 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D3BC5D6A9; Mon, 18 Sep 2017 16:01:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C62427E9EB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:53 +0200 Message-Id: <20170918160012.4317-9-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 18 Sep 2017 16:01:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 08/27] s390x/tcg: a CPU cannot switch state due to an interrupt 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Going to OPERATING here looks wrong. A CPU should even never be !OPERATING at this point. Unhalting will already be done in cpu_handle_halt() if there is work, so we can drop this statement completely. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/excp_helper.c | 1 - 1 file changed, 1 deletion(-) diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index ff257ba72e..4dc30e056a 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -432,7 +432,6 @@ void s390_cpu_do_interrupt(CPUState *cs) qemu_log_mask(CPU_LOG_INT, "%s: %d at pc=3D%" PRIx64 "\n", __func__, cs->exception_index, env->psw.addr); =20 - s390_cpu_set_state(CPU_STATE_OPERATING, cpu); /* handle machine checks */ if ((env->psw.mask & PSW_MASK_MCHECK) && (cs->exception_index =3D=3D -1)) { --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751299603763.9960106802807; Mon, 18 Sep 2017 09:14:59 -0700 (PDT) Received: from localhost ([::1]:37637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyhG-0001uF-Er for importer@patchew.org; Mon, 18 Sep 2017 12:14:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyU4-00078U-Ic for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyTy-0007vd-Ti for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48112) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyTy-0007vR-Mj for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A577B7E442; Mon, 18 Sep 2017 16:01:13 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 219305D760; Mon, 18 Sep 2017 16:01:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A577B7E442 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:54 +0200 Message-Id: <20170918160012.4317-10-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 18 Sep 2017 16:01:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 09/27] target/s390x: factor out handling of WAIT PSW into handle_wait() 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This will now also detect crashes under TCG. We can directly use cpu->env.psw.addr instead of kvm_run, as we do a cpu_synchronize_state(). Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/helper.c | 28 ++++++++++++++++++++++------ target/s390x/internal.h | 1 + target/s390x/kvm.c | 15 +-------------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index e22b93258b..75ceb0bf2b 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -26,6 +26,7 @@ #include "qemu/timer.h" #include "exec/exec-all.h" #include "hw/s390x/ioinst.h" +#include "sysemu/hw_accel.h" #ifndef CONFIG_USER_ONLY #include "sysemu/sysemu.h" #endif @@ -113,6 +114,26 @@ hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vadd= r vaddr) return phys_addr; } =20 +static inline bool is_special_wait_psw(uint64_t psw_addr) +{ + /* signal quiesce */ + return psw_addr =3D=3D 0xfffUL; +} + +void handle_wait(S390CPU *cpu) +{ + cpu_synchronize_state(CPU(cpu)); + if (s390_cpu_halt(cpu) =3D=3D 0) { +#ifndef CONFIG_USER_ONLY + if (is_special_wait_psw(cpu->env.psw.addr)) { + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } else { + qemu_system_guest_panicked(NULL); + } +#endif + } +} + void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr) { uint64_t old_mask =3D env->psw.mask; @@ -128,12 +149,7 @@ void load_psw(CPUS390XState *env, uint64_t mask, uint6= 4_t addr) } =20 if (mask & PSW_MASK_WAIT) { - S390CPU *cpu =3D s390_env_get_cpu(env); - if (s390_cpu_halt(cpu) =3D=3D 0) { -#ifndef CONFIG_USER_ONLY - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); -#endif - } + handle_wait(s390_env_get_cpu(env)); } } =20 diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 15743ec40f..cb331f35ea 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -280,6 +280,7 @@ const char *cc_name(enum cc_op cc_op); void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr); uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_= t dst, uint64_t vr); +void handle_wait(S390CPU *cpu); =20 =20 /* cpu.c */ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 3f9983154f..14f864697d 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1936,12 +1936,6 @@ static int handle_instruction(S390CPU *cpu, struct k= vm_run *run) return r; } =20 -static bool is_special_wait_psw(CPUState *cs) -{ - /* signal quiesce */ - return cs->kvm_run->psw_addr =3D=3D 0xfffUL; -} - static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswo= ffset) { CPUState *cs =3D CPU(cpu); @@ -2012,14 +2006,7 @@ static int handle_intercept(S390CPU *cpu) break; case ICPT_WAITPSW: /* disabled wait, since enabled wait is handled in kernel */ - cpu_synchronize_state(cs); - if (s390_cpu_halt(cpu) =3D=3D 0) { - if (is_special_wait_psw(cs)) { - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUT= DOWN); - } else { - qemu_system_guest_panicked(NULL); - } - } + handle_wait(cpu); r =3D EXCP_HALTED; break; case ICPT_CPU_STOP: --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751204008596.2504423674344; Mon, 18 Sep 2017 09:13:24 -0700 (PDT) Received: from localhost ([::1]:37630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyfj-0000TT-8y for importer@patchew.org; Mon, 18 Sep 2017 12:13:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyU6-00079u-11 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyU2-0007xB-1k for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyU1-0007wk-Si for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CAA747F413; Mon, 18 Sep 2017 16:01:16 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02A325D6A8; Mon, 18 Sep 2017 16:01:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CAA747F413 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:55 +0200 Message-Id: <20170918160012.4317-11-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Sep 2017 16:01:17 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 10/27] s390x/kvm: pass ipb directly into handle_sigp() 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No need to pass kvm_run. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth --- target/s390x/kvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 14f864697d..da3f7e9895 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1852,7 +1852,7 @@ static int sigp_set_architecture(S390CPU *cpu, uint32= _t param, return SIGP_CC_STATUS_STORED; } =20 -static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) +static int handle_sigp(S390CPU *cpu, uint32_t ipb, uint8_t ipa1) { CPUS390XState *env =3D &cpu->env; const uint8_t r1 =3D ipa1 >> 4; @@ -1866,7 +1866,7 @@ static int handle_sigp(S390CPU *cpu, struct kvm_run *= run, uint8_t ipa1) cpu_synchronize_state(CPU(cpu)); =20 /* get order code */ - order =3D decode_basedisp_rs(env, run->s390_sieic.ipb, NULL) + order =3D decode_basedisp_rs(env, ipb, NULL) & SIGP_ORDER_MASK; status_reg =3D &env->regs[r1]; param =3D (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; @@ -1924,7 +1924,7 @@ static int handle_instruction(S390CPU *cpu, struct kv= m_run *run) r =3D handle_diag(cpu, run, run->s390_sieic.ipb); break; case IPA0_SIGP: - r =3D handle_sigp(cpu, run, ipa1); + r =3D handle_sigp(cpu, run->s390_sieic.ipb, ipa1); break; } =20 --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751152854690.6723487539019; Mon, 18 Sep 2017 09:12:32 -0700 (PDT) Received: from localhost ([::1]:37629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyeu-00089y-17 for importer@patchew.org; Mon, 18 Sep 2017 12:12:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUB-0007FH-No for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyU5-0007zp-GK for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyU5-0007zZ-7D for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3222F3DBC2; Mon, 18 Sep 2017 16:01:20 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2748A5D6A8; Mon, 18 Sep 2017 16:01:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3222F3DBC2 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:56 +0200 Message-Id: <20170918160012.4317-12-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 18 Sep 2017 16:01:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 11/27] s390x/kvm: generalize SIGP stop and restart interrupt injection 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Preparation for factoring it out into !kvm code. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/internal.h | 2 ++ target/s390x/interrupt.c | 20 ++++++++++++++++++++ target/s390x/kvm-stub.c | 8 ++++++++ target/s390x/kvm.c | 33 +++++++++++++++++++++------------ target/s390x/kvm_s390x.h | 2 ++ 5 files changed, 53 insertions(+), 12 deletions(-) diff --git a/target/s390x/internal.h b/target/s390x/internal.h index cb331f35ea..8fdeb867e1 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -353,6 +353,8 @@ void cpu_inject_clock_comparator(S390CPU *cpu); void cpu_inject_cpu_timer(S390CPU *cpu); void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr); int cpu_inject_external_call(S390CPU *cpu, uint16_t src_cpu_addr); +void cpu_inject_restart(S390CPU *cpu); +void cpu_inject_stop(S390CPU *cpu); =20 =20 /* ioinst.c */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 462316be8e..b1dc28c8dd 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -117,6 +117,26 @@ int cpu_inject_external_call(S390CPU *cpu, uint16_t sr= c_cpu_addr) return 0; } =20 +void cpu_inject_restart(S390CPU *cpu) +{ + if (kvm_enabled()) { + kvm_s390_restart_interrupt(cpu); + return; + } + /* FIXME TCG */ + g_assert_not_reached(); +} + +void cpu_inject_stop(S390CPU *cpu) +{ + if (kvm_enabled()) { + kvm_s390_stop_interrupt(cpu); + return; + } + /* FIXME TCG */ + g_assert_not_reached(); +} + static void cpu_inject_io(S390CPU *cpu, uint16_t subchannel_id, uint16_t subchannel_number, uint32_t io_int_parm, uint32_t io_int_word) diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index 261e1cdc44..18b53b2ad6 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -109,3 +109,11 @@ int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_= t *hw_limit) void kvm_s390_crypto_reset(void) { } + +void kvm_s390_stop_interrupt(S390CPU *cpu) +{ +} + +void kvm_s390_restart_interrupt(S390CPU *cpu) +{ +} diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index da3f7e9895..66a56db175 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1500,9 +1500,6 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data a= rg) { S390CPU *cpu =3D S390_CPU(cs); SigpInfo *si =3D arg.host_ptr; - struct kvm_s390_irq irq =3D { - .type =3D KVM_S390_SIGP_STOP, - }; =20 if (s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -1515,7 +1512,7 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data a= rg) } else { /* execute the stop function */ cpu->env.sigp_order =3D SIGP_STOP; - kvm_s390_vcpu_interrupt(cpu, &irq); + cpu_inject_stop(cpu); } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } @@ -1592,9 +1589,6 @@ static void sigp_stop_and_store_status(CPUState *cs, = run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); SigpInfo *si =3D arg.host_ptr; - struct kvm_s390_irq irq =3D { - .type =3D KVM_S390_SIGP_STOP, - }; =20 /* disabled wait - sleeping in user space */ if (s390_cpu_get_state(cpu) =3D=3D CPU_STATE_OPERATING && cs->halted) { @@ -1604,7 +1598,7 @@ static void sigp_stop_and_store_status(CPUState *cs, = run_on_cpu_data arg) switch (s390_cpu_get_state(cpu)) { case CPU_STATE_OPERATING: cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; - kvm_s390_vcpu_interrupt(cpu, &irq); + cpu_inject_stop(cpu); /* store will be performed when handling the stop intercept */ break; case CPU_STATE_STOPPED: @@ -1694,9 +1688,6 @@ static void sigp_restart(CPUState *cs, run_on_cpu_dat= a arg) { S390CPU *cpu =3D S390_CPU(cs); SigpInfo *si =3D arg.host_ptr; - struct kvm_s390_irq irq =3D { - .type =3D KVM_S390_RESTART, - }; =20 switch (s390_cpu_get_state(cpu)) { case CPU_STATE_STOPPED: @@ -1706,7 +1697,7 @@ static void sigp_restart(CPUState *cs, run_on_cpu_dat= a arg) s390_cpu_set_state(CPU_STATE_OPERATING, cpu); break; case CPU_STATE_OPERATING: - kvm_s390_vcpu_interrupt(cpu, &irq); + cpu_inject_restart(cpu); break; } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -2756,3 +2747,21 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mo= del, Error **errp) kvm_s390_enable_cmma(); } } + +void kvm_s390_restart_interrupt(S390CPU *cpu) +{ + struct kvm_s390_irq irq =3D { + .type =3D KVM_S390_RESTART, + }; + + kvm_s390_vcpu_interrupt(cpu, &irq); +} + +void kvm_s390_stop_interrupt(S390CPU *cpu) +{ + struct kvm_s390_irq irq =3D { + .type =3D KVM_S390_SIGP_STOP, + }; + + kvm_s390_vcpu_interrupt(cpu, &irq); +} diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index 2d594bd4ee..fd03cd662a 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -40,6 +40,8 @@ void kvm_s390_cmma_reset(void); void kvm_s390_reset_vcpu(S390CPU *cpu); int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit); void kvm_s390_crypto_reset(void); +void kvm_s390_restart_interrupt(S390CPU *cpu); +void kvm_s390_stop_interrupt(S390CPU *cpu); =20 /* implemented outside of target/s390x/ */ int kvm_s390_inject_flic(struct kvm_s390_irq *irq); --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 150575146112016.157071458833116; Mon, 18 Sep 2017 09:17:41 -0700 (PDT) Received: from localhost ([::1]:37653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyjs-0004Kp-25 for importer@patchew.org; Mon, 18 Sep 2017 12:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUF-0007IC-1T for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyU9-00081H-48 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3239) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyU8-00080y-SV for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A44132D0FBE; Mon, 18 Sep 2017 16:01:23 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8320A5D6A8; Mon, 18 Sep 2017 16:01:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A44132D0FBE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:57 +0200 Message-Id: <20170918160012.4317-13-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Sep 2017 16:01:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 12/27] s390x/kvm: factor out storing of CPU status 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Factor it out into s390_store_status(), to be used also by TCG later on. Signed-off-by: David Hildenbrand --- target/s390x/helper.c | 38 ++++++++++++++++++++++++++++++++++++++ target/s390x/internal.h | 2 ++ target/s390x/kvm.c | 47 +++------------------------------------------= -- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 75ceb0bf2b..09468f85fa 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -245,6 +245,44 @@ void s390_cpu_recompute_watchpoints(CPUState *cs) } } =20 +#define SAVE_AREA_SIZE 512 +int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch) +{ + static const uint8_t ar_id =3D 1; + uint64_t ckc =3D cpu->env.ckc >> 8; + void *mem; + int i; + hwaddr len =3D SAVE_AREA_SIZE; + + mem =3D cpu_physical_memory_map(addr, &len, 1); + if (!mem) { + return -EFAULT; + } + if (len !=3D SAVE_AREA_SIZE) { + cpu_physical_memory_unmap(mem, len, 1, 0); + return -EFAULT; + } + + if (store_arch) { + cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id,= 1); + } + for (i =3D 0; i < 16; ++i) { + *((uint64_t *)mem + i) =3D get_freg(&cpu->env, i)->ll; + } + memcpy(mem + 128, &cpu->env.regs, 128); + memcpy(mem + 256, &cpu->env.psw, 16); + memcpy(mem + 280, &cpu->env.psa, 4); + memcpy(mem + 284, &cpu->env.fpc, 4); + memcpy(mem + 292, &cpu->env.todpr, 4); + memcpy(mem + 296, &cpu->env.cputm, 8); + memcpy(mem + 304, &ckc, 8); + memcpy(mem + 320, &cpu->env.aregs, 64); + memcpy(mem + 384, &cpu->env.cregs, 128); + + cpu_physical_memory_unmap(mem, len, 1, len); + + return 0; +} #endif /* CONFIG_USER_ONLY */ =20 void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 8fdeb867e1..30bcd7b662 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -339,6 +339,8 @@ void s390_cpu_recompute_watchpoints(CPUState *cs); void s390x_tod_timer(void *opaque); void s390x_cpu_timer(void *opaque); void do_restart_interrupt(CPUS390XState *env); +#define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area) +int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch); #ifndef CONFIG_USER_ONLY LowCore *cpu_map_lowcore(CPUS390XState *env); void cpu_unmap_lowcore(LowCore *lowcore); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 66a56db175..a6bc27eb28 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1545,46 +1545,6 @@ static int do_store_adtl_status(S390CPU *cpu, hwaddr= addr, hwaddr len) return 0; } =20 -#define KVM_S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_= area) -#define SAVE_AREA_SIZE 512 -static int kvm_s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arc= h) -{ - static const uint8_t ar_id =3D 1; - uint64_t ckc =3D cpu->env.ckc >> 8; - void *mem; - int i; - hwaddr len =3D SAVE_AREA_SIZE; - - mem =3D cpu_physical_memory_map(addr, &len, 1); - if (!mem) { - return -EFAULT; - } - if (len !=3D SAVE_AREA_SIZE) { - cpu_physical_memory_unmap(mem, len, 1, 0); - return -EFAULT; - } - - if (store_arch) { - cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id,= 1); - } - for (i =3D 0; i < 16; ++i) { - *((uint64_t *)mem + i) =3D get_freg(&cpu->env, i)->ll; - } - memcpy(mem + 128, &cpu->env.regs, 128); - memcpy(mem + 256, &cpu->env.psw, 16); - memcpy(mem + 280, &cpu->env.psa, 4); - memcpy(mem + 284, &cpu->env.fpc, 4); - memcpy(mem + 292, &cpu->env.todpr, 4); - memcpy(mem + 296, &cpu->env.cputm, 8); - memcpy(mem + 304, &ckc, 8); - memcpy(mem + 320, &cpu->env.aregs, 64); - memcpy(mem + 384, &cpu->env.cregs, 128); - - cpu_physical_memory_unmap(mem, len, 1, len); - - return 0; -} - static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -1604,7 +1564,7 @@ static void sigp_stop_and_store_status(CPUState *cs, = run_on_cpu_data arg) case CPU_STATE_STOPPED: /* already stopped, just store the status */ cpu_synchronize_state(cs); - kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, true); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); break; } si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; @@ -1624,7 +1584,7 @@ static void sigp_store_status_at_address(CPUState *cs= , run_on_cpu_data arg) =20 cpu_synchronize_state(cs); =20 - if (kvm_s390_store_status(cpu, address, false)) { + if (s390_store_status(cpu, address, false)) { set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); return; } @@ -2005,8 +1965,7 @@ static int handle_intercept(S390CPU *cpu) qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN= ); } if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { - kvm_s390_store_status(cpu, KVM_S390_STORE_STATUS_DEF_ADDR, - true); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); } cpu->env.sigp_order =3D 0; r =3D EXCP_HALTED; --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505750810198244.56216869081356; Mon, 18 Sep 2017 09:06:50 -0700 (PDT) Received: from localhost ([::1]:37605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyZN-000374-9L for importer@patchew.org; Mon, 18 Sep 2017 12:06:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUL-0007Mp-Jt for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUG-00084L-2K for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55370) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUF-000841-TA for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF4A12D0FAC; Mon, 18 Sep 2017 16:01:30 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01EA35D6A8; Mon, 18 Sep 2017 16:01:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF4A12D0FAC Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:58 +0200 Message-Id: <20170918160012.4317-14-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Sep 2017 16:01:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 13/27] target/s390x: proper cpu->be convertion in s390_store_status() 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Necessary so TCG can also use it. Signed-off-by: David Hildenbrand --- target/s390x/helper.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 09468f85fa..e44d54b932 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -267,17 +267,24 @@ int s390_store_status(S390CPU *cpu, hwaddr addr, bool= store_arch) cpu_physical_memory_write(offsetof(LowCore, ar_access_id), &ar_id,= 1); } for (i =3D 0; i < 16; ++i) { - *((uint64_t *)mem + i) =3D get_freg(&cpu->env, i)->ll; + *((uint64_t *)mem + i) =3D cpu_to_be64(get_freg(&cpu->env, i)->ll); + } + for (i =3D 0; i < 16; ++i) { + *((uint64_t *)(mem + 128) + i) =3D cpu_to_be64(cpu->env.regs[i]); + } + *((uint64_t *)(mem + 256)) =3D cpu_to_be64(get_psw_mask(&cpu->env)); + *((uint64_t *)(mem + 264)) =3D cpu_to_be64(cpu->env.psw.addr); + *((uint32_t *)(mem + 280)) =3D cpu_to_be32(cpu->env.psa); + *((uint32_t *)(mem + 284)) =3D cpu_to_be32(cpu->env.fpc); + *((uint32_t *)(mem + 292)) =3D cpu_to_be32(cpu->env.todpr); + *((uint64_t *)(mem + 296)) =3D cpu_to_be64(cpu->env.cputm); + *((uint64_t *)(mem + 304)) =3D cpu_to_be64(ckc); + for (i =3D 0; i < 16; ++i) { + *((uint32_t *)(mem + 320) + i) =3D cpu_to_be32(cpu->env.aregs[i]); + } + for (i =3D 0; i < 16; ++i) { + *((uint64_t *)(mem + 384) + i) =3D cpu_to_be64(cpu->env.cregs[i]); } - memcpy(mem + 128, &cpu->env.regs, 128); - memcpy(mem + 256, &cpu->env.psw, 16); - memcpy(mem + 280, &cpu->env.psa, 4); - memcpy(mem + 284, &cpu->env.fpc, 4); - memcpy(mem + 292, &cpu->env.todpr, 4); - memcpy(mem + 296, &cpu->env.cputm, 8); - memcpy(mem + 304, &ckc, 8); - memcpy(mem + 320, &cpu->env.aregs, 64); - memcpy(mem + 384, &cpu->env.cregs, 128); =20 cpu_physical_memory_unmap(mem, len, 1, len); =20 --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751356950195.99934564445414; Mon, 18 Sep 2017 09:15:56 -0700 (PDT) Received: from localhost ([::1]:37645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyiC-0002p4-5S for importer@patchew.org; Mon, 18 Sep 2017 12:15:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUJ-0007LV-Ta for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUI-00085r-SV for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35826) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUI-00085L-Kx for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C3FEC070E2D; Mon, 18 Sep 2017 16:01:33 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2970C5D6A8; Mon, 18 Sep 2017 16:01:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8C3FEC070E2D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:59:59 +0200 Message-Id: <20170918160012.4317-15-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Sep 2017 16:01:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 14/27] s390x/kvm: factor out storing of adtl CPU status 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Called from SIGP code to be factored out, so let's move it. Add a FIXME for TCG code in the future. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/helper.c | 29 +++++++++++++++++++++++++++++ target/s390x/internal.h | 1 + target/s390x/kvm.c | 30 +----------------------------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index e44d54b932..4d5a92c2ca 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -290,6 +290,35 @@ int s390_store_status(S390CPU *cpu, hwaddr addr, bool = store_arch) =20 return 0; } + +#define ADTL_GS_OFFSET 1024 /* offset of GS data in adtl save area */ +#define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ +int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) +{ + hwaddr save =3D len; + void *mem; + + mem =3D cpu_physical_memory_map(addr, &save, 1); + if (!mem) { + return -EFAULT; + } + if (save !=3D len) { + cpu_physical_memory_unmap(mem, len, 1, 0); + return -EFAULT; + } + + /* FIXME: as soon as TCG supports these features, convert cpu->be */ + if (s390_has_feat(S390_FEAT_VECTOR)) { + memcpy(mem, &cpu->env.vregs, 512); + } + if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >=3D ADTL_GS_MIN_S= IZE) { + memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); + } + + cpu_physical_memory_unmap(mem, len, 1, len); + + return 0; +} #endif /* CONFIG_USER_ONLY */ =20 void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 30bcd7b662..1d86f48990 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -341,6 +341,7 @@ void s390x_cpu_timer(void *opaque); void do_restart_interrupt(CPUS390XState *env); #define S390_STORE_STATUS_DEF_ADDR offsetof(LowCore, floating_pt_save_area) int s390_store_status(S390CPU *cpu, hwaddr addr, bool store_arch); +int s390_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len); #ifndef CONFIG_USER_ONLY LowCore *cpu_map_lowcore(CPUS390XState *env); void cpu_unmap_lowcore(LowCore *lowcore); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index a6bc27eb28..01c4125d21 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1517,34 +1517,6 @@ static void sigp_stop(CPUState *cs, run_on_cpu_data = arg) si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } =20 -#define ADTL_GS_OFFSET 1024 /* offset of GS data in adtl save area */ -#define ADTL_GS_MIN_SIZE 2048 /* minimal size of adtl save area for GS */ -static int do_store_adtl_status(S390CPU *cpu, hwaddr addr, hwaddr len) -{ - hwaddr save =3D len; - void *mem; - - mem =3D cpu_physical_memory_map(addr, &save, 1); - if (!mem) { - return -EFAULT; - } - if (save !=3D len) { - cpu_physical_memory_unmap(mem, len, 1, 0); - return -EFAULT; - } - - if (s390_has_feat(S390_FEAT_VECTOR)) { - memcpy(mem, &cpu->env.vregs, 512); - } - if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && len >=3D ADTL_GS_MIN_S= IZE) { - memcpy(mem + ADTL_GS_OFFSET, &cpu->env.gscb, 32); - } - - cpu_physical_memory_unmap(mem, len, 1, len); - - return 0; -} - static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -1637,7 +1609,7 @@ static void sigp_store_adtl_status(CPUState *cs, run_= on_cpu_data arg) =20 cpu_synchronize_state(cs); =20 - if (do_store_adtl_status(cpu, addr, len)) { + if (s390_store_adtl_status(cpu, addr, len)) { set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); return; } --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751308393172.6974170015376; Mon, 18 Sep 2017 09:15:08 -0700 (PDT) Received: from localhost ([::1]:37639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyhP-000216-GW for importer@patchew.org; Mon, 18 Sep 2017 12:15:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUM-0007Nl-MW for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUL-00088U-UO for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUL-00087J-Nj for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FD9B7DD00; Mon, 18 Sep 2017 16:01:36 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE86E5D6A8; Mon, 18 Sep 2017 16:01:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FD9B7DD00 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:00 +0200 Message-Id: <20170918160012.4317-16-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 18 Sep 2017 16:01:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 15/27] s390x/kvm: drop two debug prints 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Preparation for moving it out of kvm.c. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth --- target/s390x/kvm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 01c4125d21..d759edf1c8 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1640,7 +1640,6 @@ int kvm_s390_cpu_restart(S390CPU *cpu) SigpInfo si =3D {}; =20 run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); - DPRINTF("DONE: KVM cpu restart: %p\n", &cpu->env); return 0; } =20 @@ -1742,7 +1741,6 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, u= int8_t order, run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); break; default: - DPRINTF("KVM: unknown SIGP: 0x%x\n", order); set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); } =20 --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 15057509876571018.6225378657476; Mon, 18 Sep 2017 09:09:47 -0700 (PDT) Received: from localhost ([::1]:37614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtycE-0005ih-Jw for importer@patchew.org; Mon, 18 Sep 2017 12:09:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUW-0007Xu-Sg for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUP-00089n-27 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUO-00089X-Mp for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E3CB7EAA6; Mon, 18 Sep 2017 16:01:39 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0CBF5D6A8; Mon, 18 Sep 2017 16:01:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9E3CB7EAA6 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:01 +0200 Message-Id: <20170918160012.4317-17-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 18 Sep 2017 16:01:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 16/27] s390x/kvm: factor out SIGP code into sigp.c 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We want to use the same code base for TCG, so let's cleanly factor it out. The sigp mutex is currently not really needed, as everything is protected by the iothread mutex. But this could change later, so leave it in place and initialize it properly from common code. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- hw/s390x/s390-virtio-ccw.c | 3 + target/s390x/Makefile.objs | 1 + target/s390x/cpu.c | 8 - target/s390x/cpu.h | 6 +- target/s390x/internal.h | 4 + target/s390x/kvm-stub.c | 5 - target/s390x/kvm.c | 349 +----------------------------------------- target/s390x/kvm_s390x.h | 1 - target/s390x/sigp.c | 366 +++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/trace-events | 4 +- 10 files changed, 388 insertions(+), 359 deletions(-) create mode 100644 target/s390x/sigp.c diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index a57d435cbf..49c1ab29ed 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -280,6 +280,9 @@ static void ccw_init(MachineState *machine) /* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus(machine); =20 + /* init the SIGP facility */ + s390_init_sigp(); + s390_flic_init(); =20 /* get a BUS */ diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs index 9615256d81..5f8a96b1a6 100644 --- a/target/s390x/Makefile.objs +++ b/target/s390x/Makefile.objs @@ -2,6 +2,7 @@ obj-y +=3D cpu.o cpu_models.o cpu_features.o gdbstub.o inte= rrupt.o helper.o obj-$(CONFIG_TCG) +=3D translate.o cc_helper.o excp_helper.o fpu_helper.o obj-$(CONFIG_TCG) +=3D int_helper.o mem_helper.o misc_helper.o obj-$(CONFIG_SOFTMMU) +=3D machine.o ioinst.o arch_dump.o mmu_helper.o dia= g.o +obj-$(CONFIG_SOFTMMU) +=3D sigp.o obj-$(CONFIG_KVM) +=3D kvm.o obj-$(call lnot,$(CONFIG_KVM)) +=3D kvm-stub.o =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 64db086702..9a01f591b6 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -386,14 +386,6 @@ void s390_cmma_reset(void) } } =20 -int s390_cpu_restart(S390CPU *cpu) -{ - if (kvm_enabled()) { - return kvm_s390_cpu_restart(cpu); - } - return -ENOSYS; -} - int s390_get_memslot_count(void) { if (kvm_enabled()) { diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 857af21d06..5d03802c7d 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -680,7 +680,6 @@ bool s390_get_squash_mcss(void); int s390_get_memslot_count(void); int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit); void s390_cmma_reset(void); -int s390_cpu_restart(S390CPU *cpu); void s390_enable_css_support(S390CPU *cpu); int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id, int vq, bool assign); @@ -732,6 +731,11 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, ui= nt8_t ar, void *hostbuf, s390_cpu_virt_mem_rw(cpu, laddr, ar, NULL, len, true) =20 =20 +/* sigp.c */ +int s390_cpu_restart(S390CPU *cpu); +void s390_init_sigp(void); + + /* outside of target/s390x/ */ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); =20 diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 1d86f48990..99413beeae 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -397,4 +397,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, u= int64_t r3); /* translate.c */ void s390x_translate_init(void); =20 + +/* sigp.c */ +int handle_sigp(CPUS390XState *env, uint8_t order, uint64_t r1, uint64_t r= 3); + #endif /* S390X_INTERNAL_H */ diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index 18b53b2ad6..861b4dedf6 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -83,11 +83,6 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notif= ier, uint32_t sch, return -ENOSYS; } =20 -int kvm_s390_cpu_restart(S390CPU *cpu) -{ - return -ENOSYS; -} - void kvm_s390_cmma_reset(void) { } diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index d759edf1c8..142b63eef0 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -135,8 +135,6 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[= ] =3D { KVM_CAP_LAST_INFO }; =20 -static QemuMutex qemu_sigp_mutex; - static int cap_sync_regs; static int cap_async_pf; static int cap_mem_op; @@ -314,8 +312,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s) /* Try to enable AIS facility */ kvm_vm_enable_cap(s, KVM_CAP_S390_AIS, 0); =20 - qemu_mutex_init(&qemu_sigp_mutex); - return 0; } =20 @@ -1469,355 +1465,22 @@ static int handle_diag(S390CPU *cpu, struct kvm_ru= n *run, uint32_t ipb) return r; } =20 -typedef struct SigpInfo { - uint64_t param; - int cc; - uint64_t *status_reg; -} SigpInfo; - -static void set_sigp_status(SigpInfo *si, uint64_t status) -{ - *si->status_reg &=3D 0xffffffff00000000ULL; - *si->status_reg |=3D status; - si->cc =3D SIGP_CC_STATUS_STORED; -} - -static void sigp_start(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; - return; - } - - s390_cpu_set_state(CPU_STATE_OPERATING, cpu); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_stop(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; - return; - } - - /* disabled wait - sleeping in user space */ - if (cs->halted) { - s390_cpu_set_state(CPU_STATE_STOPPED, cpu); - } else { - /* execute the stop function */ - cpu->env.sigp_order =3D SIGP_STOP; - cpu_inject_stop(cpu); - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - /* disabled wait - sleeping in user space */ - if (s390_cpu_get_state(cpu) =3D=3D CPU_STATE_OPERATING && cs->halted) { - s390_cpu_set_state(CPU_STATE_STOPPED, cpu); - } - - switch (s390_cpu_get_state(cpu)) { - case CPU_STATE_OPERATING: - cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; - cpu_inject_stop(cpu); - /* store will be performed when handling the stop intercept */ - break; - case CPU_STATE_STOPPED: - /* already stopped, just store the status */ - cpu_synchronize_state(cs); - s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); - break; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_store_status_at_address(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - uint32_t address =3D si->param & 0x7ffffe00u; - - /* cpu has to be stopped */ - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); - return; - } - - cpu_synchronize_state(cs); - - if (s390_store_status(cpu, address, false)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -#define ADTL_SAVE_LC_MASK 0xfUL -static void sigp_store_adtl_status(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - uint8_t lc =3D si->param & ADTL_SAVE_LC_MASK; - hwaddr addr =3D si->param & ~ADTL_SAVE_LC_MASK; - hwaddr len =3D 1UL << (lc ? lc : 10); - - if (!s390_has_feat(S390_FEAT_VECTOR) && - !s390_has_feat(S390_FEAT_GUARDED_STORAGE)) { - set_sigp_status(si, SIGP_STAT_INVALID_ORDER); - return; - } - - /* cpu has to be stopped */ - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); - return; - } - - /* address must be aligned to length */ - if (addr & (len - 1)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - /* no GS: only lc =3D=3D 0 is valid */ - if (!s390_has_feat(S390_FEAT_GUARDED_STORAGE) && - lc !=3D 0) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - /* GS: 0, 10, 11, 12 are valid */ - if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && - lc !=3D 0 && - lc !=3D 10 && - lc !=3D 11 && - lc !=3D 12) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - cpu_synchronize_state(cs); - - if (s390_store_adtl_status(cpu, addr, len)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_restart(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - - switch (s390_cpu_get_state(cpu)) { - case CPU_STATE_STOPPED: - /* the restart irq has to be delivered prior to any other pending = irq */ - cpu_synchronize_state(cs); - do_restart_interrupt(&cpu->env); - s390_cpu_set_state(CPU_STATE_OPERATING, cpu); - break; - case CPU_STATE_OPERATING: - cpu_inject_restart(cpu); - break; - } - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -int kvm_s390_cpu_restart(S390CPU *cpu) -{ - SigpInfo si =3D {}; - - run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); - return 0; -} - -static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); - SigpInfo *si =3D arg.host_ptr; - - cpu_synchronize_state(cs); - scc->initial_cpu_reset(cs); - cpu_synchronize_post_reset(cs); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); - SigpInfo *si =3D arg.host_ptr; - - cpu_synchronize_state(cs); - scc->cpu_reset(cs); - cpu_synchronize_post_reset(cs); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) -{ - S390CPU *cpu =3D S390_CPU(cs); - SigpInfo *si =3D arg.host_ptr; - uint32_t addr =3D si->param & 0x7fffe000u; - - cpu_synchronize_state(cs); - - if (!address_space_access_valid(&address_space_memory, addr, - sizeof(struct LowCore), false)) { - set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); - return; - } - - /* cpu has to be stopped */ - if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { - set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); - return; - } - - cpu->env.psa =3D addr; - cpu_synchronize_post_init(cs); - si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; -} - -static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, - uint64_t param, uint64_t *status_reg) -{ - SigpInfo si =3D { - .param =3D param, - .status_reg =3D status_reg, - }; - - /* cpu available? */ - if (dst_cpu =3D=3D NULL) { - return SIGP_CC_NOT_OPERATIONAL; - } - - /* only resets can break pending orders */ - if (dst_cpu->env.sigp_order !=3D 0 && - order !=3D SIGP_CPU_RESET && - order !=3D SIGP_INITIAL_CPU_RESET) { - return SIGP_CC_BUSY; - } - - switch (order) { - case SIGP_START: - run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); - break; - case SIGP_STOP: - run_on_cpu(CPU(dst_cpu), sigp_stop, RUN_ON_CPU_HOST_PTR(&si)); - break; - case SIGP_RESTART: - run_on_cpu(CPU(dst_cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); - break; - case SIGP_STOP_STORE_STATUS: - run_on_cpu(CPU(dst_cpu), sigp_stop_and_store_status, RUN_ON_CPU_HO= ST_PTR(&si)); - break; - case SIGP_STORE_STATUS_ADDR: - run_on_cpu(CPU(dst_cpu), sigp_store_status_at_address, RUN_ON_CPU_= HOST_PTR(&si)); - break; - case SIGP_STORE_ADTL_STATUS: - run_on_cpu(CPU(dst_cpu), sigp_store_adtl_status, RUN_ON_CPU_HOST_P= TR(&si)); - break; - case SIGP_SET_PREFIX: - run_on_cpu(CPU(dst_cpu), sigp_set_prefix, RUN_ON_CPU_HOST_PTR(&si)= ); - break; - case SIGP_INITIAL_CPU_RESET: - run_on_cpu(CPU(dst_cpu), sigp_initial_cpu_reset, RUN_ON_CPU_HOST_P= TR(&si)); - break; - case SIGP_CPU_RESET: - run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); - break; - default: - set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); - } - - return si.cc; -} - -static int sigp_set_architecture(S390CPU *cpu, uint32_t param, - uint64_t *status_reg) -{ - CPUState *cur_cs; - S390CPU *cur_cpu; - bool all_stopped =3D true; - - CPU_FOREACH(cur_cs) { - cur_cpu =3D S390_CPU(cur_cs); - - if (cur_cpu =3D=3D cpu) { - continue; - } - if (s390_cpu_get_state(cur_cpu) !=3D CPU_STATE_STOPPED) { - all_stopped =3D false; - } - } - - *status_reg &=3D 0xffffffff00000000ULL; - - /* Reject set arch order, with czam we're always in z/Arch mode. */ - *status_reg |=3D (all_stopped ? SIGP_STAT_INVALID_PARAMETER : - SIGP_STAT_INCORRECT_STATE); - return SIGP_CC_STATUS_STORED; -} - -static int handle_sigp(S390CPU *cpu, uint32_t ipb, uint8_t ipa1) +static int kvm_s390_handle_sigp(S390CPU *cpu, uint32_t ipb, uint8_t ipa1) { CPUS390XState *env =3D &cpu->env; const uint8_t r1 =3D ipa1 >> 4; const uint8_t r3 =3D ipa1 & 0x0f; int ret; uint8_t order; - uint64_t *status_reg; - uint64_t param; - S390CPU *dst_cpu =3D NULL; =20 cpu_synchronize_state(CPU(cpu)); =20 /* get order code */ - order =3D decode_basedisp_rs(env, ipb, NULL) - & SIGP_ORDER_MASK; - status_reg =3D &env->regs[r1]; - param =3D (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; + order =3D decode_basedisp_rs(env, ipb, NULL) & SIGP_ORDER_MASK; =20 - if (qemu_mutex_trylock(&qemu_sigp_mutex)) { - ret =3D SIGP_CC_BUSY; - goto out; - } - - switch (order) { - case SIGP_SET_ARCH: - ret =3D sigp_set_architecture(cpu, param, status_reg); - break; - default: - /* all other sigp orders target a single vcpu */ - dst_cpu =3D s390_cpu_addr2state(env->regs[r3]); - ret =3D handle_sigp_single_dst(dst_cpu, order, param, status_reg); - } - qemu_mutex_unlock(&qemu_sigp_mutex); - -out: - trace_kvm_sigp_finished(order, CPU(cpu)->cpu_index, - dst_cpu ? CPU(dst_cpu)->cpu_index : -1, ret); - - if (ret >=3D 0) { - setcc(cpu, ret); - return 0; - } - - return ret; + ret =3D handle_sigp(env, order, r1, r3); + setcc(cpu, ret); + return 0; } =20 static int handle_instruction(S390CPU *cpu, struct kvm_run *run) @@ -1845,7 +1508,7 @@ static int handle_instruction(S390CPU *cpu, struct kv= m_run *run) r =3D handle_diag(cpu, run, run->s390_sieic.ipb); break; case IPA0_SIGP: - r =3D handle_sigp(cpu, run->s390_sieic.ipb, ipa1); + r =3D kvm_s390_handle_sigp(cpu, run->s390_sieic.ipb, ipa1); break; } =20 diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index fd03cd662a..33906a893b 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -33,7 +33,6 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_c= lock); void kvm_s390_enable_css_support(S390CPU *cpu); int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, int vq, bool assign); -int kvm_s390_cpu_restart(S390CPU *cpu); int kvm_s390_get_memslot_count(void); int kvm_s390_cmma_active(void); void kvm_s390_cmma_reset(void); diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c new file mode 100644 index 0000000000..4813123aad --- /dev/null +++ b/target/s390x/sigp.c @@ -0,0 +1,366 @@ +/* + * s390x SIGP instruction handling + * + * Copyright (c) 2009 Alexander Graf + * Copyright IBM Corp. 2012 + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "cpu.h" +#include "internal.h" +#include "sysemu/hw_accel.h" +#include "exec/address-spaces.h" +#include "sysemu/sysemu.h" +#include "trace.h" + +QemuMutex qemu_sigp_mutex; + +typedef struct SigpInfo { + uint64_t param; + int cc; + uint64_t *status_reg; +} SigpInfo; + +static void set_sigp_status(SigpInfo *si, uint64_t status) +{ + *si->status_reg &=3D 0xffffffff00000000ULL; + *si->status_reg |=3D status; + si->cc =3D SIGP_CC_STATUS_STORED; +} + +static void sigp_start(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + return; + } + + s390_cpu_set_state(CPU_STATE_OPERATING, cpu); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_stop(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_OPERATING) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + return; + } + + /* disabled wait - sleeping in user space */ + if (cs->halted) { + s390_cpu_set_state(CPU_STATE_STOPPED, cpu); + } else { + /* execute the stop function */ + cpu->env.sigp_order =3D SIGP_STOP; + cpu_inject_stop(cpu); + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + /* disabled wait - sleeping in user space */ + if (s390_cpu_get_state(cpu) =3D=3D CPU_STATE_OPERATING && cs->halted) { + s390_cpu_set_state(CPU_STATE_STOPPED, cpu); + } + + switch (s390_cpu_get_state(cpu)) { + case CPU_STATE_OPERATING: + cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; + cpu_inject_stop(cpu); + /* store will be performed when handling the stop intercept */ + break; + case CPU_STATE_STOPPED: + /* already stopped, just store the status */ + cpu_synchronize_state(cs); + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); + break; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_store_status_at_address(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + uint32_t address =3D si->param & 0x7ffffe00u; + + /* cpu has to be stopped */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + return; + } + + cpu_synchronize_state(cs); + + if (s390_store_status(cpu, address, false)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +#define ADTL_SAVE_LC_MASK 0xfUL +static void sigp_store_adtl_status(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + uint8_t lc =3D si->param & ADTL_SAVE_LC_MASK; + hwaddr addr =3D si->param & ~ADTL_SAVE_LC_MASK; + hwaddr len =3D 1UL << (lc ? lc : 10); + + if (!s390_has_feat(S390_FEAT_VECTOR) && + !s390_has_feat(S390_FEAT_GUARDED_STORAGE)) { + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* cpu has to be stopped */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + return; + } + + /* address must be aligned to length */ + if (addr & (len - 1)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + /* no GS: only lc =3D=3D 0 is valid */ + if (!s390_has_feat(S390_FEAT_GUARDED_STORAGE) && + lc !=3D 0) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + /* GS: 0, 10, 11, 12 are valid */ + if (s390_has_feat(S390_FEAT_GUARDED_STORAGE) && + lc !=3D 0 && + lc !=3D 10 && + lc !=3D 11 && + lc !=3D 12) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + cpu_synchronize_state(cs); + + if (s390_store_adtl_status(cpu, addr, len)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_restart(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + + switch (s390_cpu_get_state(cpu)) { + case CPU_STATE_STOPPED: + /* the restart irq has to be delivered prior to any other pending = irq */ + cpu_synchronize_state(cs); + do_restart_interrupt(&cpu->env); + s390_cpu_set_state(CPU_STATE_OPERATING, cpu); + break; + case CPU_STATE_OPERATING: + cpu_inject_restart(cpu); + break; + } + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_initial_cpu_reset(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); + SigpInfo *si =3D arg.host_ptr; + + cpu_synchronize_state(cs); + scc->initial_cpu_reset(cs); + cpu_synchronize_post_reset(cs); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_cpu_reset(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); + SigpInfo *si =3D arg.host_ptr; + + cpu_synchronize_state(cs); + scc->cpu_reset(cs); + cpu_synchronize_post_reset(cs); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static void sigp_set_prefix(CPUState *cs, run_on_cpu_data arg) +{ + S390CPU *cpu =3D S390_CPU(cs); + SigpInfo *si =3D arg.host_ptr; + uint32_t addr =3D si->param & 0x7fffe000u; + + cpu_synchronize_state(cs); + + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(struct LowCore), false)) { + set_sigp_status(si, SIGP_STAT_INVALID_PARAMETER); + return; + } + + /* cpu has to be stopped */ + if (s390_cpu_get_state(cpu) !=3D CPU_STATE_STOPPED) { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + return; + } + + cpu->env.psa =3D addr; + cpu_synchronize_post_init(cs); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + +static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, + uint64_t param, uint64_t *status_reg) +{ + SigpInfo si =3D { + .param =3D param, + .status_reg =3D status_reg, + }; + + /* cpu available? */ + if (dst_cpu =3D=3D NULL) { + return SIGP_CC_NOT_OPERATIONAL; + } + + /* only resets can break pending orders */ + if (dst_cpu->env.sigp_order !=3D 0 && + order !=3D SIGP_CPU_RESET && + order !=3D SIGP_INITIAL_CPU_RESET) { + return SIGP_CC_BUSY; + } + + switch (order) { + case SIGP_START: + run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); + break; + case SIGP_STOP: + run_on_cpu(CPU(dst_cpu), sigp_stop, RUN_ON_CPU_HOST_PTR(&si)); + break; + case SIGP_RESTART: + run_on_cpu(CPU(dst_cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); + break; + case SIGP_STOP_STORE_STATUS: + run_on_cpu(CPU(dst_cpu), sigp_stop_and_store_status, RUN_ON_CPU_HO= ST_PTR(&si)); + break; + case SIGP_STORE_STATUS_ADDR: + run_on_cpu(CPU(dst_cpu), sigp_store_status_at_address, RUN_ON_CPU_= HOST_PTR(&si)); + break; + case SIGP_STORE_ADTL_STATUS: + run_on_cpu(CPU(dst_cpu), sigp_store_adtl_status, RUN_ON_CPU_HOST_P= TR(&si)); + break; + case SIGP_SET_PREFIX: + run_on_cpu(CPU(dst_cpu), sigp_set_prefix, RUN_ON_CPU_HOST_PTR(&si)= ); + break; + case SIGP_INITIAL_CPU_RESET: + run_on_cpu(CPU(dst_cpu), sigp_initial_cpu_reset, RUN_ON_CPU_HOST_P= TR(&si)); + break; + case SIGP_CPU_RESET: + run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); + break; + default: + set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); + } + + return si.cc; +} + +static int sigp_set_architecture(S390CPU *cpu, uint32_t param, + uint64_t *status_reg) +{ + CPUState *cur_cs; + S390CPU *cur_cpu; + bool all_stopped =3D true; + + CPU_FOREACH(cur_cs) { + cur_cpu =3D S390_CPU(cur_cs); + + if (cur_cpu =3D=3D cpu) { + continue; + } + if (s390_cpu_get_state(cur_cpu) !=3D CPU_STATE_STOPPED) { + all_stopped =3D false; + } + } + + *status_reg &=3D 0xffffffff00000000ULL; + + /* Reject set arch order, with czam we're always in z/Arch mode. */ + *status_reg |=3D (all_stopped ? SIGP_STAT_INVALID_PARAMETER : + SIGP_STAT_INCORRECT_STATE); + return SIGP_CC_STATUS_STORED; +} + +int handle_sigp(CPUS390XState *env, uint8_t order, uint64_t r1, uint64_t r= 3) +{ + uint64_t *status_reg =3D &env->regs[r1]; + uint64_t param =3D (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1]; + S390CPU *cpu =3D s390_env_get_cpu(env); + S390CPU *dst_cpu =3D NULL; + int ret; + + if (qemu_mutex_trylock(&qemu_sigp_mutex)) { + ret =3D SIGP_CC_BUSY; + goto out; + } + + switch (order) { + case SIGP_SET_ARCH: + ret =3D sigp_set_architecture(cpu, param, status_reg); + break; + default: + /* all other sigp orders target a single vcpu */ + dst_cpu =3D s390_cpu_addr2state(env->regs[r3]); + ret =3D handle_sigp_single_dst(dst_cpu, order, param, status_reg); + } + qemu_mutex_unlock(&qemu_sigp_mutex); + +out: + trace_sigp_finished(order, CPU(cpu)->cpu_index, + dst_cpu ? CPU(dst_cpu)->cpu_index : -1, ret); + g_assert(ret >=3D 0); + + return ret; +} + +int s390_cpu_restart(S390CPU *cpu) +{ + SigpInfo si =3D {}; + + if (tcg_enabled()) { + /* FIXME TCG */ + return -ENOSYS; + } + + run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); + return 0; +} + +void s390_init_sigp(void) +{ + qemu_mutex_init(&qemu_sigp_mutex); +} diff --git a/target/s390x/trace-events b/target/s390x/trace-events index 4d871f5087..a84e316e49 100644 --- a/target/s390x/trace-events +++ b/target/s390x/trace-events @@ -14,9 +14,11 @@ ioinst_chsc_cmd(uint16_t cmd, uint16_t len) "IOINST: chs= c command 0x%04x, len 0x kvm_enable_cmma(int rc) "CMMA: enabling with result code %d" kvm_clear_cmma(int rc) "CMMA: clearing with result code %d" kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) "W= arning: Unable to set cpu %d state %" PRIu8 " to KVM: %s" -kvm_sigp_finished(uint8_t order, int cpu_index, int dst_index, int cc) "SI= GP: Finished order %u on cpu %d -> cpu %d with cc=3D%d" =20 # target/s390x/cpu.c cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d state to %" PR= Iu8 cpu_halt(int cpu_index) "halting cpu %d" cpu_unhalt(int cpu_index) "unhalting cpu %d" + +# target/s390x/sigp.c +sigp_finished(uint8_t order, int cpu_index, int dst_index, int cc) "SIGP: = Finished order %u on cpu %d -> cpu %d with cc=3D%d" --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751522123177.12600951743082; Mon, 18 Sep 2017 09:18:42 -0700 (PDT) Received: from localhost ([::1]:37657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtykr-0005HS-Cd for importer@patchew.org; Mon, 18 Sep 2017 12:18:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUT-0007UV-0U for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUR-0008BI-Lg for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUR-0008Ay-EV for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6A16CC0828A6; Mon, 18 Sep 2017 16:01:42 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE0B35D6A8; Mon, 18 Sep 2017 16:01:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6A16CC0828A6 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:02 +0200 Message-Id: <20170918160012.4317-18-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Sep 2017 16:01:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 17/27] s390x/kvm: factor out actual handling of STOP interrupts 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For KVM, the KVM module decides when a STOP can be performed (when the STOP interrupt can be processed). Factor it out so we can use it later for TCG. Signed-off-by: David Hildenbrand --- target/s390x/internal.h | 1 + target/s390x/kvm.c | 8 +------- target/s390x/sigp.c | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 99413beeae..2e738de6af 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -400,5 +400,6 @@ void s390x_translate_init(void); =20 /* sigp.c */ int handle_sigp(CPUS390XState *env, uint8_t order, uint64_t r1, uint64_t r= 3); +void do_stop_interrupt(CPUS390XState *env); =20 #endif /* S390X_INTERNAL_H */ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 142b63eef0..eb8b297a88 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1594,13 +1594,7 @@ static int handle_intercept(S390CPU *cpu) r =3D EXCP_HALTED; break; case ICPT_CPU_STOP: - if (s390_cpu_set_state(CPU_STATE_STOPPED, cpu) =3D=3D 0) { - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN= ); - } - if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { - s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); - } - cpu->env.sigp_order =3D 0; + do_stop_interrupt(&cpu->env); r =3D EXCP_HALTED; break; case ICPT_OPEREXC: diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 4813123aad..9587c3d319 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -81,7 +81,7 @@ static void sigp_stop_and_store_status(CPUState *cs, run_= on_cpu_data arg) case CPU_STATE_OPERATING: cpu->env.sigp_order =3D SIGP_STOP_STORE_STATUS; cpu_inject_stop(cpu); - /* store will be performed when handling the stop intercept */ + /* store will be performed in do_stop_interrup() */ break; case CPU_STATE_STOPPED: /* already stopped, just store the status */ @@ -360,6 +360,19 @@ int s390_cpu_restart(S390CPU *cpu) return 0; } =20 +void do_stop_interrupt(CPUS390XState *env) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + + if (s390_cpu_set_state(CPU_STATE_STOPPED, cpu) =3D=3D 0) { + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } + if (cpu->env.sigp_order =3D=3D SIGP_STOP_STORE_STATUS) { + s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); + } + env->sigp_order =3D 0; +} + void s390_init_sigp(void) { qemu_mutex_init(&qemu_sigp_mutex); --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751644762339.54011405446965; Mon, 18 Sep 2017 09:20:44 -0700 (PDT) Received: from localhost ([::1]:37670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtymp-0007JZ-Ek for importer@patchew.org; Mon, 18 Sep 2017 12:20:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUc-0007bJ-Dw for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUW-0008ET-QC for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46182) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUW-0008Dx-HE for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7192A3E2B1; Mon, 18 Sep 2017 16:01:47 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAA0E5D6A9; Mon, 18 Sep 2017 16:01:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7192A3E2B1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:03 +0200 Message-Id: <20170918160012.4317-19-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 18 Sep 2017 16:01:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 18/27] s390x/tcg: implement SIGP SENSE RUNNING STATUS 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Preparation for TCG, for KVM is this is completely handled in the kernel. Signed-off-by: David Hildenbrand --- target/s390x/cpu.h | 2 ++ target/s390x/sigp.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 5d03802c7d..5aa755d7b5 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -594,6 +594,7 @@ struct sysib_322 { #define SIGP_SET_PREFIX 0x0d #define SIGP_STORE_STATUS_ADDR 0x0e #define SIGP_SET_ARCH 0x12 +#define SIGP_SENSE_RUNNING 0x15 #define SIGP_STORE_ADTL_STATUS 0x17 =20 /* SIGP condition codes */ @@ -604,6 +605,7 @@ struct sysib_322 { =20 /* SIGP status bits */ #define SIGP_STAT_EQUIPMENT_CHECK 0x80000000UL +#define SIGP_STAT_NOT_RUNNING 0x00000400UL #define SIGP_STAT_INCORRECT_STATE 0x00000200UL #define SIGP_STAT_INVALID_PARAMETER 0x00000100UL #define SIGP_STAT_EXT_CALL_PENDING 0x00000080UL diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 9587c3d319..c57312b743 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -234,6 +234,28 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_d= ata arg) si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } =20 +static void sigp_sense_running(S390CPU *dst_cpu, SigpInfo *si) +{ + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* sensing without locks is racy, but it's the same for real hw */ + if (!s390_has_feat(S390_FEAT_SENSE_RUNNING_STATUS)) { + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* If halted (which includes also STOPPED), it is not running */ + if (CPU(dst_cpu)->halted) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + } else { + set_sigp_status(si, SIGP_STAT_NOT_RUNNING); + } +} + static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, uint64_t param, uint64_t *status_reg) { @@ -282,6 +304,9 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, uin= t8_t order, case SIGP_CPU_RESET: run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); break; + case SIGP_SENSE_RUNNING: + sigp_sense_running(dst_cpu, &si); + break; default: set_sigp_status(&si, SIGP_STAT_INVALID_ORDER); } --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751466993775.967288028266; Mon, 18 Sep 2017 09:17:46 -0700 (PDT) Received: from localhost ([::1]:37654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyjw-0004Qs-SC for importer@patchew.org; Mon, 18 Sep 2017 12:17:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUa-0007ZJ-BX for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUZ-0008F1-DX for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56744) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUZ-0008Eq-7E for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3574E2D0FD7; Mon, 18 Sep 2017 16:01:50 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2CFB5D6A8; Mon, 18 Sep 2017 16:01:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3574E2D0FD7 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:04 +0200 Message-Id: <20170918160012.4317-20-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Sep 2017 16:01:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 19/27] s390x/tcg: implement SIGP SENSE 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add it as preparation for TCG. Sensing coul later be done completely lockless. Signed-off-by: David Hildenbrand --- target/s390x/sigp.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index c57312b743..063a34ccc7 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -32,6 +32,32 @@ static void set_sigp_status(SigpInfo *si, uint64_t statu= s) si->cc =3D SIGP_CC_STATUS_STORED; } =20 +static void sigp_sense(S390CPU *dst_cpu, SigpInfo *si) +{ + uint8_t state =3D s390_cpu_get_state(dst_cpu); + bool ext_call =3D dst_cpu->env.pending_int & INTERRUPT_EXTERNAL_CALL; + uint64_t status =3D 0; + + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* sensing without locks is racy, but it's the same for real hw */ + if (state !=3D CPU_STATE_STOPPED && !ext_call) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + } else { + if (ext_call) { + status |=3D SIGP_STAT_EXT_CALL_PENDING; + } + if (state =3D=3D CPU_STATE_STOPPED) { + status |=3D SIGP_STAT_STOPPED; + } + set_sigp_status(si, status); + } +} + static void sigp_start(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -277,6 +303,9 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, uin= t8_t order, } =20 switch (order) { + case SIGP_SENSE: + sigp_sense(dst_cpu, &si); + break; case SIGP_START: run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); break; --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751687317959.5124362998474; Mon, 18 Sep 2017 09:21:27 -0700 (PDT) Received: from localhost ([::1]:37672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtynW-0007w4-KT for importer@patchew.org; Mon, 18 Sep 2017 12:21:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUd-0007c4-2i for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUc-0008Fo-3i for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12224) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUb-0008Fb-Tu for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFC513E2A5; Mon, 18 Sep 2017 16:01:52 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87F395D6A9; Mon, 18 Sep 2017 16:01:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DFC513E2A5 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:05 +0200 Message-Id: <20170918160012.4317-21-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 18 Sep 2017 16:01:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 20/27] s390x/tcg: implement SIGP EXTERNAL CALL 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As preparation for TCG. Signed-off-by: David Hildenbrand --- target/s390x/sigp.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 063a34ccc7..080bce3fba 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -58,6 +58,24 @@ static void sigp_sense(S390CPU *dst_cpu, SigpInfo *si) } } =20 +static void sigp_external_call(S390CPU *src_cpu, S390CPU *dst_cpu, SigpInf= o *si) +{ + int ret; + + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + ret =3D cpu_inject_external_call(dst_cpu, src_cpu->env.core_id); + if (!ret) { + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + } else { + set_sigp_status(si, SIGP_STAT_EXT_CALL_PENDING); + } +} + static void sigp_start(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -282,7 +300,7 @@ static void sigp_sense_running(S390CPU *dst_cpu, SigpIn= fo *si) } } =20 -static int handle_sigp_single_dst(S390CPU *dst_cpu, uint8_t order, +static int handle_sigp_single_dst(S390CPU *cpu, S390CPU *dst_cpu, uint8_t = order, uint64_t param, uint64_t *status_reg) { SigpInfo si =3D { @@ -306,6 +324,9 @@ static int handle_sigp_single_dst(S390CPU *dst_cpu, uin= t8_t order, case SIGP_SENSE: sigp_sense(dst_cpu, &si); break; + case SIGP_EXTERNAL_CALL: + sigp_external_call(cpu, dst_cpu, &si); + break; case SIGP_START: run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); break; @@ -389,7 +410,7 @@ int handle_sigp(CPUS390XState *env, uint8_t order, uint= 64_t r1, uint64_t r3) default: /* all other sigp orders target a single vcpu */ dst_cpu =3D s390_cpu_addr2state(env->regs[r3]); - ret =3D handle_sigp_single_dst(dst_cpu, order, param, status_reg); + ret =3D handle_sigp_single_dst(cpu, dst_cpu, order, param, status_= reg); } qemu_mutex_unlock(&qemu_sigp_mutex); =20 --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751151277518.9022928632987; Mon, 18 Sep 2017 09:12:31 -0700 (PDT) Received: from localhost ([::1]:37628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyes-00088B-HK for importer@patchew.org; Mon, 18 Sep 2017 12:12:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUh-0007gE-Ht for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUe-0008H3-Q3 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUe-0008Gn-KX for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95CDFC062EA3; Mon, 18 Sep 2017 16:01:55 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CC695D6A9; Mon, 18 Sep 2017 16:01:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 95CDFC062EA3 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:06 +0200 Message-Id: <20170918160012.4317-22-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 18 Sep 2017 16:01:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 21/27] s390x/tcg: implement SIGP EMERGENCY SIGNAL 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As preparation for TCG. Signed-off-by: David Hildenbrand --- target/s390x/sigp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 080bce3fba..d492885787 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -76,6 +76,18 @@ static void sigp_external_call(S390CPU *src_cpu, S390CPU= *dst_cpu, SigpInfo *si) } } =20 +static void sigp_emergency(S390CPU *src_cpu, S390CPU *dst_cpu, SigpInfo *s= i) +{ + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + cpu_inject_emergency_signal(dst_cpu, src_cpu->env.core_id); + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + static void sigp_start(CPUState *cs, run_on_cpu_data arg) { S390CPU *cpu =3D S390_CPU(cs); @@ -327,6 +339,9 @@ static int handle_sigp_single_dst(S390CPU *cpu, S390CPU= *dst_cpu, uint8_t order, case SIGP_EXTERNAL_CALL: sigp_external_call(cpu, dst_cpu, &si); break; + case SIGP_EMERGENCY: + sigp_emergency(cpu, dst_cpu, &si); + break; case SIGP_START: run_on_cpu(CPU(dst_cpu), sigp_start, RUN_ON_CPU_HOST_PTR(&si)); break; --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751303905358.26490891199535; Mon, 18 Sep 2017 09:15:03 -0700 (PDT) Received: from localhost ([::1]:37638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyhL-0001xd-4N for importer@patchew.org; Mon, 18 Sep 2017 12:15:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUk-0007j6-9k for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUh-0008I5-TR for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47880) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUh-0008Hm-Kg for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:01:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73AB77F3F3; Mon, 18 Sep 2017 16:01:58 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7C2E5D6A8; Mon, 18 Sep 2017 16:01:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73AB77F3F3 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:07 +0200 Message-Id: <20170918160012.4317-23-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Sep 2017 16:01:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 22/27] s390x/tcg: implement SIGP CONDITIONAL EMERGENCY SIGNAL 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Mostly analogous to the kernel/KVM version (so I assume the checks are correct :) ). As a preparation for TCG. Signed-off-by: David Hildenbrand --- target/s390x/cpu.h | 1 + target/s390x/sigp.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 5aa755d7b5..97d4abb6c0 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -594,6 +594,7 @@ struct sysib_322 { #define SIGP_SET_PREFIX 0x0d #define SIGP_STORE_STATUS_ADDR 0x0e #define SIGP_SET_ARCH 0x12 +#define SIGP_COND_EMERGENCY 0x13 #define SIGP_SENSE_RUNNING 0x15 #define SIGP_STORE_ADTL_STATUS 0x17 =20 diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index d492885787..ce8fda9d01 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -290,6 +290,40 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_d= ata arg) si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } =20 +static void sigp_cond_emergency(S390CPU *src_cpu, S390CPU *dst_cpu, + SigpInfo *si) +{ + const uint64_t psw_int_mask =3D PSW_MASK_IO | PSW_MASK_EXT; + uint16_t p_asn, s_asn, asn; + uint64_t psw_addr, psw_mask; + bool idle; + + if (!tcg_enabled()) { + /* handled in KVM */ + set_sigp_status(si, SIGP_STAT_INVALID_ORDER); + return; + } + + /* this looks racy, but these values are only used when STOPPED */ + idle =3D CPU(dst_cpu)->halted; + psw_addr =3D dst_cpu->env.psw.addr; + psw_mask =3D dst_cpu->env.psw.mask; + asn =3D si->param; + p_asn =3D dst_cpu->env.cregs[4] & 0xffff; /* Primary ASN */ + s_asn =3D dst_cpu->env.cregs[3] & 0xffff; /* Secondary ASN */ + + if (s390_cpu_get_state(dst_cpu) !=3D CPU_STATE_STOPPED || + (psw_mask & psw_int_mask) !=3D psw_int_mask || + (idle && psw_addr !=3D 0) || + (!idle && (asn =3D=3D p_asn || asn =3D=3D s_asn))) { + cpu_inject_emergency_signal(dst_cpu, src_cpu->env.core_id); + } else { + set_sigp_status(si, SIGP_STAT_INCORRECT_STATE); + } + + si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; +} + static void sigp_sense_running(S390CPU *dst_cpu, SigpInfo *si) { if (!tcg_enabled()) { @@ -369,6 +403,9 @@ static int handle_sigp_single_dst(S390CPU *cpu, S390CPU= *dst_cpu, uint8_t order, case SIGP_CPU_RESET: run_on_cpu(CPU(dst_cpu), sigp_cpu_reset, RUN_ON_CPU_HOST_PTR(&si)); break; + case SIGP_COND_EMERGENCY: + sigp_cond_emergency(cpu, dst_cpu, &si); + break; case SIGP_SENSE_RUNNING: sigp_sense_running(dst_cpu, &si); break; --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 15057518014091016.9182664388023; Mon, 18 Sep 2017 09:23:21 -0700 (PDT) Received: from localhost ([::1]:37687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtypM-0001An-AC for importer@patchew.org; Mon, 18 Sep 2017 12:23:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUq-0007os-AO for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUk-0008JR-ER for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUk-0008Iy-7B for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30F7AC05178E; Mon, 18 Sep 2017 16:02:01 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id C52B15D6A8; Mon, 18 Sep 2017 16:01:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 30F7AC05178E Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:08 +0200 Message-Id: <20170918160012.4317-24-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 18 Sep 2017 16:02:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 23/27] s390x/tcg: implement STOP and RESET interrupts for TCG 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Implement them like KVM implements/handles them. Both can only be triggered via SIGP instructions. RESET has (almos)the lowest priority if the CPU is running, and the highest if the CPU is STOPPED. This is handled in SIGP code already. On delivery, we only have to care about the "CPU running" scenario. STOP is defined to be delivered after all other interrupts have been delivered. Therefore it has the actual lowest priority. As both can wake up a CPU if sleeping, indicate them correctly to external code (e.g. cpu_has_work()). Signed-off-by: David Hildenbrand --- target/s390x/cpu.c | 4 +++- target/s390x/cpu.h | 4 ++++ target/s390x/excp_helper.c | 18 +++++++++++++++++- target/s390x/helper.c | 1 + target/s390x/interrupt.c | 14 ++++++++++---- target/s390x/sigp.c | 1 + 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 9a01f591b6..9d20434075 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -65,7 +65,9 @@ static bool s390_cpu_has_work(CPUState *cs) } =20 return (cs->interrupt_request & CPU_INTERRUPT_HARD) && - (env->psw.mask & PSW_MASK_EXT); + ((env->psw.mask & PSW_MASK_EXT) || + env->pending_int & INTERRUPT_STOP || + env->pending_int & INTERRUPT_RESTART); } =20 #if !defined(CONFIG_USER_ONLY) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 97d4abb6c0..fc1f622c52 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -399,6 +399,8 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* = env, target_ulong *pc, #define EXCP_EXT 1 /* external interrupt */ #define EXCP_SVC 2 /* supervisor call (syscall) */ #define EXCP_PGM 3 /* program interruption */ +#define EXCP_RESTART 4 /* restart interrupt */ +#define EXCP_STOP 5 /* stop interrupt */ #define EXCP_IO 7 /* I/O interrupt */ #define EXCP_MCHK 8 /* machine check */ =20 @@ -409,6 +411,8 @@ static inline void cpu_get_tb_cpu_state(CPUS390XState* = env, target_ulong *pc, #define INTERRUPT_EXT_CLOCK_COMPARATOR (1 << 4) #define INTERRUPT_EXTERNAL_CALL (1 << 5) #define INTERRUPT_EMERGENCY_SIGNAL (1 << 6) +#define INTERRUPT_RESTART (1 << 7) +#define INTERRUPT_STOP (1 << 8) #define INTERRUPT_EXT (INTERRUPT_EXT_FLOATING | \ INTERRUPT_EXT_CPU_TIMER | \ INTERRUPT_EXT_CLOCK_COMPARATOR |= \ diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 4dc30e056a..ce28708499 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -452,6 +452,14 @@ void s390_cpu_do_interrupt(CPUState *cs) cs->exception_index =3D EXCP_IO; } } + /* RESTART interrupt */ + if (cs->exception_index =3D=3D -1 && env->pending_int & INTERRUPT_REST= ART) { + cs->exception_index =3D EXCP_RESTART; + } + /* STOP interrupt has least priority */ + if (cs->exception_index =3D=3D -1 && env->pending_int & INTERRUPT_STOP= ) { + cs->exception_index =3D EXCP_STOP; + } =20 switch (cs->exception_index) { case EXCP_PGM: @@ -469,6 +477,12 @@ void s390_cpu_do_interrupt(CPUState *cs) case EXCP_MCHK: do_mchk_interrupt(env); break; + case EXCP_RESTART: + do_restart_interrupt(env); + break; + case EXCP_STOP: + do_stop_interrupt(env); + break; } cs->exception_index =3D -1; =20 @@ -488,7 +502,9 @@ bool s390_cpu_exec_interrupt(CPUState *cs, int interrup= t_request) the parent EXECUTE insn. */ return false; } - if (env->psw.mask & PSW_MASK_EXT) { + if (env->psw.mask & PSW_MASK_EXT || + env->pending_int & INTERRUPT_STOP || + env->pending_int & INTERRUPT_RESTART) { s390_cpu_do_interrupt(cs); return true; } diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 4d5a92c2ca..abda74d810 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -202,6 +202,7 @@ void do_restart_interrupt(CPUS390XState *env) addr =3D be64_to_cpu(lowcore->restart_new_psw.addr); =20 cpu_unmap_lowcore(lowcore); + env->pending_int &=3D ~INTERRUPT_RESTART; =20 load_psw(env, mask, addr); } diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index b1dc28c8dd..2f004ffe6d 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -119,22 +119,28 @@ int cpu_inject_external_call(S390CPU *cpu, uint16_t s= rc_cpu_addr) =20 void cpu_inject_restart(S390CPU *cpu) { + CPUS390XState *env =3D &cpu->env; + if (kvm_enabled()) { kvm_s390_restart_interrupt(cpu); return; } - /* FIXME TCG */ - g_assert_not_reached(); + + env->pending_int |=3D INTERRUPT_RESTART; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 void cpu_inject_stop(S390CPU *cpu) { + CPUS390XState *env =3D &cpu->env; + if (kvm_enabled()) { kvm_s390_stop_interrupt(cpu); return; } - /* FIXME TCG */ - g_assert_not_reached(); + + env->pending_int |=3D INTERRUPT_STOP; + cpu_interrupt(CPU(cpu), CPU_INTERRUPT_HARD); } =20 static void cpu_inject_io(S390CPU *cpu, uint16_t subchannel_id, diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index ce8fda9d01..521dcc75f3 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -498,6 +498,7 @@ void do_stop_interrupt(CPUS390XState *env) s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true); } env->sigp_order =3D 0; + env->pending_int &=3D ~INTERRUPT_STOP; } =20 void s390_init_sigp(void) --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751696114534.9932083788226; Mon, 18 Sep 2017 09:21:36 -0700 (PDT) Received: from localhost ([::1]:37674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtynf-00083v-AY for importer@patchew.org; Mon, 18 Sep 2017 12:21:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUu-0007s5-Jt for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUo-0008Kk-Tl for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43510) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUo-0008KV-O8 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8C01D713B; Mon, 18 Sep 2017 16:02:05 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F59A5D6A8; Mon, 18 Sep 2017 16:02:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A8C01D713B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:09 +0200 Message-Id: <20170918160012.4317-25-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 18 Sep 2017 16:02:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 24/27] s390x/tcg: flush the tlb on SIGP SET PREFIX 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Thanks to Aurelien Jarno for doing this in his prototype. We can flush the whole TLB as this should happen really rarely. Signed-off-by: David Hildenbrand --- target/s390x/sigp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index 521dcc75f3..c5a5dac911 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -14,6 +14,7 @@ #include "internal.h" #include "sysemu/hw_accel.h" #include "exec/address-spaces.h" +#include "exec/exec-all.h" #include "sysemu/sysemu.h" #include "trace.h" =20 @@ -286,6 +287,7 @@ static void sigp_set_prefix(CPUState *cs, run_on_cpu_da= ta arg) } =20 cpu->env.psa =3D addr; + tlb_flush(cs); cpu_synchronize_post_init(cs); si->cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; } --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751676176749.5133835348463; Mon, 18 Sep 2017 09:21:16 -0700 (PDT) Received: from localhost ([::1]:37671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtynL-0007lt-DU for importer@patchew.org; Mon, 18 Sep 2017 12:21:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyUz-0007wo-JZ for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUr-0008Li-OS for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUr-0008LP-Fk for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 726F43E2B6; Mon, 18 Sep 2017 16:02:08 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 053745D6A8; Mon, 18 Sep 2017 16:02:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 726F43E2B6 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:10 +0200 Message-Id: <20170918160012.4317-26-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 18 Sep 2017 16:02:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 25/27] s390x/tcg: switch to new SIGP handling code 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This effectively enables experimental SMP support. Floating interrupts are still a mess, so allow it but print a big warning. There also seems to be a problem with CPU hotplug (after the main loop started). Signed-off-by: David Hildenbrand --- hw/s390x/s390-virtio-ccw.c | 4 +--- target/s390x/helper.h | 2 +- target/s390x/misc_helper.c | 42 ++++++------------------------------------ target/s390x/translate.c | 5 +++-- 4 files changed, 11 insertions(+), 42 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 49c1ab29ed..732feb9cff 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -65,9 +65,7 @@ static void s390_init_cpus(MachineState *machine) machine->cpu_model =3D s390_default_cpu_model_name(); } if (tcg_enabled() && max_cpus > 1) { - error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " - "supported by TCG (1) on s390x", max_cpus); - exit(1); + error_report("WARNING: SMP support on s390x is experimental!"); } =20 /* initialize possible_cpus */ diff --git a/target/s390x/helper.h b/target/s390x/helper.h index 4b0290774e..a0e4bfb850 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -138,7 +138,7 @@ DEF_HELPER_FLAGS_3(sske, TCG_CALL_NO_RWG, void, env, i6= 4, i64) DEF_HELPER_FLAGS_2(rrbe, TCG_CALL_NO_RWG, i32, env, i64) DEF_HELPER_4(mvcs, i32, env, i64, i64, i64) DEF_HELPER_4(mvcp, i32, env, i64, i64, i64) -DEF_HELPER_4(sigp, i32, env, i64, i32, i64) +DEF_HELPER_4(sigp, i32, env, i64, i32, i32) DEF_HELPER_FLAGS_2(sacf, TCG_CALL_NO_WG, void, env, i64) DEF_HELPER_FLAGS_4(idte, TCG_CALL_NO_RWG, void, env, i64, i64, i32) DEF_HELPER_FLAGS_4(ipte, TCG_CALL_NO_RWG, void, env, i64, i64, i32) diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 293fc8428a..1e4d3c8526 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -319,44 +319,14 @@ uint32_t HELPER(stsi)(CPUS390XState *env, uint64_t a0, } =20 uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1, - uint64_t cpu_addr) + uint32_t r3) { - int cc =3D SIGP_CC_ORDER_CODE_ACCEPTED; + int cc; =20 - HELPER_LOG("%s: %016" PRIx64 " %08x %016" PRIx64 "\n", - __func__, order_code, r1, cpu_addr); - - /* Remember: Use "R1 or R1 + 1, whichever is the odd-numbered register" - as parameter (input). Status (output) is always R1. */ - - switch (order_code & SIGP_ORDER_MASK) { - case SIGP_SET_ARCH: - /* switch arch */ - break; - case SIGP_SENSE: - /* enumerate CPU status */ - if (cpu_addr) { - /* XXX implement when SMP comes */ - return 3; - } - env->regs[r1] &=3D 0xffffffff00000000ULL; - cc =3D 1; - break; -#if !defined(CONFIG_USER_ONLY) - case SIGP_RESTART: - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); - cpu_loop_exit(CPU(s390_env_get_cpu(env))); - break; - case SIGP_STOP: - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); - cpu_loop_exit(CPU(s390_env_get_cpu(env))); - break; -#endif - default: - /* unknown sigp */ - fprintf(stderr, "XXX unknown sigp: 0x%" PRIx64 "\n", order_code); - cc =3D SIGP_CC_NOT_OPERATIONAL; - } + /* TODO: needed to inject interrupts - push further down */ + qemu_mutex_lock_iothread(); + cc =3D handle_sigp(env, order_code & SIGP_ORDER_MASK, r1, r3); + qemu_mutex_unlock_iothread(); =20 return cc; } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 5abd34fb34..abf2feb7aa 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -3658,11 +3658,12 @@ static ExitStatus op_servc(DisasContext *s, DisasOp= s *o) static ExitStatus op_sigp(DisasContext *s, DisasOps *o) { TCGv_i32 r1 =3D tcg_const_i32(get_field(s->fields, r1)); + TCGv_i32 r3 =3D tcg_const_i32(get_field(s->fields, r3)); check_privileged(s); - potential_page_fault(s); - gen_helper_sigp(cc_op, cpu_env, o->in2, r1, o->in1); + gen_helper_sigp(cc_op, cpu_env, o->in2, r1, r3); set_cc_static(s); tcg_temp_free_i32(r1); + tcg_temp_free_i32(r3); return NO_EXIT; } #endif --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751926806576.7188395381922; Mon, 18 Sep 2017 09:25:26 -0700 (PDT) Received: from localhost ([::1]:37700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyrN-000370-UT for importer@patchew.org; Mon, 18 Sep 2017 12:25:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyV0-0007y0-6u for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUu-0008Mc-Dy for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUu-0008ML-8C for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 33068D714B; Mon, 18 Sep 2017 16:02:11 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2E845D6A8; Mon, 18 Sep 2017 16:02:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 33068D714B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:11 +0200 Message-Id: <20170918160012.4317-27-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 18 Sep 2017 16:02:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 26/27] s390x/tcg: unlock NMI 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Nothing hindering us anymore from unlocking the restart code (used for NMI). Signed-off-by: David Hildenbrand --- hw/s390x/s390-virtio-ccw.c | 4 +--- target/s390x/sigp.c | 5 ----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 732feb9cff..c5c989f673 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -418,9 +418,7 @@ static void s390_nmi(NMIState *n, int cpu_index, Error = **errp) { CPUState *cs =3D qemu_get_cpu(cpu_index); =20 - if (s390_cpu_restart(S390_CPU(cs))) { - error_setg(errp, QERR_UNSUPPORTED); - } + s390_cpu_restart(S390_CPU(cs)); } =20 static void ccw_machine_class_init(ObjectClass *oc, void *data) diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c index c5a5dac911..964c75a736 100644 --- a/target/s390x/sigp.c +++ b/target/s390x/sigp.c @@ -480,11 +480,6 @@ int s390_cpu_restart(S390CPU *cpu) { SigpInfo si =3D {}; =20 - if (tcg_enabled()) { - /* FIXME TCG */ - return -ENOSYS; - } - run_on_cpu(CPU(cpu), sigp_restart, RUN_ON_CPU_HOST_PTR(&si)); return 0; } --=20 2.13.5 From nobody Sun Apr 28 00:08:01 2024 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 1505751832883120.67402534487235; Mon, 18 Sep 2017 09:23:52 -0700 (PDT) Received: from localhost ([::1]:37693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtypr-0001b1-Ve for importer@patchew.org; Mon, 18 Sep 2017 12:23:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyV0-0007y6-8o for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyUx-0008Nj-LO for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8055) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyUx-0008NR-DV for qemu-devel@nongnu.org; Mon, 18 Sep 2017 12:02:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 637E7D7127; Mon, 18 Sep 2017 16:02:14 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 838A95D6A8; Mon, 18 Sep 2017 16:02:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 637E7D7127 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com From: David Hildenbrand To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 18:00:12 +0200 Message-Id: <20170918160012.4317-28-david@redhat.com> In-Reply-To: <20170918160012.4317-1-david@redhat.com> References: <20170918160012.4317-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 18 Sep 2017 16:02:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 27/27] s390x/tcg: refactor stfl(e) to use s390_get_feat_block() 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: Matthew Rosato , thuth@redhat.com, david@redhat.com, cohuck@redhat.com, Richard Henderson , Alexander Graf , borntraeger@de.ibm.com, Igor Mammedov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Refactor it to use s390_get_feat_block(). Directly write into the mapped lowcore with stfl and make sure it is really only compiled if needed. While at it, add an alignment check for STFLE and avoid potential_page_fault() by properly restoring the CPU state. Due to s390_get_feat_block(), we will now also indicate the "Configuration-z-architectural-mode", which is with new SIGP code the right thing to do. Signed-off-by: David Hildenbrand --- target/s390x/helper.h | 2 +- target/s390x/misc_helper.c | 72 ++++++++++++++++++++++--------------------= ---- target/s390x/translate.c | 1 - 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/target/s390x/helper.h b/target/s390x/helper.h index a0e4bfb850..a6d94d2d82 100644 --- a/target/s390x/helper.h +++ b/target/s390x/helper.h @@ -104,7 +104,6 @@ DEF_HELPER_FLAGS_5(calc_cc, TCG_CALL_NO_RWG_SE, i32, en= v, i32, i64, i64, i64) DEF_HELPER_FLAGS_2(sfpc, TCG_CALL_NO_RWG, void, env, i64) DEF_HELPER_FLAGS_2(sfas, TCG_CALL_NO_WG, void, env, i64) DEF_HELPER_FLAGS_1(popcnt, TCG_CALL_NO_RWG_SE, i64, i64) -DEF_HELPER_FLAGS_1(stfl, TCG_CALL_NO_RWG, void, env) DEF_HELPER_2(stfle, i32, env, i64) DEF_HELPER_FLAGS_2(lpq, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_4(stpq, TCG_CALL_NO_WG, void, env, i64, i64, i64) @@ -152,6 +151,7 @@ DEF_HELPER_FLAGS_3(sturg, TCG_CALL_NO_WG, void, env, i6= 4, i64) DEF_HELPER_1(per_check_exception, void, env) DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64) DEF_HELPER_FLAGS_2(per_ifetch, TCG_CALL_NO_RWG, void, env, i64) +DEF_HELPER_FLAGS_1(stfl, TCG_CALL_NO_RWG, void, env) =20 DEF_HELPER_2(xsch, void, env, i64) DEF_HELPER_2(csch, void, env, i64) diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 1e4d3c8526..4afd90b969 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -475,61 +475,57 @@ void HELPER(per_ifetch)(CPUS390XState *env, uint64_t = addr) } #endif =20 -/* The maximum bit defined at the moment is 129. */ -#define MAX_STFL_WORDS 3 +static uint8_t stfl_bytes[2048]; +static unsigned int used_stfl_bytes; =20 -/* Canonicalize the current cpu's features into the 64-bit words required - by STFLE. Return the index-1 of the max word that is non-zero. */ -static unsigned do_stfle(CPUS390XState *env, uint64_t words[MAX_STFL_WORDS= ]) +static void prepare_stfl(void) { - S390CPU *cpu =3D s390_env_get_cpu(env); - const unsigned long *features =3D cpu->model->features; - unsigned max_bit =3D 0; - S390Feat feat; - - memset(words, 0, sizeof(uint64_t) * MAX_STFL_WORDS); + static bool initialized; + int i; =20 - if (test_bit(S390_FEAT_ZARCH, features)) { - /* z/Architecture is always active if around */ - words[0] =3D 1ull << (63 - 2); + /* racy, but we don't care, the same values are always written */ + if (initialized) { + return; } =20 - for (feat =3D find_first_bit(features, S390_FEAT_MAX); - feat < S390_FEAT_MAX; - feat =3D find_next_bit(features, S390_FEAT_MAX, feat + 1)) { - const S390FeatDef *def =3D s390_feat_def(feat); - if (def->type =3D=3D S390_FEAT_TYPE_STFL) { - unsigned bit =3D def->bit; - if (bit > max_bit) { - max_bit =3D bit; - } - assert(bit / 64 < MAX_STFL_WORDS); - words[bit / 64] |=3D 1ULL << (63 - bit % 64); + s390_get_feat_block(S390_FEAT_TYPE_STFL, stfl_bytes); + for (i =3D 0; i < sizeof(stfl_bytes); i++) { + if (stfl_bytes[i]) { + used_stfl_bytes =3D i + 1; } } - - return max_bit / 64; + initialized =3D true; } =20 +#ifndef CONFIG_USER_ONLY void HELPER(stfl)(CPUS390XState *env) { - uint64_t words[MAX_STFL_WORDS]; + LowCore *lowcore; =20 - do_stfle(env, words); - cpu_stl_data(env, 200, words[0] >> 32); + lowcore =3D cpu_map_lowcore(env); + prepare_stfl(); + memcpy(&lowcore->stfl_fac_list, stfl_bytes, sizeof(lowcore->stfl_fac_l= ist)); + cpu_unmap_lowcore(lowcore); } +#endif =20 uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t addr) { - uint64_t words[MAX_STFL_WORDS]; - unsigned count_m1 =3D env->regs[0] & 0xff; - unsigned max_m1 =3D do_stfle(env, words); - unsigned i; + const uintptr_t ra =3D GETPC(); + const int count_bytes =3D ((env->regs[0] & 0xff) + 1) * 8; + const int max_bytes =3D ROUND_UP(used_stfl_bytes, 8); + int i; + + if (addr & 0x7) { + cpu_restore_state(ENV_GET_CPU(env), ra); + program_interrupt(env, PGM_SPECIFICATION, 4); + } =20 - for (i =3D 0; i <=3D count_m1; ++i) { - cpu_stq_data(env, addr + 8 * i, words[i]); + prepare_stfl(); + for (i =3D 0; i < count_bytes; ++i) { + cpu_stb_data_ra(env, addr + i, stfl_bytes[i], ra); } =20 - env->regs[0] =3D deposit64(env->regs[0], 0, 8, max_m1); - return (count_m1 >=3D max_m1 ? 0 : 3); + env->regs[0] =3D deposit64(env->regs[0], 0, 8, (max_bytes / 8) - 1); + return count_bytes >=3D max_bytes ? 0 : 3; } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index abf2feb7aa..0e05942fe9 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -4082,7 +4082,6 @@ static ExitStatus op_sturg(DisasContext *s, DisasOps = *o) =20 static ExitStatus op_stfle(DisasContext *s, DisasOps *o) { - potential_page_fault(s); gen_helper_stfle(cc_op, cpu_env, o->in2); set_cc_static(s); return NO_EXIT; --=20 2.13.5