From nobody Sat Apr 11 21:29:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1773122411; cv=none; d=zohomail.com; s=zohoarc; b=WCBcWHvIXZ7NDPlYM2leYn0KMW+IdPocXqCJQybeeo0kGIh+qDht3nUBVVg6ZIsL7jFlwsZW0AvhAYntVBXMdJeJDJXuxWg0Kx+SBr+qDDGbWfcmiwF4XFHypvPH5ObC88PByqGHzHzYxUKDjTICZyTn5TX1Hn1wRVxT7A/neYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773122411; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7HFTSQSGTDzITAOxJjwZ6A8S8EXuNQDFAnJqDDfwx/M=; b=Q4Zv6FPySJkh1krNVOsokahZGP98BLV48MV0i51/rqNp4PsmBoxZse3aaWiSzgsZ300E+os7E+0TnBiq9xQ8olLOUlSLV8ro0kbccXHgH8n3VTwjDtytE0ChU4LQhcpvdZLd8b/aDjqMrvd95kK3aO9K9HW7G7n2OP6ryjksQtE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773122411729862.4608890068902; Mon, 9 Mar 2026 23:00:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vzq62-0001Fw-LP; Tue, 10 Mar 2026 01:57:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vzq5Z-0000ob-Ne for qemu-devel@nongnu.org; Tue, 10 Mar 2026 01:57:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vzq5X-0006LO-7v for qemu-devel@nongnu.org; Tue, 10 Mar 2026 01:57:05 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-oAGewyd3MhWex9koD4Bikw-1; Tue, 10 Mar 2026 01:56:57 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD1A719560AE; Tue, 10 Mar 2026 05:56:55 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.44.32.69]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 007811956095; Tue, 10 Mar 2026 05:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773122221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7HFTSQSGTDzITAOxJjwZ6A8S8EXuNQDFAnJqDDfwx/M=; b=NIXO+X3MlDaBtBK36OGtHZ3BPfgBvq4iNmh10A5SIlnfSzN28JOdPjJditvYDxd0bzGuEC iTUCVZJrZac12HFXSQXGIrtKZQd787YT1593GGBs0NOYSHzgNeSdM719Xj3SxdD3r5bsT/ c/by+iwVtgZdcoa5y0PpZ/ASO4ARGzY= X-MC-Unique: oAGewyd3MhWex9koD4Bikw-1 X-Mimecast-MFC-AGG-ID: oAGewyd3MhWex9koD4Bikw_1773122215 From: Thomas Huth To: Peter Maydell Cc: qemu-devel@nongnu.org, Eric Farman , Jared Rossi Subject: [PULL 21/25] s390x: Build IPLB for virtio-pci devices Date: Tue, 10 Mar 2026 06:55:26 +0100 Message-ID: <20260310055530.8893-22-thuth@redhat.com> In-Reply-To: <20260310055530.8893-1-thuth@redhat.com> References: <20260310055530.8893-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1773122412423158500 Content-Type: text/plain; charset="utf-8" From: Jared Rossi Search for a corresponding S390PCIBusDevice and build an IPLB if a device h= as been indexed for boot but does not identify as a CCW device, PCI devices are not yet included in boot probing (they must have a boot ind= ex). Reviewed-by: Thomas Huth Reviewed-by: Eric Farman Signed-off-by: Jared Rossi Message-ID: <20260309003601.242634-14-jrossi@linux.ibm.com> [thuth: Fix endianness issue when running on a little endian host] Signed-off-by: Thomas Huth --- hw/s390x/ipl.h | 3 ++ include/hw/s390x/s390-pci-bus.h | 2 ++ hw/s390x/ipl.c | 56 ++++++++++++++++++++++++++++++--- hw/s390x/s390-pci-bus.c | 3 +- 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h index c542d30ce2d..403cd08450d 100644 --- a/hw/s390x/ipl.h +++ b/hw/s390x/ipl.h @@ -107,6 +107,7 @@ QEMU_BUILD_BUG_MSG(offsetof(S390IPLState, iplb) & 3, "a= lignment of iplb wrong"); #define S390_IPLB_MIN_PV_LEN 148 #define S390_IPLB_MIN_CCW_LEN 200 #define S390_IPLB_MIN_FCP_LEN 384 +#define S390_IPLB_MIN_PCI_LEN 376 #define S390_IPLB_MIN_QEMU_SCSI_LEN 200 =20 static inline bool iplb_valid_len(IplParameterBlock *iplb) @@ -179,6 +180,8 @@ static inline bool iplb_valid(IplParameterBlock *iplb) return len >=3D S390_IPLB_MIN_FCP_LEN; case S390_IPL_TYPE_CCW: return len >=3D S390_IPLB_MIN_CCW_LEN; + case S390_IPL_TYPE_PCI: + return len >=3D S390_IPLB_MIN_PCI_LEN; case S390_IPL_TYPE_QEMU_SCSI: default: return false; diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index f643e130579..9228523ce8e 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -402,6 +402,8 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(S390pciState = *s, uint32_t fh); S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid); S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s, const char *target); +S390PCIBusDevice *s390_pci_find_dev_by_pci(S390pciState *s, + PCIDevice *pci_dev); S390PCIBusDevice *s390_pci_find_next_avail_dev(S390pciState *s, S390PCIBusDevice *pbdev); void s390_pci_ism_reset(void); diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index d34adb55220..7e09a8cf80d 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -28,6 +28,8 @@ #include "hw/s390x/ebcdic.h" #include "hw/scsi/scsi.h" #include "hw/virtio/virtio-net.h" +#include "hw/virtio/virtio-pci.h" +#include "hw/s390x/s390-pci-bus.h" #include "exec/cpu-common.h" #include "ipl.h" #include "qemu/error-report.h" @@ -340,7 +342,8 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl) ipl->qipl.boot_menu_timeout =3D cpu_to_be32(splash_time); } =20 -#define CCW_DEVTYPE_NONE 0x00 +#define S390_DEVTYPE_NONE 0x00 + #define CCW_DEVTYPE_VIRTIO 0x01 #define CCW_DEVTYPE_VIRTIO_NET 0x02 #define CCW_DEVTYPE_SCSI 0x03 @@ -349,7 +352,7 @@ static void s390_ipl_set_boot_menu(S390IPLState *ipl) static CcwDevice *s390_get_ccw_device(DeviceState *dev_st, int *devtype) { CcwDevice *ccw_dev =3D NULL; - int tmp_dt =3D CCW_DEVTYPE_NONE; + int tmp_dt =3D S390_DEVTYPE_NONE; =20 if (dev_st) { VirtIONet *virtio_net_dev =3D (VirtIONet *) @@ -396,6 +399,31 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev= _st, int *devtype) return ccw_dev; } =20 +#define PCI_DEVTYPE_VIRTIO 0x05 + +static S390PCIBusDevice *s390_get_pci_device(DeviceState *dev_st, int *dev= type) +{ + S390PCIBusDevice *pbdev =3D NULL; + int tmp_dt =3D S390_DEVTYPE_NONE; + + if (dev_st) { + PCIDevice *pci_dev =3D (PCIDevice *) + object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent= ), + TYPE_VIRTIO_PCI); + if (pci_dev) { + pbdev =3D s390_pci_find_dev_by_pci(s390_get_phb(), pci_dev); + if (pbdev) { + tmp_dt =3D PCI_DEVTYPE_VIRTIO; + } + } + } + if (devtype) { + *devtype =3D tmp_dt; + } + + return pbdev; +} + static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) { S390IPLState *ipl =3D get_ipl_device(); @@ -428,14 +456,12 @@ void s390_ipl_convert_loadparm(char *ascii_lp, uint8_= t *ebcdic_lp) static bool s390_build_iplb(DeviceState *dev_st, IplParameterBlock *iplb) { CcwDevice *ccw_dev =3D NULL; + S390PCIBusDevice *pbdev =3D NULL; SCSIDevice *sd; int devtype; uint8_t *lp; g_autofree void *scsi_lp =3D NULL; =20 - /* - * Currently allow IPL only from CCW devices. - */ ccw_dev =3D s390_get_ccw_device(dev_st, &devtype); if (ccw_dev) { lp =3D ccw_dev->loadparm; @@ -485,6 +511,26 @@ static bool s390_build_iplb(DeviceState *dev_st, IplPa= rameterBlock *iplb) return true; } =20 + pbdev =3D s390_get_pci_device(dev_st, &devtype); + if (pbdev) { + switch (devtype) { + case PCI_DEVTYPE_VIRTIO: + iplb->len =3D cpu_to_be32(S390_IPLB_MIN_PCI_LEN); + iplb->pbt =3D S390_IPL_TYPE_PCI; + iplb->pci.fid =3D cpu_to_be32(pbdev->fid); + break; + default: + return false; + } + + /* Per-device loadparm not yet supported for non-ccw IPL */ + lp =3D S390_CCW_MACHINE(qdev_get_machine())->loadparm; + s390_ipl_convert_loadparm((char *)lp, iplb->loadparm); + iplb->flags |=3D DIAG308_FLAGS_LP_VALID; + + return true; + } + return false; } =20 diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 3166b91c461..4de7b587e8a 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -250,8 +250,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciSt= ate *s, return NULL; } =20 -static S390PCIBusDevice *s390_pci_find_dev_by_pci(S390pciState *s, - PCIDevice *pci_dev) +S390PCIBusDevice *s390_pci_find_dev_by_pci(S390pciState *s, PCIDevice *pci= _dev) { S390PCIBusDevice *pbdev; =20 --=20 2.53.0