From nobody Mon Oct 13 23:47:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552319178342654.3583056108354; Mon, 11 Mar 2019 08:46:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:35530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3N80-0000jT-6Z for importer@patchew.org; Mon, 11 Mar 2019 11:46:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Mwa-0005vg-CV for qemu-devel@nongnu.org; Mon, 11 Mar 2019 11:34:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3MkJ-0006oR-6Q for qemu-devel@nongnu.org; Mon, 11 Mar 2019 11:21:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42774 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 1h3MkJ-0006mq-1M for qemu-devel@nongnu.org; Mon, 11 Mar 2019 11:21:43 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2BFGbO9062083 for ; Mon, 11 Mar 2019 11:21:42 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0b-001b2d01.pphosted.com with ESMTP id 2r5sv21a5b-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Mar 2019 11:21:42 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 11 Mar 2019 15:21:41 -0000 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 11 Mar 2019 15:21:37 -0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2BFLZpp13107216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Mar 2019 15:21:35 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44784112069; Mon, 11 Mar 2019 15:21:35 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0CB2A112063; Mon, 11 Mar 2019 15:21:35 +0000 (GMT) Received: from jason-laptop.endicott.ibm.com (unknown [9.60.75.251]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 11 Mar 2019 15:21:34 +0000 (GMT) From: "Jason J. Herne" To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org, cohuck@redhat.com, thuth@redhat.com, pasic@linux.ibm.com, alifm@linux.ibm.com, borntraeger@de.ibm.com Date: Mon, 11 Mar 2019 11:21:19 -0400 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552317693-21979-1-git-send-email-jjherne@linux.ibm.com> References: <1552317693-21979-1-git-send-email-jjherne@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19031115-0040-0000-0000-000004D00AEF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010739; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01172862; UDB=6.00606765; IPR=6.00953516; MB=3.00025928; MTD=3.00000008; XFM=3.00000015; UTC=2019-03-11 15:21:39 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031115-0041-0000-0000-000008DB1EB3 Message-Id: <1552317693-21979-2-git-send-email-jjherne@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-11_12:, , 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903110109 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v4 01/15] s390 vfio-ccw: Add bootindex property and IPLB data 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add bootindex property and iplb data for vfio-ccw devices. This allows us to forward boot information into the bios for vfio-ccw devices. Refactor s390_get_ccw_device() to return device type. This prevents us from having to use messy casting logic in several places. Signed-off-by: Jason J. Herne Acked-by: Halil Pasic Reviewed-by: Cornelia Huck --- MAINTAINERS | 1 + hw/s390x/ipl.c | 61 ++++++++++++++++++++++++++++++++++-------= ---- hw/s390x/s390-ccw.c | 9 +++++++ hw/vfio/ccw.c | 2 +- include/hw/s390x/s390-ccw.h | 1 + include/hw/s390x/vfio-ccw.h | 28 +++++++++++++++++++++ 6 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 include/hw/s390x/vfio-ccw.h diff --git a/MAINTAINERS b/MAINTAINERS index 5040d9d..4801a48 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1430,6 +1430,7 @@ S: Supported F: hw/vfio/ccw.c F: hw/s390x/s390-ccw.c F: include/hw/s390x/s390-ccw.h +F: include/hw/s390x/vfio-ccw.h T: git https://github.com/cohuck/qemu.git s390-next L: qemu-s390x@nongnu.org =20 diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 896888b..2307e5b 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -19,6 +19,7 @@ #include "hw/loader.h" #include "hw/boards.h" #include "hw/s390x/virtio-ccw.h" +#include "hw/s390x/vfio-ccw.h" #include "hw/s390x/css.h" #include "hw/s390x/ebcdic.h" #include "ipl.h" @@ -305,16 +306,36 @@ 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) +#define CCW_DEVTYPE_NONE 0x00 +#define CCW_DEVTYPE_VIRTIO 0x01 +#define CCW_DEVTYPE_VIRTIO_NET 0x02 +#define CCW_DEVTYPE_SCSI 0x03 +#define CCW_DEVTYPE_VFIO 0x04 + +static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) { CcwDevice *ccw_dev =3D NULL; + int tmp_dt =3D CCW_DEVTYPE_NONE; =20 if (dev_st) { + VirtIONet *virtio_net_dev =3D (VirtIONet *) + object_dynamic_cast(OBJECT(dev_st), TYPE_VIRTIO_NET); VirtioCcwDevice *virtio_ccw_dev =3D (VirtioCcwDevice *) object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent= ), TYPE_VIRTIO_CCW_DEVICE); + VFIOCCWDevice *vfio_ccw_dev =3D (VFIOCCWDevice *) + object_dynamic_cast(OBJECT(dev_st), TYPE_VFIO_CCW); + if (virtio_ccw_dev) { ccw_dev =3D CCW_DEVICE(virtio_ccw_dev); + if (virtio_net_dev) { + tmp_dt =3D CCW_DEVTYPE_VIRTIO_NET; + } else { + tmp_dt =3D CCW_DEVTYPE_VIRTIO; + } + } else if (vfio_ccw_dev) { + ccw_dev =3D CCW_DEVICE(vfio_ccw_dev); + tmp_dt =3D CCW_DEVTYPE_VFIO; } else { SCSIDevice *sd =3D (SCSIDevice *) object_dynamic_cast(OBJECT(dev_st), @@ -327,9 +348,13 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev= _st) =20 ccw_dev =3D (CcwDevice *)object_dynamic_cast(OBJECT(scsi_c= cw), TYPE_CCW_DEVICE= ); + tmp_dt =3D CCW_DEVTYPE_SCSI; } } } + if (devtype) { + *devtype =3D tmp_dt; + } return ccw_dev; } =20 @@ -337,20 +362,22 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) { DeviceState *dev_st; CcwDevice *ccw_dev =3D NULL; + SCSIDevice *sd; + int devtype; =20 dev_st =3D get_boot_device(0); if (dev_st) { - ccw_dev =3D s390_get_ccw_device(dev_st); + ccw_dev =3D s390_get_ccw_device(dev_st, &devtype); } =20 /* * 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); - - if (sd) { + switch (devtype) { + case CCW_DEVTYPE_SCSI: + sd =3D (SCSIDevice *) object_dynamic_cast(OBJECT(dev_st), + TYPE_SCSI_DEVIC= E); 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); @@ -360,20 +387,24 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl) ipl->iplb.scsi.channel =3D cpu_to_be16(sd->channel); ipl->iplb.scsi.devno =3D cpu_to_be16(ccw_dev->sch->devno); ipl->iplb.scsi.ssid =3D ccw_dev->sch->ssid & 3; - } else { - VirtIONet *vn =3D (VirtIONet *) object_dynamic_cast(OBJECT(dev= _st), - TYPE_VIRTIO_= NET); - + break; + case CCW_DEVTYPE_VFIO: + ipl->iplb.len =3D cpu_to_be32(S390_IPLB_MIN_CCW_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; + break; + case CCW_DEVTYPE_VIRTIO_NET: + ipl->netboot =3D true; + /* Fall through to CCW_DEVTYPE_VIRTIO case */ + case CCW_DEVTYPE_VIRTIO: 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; - } + break; } =20 if (!s390_ipl_set_loadparm(ipl->iplb.loadparm)) { @@ -532,7 +563,7 @@ void s390_ipl_reset_request(CPUState *cs, enum s390_res= et reset_type) !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)); + CcwDevice *ccw_dev =3D s390_get_ccw_device(get_boot_device(0), NUL= L); =20 if (ccw_dev && cpu_to_be16(ccw_dev->sch->devno) =3D=3D ipl->iplb.ccw.devno && diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index cad91ee..f5f025d 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -124,6 +124,14 @@ static void s390_ccw_unrealize(S390CCWDevice *cdev, Er= ror **errp) g_free(cdev->mdevid); } =20 +static void s390_ccw_instance_init(Object *obj) +{ + S390CCWDevice *dev =3D S390_CCW_DEVICE(obj); + + device_add_bootindex_property(obj, &dev->bootindex, "bootindex", + "/disk@0,0", DEVICE(obj), NULL); +} + static void s390_ccw_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -137,6 +145,7 @@ static void s390_ccw_class_init(ObjectClass *klass, voi= d *data) static const TypeInfo s390_ccw_info =3D { .name =3D TYPE_S390_CCW, .parent =3D TYPE_CCW_DEVICE, + .instance_init =3D s390_ccw_instance_init, .instance_size =3D sizeof(S390CCWDevice), .class_size =3D sizeof(S390CCWDeviceClass), .class_init =3D s390_ccw_class_init, diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 9246729..507d513 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -21,11 +21,11 @@ #include "hw/vfio/vfio.h" #include "hw/vfio/vfio-common.h" #include "hw/s390x/s390-ccw.h" +#include "hw/s390x/vfio-ccw.h" #include "hw/s390x/ccw-device.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" =20 -#define TYPE_VFIO_CCW "vfio-ccw" typedef struct VFIOCCWDevice { S390CCWDevice cdev; VFIODevice vdev; diff --git a/include/hw/s390x/s390-ccw.h b/include/hw/s390x/s390-ccw.h index 7d15a1a..901d805 100644 --- a/include/hw/s390x/s390-ccw.h +++ b/include/hw/s390x/s390-ccw.h @@ -27,6 +27,7 @@ typedef struct S390CCWDevice { CcwDevice parent_obj; CssDevId hostid; char *mdevid; + int32_t bootindex; } S390CCWDevice; =20 typedef struct S390CCWDeviceClass { diff --git a/include/hw/s390x/vfio-ccw.h b/include/hw/s390x/vfio-ccw.h new file mode 100644 index 0000000..2fceaa2 --- /dev/null +++ b/include/hw/s390x/vfio-ccw.h @@ -0,0 +1,28 @@ +/* + * vfio based subchannel assignment support + * + * Copyright 2017 IBM Corp. + * Author(s): Dong Jia Shi + * Xiao Feng Ren + * Pierre Morel + * + * This work is licensed under the terms of the GNU GPL, version 2 or (at + * your option) any later version. See the COPYING file in the top-level + * directory. + */ + +#ifndef HW_VFIO_CCW_H +#define HW_VFIO_CCW_H + +#include "hw/vfio/vfio-common.h" +#include "hw/s390x/s390-ccw.h" +#include "hw/s390x/ccw-device.h" + +#define TYPE_VFIO_CCW "vfio-ccw" +#define VFIO_CCW(obj) \ + OBJECT_CHECK(VFIOCCWDevice, (obj), TYPE_VFIO_CCW) + +#define TYPE_VFIO_CCW "vfio-ccw" +typedef struct VFIOCCWDevice VFIOCCWDevice; + +#endif --=20 2.7.4