From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500975806823660.5029036496263; Tue, 25 Jul 2017 02:43:26 -0700 (PDT) Received: from localhost ([::1]:59490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwN9-0003gS-BS for importer@patchew.org; Tue, 25 Jul 2017 05:43:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKT-0001gr-Vi for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKS-0003JD-PL for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35432) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKS-0003It-In for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12C81624A8; Tue, 25 Jul 2017 09:40:35 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DABEF5C2F3; Tue, 25 Jul 2017 09:40:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 12C81624A8 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:13 +0200 Message-Id: <20170725094026.5376-2-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 25 Jul 2017 09:40:35 +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] [PULL for-2.10 01/14] vfio/ccw: allocate irq info with the right size 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: thuth@redhat.com, Jing Zhang , david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, Dong Jia Shi , rth@twiddle.net 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" From: Jing Zhang When allocating memory for the vfio_irq_info parameter of the VFIO_DEVICE_GET_IRQ_INFO ioctl, we used the wrong size. Let's fix it by using the right size. Reviewed-by: Dong Jia Shi Signed-off-by: Jing Zhang Signed-off-by: Dong Jia Shi Message-Id: <20170718014926.44781-2-bjsdjshi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck --- hw/vfio/ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 12d0262336..8d97b53e77 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -168,7 +168,7 @@ static void vfio_ccw_register_io_notifier(VFIOCCWDevice= *vcdev, Error **errp) return; } =20 - argsz =3D sizeof(*irq_set); + argsz =3D sizeof(*irq_info); irq_info =3D g_malloc0(argsz); irq_info->index =3D VFIO_CCW_IO_IRQ_INDEX; irq_info->argsz =3D argsz; --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500975757175794.2723956688288; Tue, 25 Jul 2017 02:42:37 -0700 (PDT) Received: from localhost ([::1]:59488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwMK-0002ye-JG for importer@patchew.org; Tue, 25 Jul 2017 05:42:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKX-0001if-9Z for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKW-0003Ml-An for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47546) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKW-0003MN-4Y for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 130648553C; Tue, 25 Jul 2017 09:40:39 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC49F65E84; Tue, 25 Jul 2017 09:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 130648553C 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:14 +0200 Message-Id: <20170725094026.5376-3-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 25 Jul 2017 09:40: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] [PULL for-2.10 02/14] vfio/ccw: fix initialization of the Object DeviceState pointer in the common base-device 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, Alex Williamson , Dong Jia Shi , rth@twiddle.net 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" From: Dong Jia Shi Commit 7da624e2 ("vfio: Test realized when using VFIOGroup.device_list iterator") introduced a pointer to the Object DeviceState in the VFIO common base-device and skipped non-realized devices as we iterate VFIOGroup.device_list. While it missed to initialize the pointer for the vfio-ccw case. Let's fix it. Fixes: 7da624e2 ("vfio: Test realized when using VFIOGroup.device_list iterator") Cc: Alex Williamson Reviewed-by: Halil Pasic Signed-off-by: Dong Jia Shi Reviewed-by: Alex Williamson Message-Id: <20170718014926.44781-3-bjsdjshi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck --- hw/vfio/ccw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 8d97b53e77..a8baadf57a 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -338,6 +338,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) vcdev->vdev.type =3D VFIO_DEVICE_TYPE_CCW; vcdev->vdev.name =3D g_strdup_printf("%x.%x.%04x", cdev->hostid.cssid, cdev->hostid.ssid, cdev->hostid.dev= id); + vcdev->vdev.dev =3D dev; QLIST_FOREACH(vbasedev, &group->device_list, next) { if (strcmp(vbasedev->name, vcdev->vdev.name) =3D=3D 0) { error_setg(&err, "vfio: subchannel %s has already been attache= d", --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500975757348400.57419753945203; Tue, 25 Jul 2017 02:42:37 -0700 (PDT) Received: from localhost ([::1]:59489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwMO-00030O-1O for importer@patchew.org; Tue, 25 Jul 2017 05:42:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKd-0001m8-Fx for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKc-0003TA-KO for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKc-0003Re-Dq for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:46 -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 690B9285D0; Tue, 25 Jul 2017 09:40:45 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D70AD18430; Tue, 25 Jul 2017 09:40:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 690B9285D0 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:15 +0200 Message-Id: <20170725094026.5376-4-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@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]); Tue, 25 Jul 2017 09:40:45 +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] [PULL for-2.10 03/14] s390/cpumodel: remove KSS from the default model of z14 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: Christian Borntraeger The SIE_KSS feature will allow a guest to use KSS for a nested guest. To create a nested guest the SIE_F2 facility is still necessary. Since SIE_F2 is not part of the default model it does not make a lot of sense to provide the SIE_KSS feature in the default model. Let's also create a dependency check. Signed-off-by: Christian Borntraeger Reviewed-by: Jason J. Herne Reviewed-by: Janosch Frank Message-Id: <1500550051-7821-2-git-send-email-borntraeger@de.ibm.com> Acked-by: David Hildenbrand Signed-off-by: Cornelia Huck --- target/s390x/cpu_models.c | 1 + target/s390x/gen-features.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index f4e5bb6611..d91b7b85f6 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -723,6 +723,7 @@ static void check_consistency(const S390CPUModel *model) { S390_FEAT_KLMD_SHAKE_256, S390_FEAT_MSA }, { S390_FEAT_PRNO_TRNG_QRTCR, S390_FEAT_MSA_EXT_5 }, { S390_FEAT_PRNO_TRNG, S390_FEAT_MSA_EXT_5 }, + { S390_FEAT_SIE_KSS, S390_FEAT_SIE_F2 }, }; int i; =20 diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index cf69157610..c8dc104bc1 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -535,7 +535,6 @@ static uint16_t default_GEN14_GA1[] =3D { S390_FEAT_GROUP_MSA_EXT_6, S390_FEAT_GROUP_MSA_EXT_7, S390_FEAT_GROUP_MSA_EXT_8, - S390_FEAT_SIE_KSS, }; =20 /****** END FEATURE DEFS ******/ --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15009759405071009.8504977781491; Tue, 25 Jul 2017 02:45:40 -0700 (PDT) Received: from localhost ([::1]:59506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwPL-0005wa-5X for importer@patchew.org; Tue, 25 Jul 2017 05:45:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKf-0001oP-RR for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKe-0003XL-Tu for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKe-0003Vl-N3 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A9BD17F3E4; Tue, 25 Jul 2017 09:40:47 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 457D865E84; Tue, 25 Jul 2017 09:40:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A9BD17F3E4 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:16 +0200 Message-Id: <20170725094026.5376-5-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 25 Jul 2017 09:40: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] [PULL for-2.10 04/14] target/s390x: drop BE_BIT() 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: David Hildenbrand Unused and broken, let's just get rid of it. Acked-by: Christian Borntraeger Signed-off-by: David Hildenbrand Message-Id: <20170720123721.12366-2-david@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/cpu_features.h | 1 - 1 file changed, 1 deletion(-) diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h index 14bc311dbe..770435e0cc 100644 --- a/target/s390x/cpu_features.h +++ b/target/s390x/cpu_features.h @@ -92,6 +92,5 @@ typedef struct { const S390FeatGroupDef *s390_feat_group_def(S390FeatGroup group); =20 #define BE_BIT_NR(BIT) (BIT ^ (BITS_PER_LONG - 1)) -#define BE_BIT(BIT) (1ULL < BE_BIT_NR(BIT)) =20 #endif /* TARGET_S390X_CPU_FEATURES_H */ --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150097590395541.95742549457975; Tue, 25 Jul 2017 02:45:03 -0700 (PDT) Received: from localhost ([::1]:59499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwOj-0005Gt-FJ for importer@patchew.org; Tue, 25 Jul 2017 05:45:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKn-0001w1-Ac for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKj-0003bb-Bs for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49948) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKj-0003b9-1w for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1399FFB83; Tue, 25 Jul 2017 09:40:52 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BD7395A70; Tue, 25 Jul 2017 09:40:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1399FFB83 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:17 +0200 Message-Id: <20170725094026.5376-6-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 25 Jul 2017 09:40:52 +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] [PULL for-2.10 05/14] target/s390x: indicate query subfunction in s390_fill_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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: David Hildenbrand We'll have to do the same for TCG, so let's just move it in there. Reviewed-by: Christian Borntraeger Signed-off-by: David Hildenbrand Message-Id: <20170720123721.12366-3-david@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/cpu_features.c | 31 ++++++++++++++++++++++++++----- target/s390x/kvm.c | 13 ------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index fa887d9b6f..8b1491734f 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -336,11 +336,32 @@ void s390_fill_feat_block(const S390FeatBitmap featur= es, S390FeatType type, S390Feat feat; int bit_nr; =20 - if (type =3D=3D S390_FEAT_TYPE_STFL && test_bit(S390_FEAT_ZARCH, featu= res)) { - /* Features that are always active */ - data[0] |=3D 0x20; /* z/Architecture */ - data[17] |=3D 0x20; /* Configuration-z-architectural-mode */ - } + switch (type) { + case S390_FEAT_TYPE_STFL: + if (test_bit(S390_FEAT_ZARCH, features)) { + /* Features that are always active */ + data[0] |=3D 0x20; /* z/Architecture */ + data[17] |=3D 0x20; /* Configuration-z-architectural-mode */ + } + break; + case S390_FEAT_TYPE_PTFF: + case S390_FEAT_TYPE_KMAC: + case S390_FEAT_TYPE_KMC: + case S390_FEAT_TYPE_KM: + case S390_FEAT_TYPE_KIMD: + case S390_FEAT_TYPE_KLMD: + case S390_FEAT_TYPE_PCKMO: + case S390_FEAT_TYPE_KMCTR: + case S390_FEAT_TYPE_KMF: + case S390_FEAT_TYPE_KMO: + case S390_FEAT_TYPE_PCC: + case S390_FEAT_TYPE_PPNO: + case S390_FEAT_TYPE_KMA: + data[0] |=3D 0x80; /* query is always available */ + break; + default: + break; + }; =20 feat =3D find_first_bit(features, S390_FEAT_MAX); while (feat < S390_FEAT_MAX) { diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 831492f9a2..999ea570c3 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2506,41 +2506,28 @@ static int configure_cpu_subfunc(const S390FeatBitm= ap features) s390_fill_feat_block(features, S390_FEAT_TYPE_PLO, prop.plo); if (test_bit(S390_FEAT_TOD_CLOCK_STEERING, features)) { s390_fill_feat_block(features, S390_FEAT_TYPE_PTFF, prop.ptff); - prop.ptff[0] |=3D 0x80; /* query is always available */ } if (test_bit(S390_FEAT_MSA, features)) { s390_fill_feat_block(features, S390_FEAT_TYPE_KMAC, prop.kmac); - prop.kmac[0] |=3D 0x80; /* query is always available */ s390_fill_feat_block(features, S390_FEAT_TYPE_KMC, prop.kmc); - prop.kmc[0] |=3D 0x80; /* query is always available */ s390_fill_feat_block(features, S390_FEAT_TYPE_KM, prop.km); - prop.km[0] |=3D 0x80; /* query is always available */ s390_fill_feat_block(features, S390_FEAT_TYPE_KIMD, prop.kimd); - prop.kimd[0] |=3D 0x80; /* query is always available */ s390_fill_feat_block(features, S390_FEAT_TYPE_KLMD, prop.klmd); - prop.klmd[0] |=3D 0x80; /* query is always available */ } if (test_bit(S390_FEAT_MSA_EXT_3, features)) { s390_fill_feat_block(features, S390_FEAT_TYPE_PCKMO, prop.pckmo); - prop.pckmo[0] |=3D 0x80; /* query is always available */ } if (test_bit(S390_FEAT_MSA_EXT_4, features)) { s390_fill_feat_block(features, S390_FEAT_TYPE_KMCTR, prop.kmctr); - prop.kmctr[0] |=3D 0x80; /* query is always available */ s390_fill_feat_block(features, S390_FEAT_TYPE_KMF, prop.kmf); - prop.kmf[0] |=3D 0x80; /* query is always available */ s390_fill_feat_block(features, S390_FEAT_TYPE_KMO, prop.kmo); - prop.kmo[0] |=3D 0x80; /* query is always available */ s390_fill_feat_block(features, S390_FEAT_TYPE_PCC, prop.pcc); - prop.pcc[0] |=3D 0x80; /* query is always available */ } if (test_bit(S390_FEAT_MSA_EXT_5, features)) { s390_fill_feat_block(features, S390_FEAT_TYPE_PPNO, prop.ppno); - prop.ppno[0] |=3D 0x80; /* query is always available */ } if (test_bit(S390_FEAT_MSA_EXT_8, features)) { s390_fill_feat_block(features, S390_FEAT_TYPE_KMA, prop.kma); - prop.kma[0] |=3D 0x80; /* query is always available */ } return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); } --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500975892474527.7149450245452; Tue, 25 Jul 2017 02:44:52 -0700 (PDT) Received: from localhost ([::1]:59497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwOZ-00054S-2s for importer@patchew.org; Tue, 25 Jul 2017 05:44:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKo-0001xX-PF for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKn-0003er-Nq for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51618) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKn-0003dD-F1 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:40:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70EB6356F2; Tue, 25 Jul 2017 09:40:56 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E663D171E5; Tue, 25 Jul 2017 09:40:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 70EB6356F2 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:18 +0200 Message-Id: <20170725094026.5376-7-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 25 Jul 2017 09:40:56 +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] [PULL for-2.10 06/14] target/s390x: introduce (test|set)_be_bit 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: David Hildenbrand Using ordinary bitmap operations to set/test bits does not work properly on architectures !s390x. Let's drop (test|set)_bit_inv and introduce (test|set)_be_bit instead. These functions work on uint8_t array, not on unsigned longs arrays and are for now only used in the context of CPU features. Signed-off-by: David Hildenbrand Message-Id: <20170720123721.12366-4-david@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/cpu_features.c | 8 ++++---- target/s390x/cpu_features.h | 8 ++++++++ target/s390x/kvm.c | 14 ++------------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 8b1491734f..1d3a036393 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -340,8 +340,8 @@ void s390_fill_feat_block(const S390FeatBitmap features= , S390FeatType type, case S390_FEAT_TYPE_STFL: if (test_bit(S390_FEAT_ZARCH, features)) { /* Features that are always active */ - data[0] |=3D 0x20; /* z/Architecture */ - data[17] |=3D 0x20; /* Configuration-z-architectural-mode */ + set_be_bit(2, data); /* z/Architecture */ + set_be_bit(138, data); /* Configuration-z-architectural-mode */ } break; case S390_FEAT_TYPE_PTFF: @@ -357,7 +357,7 @@ void s390_fill_feat_block(const S390FeatBitmap features= , S390FeatType type, case S390_FEAT_TYPE_PCC: case S390_FEAT_TYPE_PPNO: case S390_FEAT_TYPE_KMA: - data[0] |=3D 0x80; /* query is always available */ + set_be_bit(0, data); /* query is always available */ break; default: break; @@ -368,7 +368,7 @@ void s390_fill_feat_block(const S390FeatBitmap features= , S390FeatType type, if (s390_features[feat].type =3D=3D type) { bit_nr =3D s390_features[feat].bit; /* big endian on uint8_t array */ - data[bit_nr / 8] |=3D 0x80 >> (bit_nr % 8); + set_be_bit(bit_nr, data); } feat =3D find_next_bit(features, S390_FEAT_MAX, feat + 1); } diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h index 770435e0cc..e306aa7ab2 100644 --- a/target/s390x/cpu_features.h +++ b/target/s390x/cpu_features.h @@ -93,4 +93,12 @@ const S390FeatGroupDef *s390_feat_group_def(S390FeatGrou= p group); =20 #define BE_BIT_NR(BIT) (BIT ^ (BITS_PER_LONG - 1)) =20 +static inline void set_be_bit(unsigned int bit_nr, uint8_t *array) +{ + array[bit_nr / 8] |=3D 0x80 >> (bit_nr % 8); +} +static inline bool test_be_bit(unsigned int bit_nr, const uint8_t *array) +{ + return array[bit_nr / 8] & (0x80 >> (bit_nr % 8)); +} #endif /* TARGET_S390X_CPU_FEATURES_H */ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 999ea570c3..9bec48152f 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2430,16 +2430,6 @@ int kvm_arch_msi_data_to_gsi(uint32_t data) abort(); } =20 -static inline int test_bit_inv(long nr, const unsigned long *addr) -{ - return test_bit(BE_BIT_NR(nr), addr); -} - -static inline void set_bit_inv(long nr, unsigned long *addr) -{ - set_bit(BE_BIT_NR(nr), addr); -} - static int query_cpu_subfunc(S390FeatBitmap features) { struct kvm_s390_vm_cpu_subfunc prop; @@ -2566,7 +2556,7 @@ static int query_cpu_feat(S390FeatBitmap features) } =20 for (i =3D 0; i < ARRAY_SIZE(kvm_to_feat); i++) { - if (test_bit_inv(kvm_to_feat[i][0], (unsigned long *)prop.feat)) { + if (test_be_bit(kvm_to_feat[i][0], (uint8_t *) prop.feat)) { set_bit(kvm_to_feat[i][1], features); } } @@ -2585,7 +2575,7 @@ static int configure_cpu_feat(const S390FeatBitmap fe= atures) =20 for (i =3D 0; i < ARRAY_SIZE(kvm_to_feat); i++) { if (test_bit(kvm_to_feat[i][1], features)) { - set_bit_inv(kvm_to_feat[i][0], (unsigned long *)prop.feat); + set_be_bit(kvm_to_feat[i][0], (uint8_t *) prop.feat); } } return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976064067383.34012283665254; Tue, 25 Jul 2017 02:47:44 -0700 (PDT) Received: from localhost ([::1]:59513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwRI-0007Uk-SH for importer@patchew.org; Tue, 25 Jul 2017 05:47:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKr-0001zh-1K for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKq-0003gx-7Z for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKq-0003g1-0F for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:00 -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 B9C26356F2; Tue, 25 Jul 2017 09:40:58 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BC2C8FAFC; Tue, 25 Jul 2017 09:40:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B9C26356F2 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:19 +0200 Message-Id: <20170725094026.5376-8-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@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]); Tue, 25 Jul 2017 09:40:59 +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] [PULL for-2.10 07/14] s390x/kvm: better comment regarding zPCI feature availability 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: David Hildenbrand Acked-by: Christian Borntraeger Signed-off-by: David Hildenbrand Message-Id: <20170720123721.12366-5-david@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 9bec48152f..84416c0a64 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2661,7 +2661,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) clear_bit(S390_FEAT_CMM_NT, model->features); } =20 - /* set zpci and aen facilities */ + /* We emulate a zPCI bus and AEN, therefore we don't need HW support */ set_bit(S390_FEAT_ZPCI, model->features); set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features); =20 --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976014796420.33027711454395; Tue, 25 Jul 2017 02:46:54 -0700 (PDT) Received: from localhost ([::1]:59512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwQW-0006sL-Ee for importer@patchew.org; Tue, 25 Jul 2017 05:46:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKy-000276-Dj for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKu-0003lo-DH for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40266) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKu-0003lM-5r for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:04 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0941B7F403; Tue, 25 Jul 2017 09:41:03 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92A76189FE; Tue, 25 Jul 2017 09:41:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0941B7F403 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:20 +0200 Message-Id: <20170725094026.5376-9-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 25 Jul 2017 09:41: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] [PULL for-2.10 08/14] target/s390x: improve baselining if certain base features are missing 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: David Hildenbrand There are certain features that we put into base models, but that are not relevant for the actual search. The most famous example are MSA subfunctions that might be disabled on certain real hardware out there. While the kvm host model detection will usually detect the correct model on such machines (as it will in the common case not pass features to check for into s390_find_cpu_def()), baselining will fall back to a quite old model just because some MSA subfunctions are missing. Let's improve that by ignoring lack of these features while performing the search for a base model. Signed-off-by: David Hildenbrand Message-Id: <20170720123721.12366-6-david@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/cpu_models.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index d91b7b85f6..fa1338fc72 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -78,6 +78,9 @@ static S390CPUDef s390_cpu_defs[] =3D { CPUDEF_INIT(0x3906, 14, 1, 47, 0x08000000U, "z14", "IBM z14 GA1"), }; =20 +/* features part of a base model but not relevant for finding a base model= */ +S390FeatBitmap ignored_base_feat; + void s390_cpudef_featoff(uint8_t gen, uint8_t ec_ga, S390Feat feat) { const S390CPUDef *def; @@ -237,6 +240,11 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uin= t8_t gen, uint8_t ec_ga, if (features) { /* see if the model satisfies the minimum features */ bitmap_andnot(missing, def->base_feat, features, S390_FEAT_MAX= ); + /* + * Ignore certain features that are in the base model, but not + * relevant for the search (esp. MSA subfunctions). + */ + bitmap_andnot(missing, missing, ignored_base_feat, S390_FEAT_M= AX); if (!bitmap_empty(missing, S390_FEAT_MAX)) { break; } @@ -1210,10 +1218,35 @@ static const TypeInfo host_s390_cpu_type_info =3D { }; #endif =20 +static void init_ignored_base_feat(void) +{ + static const int feats[] =3D { + /* MSA subfunctions that could not be available on certain machin= es */ + S390_FEAT_KMAC_DEA, + S390_FEAT_KMAC_TDEA_128, + S390_FEAT_KMAC_TDEA_192, + S390_FEAT_KMC_DEA, + S390_FEAT_KMC_TDEA_128, + S390_FEAT_KMC_TDEA_192, + S390_FEAT_KM_DEA, + S390_FEAT_KM_TDEA_128, + S390_FEAT_KM_TDEA_192, + S390_FEAT_KIMD_SHA_1, + S390_FEAT_KLMD_SHA_1, + }; + int i; + + for (i =3D 0; i < ARRAY_SIZE(feats); i++) { + set_bit(feats[i], ignored_base_feat); + } +} + static void register_types(void) { int i; =20 + init_ignored_base_feat(); + /* init all bitmaps from gnerated data initially */ for (i =3D 0; i < ARRAY_SIZE(s390_cpu_defs); i++) { s390_init_feat_bitmap(s390_cpu_defs[i].base_init, --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976074582998.5978824663791; Tue, 25 Jul 2017 02:47:54 -0700 (PDT) Received: from localhost ([::1]:59514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwRS-0007e4-6l for importer@patchew.org; Tue, 25 Jul 2017 05:47:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwKy-000274-DU for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKw-0003n5-Dm for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50296) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKw-0003mW-5M for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2EC327C846; Tue, 25 Jul 2017 09:41:05 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B508D5C3FA; Tue, 25 Jul 2017 09:41:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2EC327C846 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:21 +0200 Message-Id: <20170725094026.5376-10-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 25 Jul 2017 09:41: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] [PULL for-2.10 09/14] target/s390x: Move s390_cpu_dump_state() to helper.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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: Thomas Huth translate.c can not be compiled with --disable-tcg, but we need the s390_cpu_dump_state() in KVM-only builds, too. So let's move that function to helper.c instead, which will also be compiled when --disable-tcg has been specified. Reviewed-by: Richard Henderson Signed-off-by: Thomas Huth Message-Id: <1500886370-14572-2-git-send-email-thuth@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/helper.c | 60 ++++++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/translate.c | 60 --------------------------------------------= ---- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index aef09e1234..30ac2a77b3 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -766,3 +766,63 @@ void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr= addr, program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); } #endif /* CONFIG_USER_ONLY */ + +void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, + int flags) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + int i; + + if (env->cc_op > 3) { + cpu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc %= 15s\n", + env->psw.mask, env->psw.addr, cc_name(env->cc_op)); + } else { + cpu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc %= 02x\n", + env->psw.mask, env->psw.addr, env->cc_op); + } + + for (i =3D 0; i < 16; i++) { + cpu_fprintf(f, "R%02d=3D%016" PRIx64, i, env->regs[i]); + if ((i % 4) =3D=3D 3) { + cpu_fprintf(f, "\n"); + } else { + cpu_fprintf(f, " "); + } + } + + for (i =3D 0; i < 16; i++) { + cpu_fprintf(f, "F%02d=3D%016" PRIx64, i, get_freg(env, i)->ll); + if ((i % 4) =3D=3D 3) { + cpu_fprintf(f, "\n"); + } else { + cpu_fprintf(f, " "); + } + } + + for (i =3D 0; i < 32; i++) { + cpu_fprintf(f, "V%02d=3D%016" PRIx64 "%016" PRIx64, i, + env->vregs[i][0].ll, env->vregs[i][1].ll); + cpu_fprintf(f, (i % 2) ? "\n" : " "); + } + +#ifndef CONFIG_USER_ONLY + for (i =3D 0; i < 16; i++) { + cpu_fprintf(f, "C%02d=3D%016" PRIx64, i, env->cregs[i]); + if ((i % 4) =3D=3D 3) { + cpu_fprintf(f, "\n"); + } else { + cpu_fprintf(f, " "); + } + } +#endif + +#ifdef DEBUG_INLINE_BRANCHES + for (i =3D 0; i < CC_OP_MAX; i++) { + cpu_fprintf(f, " %15s =3D %10ld\t%10ld\n", cc_name(i), + inline_branch_miss[i], inline_branch_hit[i]); + } +#endif + + cpu_fprintf(f, "\n"); +} diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 48b71f9604..cd96a8dee2 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -93,66 +93,6 @@ static uint64_t pc_to_link_info(DisasContext *s, uint64_= t pc) return pc; } =20 -void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, - int flags) -{ - S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; - int i; - - if (env->cc_op > 3) { - cpu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc %= 15s\n", - env->psw.mask, env->psw.addr, cc_name(env->cc_op)); - } else { - cpu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc %= 02x\n", - env->psw.mask, env->psw.addr, env->cc_op); - } - - for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "R%02d=3D%016" PRIx64, i, env->regs[i]); - if ((i % 4) =3D=3D 3) { - cpu_fprintf(f, "\n"); - } else { - cpu_fprintf(f, " "); - } - } - - for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "F%02d=3D%016" PRIx64, i, get_freg(env, i)->ll); - if ((i % 4) =3D=3D 3) { - cpu_fprintf(f, "\n"); - } else { - cpu_fprintf(f, " "); - } - } - - for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, "V%02d=3D%016" PRIx64 "%016" PRIx64, i, - env->vregs[i][0].ll, env->vregs[i][1].ll); - cpu_fprintf(f, (i % 2) ? "\n" : " "); - } - -#ifndef CONFIG_USER_ONLY - for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "C%02d=3D%016" PRIx64, i, env->cregs[i]); - if ((i % 4) =3D=3D 3) { - cpu_fprintf(f, "\n"); - } else { - cpu_fprintf(f, " "); - } - } -#endif - -#ifdef DEBUG_INLINE_BRANCHES - for (i =3D 0; i < CC_OP_MAX; i++) { - cpu_fprintf(f, " %15s =3D %10ld\t%10ld\n", cc_name(i), - inline_branch_miss[i], inline_branch_hit[i]); - } -#endif - - cpu_fprintf(f, "\n"); -} - static TCGv_i64 psw_addr; static TCGv_i64 psw_mask; static TCGv_i64 gbea; --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976166242120.17666523838909; Tue, 25 Jul 2017 02:49:26 -0700 (PDT) Received: from localhost ([::1]:59518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwSy-0000Cp-Pw for importer@patchew.org; Tue, 25 Jul 2017 05:49:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwL0-00029j-Rr for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwKz-0003od-4E for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwKy-0003nx-R5 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C9E7AC0587E8; Tue, 25 Jul 2017 09:41:07 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7579189FE; Tue, 25 Jul 2017 09:41:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C9E7AC0587E8 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:22 +0200 Message-Id: <20170725094026.5376-11-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 25 Jul 2017 09:41:07 +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] [PULL for-2.10 10/14] target/s390x: Move diag helpers to a separate file 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: Thomas Huth misc_helper.c won't be compiled with --disable-tcg anymore, but we still need the diag helpers in KVM builds, too, so move the helper functions to a separate file. Reviewed-by: Richard Henderson Signed-off-by: Thomas Huth Message-Id: <1500886370-14572-3-git-send-email-thuth@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/Makefile.objs | 2 +- target/s390x/diag.c | 179 +++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/misc_helper.c | 167 ------------------------------------------ 3 files changed, 180 insertions(+), 168 deletions(-) create mode 100644 target/s390x/diag.c diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs index 46f6a8c6b6..80028521ef 100644 --- a/target/s390x/Makefile.objs +++ b/target/s390x/Makefile.objs @@ -1,7 +1,7 @@ obj-y +=3D translate.o helper.o cpu.o interrupt.o obj-y +=3D int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o obj-y +=3D gdbstub.o cpu_models.o cpu_features.o -obj-$(CONFIG_SOFTMMU) +=3D machine.o ioinst.o arch_dump.o mmu_helper.o +obj-$(CONFIG_SOFTMMU) +=3D machine.o ioinst.o arch_dump.o mmu_helper.o dia= g.o obj-$(CONFIG_KVM) +=3D kvm.o =20 # build and run feature list generator diff --git a/target/s390x/diag.c b/target/s390x/diag.c new file mode 100644 index 0000000000..10ac845bcd --- /dev/null +++ b/target/s390x/diag.c @@ -0,0 +1,179 @@ +/* + * S390x DIAG instruction helper functions + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "exec/address-spaces.h" +#include "exec/exec-all.h" +#include "hw/watchdog/wdt_diag288.h" +#include "sysemu/cpus.h" +#include "hw/s390x/ipl.h" + +static int modified_clear_reset(S390CPU *cpu) +{ + S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); + CPUState *t; + + pause_all_vcpus(); + cpu_synchronize_all_states(); + CPU_FOREACH(t) { + run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); + } + s390_cmma_reset(); + subsystem_reset(); + s390_crypto_reset(); + scc->load_normal(CPU(cpu)); + cpu_synchronize_all_post_reset(); + resume_all_vcpus(); + return 0; +} + +static int load_normal_reset(S390CPU *cpu) +{ + S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); + CPUState *t; + + pause_all_vcpus(); + cpu_synchronize_all_states(); + CPU_FOREACH(t) { + run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL); + } + s390_cmma_reset(); + subsystem_reset(); + scc->initial_cpu_reset(CPU(cpu)); + scc->load_normal(CPU(cpu)); + cpu_synchronize_all_post_reset(); + resume_all_vcpus(); + return 0; +} + +int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) +{ + uint64_t func =3D env->regs[r1]; + uint64_t timeout =3D env->regs[r1 + 1]; + uint64_t action =3D env->regs[r3]; + Object *obj; + DIAG288State *diag288; + DIAG288Class *diag288_class; + + if (r1 % 2 || action !=3D 0) { + return -1; + } + + /* Timeout must be more than 15 seconds except for timer deletion */ + if (func !=3D WDT_DIAG288_CANCEL && timeout < 15) { + return -1; + } + + obj =3D object_resolve_path_type("", TYPE_WDT_DIAG288, NULL); + if (!obj) { + return -1; + } + + diag288 =3D DIAG288(obj); + diag288_class =3D DIAG288_GET_CLASS(diag288); + return diag288_class->handle_timer(diag288, func, timeout); +} + +#define DIAG_308_RC_OK 0x0001 +#define DIAG_308_RC_NO_CONF 0x0102 +#define DIAG_308_RC_INVALID 0x0402 + +void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3) +{ + uint64_t addr =3D env->regs[r1]; + uint64_t subcode =3D env->regs[r3]; + IplParameterBlock *iplb; + + if (env->psw.mask & PSW_MASK_PSTATE) { + program_interrupt(env, PGM_PRIVILEGED, ILEN_AUTO); + return; + } + + if ((subcode & ~0x0ffffULL) || (subcode > 6)) { + program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); + return; + } + + switch (subcode) { + case 0: + modified_clear_reset(s390_env_get_cpu(env)); + if (tcg_enabled()) { + cpu_loop_exit(CPU(s390_env_get_cpu(env))); + } + break; + case 1: + load_normal_reset(s390_env_get_cpu(env)); + if (tcg_enabled()) { + cpu_loop_exit(CPU(s390_env_get_cpu(env))); + } + break; + case 3: + s390_reipl_request(); + if (tcg_enabled()) { + cpu_loop_exit(CPU(s390_env_get_cpu(env))); + } + break; + case 5: + if ((r1 & 1) || (addr & 0x0fffULL)) { + program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); + return; + } + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(IplParameterBlock), false))= { + program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO); + return; + } + iplb =3D g_malloc0(sizeof(IplParameterBlock)); + cpu_physical_memory_read(addr, iplb, sizeof(iplb->len)); + if (!iplb_valid_len(iplb)) { + env->regs[r1 + 1] =3D DIAG_308_RC_INVALID; + goto out; + } + + cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len)); + + if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb)) { + env->regs[r1 + 1] =3D DIAG_308_RC_INVALID; + goto out; + } + + s390_ipl_update_diag308(iplb); + env->regs[r1 + 1] =3D DIAG_308_RC_OK; +out: + g_free(iplb); + return; + case 6: + if ((r1 & 1) || (addr & 0x0fffULL)) { + program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); + return; + } + if (!address_space_access_valid(&address_space_memory, addr, + sizeof(IplParameterBlock), true)) { + program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO); + return; + } + iplb =3D s390_ipl_get_iplb(); + if (iplb) { + cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->len)); + env->regs[r1 + 1] =3D DIAG_308_RC_OK; + } else { + env->regs[r1 + 1] =3D DIAG_308_RC_NO_CONF; + } + return; + default: + hw_error("Unhandled diag308 subcode %" PRIx64, subcode); + break; + } +} diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index b5081019c5..6a90ad55cc 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -24,22 +24,15 @@ #include "exec/memory.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" -#include "sysemu/kvm.h" #include "qemu/timer.h" -#include "qemu/main-loop.h" #include "exec/address-spaces.h" -#ifdef CONFIG_KVM -#include -#endif #include "exec/exec-all.h" #include "exec/cpu_ldst.h" =20 #if !defined(CONFIG_USER_ONLY) -#include "hw/watchdog/wdt_diag288.h" #include "sysemu/cpus.h" #include "sysemu/sysemu.h" #include "hw/s390x/ebcdic.h" -#include "hw/s390x/ipl.h" #endif =20 /* #define DEBUG_HELPER */ @@ -116,166 +109,6 @@ uint32_t HELPER(servc)(CPUS390XState *env, uint64_t r= 1, uint64_t r2) return r; } =20 -#ifndef CONFIG_USER_ONLY -static int modified_clear_reset(S390CPU *cpu) -{ - S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); - CPUState *t; - - pause_all_vcpus(); - cpu_synchronize_all_states(); - CPU_FOREACH(t) { - run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); - } - s390_cmma_reset(); - subsystem_reset(); - s390_crypto_reset(); - scc->load_normal(CPU(cpu)); - cpu_synchronize_all_post_reset(); - resume_all_vcpus(); - return 0; -} - -static int load_normal_reset(S390CPU *cpu) -{ - S390CPUClass *scc =3D S390_CPU_GET_CLASS(cpu); - CPUState *t; - - pause_all_vcpus(); - cpu_synchronize_all_states(); - CPU_FOREACH(t) { - run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL); - } - s390_cmma_reset(); - subsystem_reset(); - scc->initial_cpu_reset(CPU(cpu)); - scc->load_normal(CPU(cpu)); - cpu_synchronize_all_post_reset(); - resume_all_vcpus(); - return 0; -} - -int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3) -{ - uint64_t func =3D env->regs[r1]; - uint64_t timeout =3D env->regs[r1 + 1]; - uint64_t action =3D env->regs[r3]; - Object *obj; - DIAG288State *diag288; - DIAG288Class *diag288_class; - - if (r1 % 2 || action !=3D 0) { - return -1; - } - - /* Timeout must be more than 15 seconds except for timer deletion */ - if (func !=3D WDT_DIAG288_CANCEL && timeout < 15) { - return -1; - } - - obj =3D object_resolve_path_type("", TYPE_WDT_DIAG288, NULL); - if (!obj) { - return -1; - } - - diag288 =3D DIAG288(obj); - diag288_class =3D DIAG288_GET_CLASS(diag288); - return diag288_class->handle_timer(diag288, func, timeout); -} - -#define DIAG_308_RC_OK 0x0001 -#define DIAG_308_RC_NO_CONF 0x0102 -#define DIAG_308_RC_INVALID 0x0402 - -void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3) -{ - uint64_t addr =3D env->regs[r1]; - uint64_t subcode =3D env->regs[r3]; - IplParameterBlock *iplb; - - if (env->psw.mask & PSW_MASK_PSTATE) { - program_interrupt(env, PGM_PRIVILEGED, ILEN_AUTO); - return; - } - - if ((subcode & ~0x0ffffULL) || (subcode > 6)) { - program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); - return; - } - - switch (subcode) { - case 0: - modified_clear_reset(s390_env_get_cpu(env)); - if (tcg_enabled()) { - cpu_loop_exit(CPU(s390_env_get_cpu(env))); - } - break; - case 1: - load_normal_reset(s390_env_get_cpu(env)); - if (tcg_enabled()) { - cpu_loop_exit(CPU(s390_env_get_cpu(env))); - } - break; - case 3: - s390_reipl_request(); - if (tcg_enabled()) { - cpu_loop_exit(CPU(s390_env_get_cpu(env))); - } - break; - case 5: - if ((r1 & 1) || (addr & 0x0fffULL)) { - program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); - return; - } - if (!address_space_access_valid(&address_space_memory, addr, - sizeof(IplParameterBlock), false))= { - program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO); - return; - } - iplb =3D g_malloc0(sizeof(IplParameterBlock)); - cpu_physical_memory_read(addr, iplb, sizeof(iplb->len)); - if (!iplb_valid_len(iplb)) { - env->regs[r1 + 1] =3D DIAG_308_RC_INVALID; - goto out; - } - - cpu_physical_memory_read(addr, iplb, be32_to_cpu(iplb->len)); - - if (!iplb_valid_ccw(iplb) && !iplb_valid_fcp(iplb)) { - env->regs[r1 + 1] =3D DIAG_308_RC_INVALID; - goto out; - } - - s390_ipl_update_diag308(iplb); - env->regs[r1 + 1] =3D DIAG_308_RC_OK; -out: - g_free(iplb); - return; - case 6: - if ((r1 & 1) || (addr & 0x0fffULL)) { - program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); - return; - } - if (!address_space_access_valid(&address_space_memory, addr, - sizeof(IplParameterBlock), true)) { - program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO); - return; - } - iplb =3D s390_ipl_get_iplb(); - if (iplb) { - cpu_physical_memory_write(addr, iplb, be32_to_cpu(iplb->len)); - env->regs[r1 + 1] =3D DIAG_308_RC_OK; - } else { - env->regs[r1 + 1] =3D DIAG_308_RC_NO_CONF; - } - return; - default: - hw_error("Unhandled diag308 subcode %" PRIx64, subcode); - break; - } -} -#endif - void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t n= um) { uint64_t r; --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976181025899.4301785042131; Tue, 25 Jul 2017 02:49:41 -0700 (PDT) Received: from localhost ([::1]:59519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwTD-0000Jo-K3 for importer@patchew.org; Tue, 25 Jul 2017 05:49:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwL3-0002Bl-1y for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwL1-0003pn-Gq for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwL1-0003pO-7t for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2CC8E61E48; Tue, 25 Jul 2017 09:41:10 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 950BD8E238; Tue, 25 Jul 2017 09:41:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2CC8E61E48 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:23 +0200 Message-Id: <20170725094026.5376-12-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 25 Jul 2017 09:41:10 +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] [PULL for-2.10 11/14] target/s390x: Rework program_interrupt() and related functions 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: Thomas Huth misc_helper.c won't be compiled with --disable-tcg anymore, but we still need the program_interrupt() function in that case. Move it to interrupt.c instead, and refactor it to re-use the code from trigger_pgm_exception() (for TCG) and enter_pgmcheck() (for KVM, which now got renamed to kvm_s390_program_interrupt() for clarity). Signed-off-by: Thomas Huth Message-Id: <1500886370-14572-4-git-send-email-thuth@redhat.com> Reviewed-by: Richard Henderson Signed-off-by: Cornelia Huck --- target/s390x/cpu.h | 9 +++++---- target/s390x/helper.c | 10 ---------- target/s390x/interrupt.c | 39 +++++++++++++++++++++++++++++++++++++++ target/s390x/kvm.c | 16 ++++++++-------- target/s390x/misc_helper.c | 26 -------------------------- 5 files changed, 52 insertions(+), 48 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7732d01784..4041bfc4bc 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -474,10 +474,6 @@ static inline bool get_per_in_range(CPUS390XState *env= , uint64_t addr) } } =20 -#ifndef CONFIG_USER_ONLY -void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n); -#endif - S390CPU *cpu_s390x_init(const char *cpu_model); S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp); S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp); @@ -1146,10 +1142,12 @@ void handle_diag_308(CPUS390XState *env, uint64_t r= 1, uint64_t r3); /* automatically detect the instruction length */ #define ILEN_AUTO 0xff void program_interrupt(CPUS390XState *env, uint32_t code, int ilen); +void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n); void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp, uintptr_t retaddr); =20 #ifdef CONFIG_KVM +void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code); void kvm_s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, uint32_t io_int_word); @@ -1170,6 +1168,9 @@ int kvm_s390_get_ri(void); int kvm_s390_get_gs(void); void kvm_s390_crypto_reset(void); #else +static inline void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) +{ +} static inline void kvm_s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr, uint32_t io_int_parm, diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 30ac2a77b3..e2040d65a6 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -165,16 +165,6 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr addr= ess, =20 #else /* !CONFIG_USER_ONLY */ =20 -/* Ensure to exit the TB after this call! */ -void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n) -{ - CPUState *cs =3D CPU(s390_env_get_cpu(env)); - - cs->exception_index =3D EXCP_PGM; - env->int_pgm_code =3D code; - env->int_pgm_ilen =3D ilen; -} - int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int rw, int mmu_idx) { diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index 9edef96795..fde3da793a 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -8,10 +8,49 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" #include "cpu.h" +#include "exec/exec-all.h" #include "sysemu/kvm.h" #include "hw/s390x/ioinst.h" =20 +/* Ensure to exit the TB after this call! */ +void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n) +{ + CPUState *cs =3D CPU(s390_env_get_cpu(env)); + + cs->exception_index =3D EXCP_PGM; + env->int_pgm_code =3D code; + env->int_pgm_ilen =3D ilen; +} + +static void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, + int ilen) +{ +#ifdef CONFIG_TCG + trigger_pgm_exception(env, code, ilen); + cpu_loop_exit(CPU(s390_env_get_cpu(env))); +#else + g_assert_not_reached(); +#endif +} + +void program_interrupt(CPUS390XState *env, uint32_t code, int ilen) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + + qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n", + env->psw.addr); + + if (kvm_enabled()) { + kvm_s390_program_interrupt(cpu, code); + } else if (tcg_enabled()) { + tcg_s390_program_interrupt(env, code, ilen); + } else { + g_assert_not_reached(); + } +} + #if !defined(CONFIG_USER_ONLY) void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param, uint64_t param64) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 84416c0a64..c4c5791d27 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1032,7 +1032,7 @@ void kvm_s390_service_interrupt(uint32_t parm) kvm_s390_floating_interrupt(&irq); } =20 -static void enter_pgmcheck(S390CPU *cpu, uint16_t code) +void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) { struct kvm_s390_irq irq =3D { .type =3D KVM_S390_PROGRAM_INT, @@ -1068,7 +1068,7 @@ static int kvm_sclp_service_call(S390CPU *cpu, struct= kvm_run *run, =20 r =3D sclp_service_call(env, sccb, code); if (r < 0) { - enter_pgmcheck(cpu, -r); + kvm_s390_program_interrupt(cpu, -r); } else { setcc(cpu, r); } @@ -1236,7 +1236,7 @@ static int kvm_sic_service_call(S390CPU *cpu, struct = kvm_run *run) isc =3D (env->regs[r3] >> 27) & 0x7; r =3D css_do_sic(env, isc, mode); if (r) { - enter_pgmcheck(cpu, -r); + kvm_s390_program_interrupt(cpu, -r); } =20 return 0; @@ -1357,7 +1357,7 @@ static int handle_hypercall(S390CPU *cpu, struct kvm_= run *run) cpu_synchronize_state(CPU(cpu)); ret =3D s390_virtio_hypercall(env); if (ret =3D=3D -EINVAL) { - enter_pgmcheck(cpu, PGM_SPECIFICATION); + kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION); return 0; } =20 @@ -1374,7 +1374,7 @@ static void kvm_handle_diag_288(S390CPU *cpu, struct = kvm_run *run) r3 =3D run->s390_sieic.ipa & 0x000f; rc =3D handle_diag_288(&cpu->env, r1, r3); if (rc) { - enter_pgmcheck(cpu, PGM_SPECIFICATION); + kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION); } } =20 @@ -1431,7 +1431,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *= run, uint32_t ipb) break; default: DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code); - enter_pgmcheck(cpu, PGM_SPECIFICATION); + kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION); break; } =20 @@ -1899,7 +1899,7 @@ static int handle_instruction(S390CPU *cpu, struct kv= m_run *run) =20 if (r < 0) { r =3D 0; - enter_pgmcheck(cpu, 0x0001); + kvm_s390_program_interrupt(cpu, PGM_OPERATION); } =20 return r; @@ -2009,7 +2009,7 @@ static int handle_intercept(S390CPU *cpu) /* Then check for potential pgm check loops */ r =3D handle_oper_loop(cpu, run); if (r =3D=3D 0) { - enter_pgmcheck(cpu, PGM_OPERATION); + kvm_s390_program_interrupt(cpu, PGM_OPERATION); } } break; diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 6a90ad55cc..44c5c401fb 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -68,32 +68,6 @@ void HELPER(exception)(CPUS390XState *env, uint32_t excp) cpu_loop_exit(cs); } =20 -void program_interrupt(CPUS390XState *env, uint32_t code, int ilen) -{ - S390CPU *cpu =3D s390_env_get_cpu(env); - - qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n", - env->psw.addr); - - if (kvm_enabled()) { -#ifdef CONFIG_KVM - struct kvm_s390_irq irq =3D { - .type =3D KVM_S390_PROGRAM_INT, - .u.pgm.code =3D code, - }; - - kvm_s390_vcpu_interrupt(cpu, &irq); -#endif - } else { - CPUState *cs =3D CPU(cpu); - - env->int_pgm_code =3D code; - env->int_pgm_ilen =3D ilen; - cs->exception_index =3D EXCP_PGM; - cpu_loop_exit(cs); - } -} - #ifndef CONFIG_USER_ONLY =20 /* SCLP service call */ --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976463704331.8443977156926; Tue, 25 Jul 2017 02:54:23 -0700 (PDT) Received: from localhost ([::1]:59542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwXm-0004Nu-8x for importer@patchew.org; Tue, 25 Jul 2017 05:54:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwLA-0002IQ-M1 for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwL6-0003sJ-Hf for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwL6-0003ru-3n for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 009F2C04D288; Tue, 25 Jul 2017 09:41:15 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FE059172D; Tue, 25 Jul 2017 09:41:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 009F2C04D288 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:24 +0200 Message-Id: <20170725094026.5376-13-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 25 Jul 2017 09:41:15 +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] [PULL for-2.10 12/14] target/s390x: Move exception-related functions to a new excp_helper.c file 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: Thomas Huth These functions can not be compiled with --disable-tcg. But since we need the other functions from helper.c in the non-tcg build, we can also not simply remove helper.c from the non-tcg builds. Thus the problematic functions have to be moved into a separate new file instead that we can later omit in the non-tcg builds. Reviewed-by: Richard Henderson Signed-off-by: Thomas Huth Message-Id: <1500886370-14572-5-git-send-email-thuth@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/Makefile.objs | 2 +- target/s390x/cpu.h | 8 + target/s390x/excp_helper.c | 515 +++++++++++++++++++++++++++++++++++++++++= ++++ target/s390x/helper.c | 472 +---------------------------------------- 4 files changed, 528 insertions(+), 469 deletions(-) create mode 100644 target/s390x/excp_helper.c diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs index 80028521ef..cc2b4c9257 100644 --- a/target/s390x/Makefile.objs +++ b/target/s390x/Makefile.objs @@ -1,6 +1,6 @@ obj-y +=3D translate.o helper.o cpu.o interrupt.o obj-y +=3D int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o -obj-y +=3D gdbstub.o cpu_models.o cpu_features.o +obj-y +=3D gdbstub.o cpu_models.o cpu_features.o excp_helper.o obj-$(CONFIG_SOFTMMU) +=3D machine.o ioinst.o arch_dump.o mmu_helper.o dia= g.o obj-$(CONFIG_KVM) +=3D kvm.o =20 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 4041bfc4bc..29fdd5d49a 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -801,6 +801,8 @@ static inline void setcc(S390CPU *cpu, uint64_t cc) env->cc_op =3D cc; } =20 +#ifndef CONFIG_USER_ONLY + typedef struct LowCore { /* prefix area: defined by architecture */ @@ -918,6 +920,11 @@ typedef struct LowCore uint8_t pad18[0x2000-0x1400]; /* 0x1400 */ } QEMU_PACKED LowCore; =20 +LowCore *cpu_map_lowcore(CPUS390XState *env); +void cpu_unmap_lowcore(LowCore *lowcore); + +#endif + /* STSI */ #define STSI_LEVEL_MASK 0x00000000f0000000ULL #define STSI_LEVEL_CURRENT 0x0000000000000000ULL @@ -1094,6 +1101,7 @@ struct sysib_322 { #define SIGP_ORDER_MASK 0x000000ff =20 void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr); +uint64_t get_psw_mask(CPUS390XState *env); target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr); int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t= asc, target_ulong *raddr, int *flags, bool exc); diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c new file mode 100644 index 0000000000..d1833772d5 --- /dev/null +++ b/target/s390x/excp_helper.c @@ -0,0 +1,515 @@ +/* + * s390x exception / interrupt helpers + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "cpu.h" +#include "qemu/timer.h" +#include "exec/exec-all.h" +#include "exec/cpu_ldst.h" +#include "hw/s390x/ioinst.h" +#ifndef CONFIG_USER_ONLY +#include "sysemu/sysemu.h" +#endif + +/* #define DEBUG_S390 */ +/* #define DEBUG_S390_STDOUT */ + +#ifdef DEBUG_S390 +#ifdef DEBUG_S390_STDOUT +#define DPRINTF(fmt, ...) \ + do { fprintf(stderr, fmt, ## __VA_ARGS__); \ + if (qemu_log_separate()) { qemu_log(fmt, ##__VA_ARGS__); } } whil= e (0) +#else +#define DPRINTF(fmt, ...) \ + do { qemu_log(fmt, ## __VA_ARGS__); } while (0) +#endif +#else +#define DPRINTF(fmt, ...) \ + do { } while (0) +#endif + +#if defined(CONFIG_USER_ONLY) + +void s390_cpu_do_interrupt(CPUState *cs) +{ + cs->exception_index =3D -1; +} + +int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, + int rw, int mmu_idx) +{ + S390CPU *cpu =3D S390_CPU(cs); + + cs->exception_index =3D EXCP_PGM; + cpu->env.int_pgm_code =3D PGM_ADDRESSING; + /* On real machines this value is dropped into LowMem. Since this + is userland, simply put this someplace that cpu_loop can find it. = */ + cpu->env.__excp_addr =3D address; + return 1; +} + +#else /* !CONFIG_USER_ONLY */ + +int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, + int rw, int mmu_idx) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + uint64_t asc =3D cpu_mmu_idx_to_asc(mmu_idx); + target_ulong vaddr, raddr; + int prot; + + DPRINTF("%s: address 0x%" VADDR_PRIx " rw %d mmu_idx %d\n", + __func__, orig_vaddr, rw, mmu_idx); + + orig_vaddr &=3D TARGET_PAGE_MASK; + vaddr =3D orig_vaddr; + + /* 31-Bit mode */ + if (!(env->psw.mask & PSW_MASK_64)) { + vaddr &=3D 0x7fffffff; + } + + if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) { + /* Translation ended in exception */ + return 1; + } + + /* check out of RAM access */ + if (raddr > ram_size) { + DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__, + (uint64_t)raddr, (uint64_t)ram_size); + trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO); + return 1; + } + + qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x= )\n", + __func__, (uint64_t)vaddr, (uint64_t)raddr, prot); + + tlb_set_page(cs, orig_vaddr, raddr, prot, + mmu_idx, TARGET_PAGE_SIZE); + + return 0; +} + +static void do_program_interrupt(CPUS390XState *env) +{ + uint64_t mask, addr; + LowCore *lowcore; + int ilen =3D env->int_pgm_ilen; + + if (ilen =3D=3D ILEN_AUTO) { + ilen =3D get_ilen(cpu_ldub_code(env, env->psw.addr)); + } + assert(ilen =3D=3D 2 || ilen =3D=3D 4 || ilen =3D=3D 6); + + switch (env->int_pgm_code) { + case PGM_PER: + if (env->per_perc_atmid & PER_CODE_EVENT_NULLIFICATION) { + break; + } + /* FALL THROUGH */ + case PGM_OPERATION: + case PGM_PRIVILEGED: + case PGM_EXECUTE: + case PGM_PROTECTION: + case PGM_ADDRESSING: + case PGM_SPECIFICATION: + case PGM_DATA: + case PGM_FIXPT_OVERFLOW: + case PGM_FIXPT_DIVIDE: + case PGM_DEC_OVERFLOW: + case PGM_DEC_DIVIDE: + case PGM_HFP_EXP_OVERFLOW: + case PGM_HFP_EXP_UNDERFLOW: + case PGM_HFP_SIGNIFICANCE: + case PGM_HFP_DIVIDE: + case PGM_TRANS_SPEC: + case PGM_SPECIAL_OP: + case PGM_OPERAND: + case PGM_HFP_SQRT: + case PGM_PC_TRANS_SPEC: + case PGM_ALET_SPEC: + case PGM_MONITOR: + /* advance the PSW if our exception is not nullifying */ + env->psw.addr +=3D ilen; + break; + } + + qemu_log_mask(CPU_LOG_INT, "%s: code=3D0x%x ilen=3D%d\n", + __func__, env->int_pgm_code, ilen); + + lowcore =3D cpu_map_lowcore(env); + + /* Signal PER events with the exception. */ + if (env->per_perc_atmid) { + env->int_pgm_code |=3D PGM_PER; + lowcore->per_address =3D cpu_to_be64(env->per_address); + lowcore->per_perc_atmid =3D cpu_to_be16(env->per_perc_atmid); + env->per_perc_atmid =3D 0; + } + + lowcore->pgm_ilen =3D cpu_to_be16(ilen); + lowcore->pgm_code =3D cpu_to_be16(env->int_pgm_code); + lowcore->program_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); + lowcore->program_old_psw.addr =3D cpu_to_be64(env->psw.addr); + mask =3D be64_to_cpu(lowcore->program_new_psw.mask); + addr =3D be64_to_cpu(lowcore->program_new_psw.addr); + lowcore->per_breaking_event_addr =3D cpu_to_be64(env->gbea); + + cpu_unmap_lowcore(lowcore); + + DPRINTF("%s: %x %x %" PRIx64 " %" PRIx64 "\n", __func__, + env->int_pgm_code, ilen, env->psw.mask, + env->psw.addr); + + load_psw(env, mask, addr); +} + +static void do_svc_interrupt(CPUS390XState *env) +{ + uint64_t mask, addr; + LowCore *lowcore; + + lowcore =3D cpu_map_lowcore(env); + + lowcore->svc_code =3D cpu_to_be16(env->int_svc_code); + lowcore->svc_ilen =3D cpu_to_be16(env->int_svc_ilen); + lowcore->svc_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); + lowcore->svc_old_psw.addr =3D cpu_to_be64(env->psw.addr + env->int_svc= _ilen); + mask =3D be64_to_cpu(lowcore->svc_new_psw.mask); + addr =3D be64_to_cpu(lowcore->svc_new_psw.addr); + + cpu_unmap_lowcore(lowcore); + + load_psw(env, mask, addr); + + /* When a PER event is pending, the PER exception has to happen + immediately after the SERVICE CALL one. */ + if (env->per_perc_atmid) { + env->int_pgm_code =3D PGM_PER; + env->int_pgm_ilen =3D env->int_svc_ilen; + do_program_interrupt(env); + } +} + +#define VIRTIO_SUBCODE_64 0x0D00 + +static void do_ext_interrupt(CPUS390XState *env) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + uint64_t mask, addr; + LowCore *lowcore; + ExtQueue *q; + + if (!(env->psw.mask & PSW_MASK_EXT)) { + cpu_abort(CPU(cpu), "Ext int w/o ext mask\n"); + } + + 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); + + 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->cpu_num | VIRTIO_SUBCODE_64); + mask =3D be64_to_cpu(lowcore->external_new_psw.mask); + addr =3D be64_to_cpu(lowcore->external_new_psw.addr); + + cpu_unmap_lowcore(lowcore); + + 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); + + load_psw(env, mask, addr); +} + +static void do_io_interrupt(CPUS390XState *env) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + LowCore *lowcore; + IOIntQueue *q; + uint8_t isc; + int disable =3D 1; + int found =3D 0; + + if (!(env->psw.mask & PSW_MASK_IO)) { + cpu_abort(CPU(cpu), "I/O int w/o I/O mask\n"); + } + + for (isc =3D 0; isc < ARRAY_SIZE(env->io_index); isc++) { + uint64_t isc_bits; + + if (env->io_index[isc] < 0) { + continue; + } + if (env->io_index[isc] >=3D MAX_IO_QUEUE) { + cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n", + isc, env->io_index[isc]); + } + + q =3D &env->io_queue[env->io_index[isc]][isc]; + isc_bits =3D ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word)); + if (!(env->cregs[6] & isc_bits)) { + disable =3D 0; + continue; + } + if (!found) { + uint64_t mask, addr; + + found =3D 1; + lowcore =3D cpu_map_lowcore(env); + + lowcore->subchannel_id =3D cpu_to_be16(q->id); + lowcore->subchannel_nr =3D cpu_to_be16(q->nr); + lowcore->io_int_parm =3D cpu_to_be32(q->parm); + lowcore->io_int_word =3D cpu_to_be32(q->word); + lowcore->io_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); + lowcore->io_old_psw.addr =3D cpu_to_be64(env->psw.addr); + mask =3D be64_to_cpu(lowcore->io_new_psw.mask); + addr =3D be64_to_cpu(lowcore->io_new_psw.addr); + + cpu_unmap_lowcore(lowcore); + + env->io_index[isc]--; + + DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, + env->psw.mask, env->psw.addr); + load_psw(env, mask, addr); + } + if (env->io_index[isc] >=3D 0) { + disable =3D 0; + } + continue; + } + + if (disable) { + env->pending_int &=3D ~INTERRUPT_IO; + } + +} + +static void do_mchk_interrupt(CPUS390XState *env) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + uint64_t mask, addr; + LowCore *lowcore; + MchkQueue *q; + int i; + + if (!(env->psw.mask & PSW_MASK_MCHECK)) { + cpu_abort(CPU(cpu), "Machine check w/o mchk mask\n"); + } + + if (env->mchk_index < 0 || env->mchk_index >=3D MAX_MCHK_QUEUE) { + cpu_abort(CPU(cpu), "Mchk queue overrun: %d\n", env->mchk_index); + } + + q =3D &env->mchk_queue[env->mchk_index]; + + if (q->type !=3D 1) { + /* Don't know how to handle this... */ + cpu_abort(CPU(cpu), "Unknown machine check type %d\n", q->type); + } + if (!(env->cregs[14] & (1 << 28))) { + /* CRW machine checks disabled */ + return; + } + + lowcore =3D cpu_map_lowcore(env); + + for (i =3D 0; i < 16; i++) { + lowcore->floating_pt_save_area[i] =3D cpu_to_be64(get_freg(env, i)= ->ll); + lowcore->gpregs_save_area[i] =3D cpu_to_be64(env->regs[i]); + lowcore->access_regs_save_area[i] =3D cpu_to_be32(env->aregs[i]); + lowcore->cregs_save_area[i] =3D cpu_to_be64(env->cregs[i]); + } + lowcore->prefixreg_save_area =3D cpu_to_be32(env->psa); + lowcore->fpt_creg_save_area =3D cpu_to_be32(env->fpc); + lowcore->tod_progreg_save_area =3D cpu_to_be32(env->todpr); + lowcore->cpu_timer_save_area[0] =3D cpu_to_be32(env->cputm >> 32); + lowcore->cpu_timer_save_area[1] =3D cpu_to_be32((uint32_t)env->cputm); + lowcore->clock_comp_save_area[0] =3D cpu_to_be32(env->ckc >> 32); + lowcore->clock_comp_save_area[1] =3D cpu_to_be32((uint32_t)env->ckc); + + lowcore->mcck_interruption_code[0] =3D cpu_to_be32(0x00400f1d); + lowcore->mcck_interruption_code[1] =3D cpu_to_be32(0x40330000); + lowcore->mcck_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); + lowcore->mcck_old_psw.addr =3D cpu_to_be64(env->psw.addr); + mask =3D be64_to_cpu(lowcore->mcck_new_psw.mask); + addr =3D be64_to_cpu(lowcore->mcck_new_psw.addr); + + cpu_unmap_lowcore(lowcore); + + env->mchk_index--; + if (env->mchk_index =3D=3D -1) { + env->pending_int &=3D ~INTERRUPT_MCHK; + } + + DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, + env->psw.mask, env->psw.addr); + + load_psw(env, mask, addr); +} + +void s390_cpu_do_interrupt(CPUState *cs) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + + qemu_log_mask(CPU_LOG_INT, "%s: %d at pc=3D%" PRIx64 "\n", + __func__, cs->exception_index, env->psw.addr); + + s390_cpu_set_state(CPU_STATE_OPERATING, cpu); + /* handle machine checks */ + if ((env->psw.mask & PSW_MASK_MCHECK) && + (cs->exception_index =3D=3D -1)) { + if (env->pending_int & INTERRUPT_MCHK) { + cs->exception_index =3D EXCP_MCHK; + } + } + /* 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; + } + } + /* handle I/O interrupts */ + if ((env->psw.mask & PSW_MASK_IO) && + (cs->exception_index =3D=3D -1)) { + if (env->pending_int & INTERRUPT_IO) { + cs->exception_index =3D EXCP_IO; + } + } + + switch (cs->exception_index) { + case EXCP_PGM: + do_program_interrupt(env); + break; + case EXCP_SVC: + do_svc_interrupt(env); + break; + case EXCP_EXT: + do_ext_interrupt(env); + break; + case EXCP_IO: + do_io_interrupt(env); + break; + case EXCP_MCHK: + do_mchk_interrupt(env); + break; + } + cs->exception_index =3D -1; + + if (!env->pending_int) { + cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; + } +} + +bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request) +{ + if (interrupt_request & CPU_INTERRUPT_HARD) { + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + + if (env->ex_value) { + /* Execution of the target insn is indivisible from + the parent EXECUTE insn. */ + return false; + } + if (env->psw.mask & PSW_MASK_EXT) { + s390_cpu_do_interrupt(cs); + return true; + } + } + return false; +} + +void s390x_cpu_debug_excp_handler(CPUState *cs) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + CPUWatchpoint *wp_hit =3D cs->watchpoint_hit; + + if (wp_hit && wp_hit->flags & BP_CPU) { + /* FIXME: When the storage-alteration-space control bit is set, + the exception should only be triggered if the memory access + is done using an address space with the storage-alteration-event + bit set. We have no way to detect that with the current + watchpoint code. */ + cs->watchpoint_hit =3D NULL; + + env->per_address =3D env->psw.addr; + env->per_perc_atmid |=3D PER_CODE_EVENT_STORE | get_per_atmid(env); + /* FIXME: We currently no way to detect the address space used + to trigger the watchpoint. For now just consider it is the + current default ASC. This turn to be true except when MVCP + and MVCS instrutions are not used. */ + env->per_perc_atmid |=3D env->psw.mask & (PSW_MASK_ASC) >> 46; + + /* Remove all watchpoints to re-execute the code. A PER exception + will be triggered, it will call load_psw which will recompute + the watchpoints. */ + cpu_watchpoint_remove_all(cs, BP_CPU); + cpu_loop_exit_noexc(cs); + } +} + +/* Unaligned accesses are only diagnosed with MO_ALIGN. At the moment, + this is only for the atomic operations, for which we want to raise a + specification exception. */ +void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + + if (retaddr) { + cpu_restore_state(cs, retaddr); + } + program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); +} + +#endif /* CONFIG_USER_ONLY */ diff --git a/target/s390x/helper.c b/target/s390x/helper.c index e2040d65a6..0c989b1610 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -24,7 +24,6 @@ #include "exec/gdbstub.h" #include "qemu/timer.h" #include "exec/exec-all.h" -#include "exec/cpu_ldst.h" #include "hw/s390x/ioinst.h" #ifndef CONFIG_USER_ONLY #include "sysemu/sysemu.h" @@ -143,69 +142,7 @@ S390CPU *cpu_s390x_init(const char *cpu_model) return cpu; } =20 -#if defined(CONFIG_USER_ONLY) - -void s390_cpu_do_interrupt(CPUState *cs) -{ - cs->exception_index =3D -1; -} - -int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, - int rw, int mmu_idx) -{ - S390CPU *cpu =3D S390_CPU(cs); - - cs->exception_index =3D EXCP_PGM; - cpu->env.int_pgm_code =3D PGM_ADDRESSING; - /* On real machines this value is dropped into LowMem. Since this - is userland, simply put this someplace that cpu_loop can find it. = */ - cpu->env.__excp_addr =3D address; - return 1; -} - -#else /* !CONFIG_USER_ONLY */ - -int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, - int rw, int mmu_idx) -{ - S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; - uint64_t asc =3D cpu_mmu_idx_to_asc(mmu_idx); - target_ulong vaddr, raddr; - int prot; - - DPRINTF("%s: address 0x%" VADDR_PRIx " rw %d mmu_idx %d\n", - __func__, orig_vaddr, rw, mmu_idx); - - orig_vaddr &=3D TARGET_PAGE_MASK; - vaddr =3D orig_vaddr; - - /* 31-Bit mode */ - if (!(env->psw.mask & PSW_MASK_64)) { - vaddr &=3D 0x7fffffff; - } - - if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) { - /* Translation ended in exception */ - return 1; - } - - /* check out of RAM access */ - if (raddr > ram_size) { - DPRINTF("%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__, - (uint64_t)raddr, (uint64_t)ram_size); - trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO); - return 1; - } - - qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x= )\n", - __func__, (uint64_t)vaddr, (uint64_t)raddr, prot); - - tlb_set_page(cs, orig_vaddr, raddr, prot, - mmu_idx, TARGET_PAGE_SIZE); - - return 0; -} +#ifndef CONFIG_USER_ONLY =20 hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr) { @@ -262,7 +199,7 @@ void load_psw(CPUS390XState *env, uint64_t mask, uint64= _t addr) } } =20 -static uint64_t get_psw_mask(CPUS390XState *env) +uint64_t get_psw_mask(CPUS390XState *env) { uint64_t r =3D env->psw.mask; =20 @@ -278,7 +215,7 @@ static uint64_t get_psw_mask(CPUS390XState *env) return r; } =20 -static LowCore *cpu_map_lowcore(CPUS390XState *env) +LowCore *cpu_map_lowcore(CPUS390XState *env) { S390CPU *cpu =3D s390_env_get_cpu(env); LowCore *lowcore; @@ -293,7 +230,7 @@ static LowCore *cpu_map_lowcore(CPUS390XState *env) return lowcore; } =20 -static void cpu_unmap_lowcore(LowCore *lowcore) +void cpu_unmap_lowcore(LowCore *lowcore) { cpu_physical_memory_unmap(lowcore, sizeof(LowCore), 1, sizeof(LowCore)= ); } @@ -315,362 +252,6 @@ void do_restart_interrupt(CPUS390XState *env) load_psw(env, mask, addr); } =20 -static void do_program_interrupt(CPUS390XState *env) -{ - uint64_t mask, addr; - LowCore *lowcore; - int ilen =3D env->int_pgm_ilen; - - if (ilen =3D=3D ILEN_AUTO) { - ilen =3D get_ilen(cpu_ldub_code(env, env->psw.addr)); - } - assert(ilen =3D=3D 2 || ilen =3D=3D 4 || ilen =3D=3D 6); - - switch (env->int_pgm_code) { - case PGM_PER: - if (env->per_perc_atmid & PER_CODE_EVENT_NULLIFICATION) { - break; - } - /* FALL THROUGH */ - case PGM_OPERATION: - case PGM_PRIVILEGED: - case PGM_EXECUTE: - case PGM_PROTECTION: - case PGM_ADDRESSING: - case PGM_SPECIFICATION: - case PGM_DATA: - case PGM_FIXPT_OVERFLOW: - case PGM_FIXPT_DIVIDE: - case PGM_DEC_OVERFLOW: - case PGM_DEC_DIVIDE: - case PGM_HFP_EXP_OVERFLOW: - case PGM_HFP_EXP_UNDERFLOW: - case PGM_HFP_SIGNIFICANCE: - case PGM_HFP_DIVIDE: - case PGM_TRANS_SPEC: - case PGM_SPECIAL_OP: - case PGM_OPERAND: - case PGM_HFP_SQRT: - case PGM_PC_TRANS_SPEC: - case PGM_ALET_SPEC: - case PGM_MONITOR: - /* advance the PSW if our exception is not nullifying */ - env->psw.addr +=3D ilen; - break; - } - - qemu_log_mask(CPU_LOG_INT, "%s: code=3D0x%x ilen=3D%d\n", - __func__, env->int_pgm_code, ilen); - - lowcore =3D cpu_map_lowcore(env); - - /* Signal PER events with the exception. */ - if (env->per_perc_atmid) { - env->int_pgm_code |=3D PGM_PER; - lowcore->per_address =3D cpu_to_be64(env->per_address); - lowcore->per_perc_atmid =3D cpu_to_be16(env->per_perc_atmid); - env->per_perc_atmid =3D 0; - } - - lowcore->pgm_ilen =3D cpu_to_be16(ilen); - lowcore->pgm_code =3D cpu_to_be16(env->int_pgm_code); - lowcore->program_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); - lowcore->program_old_psw.addr =3D cpu_to_be64(env->psw.addr); - mask =3D be64_to_cpu(lowcore->program_new_psw.mask); - addr =3D be64_to_cpu(lowcore->program_new_psw.addr); - lowcore->per_breaking_event_addr =3D cpu_to_be64(env->gbea); - - cpu_unmap_lowcore(lowcore); - - DPRINTF("%s: %x %x %" PRIx64 " %" PRIx64 "\n", __func__, - env->int_pgm_code, ilen, env->psw.mask, - env->psw.addr); - - load_psw(env, mask, addr); -} - -static void do_svc_interrupt(CPUS390XState *env) -{ - uint64_t mask, addr; - LowCore *lowcore; - - lowcore =3D cpu_map_lowcore(env); - - lowcore->svc_code =3D cpu_to_be16(env->int_svc_code); - lowcore->svc_ilen =3D cpu_to_be16(env->int_svc_ilen); - lowcore->svc_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); - lowcore->svc_old_psw.addr =3D cpu_to_be64(env->psw.addr + env->int_svc= _ilen); - mask =3D be64_to_cpu(lowcore->svc_new_psw.mask); - addr =3D be64_to_cpu(lowcore->svc_new_psw.addr); - - cpu_unmap_lowcore(lowcore); - - load_psw(env, mask, addr); - - /* When a PER event is pending, the PER exception has to happen - immediately after the SERVICE CALL one. */ - if (env->per_perc_atmid) { - env->int_pgm_code =3D PGM_PER; - env->int_pgm_ilen =3D env->int_svc_ilen; - do_program_interrupt(env); - } -} - -#define VIRTIO_SUBCODE_64 0x0D00 - -static void do_ext_interrupt(CPUS390XState *env) -{ - S390CPU *cpu =3D s390_env_get_cpu(env); - uint64_t mask, addr; - LowCore *lowcore; - ExtQueue *q; - - if (!(env->psw.mask & PSW_MASK_EXT)) { - cpu_abort(CPU(cpu), "Ext int w/o ext mask\n"); - } - - 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); - - 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->cpu_num | VIRTIO_SUBCODE_64); - mask =3D be64_to_cpu(lowcore->external_new_psw.mask); - addr =3D be64_to_cpu(lowcore->external_new_psw.addr); - - cpu_unmap_lowcore(lowcore); - - 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); - - load_psw(env, mask, addr); -} - -static void do_io_interrupt(CPUS390XState *env) -{ - S390CPU *cpu =3D s390_env_get_cpu(env); - LowCore *lowcore; - IOIntQueue *q; - uint8_t isc; - int disable =3D 1; - int found =3D 0; - - if (!(env->psw.mask & PSW_MASK_IO)) { - cpu_abort(CPU(cpu), "I/O int w/o I/O mask\n"); - } - - for (isc =3D 0; isc < ARRAY_SIZE(env->io_index); isc++) { - uint64_t isc_bits; - - if (env->io_index[isc] < 0) { - continue; - } - if (env->io_index[isc] >=3D MAX_IO_QUEUE) { - cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n", - isc, env->io_index[isc]); - } - - q =3D &env->io_queue[env->io_index[isc]][isc]; - isc_bits =3D ISC_TO_ISC_BITS(IO_INT_WORD_ISC(q->word)); - if (!(env->cregs[6] & isc_bits)) { - disable =3D 0; - continue; - } - if (!found) { - uint64_t mask, addr; - - found =3D 1; - lowcore =3D cpu_map_lowcore(env); - - lowcore->subchannel_id =3D cpu_to_be16(q->id); - lowcore->subchannel_nr =3D cpu_to_be16(q->nr); - lowcore->io_int_parm =3D cpu_to_be32(q->parm); - lowcore->io_int_word =3D cpu_to_be32(q->word); - lowcore->io_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); - lowcore->io_old_psw.addr =3D cpu_to_be64(env->psw.addr); - mask =3D be64_to_cpu(lowcore->io_new_psw.mask); - addr =3D be64_to_cpu(lowcore->io_new_psw.addr); - - cpu_unmap_lowcore(lowcore); - - env->io_index[isc]--; - - DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, - env->psw.mask, env->psw.addr); - load_psw(env, mask, addr); - } - if (env->io_index[isc] >=3D 0) { - disable =3D 0; - } - continue; - } - - if (disable) { - env->pending_int &=3D ~INTERRUPT_IO; - } - -} - -static void do_mchk_interrupt(CPUS390XState *env) -{ - S390CPU *cpu =3D s390_env_get_cpu(env); - uint64_t mask, addr; - LowCore *lowcore; - MchkQueue *q; - int i; - - if (!(env->psw.mask & PSW_MASK_MCHECK)) { - cpu_abort(CPU(cpu), "Machine check w/o mchk mask\n"); - } - - if (env->mchk_index < 0 || env->mchk_index >=3D MAX_MCHK_QUEUE) { - cpu_abort(CPU(cpu), "Mchk queue overrun: %d\n", env->mchk_index); - } - - q =3D &env->mchk_queue[env->mchk_index]; - - if (q->type !=3D 1) { - /* Don't know how to handle this... */ - cpu_abort(CPU(cpu), "Unknown machine check type %d\n", q->type); - } - if (!(env->cregs[14] & (1 << 28))) { - /* CRW machine checks disabled */ - return; - } - - lowcore =3D cpu_map_lowcore(env); - - for (i =3D 0; i < 16; i++) { - lowcore->floating_pt_save_area[i] =3D cpu_to_be64(get_freg(env, i)= ->ll); - lowcore->gpregs_save_area[i] =3D cpu_to_be64(env->regs[i]); - lowcore->access_regs_save_area[i] =3D cpu_to_be32(env->aregs[i]); - lowcore->cregs_save_area[i] =3D cpu_to_be64(env->cregs[i]); - } - lowcore->prefixreg_save_area =3D cpu_to_be32(env->psa); - lowcore->fpt_creg_save_area =3D cpu_to_be32(env->fpc); - lowcore->tod_progreg_save_area =3D cpu_to_be32(env->todpr); - lowcore->cpu_timer_save_area[0] =3D cpu_to_be32(env->cputm >> 32); - lowcore->cpu_timer_save_area[1] =3D cpu_to_be32((uint32_t)env->cputm); - lowcore->clock_comp_save_area[0] =3D cpu_to_be32(env->ckc >> 32); - lowcore->clock_comp_save_area[1] =3D cpu_to_be32((uint32_t)env->ckc); - - lowcore->mcck_interruption_code[0] =3D cpu_to_be32(0x00400f1d); - lowcore->mcck_interruption_code[1] =3D cpu_to_be32(0x40330000); - lowcore->mcck_old_psw.mask =3D cpu_to_be64(get_psw_mask(env)); - lowcore->mcck_old_psw.addr =3D cpu_to_be64(env->psw.addr); - mask =3D be64_to_cpu(lowcore->mcck_new_psw.mask); - addr =3D be64_to_cpu(lowcore->mcck_new_psw.addr); - - cpu_unmap_lowcore(lowcore); - - env->mchk_index--; - if (env->mchk_index =3D=3D -1) { - env->pending_int &=3D ~INTERRUPT_MCHK; - } - - DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__, - env->psw.mask, env->psw.addr); - - load_psw(env, mask, addr); -} - -void s390_cpu_do_interrupt(CPUState *cs) -{ - S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; - - qemu_log_mask(CPU_LOG_INT, "%s: %d at pc=3D%" PRIx64 "\n", - __func__, cs->exception_index, env->psw.addr); - - s390_cpu_set_state(CPU_STATE_OPERATING, cpu); - /* handle machine checks */ - if ((env->psw.mask & PSW_MASK_MCHECK) && - (cs->exception_index =3D=3D -1)) { - if (env->pending_int & INTERRUPT_MCHK) { - cs->exception_index =3D EXCP_MCHK; - } - } - /* 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; - } - } - /* handle I/O interrupts */ - if ((env->psw.mask & PSW_MASK_IO) && - (cs->exception_index =3D=3D -1)) { - if (env->pending_int & INTERRUPT_IO) { - cs->exception_index =3D EXCP_IO; - } - } - - switch (cs->exception_index) { - case EXCP_PGM: - do_program_interrupt(env); - break; - case EXCP_SVC: - do_svc_interrupt(env); - break; - case EXCP_EXT: - do_ext_interrupt(env); - break; - case EXCP_IO: - do_io_interrupt(env); - break; - case EXCP_MCHK: - do_mchk_interrupt(env); - break; - } - cs->exception_index =3D -1; - - if (!env->pending_int) { - cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; - } -} - -bool s390_cpu_exec_interrupt(CPUState *cs, int interrupt_request) -{ - if (interrupt_request & CPU_INTERRUPT_HARD) { - S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; - - if (env->ex_value) { - /* Execution of the target insn is indivisible from - the parent EXECUTE insn. */ - return false; - } - if (env->psw.mask & PSW_MASK_EXT) { - s390_cpu_do_interrupt(cs); - return true; - } - } - return false; -} - void s390_cpu_recompute_watchpoints(CPUState *cs) { const int wp_flags =3D BP_CPU | BP_MEM_WRITE | BP_STOP_BEFORE_ACCESS; @@ -710,51 +291,6 @@ void s390_cpu_recompute_watchpoints(CPUState *cs) } } =20 -void s390x_cpu_debug_excp_handler(CPUState *cs) -{ - S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; - CPUWatchpoint *wp_hit =3D cs->watchpoint_hit; - - if (wp_hit && wp_hit->flags & BP_CPU) { - /* FIXME: When the storage-alteration-space control bit is set, - the exception should only be triggered if the memory access - is done using an address space with the storage-alteration-event - bit set. We have no way to detect that with the current - watchpoint code. */ - cs->watchpoint_hit =3D NULL; - - env->per_address =3D env->psw.addr; - env->per_perc_atmid |=3D PER_CODE_EVENT_STORE | get_per_atmid(env); - /* FIXME: We currently no way to detect the address space used - to trigger the watchpoint. For now just consider it is the - current default ASC. This turn to be true except when MVCP - and MVCS instrutions are not used. */ - env->per_perc_atmid |=3D env->psw.mask & (PSW_MASK_ASC) >> 46; - - /* Remove all watchpoints to re-execute the code. A PER exception - will be triggered, it will call load_psw which will recompute - the watchpoints. */ - cpu_watchpoint_remove_all(cs, BP_CPU); - cpu_loop_exit_noexc(cs); - } -} - -/* Unaligned accesses are only diagnosed with MO_ALIGN. At the moment, - this is only for the atomic operations, for which we want to raise a - specification exception. */ -void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, - MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr) -{ - S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; - - if (retaddr) { - cpu_restore_state(cs, retaddr); - } - program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); -} #endif /* CONFIG_USER_ONLY */ =20 void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976324938229.20115847419595; Tue, 25 Jul 2017 02:52:04 -0700 (PDT) Received: from localhost ([::1]:59532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwVX-0002Bf-C4 for importer@patchew.org; Tue, 25 Jul 2017 05:52:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwLA-0002IN-LK for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwL8-0003u9-Ap for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55618) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwL8-0003sx-4A for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13FEDC0587C1; Tue, 25 Jul 2017 09:41:17 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A8A529174B; Tue, 25 Jul 2017 09:41:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13FEDC0587C1 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:25 +0200 Message-Id: <20170725094026.5376-14-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 25 Jul 2017 09:41: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] [PULL for-2.10 13/14] target/s390x: Add remaining switches to compile with --disable-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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, rth@twiddle.net 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" From: Thomas Huth Adding some CONFIG_TCG tests to be finally able to compile QEMU on s390x also without TCG. Reviewed-by: Richard Henderson Signed-off-by: Thomas Huth Message-Id: <1500886370-14572-6-git-send-email-thuth@redhat.com> Signed-off-by: Cornelia Huck --- target/s390x/Makefile.objs | 6 +++--- target/s390x/cpu.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/target/s390x/Makefile.objs b/target/s390x/Makefile.objs index cc2b4c9257..f42cd1f9cc 100644 --- a/target/s390x/Makefile.objs +++ b/target/s390x/Makefile.objs @@ -1,6 +1,6 @@ -obj-y +=3D translate.o helper.o cpu.o interrupt.o -obj-y +=3D int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o -obj-y +=3D gdbstub.o cpu_models.o cpu_features.o excp_helper.o +obj-y +=3D cpu.o cpu_models.o cpu_features.o gdbstub.o interrupt.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_KVM) +=3D kvm.o =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index accef03234..489bc25334 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -417,7 +417,9 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->reset =3D s390_cpu_full_reset; cc->class_by_name =3D s390_cpu_class_by_name, cc->has_work =3D s390_cpu_has_work; +#ifdef CONFIG_TCG cc->do_interrupt =3D s390_cpu_do_interrupt; +#endif cc->dump_state =3D s390_cpu_dump_state; cc->set_pc =3D s390_cpu_set_pc; cc->gdb_read_register =3D s390_cpu_gdb_read_register; @@ -428,10 +430,12 @@ static void s390_cpu_class_init(ObjectClass *oc, void= *data) cc->get_phys_page_debug =3D s390_cpu_get_phys_page_debug; cc->vmsd =3D &vmstate_s390_cpu; cc->write_elf64_note =3D s390_cpu_write_elf64_note; +#ifdef CONFIG_TCG cc->cpu_exec_interrupt =3D s390_cpu_exec_interrupt; cc->debug_excp_handler =3D s390x_cpu_debug_excp_handler; cc->do_unaligned_access =3D s390x_cpu_do_unaligned_access; #endif +#endif cc->disas_set_info =3D s390_cpu_disas_set_info; =20 cc->gdb_num_core_regs =3D S390_NUM_CORE_REGS; --=20 2.13.3 From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500976311544586.9016615474956; Tue, 25 Jul 2017 02:51:51 -0700 (PDT) Received: from localhost ([::1]:59531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwVJ-0001yC-6R for importer@patchew.org; Tue, 25 Jul 2017 05:51:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZwLF-0002MG-AR for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZwLD-0003yG-VK for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55836) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZwLD-0003xd-Li for qemu-devel@nongnu.org; Tue, 25 Jul 2017 05:41:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81391C058EC2; Tue, 25 Jul 2017 09:41:22 +0000 (UTC) Received: from localhost (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBEE360602; Tue, 25 Jul 2017 09:41:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 81391C058EC2 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=pass smtp.mailfrom=cohuck@redhat.com From: Cornelia Huck To: peter.maydell@linaro.org Date: Tue, 25 Jul 2017 11:40:26 +0200 Message-Id: <20170725094026.5376-15-cohuck@redhat.com> In-Reply-To: <20170725094026.5376-1-cohuck@redhat.com> References: <20170725094026.5376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 25 Jul 2017 09:41:22 +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] [PULL for-2.10 14/14] s390x/css: fix ilen in IO instruction handlers 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: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, Halil Pasic , rth@twiddle.net 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" From: Halil Pasic When initiating a program check interruption by calling program_interrupt the instruction length (ilen) of the current instruction is supplied as the third parameter. On s390x all the IO instructions are of instruction format S and their ilen is 4. The calls to program_interrupt (introduced by commits 7b18aad543 ("s390: Add channel I/O instructions.", 2013-01-24) and 61bf0dcb2e ("s390x/ioinst: Add missing alignment checks for IO instructions", 2013-06-21)) however use ilen =3D=3D 2. This is probably due to a confusion between ilen which specifies the instruction length in bytes and ILC which does the same but in halfwords. If kvm_enabled() this does not actually matter, because the ilen parameter of program_interrupt is effectively unused. Let's provide the correct ilen to program_interrupt. Signed-off-by: Halil Pasic Fixes: 7b18aad543 ("s390: Add channel I/O instructions.") Fixes: 61bf0dcb2e ("s390x/ioinst: Add missing alignment checks for IO instr= uctions") Reviewed-by: David Hildenbrand Message-Id: <20170724143452.55534-1-pasic@linux.vnet.ibm.com> Reviewed-by: Dong Jia Shi Signed-off-by: Cornelia Huck --- target/s390x/ioinst.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index d5e6b8066b..51fbea620d 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -45,7 +45,7 @@ void ioinst_handle_xsch(S390CPU *cpu, uint64_t reg1) int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(&cpu->env, PGM_OPERAND, 2); + program_interrupt(&cpu->env, PGM_OPERAND, 4); return; } trace_ioinst_sch_id("xsch", cssid, ssid, schid); @@ -78,7 +78,7 @@ void ioinst_handle_csch(S390CPU *cpu, uint64_t reg1) int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(&cpu->env, PGM_OPERAND, 2); + program_interrupt(&cpu->env, PGM_OPERAND, 4); return; } trace_ioinst_sch_id("csch", cssid, ssid, schid); @@ -102,7 +102,7 @@ void ioinst_handle_hsch(S390CPU *cpu, uint64_t reg1) int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(&cpu->env, PGM_OPERAND, 2); + program_interrupt(&cpu->env, PGM_OPERAND, 4); return; } trace_ioinst_sch_id("hsch", cssid, ssid, schid); @@ -153,7 +153,7 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, ui= nt32_t ipb) =20 addr =3D decode_basedisp_s(env, ipb, &ar); if (addr & 3) { - program_interrupt(env, PGM_SPECIFICATION, 2); + program_interrupt(env, PGM_SPECIFICATION, 4); return; } if (s390_cpu_virt_mem_read(cpu, addr, ar, &schib, sizeof(schib))) { @@ -161,7 +161,7 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, ui= nt32_t ipb) } if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) || !ioinst_schib_valid(&schib)) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return; } trace_ioinst_sch_id("msch", cssid, ssid, schid); @@ -224,7 +224,7 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, ui= nt32_t ipb) =20 addr =3D decode_basedisp_s(env, ipb, &ar); if (addr & 3) { - program_interrupt(env, PGM_SPECIFICATION, 2); + program_interrupt(env, PGM_SPECIFICATION, 4); return; } if (s390_cpu_virt_mem_read(cpu, addr, ar, &orig_orb, sizeof(orb))) { @@ -233,7 +233,7 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, ui= nt32_t ipb) copy_orb_from_guest(&orb, &orig_orb); if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) || !ioinst_orb_valid(&orb)) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return; } trace_ioinst_sch_id("ssch", cssid, ssid, schid); @@ -277,7 +277,7 @@ void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb) =20 addr =3D decode_basedisp_s(env, ipb, &ar); if (addr & 3) { - program_interrupt(env, PGM_SPECIFICATION, 2); + program_interrupt(env, PGM_SPECIFICATION, 4); return; } =20 @@ -304,7 +304,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, u= int32_t ipb) =20 addr =3D decode_basedisp_s(env, ipb, &ar); if (addr & 3) { - program_interrupt(env, PGM_SPECIFICATION, 2); + program_interrupt(env, PGM_SPECIFICATION, 4); return; } =20 @@ -315,7 +315,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, u= int32_t ipb) * access execption if it is not) first. */ if (!s390_cpu_virt_mem_check_write(cpu, addr, ar, sizeof(schib))) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); } return; } @@ -363,13 +363,13 @@ int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, u= int32_t ipb) uint8_t ar; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return -EIO; } trace_ioinst_sch_id("tsch", cssid, ssid, schid); addr =3D decode_basedisp_s(env, ipb, &ar); if (addr & 3) { - program_interrupt(env, PGM_SPECIFICATION, 2); + program_interrupt(env, PGM_SPECIFICATION, 4); return -EIO; } =20 @@ -659,7 +659,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) addr =3D env->regs[reg]; /* Page boundary? */ if (addr & 0xfff) { - program_interrupt(env, PGM_SPECIFICATION, 2); + program_interrupt(env, PGM_SPECIFICATION, 4); return; } /* @@ -674,7 +674,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) len =3D be16_to_cpu(req->len); /* Length field valid? */ if ((len < 16) || (len > 4088) || (len & 7)) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return; } memset((char *)req + len, 0, TARGET_PAGE_SIZE - len); @@ -718,7 +718,7 @@ int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb) trace_ioinst("tpi"); addr =3D decode_basedisp_s(env, ipb, &ar); if (addr & 3) { - program_interrupt(env, PGM_SPECIFICATION, 2); + program_interrupt(env, PGM_SPECIFICATION, 4); return -EIO; } =20 @@ -747,7 +747,7 @@ void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, ui= nt64_t reg2, trace_ioinst("schm"); =20 if (SCHM_REG1_RES(reg1)) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return; } =20 @@ -756,7 +756,7 @@ void ioinst_handle_schm(S390CPU *cpu, uint64_t reg1, ui= nt64_t reg2, dct =3D SCHM_REG1_DCT(reg1); =20 if (update && (reg2 & 0x000000000000001f)) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return; } =20 @@ -771,7 +771,7 @@ void ioinst_handle_rsch(S390CPU *cpu, uint64_t reg1) int cc; =20 if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(&cpu->env, PGM_OPERAND, 2); + program_interrupt(&cpu->env, PGM_OPERAND, 4); return; } trace_ioinst_sch_id("rsch", cssid, ssid, schid); @@ -808,7 +808,7 @@ void ioinst_handle_rchp(S390CPU *cpu, uint64_t reg1) CPUS390XState *env =3D &cpu->env; =20 if (RCHP_REG1_RES(reg1)) { - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return; } =20 @@ -831,7 +831,7 @@ void ioinst_handle_rchp(S390CPU *cpu, uint64_t reg1) break; default: /* Invalid channel subsystem. */ - program_interrupt(env, PGM_OPERAND, 2); + program_interrupt(env, PGM_OPERAND, 4); return; } setcc(cpu, cc); @@ -842,6 +842,6 @@ void ioinst_handle_sal(S390CPU *cpu, uint64_t reg1) { /* We do not provide address limit checking, so let's suppress it. */ if (SAL_REG1_INVALID(reg1) || reg1 & 0x000000000000ffff) { - program_interrupt(&cpu->env, PGM_OPERAND, 2); + program_interrupt(&cpu->env, PGM_OPERAND, 4); } } --=20 2.13.3