From nobody Mon Feb 9 00:49:14 2026 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.zoho.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 1496773877836305.71502377269826; Tue, 6 Jun 2017 11:31:17 -0700 (PDT) Received: from localhost ([::1]:39671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJG8-0007bn-9n for importer@patchew.org; Tue, 06 Jun 2017 14:31:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJEP-0006M9-F4 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIJEK-00032S-HL for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIJEK-000323-7q for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:24 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v56IT73x068512 for ; Tue, 6 Jun 2017 14:29:22 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2awynhxd2c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 06 Jun 2017 14:29:22 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Jun 2017 19:29:20 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Jun 2017 19:29:18 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v56ITIgu18678060; Tue, 6 Jun 2017 18:29:18 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C09D552041; Tue, 6 Jun 2017 18:26:09 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id A222B5203F; Tue, 6 Jun 2017 18:26:09 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id A65EF20F677; Tue, 6 Jun 2017 20:29:17 +0200 (CEST) From: Christian Borntraeger To: Peter Maydell Date: Tue, 6 Jun 2017 20:29:11 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> References: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060618-0040-0000-0000-000003C31B38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060618-0041-0000-0000-0000205AEFB7 Message-Id: <1496773755-53343-2-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-06_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706060316 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 1/5] s390x/css: catch section mismatch on load 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: Alexander Graf , Halil Pasic , qemu-devel , qemu-stable@nongnu.org, Christian Borntraeger , Cornelia Huck , Richard Henderson 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 Prior to the virtio-ccw-2.7 machine (and commit 2a79eb1a), our virtio devices residing under the virtual-css bus do not have qdev_path based migration stream identifiers (because their qdev_path is NULL). The ids are instead generated when the device is registered as a composition of the so called idstr, which takes the vmsd name as its value, and an instance_id, which is which is calculated as a maximal instance_id registered with the same idstr plus one, or zero (if none was registered previously). That means, under certain circumstances, one device might try, and even succeed, to load the state of a different device. This can lead to trouble. Let us fail the migration if the above problem is detected during load. How to reproduce the problem: 1) start qemu-system-s390x making sure you have the following devices defined on your command line: -device virtio-rng-ccw,id=3Drng1,devno=3Dfe.0.0001 -device virtio-rng-ccw,id=3Drng2,devno=3Dfe.0.0002 2) detach the devices and reattach in reverse order using the monitor: (qemu) device_del rng1 (qemu) device_del rng2 (qemu) device_add virtio-rng-ccw,id=3Drng2,devno=3Dfe.0.0002 (qemu) device_add virtio-rng-ccw,id=3Drng1,devno=3Dfe.0.0001 3) save the state of the vm into a temporary file and quit QEMU: (qemu) migrate "exec:gzip -c > /tmp/tmp_vmstate.gz" (qemu) q 4) use your command line from step 1 with -incoming "exec:gzip -c -d /tmp/tmp_vmstate.gz" appended to reproduce the problem (while trying to to load the saved vm) CC: qemu-stable@nongnu.org Signed-off-by: Halil Pasic Reviewed-by: Dong Jia Shi Reviewed-by: Cornelia Huck Message-Id: <20170518111405.56947-1-pasic@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger --- hw/s390x/css.c | 14 ++++++++++++++ hw/s390x/virtio-ccw.c | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 1e2f26b..cc76c53 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -15,6 +15,7 @@ #include "hw/qdev.h" #include "qemu/error-report.h" #include "qemu/bitops.h" +#include "qemu/error-report.h" #include "exec/address-spaces.h" #include "cpu.h" #include "hw/s390x/ioinst.h" @@ -1800,13 +1801,26 @@ void subch_device_save(SubchDev *s, QEMUFile *f) int subch_device_load(SubchDev *s, QEMUFile *f) { SubchDev *old_s; + Error *err =3D NULL; uint16_t old_schid =3D s->schid; + uint16_t old_devno =3D s->devno; int i; =20 s->cssid =3D qemu_get_byte(f); s->ssid =3D qemu_get_byte(f); s->schid =3D qemu_get_be16(f); s->devno =3D qemu_get_be16(f); + if (s->devno !=3D old_devno) { + /* Only possible if machine < 2.7 (no css_dev_path) */ + + error_setg(&err, "%x !=3D %x", old_devno, s->devno); + error_append_hint(&err, "Devno mismatch, tried to load wrong secti= on!" + " Likely reason: some sequences of plug and unpl= ug" + " can break migration for machine versions prior= to" + " 2.7 (known design flaw).\n"); + error_report_err(err); + return -EINVAL; + } /* Re-assign subch. */ if (old_schid !=3D s->schid) { old_s =3D channel_subsys.css[s->cssid]->sch_set[s->ssid]->sch[old_= schid]; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index e6a6f74..90d37cb 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1279,9 +1279,13 @@ static int virtio_ccw_load_config(DeviceState *d, QE= MUFile *f) SubchDev *s =3D ccw_dev->sch; VirtIODevice *vdev =3D virtio_ccw_get_vdev(s); int len; + int ret; =20 s->driver_data =3D dev; - subch_device_load(s, f); + ret =3D subch_device_load(s, f); + if (ret) { + return ret; + } /* Re-fill subch_id after loading the subchannel states.*/ if (ck->refill_ids) { ck->refill_ids(ccw_dev); --=20 2.7.4 From nobody Mon Feb 9 00:49:14 2026 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.zoho.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 1496774038611318.43908325647726; Tue, 6 Jun 2017 11:33:58 -0700 (PDT) Received: from localhost ([::1]:39680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJIi-0001Wo-OC for importer@patchew.org; Tue, 06 Jun 2017 14:33:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJEQ-0006Mz-Cy for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIJEL-00033N-Pk for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34042 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIJEL-00032x-J8 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:25 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v56IT4ZC049019 for ; Tue, 6 Jun 2017 14:29:24 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ax0374nqc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 06 Jun 2017 14:29:23 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Jun 2017 19:29:21 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Jun 2017 19:29:18 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v56ITI667274880; Tue, 6 Jun 2017 18:29:18 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D5F911C04C; Tue, 6 Jun 2017 19:27:27 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3CB5D11C04A; Tue, 6 Jun 2017 19:27:27 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 6 Jun 2017 19:27:27 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 0CAAB20F677; Tue, 6 Jun 2017 20:29:18 +0200 (CEST) From: Christian Borntraeger To: Peter Maydell Date: Tue, 6 Jun 2017 20:29:12 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> References: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060618-0012-0000-0000-000005461D79 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060618-0013-0000-0000-000018B4FB7F Message-Id: <1496773755-53343-3-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-06_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706060316 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 2/5] s390x/css: fence off MIDA 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: Cornelia Huck , Christian Borntraeger , Richard Henderson , qemu-devel , Alexander Graf 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: Cornelia Huck MIDA (modified indirect data addressing) is an optional facility, and we (currently) don't support it. Let's post an operand exception if the guest tries to set it in the orb and a channel program check if it is set in a ccw, as specified in the Principles of Operation. Reviewed-by: Claudio Imbrenda Reviewed-by: Halil Pasic Signed-off-by: Cornelia Huck Signed-off-by: Christian Borntraeger --- hw/s390x/css.c | 5 +++++ include/hw/s390x/ioinst.h | 1 + target/s390x/ioinst.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index cc76c53..599805d 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -433,6 +433,11 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr ccw= _addr, return -EINVAL; } =20 + /* We don't support MIDA. */ + if (ccw.flags & CCW_FLAG_MIDA) { + return -EINVAL; + } + if (ccw.flags & CCW_FLAG_SUSPEND) { return suspend_allowed ? -EINPROGRESS : -EINVAL; } diff --git a/include/hw/s390x/ioinst.h b/include/hw/s390x/ioinst.h index c559f53..92d1565 100644 --- a/include/hw/s390x/ioinst.h +++ b/include/hw/s390x/ioinst.h @@ -182,6 +182,7 @@ typedef struct CCW1 { #define CCW_FLAG_PCI 0x08 #define CCW_FLAG_IDA 0x04 #define CCW_FLAG_SUSPEND 0x02 +#define CCW_FLAG_MIDA 0x01 =20 #define CCW_CMD_NOOP 0x03 #define CCW_CMD_BASIC_SENSE 0x04 diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index 62a7771..d5e6b80 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -201,6 +201,10 @@ static int ioinst_orb_valid(ORB *orb) (orb->ctrl1 & ORB_CTRL1_MASK_INVALID)) { return 0; } + /* We don't support MIDA. */ + if (orb->ctrl1 & ORB_CTRL1_MASK_MIDAW) { + return 0; + } if ((orb->cpa & HIGH_ORDER_BIT) !=3D 0) { return 0; } --=20 2.7.4 From nobody Mon Feb 9 00:49:14 2026 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.zoho.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 1496774587679709.1943017513088; Tue, 6 Jun 2017 11:43:07 -0700 (PDT) Received: from localhost ([::1]:39720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJRZ-0000nl-U4 for importer@patchew.org; Tue, 06 Jun 2017 14:43:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJEQ-0006Mv-At for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIJEL-000331-BM for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38047 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIJEL-00032b-4d for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:25 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v56IT3sm025420 for ; Tue, 6 Jun 2017 14:29:24 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ax1derres-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 06 Jun 2017 14:29:24 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Jun 2017 19:29:22 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Jun 2017 19:29:19 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v56ITIZS7274884; Tue, 6 Jun 2017 18:29:18 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC65CAE04D; Tue, 6 Jun 2017 19:26:49 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC401AE045; Tue, 6 Jun 2017 19:26:49 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 6 Jun 2017 19:26:49 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 66CFA20F677; Tue, 6 Jun 2017 20:29:18 +0200 (CEST) From: Christian Borntraeger To: Peter Maydell Date: Tue, 6 Jun 2017 20:29:13 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> References: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060618-0040-0000-0000-000003A31F7B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060618-0041-0000-0000-0000259AF337 Message-Id: <1496773755-53343-4-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-06_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706060316 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 3/5] pc-bios/s390-ccw: use STRIP variable in Makefile 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: Alexander Graf , Greg Kurz , qemu-devel , Christian Borntraeger , Cornelia Huck , Richard Henderson 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: Greg Kurz The docker-run-test-build@debian-s390x-cross target fails with: strip --strip-unneeded s390-ccw.elf -o s390-ccw.img strip: Unable to recognise the format of the input file `s390-ccw.elf' The configure script defines a STRIP makefile variable whose default value is ${cross_prefix}strip. Let's use it. We default to using the non-prefixed strip command in case --enable-debug or --disable-strip was passed to configure during a regular build. Signed-off-by: Greg Kurz Message-Id: <149623617700.4947.12490877660892961664.stgit@bahia.lan> Reviewed-by: Laurent Vivier Reviewed-by: Fam Zheng Signed-off-by: Christian Borntraeger --- pc-bios/s390-ccw/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile index 79a46b6..fb88c13 100644 --- a/pc-bios/s390-ccw/Makefile +++ b/pc-bios/s390-ccw/Makefile @@ -21,8 +21,10 @@ build-all: s390-ccw.img s390-ccw.elf: $(OBJECTS) $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),"BUILD","$(TARGET_= DIR)$@") =20 +STRIP ?=3D strip + s390-ccw.img: s390-ccw.elf - $(call quiet-command,strip --strip-unneeded $< -o $@,"STRIP","$(TARGET_DI= R)$@") + $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@,"STRIP","$(TARGET= _DIR)$@") =20 $(OBJECTS): Makefile =20 --=20 2.7.4 From nobody Mon Feb 9 00:49:14 2026 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.zoho.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 1496774297289610.5472040095182; Tue, 6 Jun 2017 11:38:17 -0700 (PDT) Received: from localhost ([::1]:39700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJMt-0005l1-SC for importer@patchew.org; Tue, 06 Jun 2017 14:38:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJES-0006PN-Az for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIJEN-00034W-RJ for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:32 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38850) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIJEN-000343-Hb for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:27 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v56IT5C7115921 for ; Tue, 6 Jun 2017 14:29:25 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2aww80y4vf-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 06 Jun 2017 14:29:25 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Jun 2017 19:29:22 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Jun 2017 19:29:19 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v56ITJAD2884086; Tue, 6 Jun 2017 18:29:19 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94E274C044; Tue, 6 Jun 2017 19:27:39 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FAE64C040; Tue, 6 Jun 2017 19:27:39 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 6 Jun 2017 19:27:39 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id C636F20F677; Tue, 6 Jun 2017 20:29:18 +0200 (CEST) From: Christian Borntraeger To: Peter Maydell Date: Tue, 6 Jun 2017 20:29:14 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> References: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060618-0008-0000-0000-000004601E0A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060618-0009-0000-0000-00001DE7EF27 Message-Id: <1496773755-53343-5-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-06_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706060316 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 4/5] s390x/cpumodel: take care of the cpuid format bit for KVM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand , qemu-devel , Alexander Graf , Christian Borntraeger , Cornelia Huck , Richard Henderson 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 Let's also properly forward that bit. It should always be set. I verified it under z/VM, it seems to be always set there. For now, zKVM guests never get that bit set when the CPU model is active. The PoP mentiones, that z800 + z900 (HW generation 7) always set this bit to 0, so let's take care of that. Signed-off-by: David Hildenbrand Message-Id: <20170531193434.6918-2-david@redhat.com> Acked-by: Jason J. Herne Signed-off-by: Christian Borntraeger --- target/s390x/cpu_models.c | 1 + target/s390x/cpu_models.h | 10 +++++++--- target/s390x/kvm.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8d27363..9e23535 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -740,6 +740,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) /* copy over properties that can vary */ cpu->model->lowest_ibc =3D max_model->lowest_ibc; cpu->model->cpu_id =3D max_model->cpu_id; + cpu->model->cpu_id_format =3D max_model->cpu_id_format; cpu->model->cpu_ver =3D max_model->cpu_ver; =20 check_consistency(cpu->model); diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index 136a602..d41f8d6 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -46,6 +46,7 @@ typedef struct S390CPUModel { /* values copied from the "host" model, can change during migration */ uint16_t lowest_ibc; /* lowest IBC that the hardware supports */ uint32_t cpu_id; /* CPU id */ + uint8_t cpu_id_format; /* CPU id format bit */ uint8_t cpu_ver; /* CPU version, usually "ff" for kvm */ } S390CPUModel; =20 @@ -54,12 +55,14 @@ typedef struct S390CPUModel { * * bits 0-7: Zeroes (ff for kvm) * bits 8-31: CPU ID (serial number) - * bits 32-48: Machine type - * bits 48-63: Zeroes + * bits 32-47: Machine type + * bit 48: CPU ID format + * bits 49-63: Zeroes */ #define cpuid_type(x) (((x) >> 16) & 0xffff) #define cpuid_id(x) (((x) >> 32) & 0xffffff) #define cpuid_ver(x) (((x) >> 56) & 0xff) +#define cpuid_format(x) (((x) >> 15) & 0x1) =20 #define lowest_ibc(x) (((uint32_t)(x) >> 16) & 0xfff) #define unblocked_ibc(x) ((uint32_t)(x) & 0xfff) @@ -92,7 +95,8 @@ static inline uint64_t s390_cpuid_from_cpu_model(const S3= 90CPUModel *model) { return ((uint64_t)model->cpu_ver << 56) | ((uint64_t)model->cpu_id << 32) | - ((uint64_t)model->def->type << 16); + ((uint64_t)model->def->type << 16) | + (model->def->gen =3D=3D 7 ? 0 : (uint64_t)model->cpu_id_format = << 15); } S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec= _ga, S390FeatBitmap features); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index ba1e60f..a3d0019 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2580,6 +2580,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) unblocked_ibc =3D unblocked_ibc(prop.ibc); } model->cpu_id =3D cpuid_id(prop.cpuid); + model->cpu_id_format =3D cpuid_format(prop.cpuid); model->cpu_ver =3D 0xff; =20 /* get supported cpu features indicated via STFL(E) */ --=20 2.7.4 From nobody Mon Feb 9 00:49:14 2026 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.zoho.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 1496774176955811.147426910528; Tue, 6 Jun 2017 11:36:16 -0700 (PDT) Received: from localhost ([::1]:39694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJKx-0003Zm-Hu for importer@patchew.org; Tue, 06 Jun 2017 14:36:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJER-0006OV-PT for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIJEM-00034A-SG for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:31 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIJEM-00033R-IG for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:29:26 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v56IT4Mb109493 for ; Tue, 6 Jun 2017 14:29:25 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2aww9sf3pq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 06 Jun 2017 14:29:25 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 6 Jun 2017 19:29:22 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 6 Jun 2017 19:29:20 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v56ITJNb37421126; Tue, 6 Jun 2017 18:29:19 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF04F4C044; Tue, 6 Jun 2017 19:27:39 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DEB104C040; Tue, 6 Jun 2017 19:27:39 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 6 Jun 2017 19:27:39 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id 3139120F677; Tue, 6 Jun 2017 20:29:19 +0200 (CEST) From: Christian Borntraeger To: Peter Maydell Date: Tue, 6 Jun 2017 20:29:15 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> References: <1496773755-53343-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17060618-0016-0000-0000-000004B61FAE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17060618-0017-0000-0000-000027E5FA32 Message-Id: <1496773755-53343-6-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-06_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706060316 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 5/5] s390x/cpumodel: improve defintion search without an IBC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Hildenbrand , qemu-devel , Alexander Graf , Christian Borntraeger , Cornelia Huck , Richard Henderson 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 Currently, under z/VM on a 0x2827, QEMU will detect a 0x2828 if no IBC value is provided. QEMU will simply take the last model of that HW generation, which happens to be the BC version. Let's improve our search for that case by selecting the latest CPU definition that matches the CPU type. This for example will avoid detecting an z13 as a z13s. We might still detect a GA2 version on a GA1 system, but as we don't have further information at hand, there isn't too much we can do about it. The alternative of always presenting the oldest GA is not backward compatible, e.g: You're running on 0x2827 GA2. Old QEMU version indicated "0x2828 GA1 =3D=3D 0x2827 GA2". After you updated QEMU, you suddenly detect "0x2827 GA1". You're previous libvirt guest might suddenly refuse to run. In the end presenting a newer GA level does not matter because: 1: All GAX models share the same base feature set. A GAX++ might support "more features". 2: Without an IBC, the guest can't detect the GA version. If we have no IBC (esp. unblocked_ibc =3D=3D 0), the IBC we will present to the guest in read_SCP_info() will be 0. The guest will not know which GA version it has. The problem of missing IBC propagates. If we don't have a feature of the GA++ version, also our guest won't have it. So in summary, the guest also has no idea of its GA version. Signed-off-by: David Hildenbrand Message-Id: <20170531193434.6918-3-david@redhat.com> Acked-by: Jason J. Herne Reviewed-by: Halil Pasic Signed-off-by: Christian Borntraeger [improve patch description by reusing mailing list discussion] --- target/s390x/cpu_models.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 9e23535..b6220c8 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -184,6 +184,7 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint= 8_t gen, uint8_t ec_ga, S390FeatBitmap features) { const S390CPUDef *last_compatible =3D NULL; + const S390CPUDef *matching_cpu_type =3D NULL; int i; =20 if (!gen) { @@ -218,8 +219,16 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uin= t8_t gen, uint8_t ec_ga, if (def->type =3D=3D type && def->ec_ga =3D=3D ec_ga) { return def; } + /* remember if we've at least seen one with the same cpu type */ + if (def->type =3D=3D type) { + matching_cpu_type =3D def; + } last_compatible =3D def; } + /* prefer the model with the same cpu type, esp. don't take the BC for= EC */ + if (matching_cpu_type) { + return matching_cpu_type; + } return last_compatible; } =20 --=20 2.7.4