From nobody Tue Feb 10 09:25:07 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.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15232870784174.9504146051580165; Mon, 9 Apr 2018 08:17:58 -0700 (PDT) Received: from localhost ([::1]:45887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5YYJ-0007Jc-E4 for importer@patchew.org; Mon, 09 Apr 2018 11:17:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5YWI-00061Z-Vq for qemu-devel@nongnu.org; Mon, 09 Apr 2018 11:15:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5YWF-0005Nj-TH for qemu-devel@nongnu.org; Mon, 09 Apr 2018 11:15:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48392 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f5YWF-0005NN-MV; Mon, 09 Apr 2018 11:15:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49E5140201A1; Mon, 9 Apr 2018 15:15:43 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02211D7DFD; Mon, 9 Apr 2018 15:15:42 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Mon, 9 Apr 2018 17:15:27 +0200 Message-Id: <20180409151533.2253-3-cohuck@redhat.com> In-Reply-To: <20180409151533.2253-1-cohuck@redhat.com> References: <20180409151533.2253-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Apr 2018 15:15:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Apr 2018 15:15:43 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL for-2.12 2/8] 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: Thomas Huth , David Hildenbrand , Cornelia Huck , Alexander Graf , qemu-devel@nongnu.org, Christian Borntraeger , qemu-s390x@nongnu.org, Viktor Mihajlovski , 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: Viktor Mihajlovski Splitting out the the CCW device extraction allows reuse. Signed-off-by: Viktor Mihajlovski Message-Id: <1522940844-12336-2-git-send-email-mihajlov@linux.vnet.ibm.com> Reviewed-by: Farhan Ali Reviewed-by: Thomas Huth Signed-off-by: Cornelia Huck --- 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 fdeaec3a58..58e33c5446 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 2.14.3