From nobody Sun May 5 09:09:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522941109256802.5614167004725; Thu, 5 Apr 2018 08:11:49 -0700 (PDT) Received: from localhost ([::1]:35823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f46YG-0004XH-FS for importer@patchew.org; Thu, 05 Apr 2018 11:11:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f46UE-0001R6-LM for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f46U8-0007we-IO for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57794 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 1f46U8-0007vl-Cl for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:32 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w35F3JdT144709 for ; Thu, 5 Apr 2018 11:07:31 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2h5nuu9b8m-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 05 Apr 2018 11:07:31 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Apr 2018 16:07:28 +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; Thu, 5 Apr 2018 16:07:26 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w35F7PZD52953114; Thu, 5 Apr 2018 15:07:25 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C571A4051; Thu, 5 Apr 2018 15:59:51 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C27E3A4059; Thu, 5 Apr 2018 15:59:50 +0100 (BST) Received: from bradbury.ibm.com (unknown [9.152.222.211]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Apr 2018 15:59:50 +0100 (BST) From: Viktor Mihajlovski To: cohuck@redhat.com, borntraeger@de.ibm.com, agraf@suse.de, rth@twiddle.net, david@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 17:07:22 +0200 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522940844-12336-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1522940844-12336-1-git-send-email-mihajlov@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18040515-0044-0000-0000-00000543DEF9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040515-0045-0000-0000-00002883FC69 Message-Id: <1522940844-12336-2-git-send-email-mihajlov@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-04-05_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804050157 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 1/3] s390: Refactor IPL parameter block generation 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: qemu-s390x@nongnu.org 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" Splitting out the the CCW device extraction allows reuse. Signed-off-by: Viktor Mihajlovski Reviewed-by: Farhan Ali Reviewed-by: Thomas Huth --- hw/s390x/ipl.c | 81 ++++++++++++++++++++++++++++++++++++------------------= ---- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index fdeaec3..58e33c5 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -279,44 +279,52 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl) *timeout =3D cpu_to_be32(splash_time); } =20 +static CcwDevice *s390_get_ccw_device(DeviceState *dev_st) +{ + CcwDevice *ccw_dev =3D NULL; + + if (dev_st) { + VirtioCcwDevice *virtio_ccw_dev =3D (VirtioCcwDevice *) + object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent= ), + TYPE_VIRTIO_CCW_DEVICE); + if (virtio_ccw_dev) { + ccw_dev =3D CCW_DEVICE(virtio_ccw_dev); + } else { + SCSIDevice *sd =3D (SCSIDevice *) + object_dynamic_cast(OBJECT(dev_st), + TYPE_SCSI_DEVICE); + if (sd) { + SCSIBus *bus =3D scsi_bus_from_device(sd); + VirtIOSCSI *vdev =3D container_of(bus, VirtIOSCSI, bus); + VirtIOSCSICcw *scsi_ccw =3D container_of(vdev, VirtIOSCSIC= cw, + vdev); + + ccw_dev =3D (CcwDevice *)object_dynamic_cast(OBJECT(scsi_c= cw), + TYPE_CCW_DEVICE= ); + } + } + } + return ccw_dev; +} + static bool s390_gen_initial_iplb(S390IPLState *ipl) { DeviceState *dev_st; + CcwDevice *ccw_dev =3D NULL; =20 dev_st =3D get_boot_device(0); if (dev_st) { - VirtioCcwDevice *virtio_ccw_dev =3D (VirtioCcwDevice *) - object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent= ), - TYPE_VIRTIO_CCW_DEVICE); + ccw_dev =3D s390_get_ccw_device(dev_st); + } + + /* + * Currently allow IPL only from CCW devices. + */ + if (ccw_dev) { SCSIDevice *sd =3D (SCSIDevice *) object_dynamic_cast(OBJECT(dev_s= t), TYPE_SCSI_DEVI= CE); - VirtIONet *vn =3D (VirtIONet *) object_dynamic_cast(OBJECT(dev_st), - TYPE_VIRTIO_NET); - - if (vn) { - ipl->netboot =3D true; - } - if (virtio_ccw_dev) { - CcwDevice *ccw_dev =3D CCW_DEVICE(virtio_ccw_dev); - - ipl->iplb.len =3D cpu_to_be32(S390_IPLB_MIN_CCW_LEN); - ipl->iplb.blk0_len =3D - cpu_to_be32(S390_IPLB_MIN_CCW_LEN - S390_IPLB_HEADER_LEN); - ipl->iplb.pbt =3D S390_IPL_TYPE_CCW; - ipl->iplb.ccw.devno =3D cpu_to_be16(ccw_dev->sch->devno); - ipl->iplb.ccw.ssid =3D ccw_dev->sch->ssid & 3; - } else if (sd) { - SCSIBus *bus =3D scsi_bus_from_device(sd); - VirtIOSCSI *vdev =3D container_of(bus, VirtIOSCSI, bus); - VirtIOSCSICcw *scsi_ccw =3D container_of(vdev, VirtIOSCSICcw, = vdev); - CcwDevice *ccw_dev; - - ccw_dev =3D (CcwDevice *)object_dynamic_cast(OBJECT(scsi_ccw), - TYPE_CCW_DEVICE); - if (!ccw_dev) { /* It might be a PCI device instead */ - return false; - } =20 + if (sd) { ipl->iplb.len =3D cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN); ipl->iplb.blk0_len =3D cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN - S390_IPLB_HEADER= _LEN); @@ -327,12 +335,25 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) ipl->iplb.scsi.devno =3D cpu_to_be16(ccw_dev->sch->devno); ipl->iplb.scsi.ssid =3D ccw_dev->sch->ssid & 3; } else { - return false; /* unknown device */ + VirtIONet *vn =3D (VirtIONet *) object_dynamic_cast(OBJECT(dev= _st), + TYPE_VIRTIO_= NET); + + ipl->iplb.len =3D cpu_to_be32(S390_IPLB_MIN_CCW_LEN); + ipl->iplb.blk0_len =3D + cpu_to_be32(S390_IPLB_MIN_CCW_LEN - S390_IPLB_HEADER_LEN); + ipl->iplb.pbt =3D S390_IPL_TYPE_CCW; + ipl->iplb.ccw.devno =3D cpu_to_be16(ccw_dev->sch->devno); + ipl->iplb.ccw.ssid =3D ccw_dev->sch->ssid & 3; + + if (vn) { + ipl->netboot =3D true; + } } =20 if (!s390_ipl_set_loadparm(ipl->iplb.loadparm)) { ipl->iplb.flags |=3D DIAG308_FLAGS_LP_VALID; } + return true; } =20 --=20 1.9.1 From nobody Sun May 5 09:09:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522940981929576.3235736094884; Thu, 5 Apr 2018 08:09:41 -0700 (PDT) Received: from localhost ([::1]:35655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f46W9-0002jR-Ol for importer@patchew.org; Thu, 05 Apr 2018 11:09:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f46UE-0001RF-Og for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f46UB-0007yd-IY for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f46UB-0007yB-9n for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:35 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w35F6DP4067397 for ; Thu, 5 Apr 2018 11:07:34 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h5jxyaes7-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 05 Apr 2018 11:07:33 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Apr 2018 16:07:31 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Apr 2018 16:07:27 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w35F7Rhd58065074; Thu, 5 Apr 2018 15:07:27 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 60477A405B; Thu, 5 Apr 2018 15:59:52 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16CD1A4059; Thu, 5 Apr 2018 15:59:52 +0100 (BST) Received: from bradbury.ibm.com (unknown [9.152.222.211]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Apr 2018 15:59:52 +0100 (BST) From: Viktor Mihajlovski To: cohuck@redhat.com, borntraeger@de.ibm.com, agraf@suse.de, rth@twiddle.net, david@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 17:07:23 +0200 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522940844-12336-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1522940844-12336-1-git-send-email-mihajlov@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18040515-0008-0000-0000-000004E722E1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040515-0009-0000-0000-00001E7A3935 Message-Id: <1522940844-12336-3-git-send-email-mihajlov@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-04-05_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804050157 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 2/3] s390: Ensure IPL from SCSI works as expected 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: qemu-s390x@nongnu.org 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" Operating systems may request an IPL from a virtio-scsi device by specifying an IPL parameter type of CCW. In this case QEMU won't set up the IPLB correctly. The BIOS will still detect it's a SCSI device to boot from, but it will now have to search for the first LUN and attempt to boot from there. However this may not be the original boot LUN if there's more than one SCSI disk attached to the HBA. With this change QEMU will detect that the request is for a SCSI device and will rebuild the initial IPL parameter info if it's the SCSI device used for the first boot. In consequence the BIOS can use the boot LUN from the IPL information block. In case a different SCSI device has been set, the BIOS will find and use the first available LUN. Signed-off-by: Viktor Mihajlovski Reviewed-by: Farhan Ali Reviewed-by: Thomas Huth --- hw/s390x/ipl.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 58e33c5..fb554ab 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -427,7 +427,8 @@ unref_mr: return img_size; } =20 -static bool is_virtio_net_device(IplParameterBlock *iplb) +static bool is_virtio_ccw_device_of_type(IplParameterBlock *iplb, + int virtio_id) { uint8_t cssid; uint8_t ssid; @@ -447,13 +448,23 @@ static bool is_virtio_net_device(IplParameterBlock *i= plb) sch =3D css_find_subch(1, cssid, ssid, schid); =20 if (sch && sch->devno =3D=3D devno) { - return sch->id.cu_model =3D=3D VIRTIO_ID_NET; + return sch->id.cu_model =3D=3D virtio_id; } } } return false; } =20 +static bool is_virtio_net_device(IplParameterBlock *iplb) +{ + return is_virtio_ccw_device_of_type(iplb, VIRTIO_ID_NET); +} + +static bool is_virtio_scsi_device(IplParameterBlock *iplb) +{ + return is_virtio_ccw_device_of_type(iplb, VIRTIO_ID_SCSI); +} + void s390_ipl_update_diag308(IplParameterBlock *iplb) { S390IPLState *ipl =3D get_ipl_device(); @@ -478,6 +489,22 @@ void s390_reipl_request(void) S390IPLState *ipl =3D get_ipl_device(); =20 ipl->reipl_requested =3D true; + if (ipl->iplb_valid && + !ipl->netboot && + ipl->iplb.pbt =3D=3D S390_IPL_TYPE_CCW && + is_virtio_scsi_device(&ipl->iplb)) { + CcwDevice *ccw_dev =3D s390_get_ccw_device(get_boot_device(0)); + + if (ccw_dev && + cpu_to_be16(ccw_dev->sch->devno) =3D=3D ipl->iplb.ccw.devno && + (ccw_dev->sch->ssid & 3) =3D=3D ipl->iplb.ccw.ssid) { + /* + * this is the original boot device's SCSI + * so restore IPL parameter info from it + */ + ipl->iplb_valid =3D s390_gen_initial_iplb(ipl); + } + } qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); } =20 --=20 1.9.1 From nobody Sun May 5 09:09:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522940978627141.37673551778698; Thu, 5 Apr 2018 08:09:38 -0700 (PDT) Received: from localhost ([::1]:35649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f46W7-0002gt-OX for importer@patchew.org; Thu, 05 Apr 2018 11:09:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f46UF-0001Re-AM for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f46UB-0007yp-Vq for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f46UB-0007yH-MW for qemu-devel@nongnu.org; Thu, 05 Apr 2018 11:07:35 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w35F3ctc088535 for ; Thu, 5 Apr 2018 11:07:34 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2h5jjrbfkw-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 05 Apr 2018 11:07:34 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Apr 2018 16:07:31 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 5 Apr 2018 16:07:29 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w35F7S4q50987106; Thu, 5 Apr 2018 15:07:28 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B21F9A4051; Thu, 5 Apr 2018 15:59:53 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B03FA4053; Thu, 5 Apr 2018 15:59:53 +0100 (BST) Received: from bradbury.ibm.com (unknown [9.152.222.211]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Apr 2018 15:59:53 +0100 (BST) From: Viktor Mihajlovski To: cohuck@redhat.com, borntraeger@de.ibm.com, agraf@suse.de, rth@twiddle.net, david@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org Date: Thu, 5 Apr 2018 17:07:24 +0200 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522940844-12336-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1522940844-12336-1-git-send-email-mihajlov@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18040515-0040-0000-0000-0000042AD8D5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18040515-0041-0000-0000-0000262E1119 Message-Id: <1522940844-12336-4-git-send-email-mihajlov@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-04-05_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804050157 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 3/3] s390: Do not pass inofficial IPL type to the guest 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: qemu-s390x@nongnu.org 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" IPL over a virtio-scsi device requires special handling not available in the real architecture. For this purpose the IPL type 0xFF has been chosen as means of communication between QEMU and the pc-bios. However, a guest OS could be confused by seeing an unknown IPL type. This change sets the IPL parameter type to 0x02 (CCW) to prevent this. Pre-existing Linux has looked up the IPL parameters only in the case of FCP IPL. This means that the behavior should stay the same even if Linux checks for the IPL type unconditionally. Signed-off-by: Viktor Mihajlovski Reviewed-by: Christian Borntraeger --- pc-bios/s390-ccw/bootmap.c | 7 +++++++ pc-bios/s390-ccw/iplb.h | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index fc2a9fe..9287b7a 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -70,6 +70,13 @@ static void jump_to_IPL_code(uint64_t address) { /* store the subsystem information _after_ the bootmap was loaded */ write_subsystem_identification(); + + /* prevent unknown IPL types in the guest */ + if (iplb.pbt =3D=3D S390_IPL_TYPE_QEMU_SCSI) { + iplb.pbt =3D S390_IPL_TYPE_CCW; + set_iplb(&iplb); + } + /* * The IPL PSW is at address 0. We also must not overwrite the * content of non-BIOS memory after we loaded the guest, so we diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 7dfce4f..5357a36 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -97,16 +97,27 @@ extern QemuIplParameters qipl; #define S390_IPL_TYPE_CCW 0x02 #define S390_IPL_TYPE_QEMU_SCSI 0xff =20 -static inline bool store_iplb(IplParameterBlock *iplb) +static inline bool manage_iplb(IplParameterBlock *iplb, bool store) { register unsigned long addr asm("0") =3D (unsigned long) iplb; register unsigned long rc asm("1") =3D 0; =20 asm volatile ("diag %0,%2,0x308\n" : "+d" (addr), "+d" (rc) - : "d" (6) + : "d" (store ? 6 : 5) : "memory", "cc"); return rc =3D=3D 0x01; } =20 + +static inline bool store_iplb(IplParameterBlock *iplb) +{ + return manage_iplb(iplb, true); +} + +static inline bool set_iplb(IplParameterBlock *iplb) +{ + return manage_iplb(iplb, false); +} + #endif /* IPLB_H */ --=20 1.9.1