From nobody Thu Apr 3 10:08:38 2025 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1740603751; cv=none; d=zohomail.com; s=zohoarc; b=ahESg5NOFkjmYBsD8DwL1cjqsc0KEQjZ5jPXXp29vnkbnXOiXTyx34lmO21LAEb2ACIdCmmzeiS3sj/mLgEDizY2gG1Evz0SPyTkAVWlXf/iPK289gEMn8xTQcAbA9dNXT+KXvEH5M5L6HZ96+DAb2xgqq6pkWvQY/tIvp4jXk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740603751; 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=SR2iXPYNuYqGCyBu6XhoyZ+m6dQSVNS7RmhG5V5d7Us=; b=PhxgM/1xLX4IEpEpC3I8pwW/t46Jx0zNtnzQGgrR5+SSjkujkluSvRhr2yAC1mcNd1GjlxQdUQjZFDOmQau5ywtiejMJfAFeOp/SzcnFX49AqYnGR+QEibZJ/sgpIgOPoiLqaYXCIqDcIZZBdpTkUBQJvE4vHxfwP9XhB1/0yMs= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1740603750493489.00293849499985; Wed, 26 Feb 2025 13:02:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnOXn-0000JV-FF; Wed, 26 Feb 2025 16:02:15 -0500 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 1tnOXk-0000ES-6f; Wed, 26 Feb 2025 16:02:12 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnOXi-00035H-4q; Wed, 26 Feb 2025 16:02:11 -0500 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51QG7FEM020718; Wed, 26 Feb 2025 21:02:07 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 451vs84efv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Feb 2025 21:02:07 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 51QJ0KWI026990; Wed, 26 Feb 2025 21:02:06 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 44ytdkmtx8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Feb 2025 21:02:06 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 51QL24c733161840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2025 21:02:05 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1AA158059; Wed, 26 Feb 2025 21:02:04 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90A8C58043; Wed, 26 Feb 2025 21:02:03 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.46.135]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 26 Feb 2025 21:02:03 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=SR2iXPYNuYqGCyBu6 XhoyZ+m6dQSVNS7RmhG5V5d7Us=; b=UG3tJY8S5Ya1pX+eA6ho7A/RbuI7E7r+P smSz2b7/UPFZaJKbXx2f+/f0IRv/23o97qyni7Cgwy4n44rpeNHZkaxUUeBPysUv ZA0/xuWwQupoAUw+5+rwiKmOK4KiAG6jBi8+aGKZTx9lei5trm5IN+7E353+JuSM ksMYvXfVAUcK52bbb9WOeVO7AUBsS4ukU+K/3KN0m75/OLYRzQ3vHf2ZEUCJHmSt xU3Jlq0xMi+ASan7yNB7Vt22Wao430YnKn/1Rw3NtOHN1gdGCl7E08MRNNppQBDe Mqy/m97GDZBXOMRTwX6M7iE5GFLXQXEVKpxYoibg8y254Bl3lTVNg== From: Matthew Rosato To: qemu-s390x@nongnu.org Cc: farman@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, iii@linux.ibm.com, clg@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 1/2] s390x/pci: fix cleanup of failed hotplug Date: Wed, 26 Feb 2025 16:02:00 -0500 Message-ID: <20250226210201.238489-2-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250226210201.238489-1-mjrosato@linux.ibm.com> References: <20250226210201.238489-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: AB88-EsnPtMVVlFSewWmlB0-kVgtDfsL X-Proofpoint-GUID: AB88-EsnPtMVVlFSewWmlB0-kVgtDfsL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-26_06,2025-02-26_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 suspectscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 mlxlogscore=776 spamscore=0 mlxscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502100000 definitions=main-2502260163 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=148.163.156.1; envelope-from=mjrosato@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1740603754160019100 Content-Type: text/plain; charset="utf-8" In the unlikely event that we must fail hotplug of a PCI passthrough device, ensure appropriate clean up of the associated zPCI device is performed. Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-bus.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 913d72cc74..6cc0e7538a 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1119,7 +1119,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, if (rc) { error_setg(errp, "Plug failed for zPCI device in " "interpretation mode: %d", rc); - return; + goto pbdev_cleanup; } } else { trace_s390_pcihost("zPCI interpretation missing"); @@ -1150,7 +1150,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, if (s390_pci_msix_init(pbdev) && !pbdev->interp) { error_setg(errp, "MSI-X support is mandatory " "in the S390 architecture"); - return; + goto pbdev_cleanup; } =20 if (dev->hotplugged) { @@ -1168,6 +1168,23 @@ static void s390_pcihost_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, } else { g_assert_not_reached(); } + + return; + + pbdev_cleanup: + DeviceState *bdev =3D DEVICE(pbdev); + + if (pbdev->shutdown_notifier.notify) { + notifier_remove(&pbdev->shutdown_notifier); + } + if (pbdev->iommu->dma_limit) { + s390_pci_end_dma_count(s, pbdev->iommu->dma_limit); + } + s390_pci_iommu_free(s, pci_get_bus(pbdev->pdev), pbdev->pdev->devfn); + QTAILQ_REMOVE(&s->zpci_devs, pbdev, link); + g_hash_table_remove(s->zpci_table, &pbdev->idx); + object_unparent(OBJECT(bdev)); + qdev_unrealize(bdev); } =20 static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *= dev, --=20 2.48.1 From nobody Thu Apr 3 10:08:38 2025 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1740603741; cv=none; d=zohomail.com; s=zohoarc; b=jLncfu3qF0jy17tS/O5j+Kg2XDnGhMzFsF6/KEXdk9fD2fi3rbWV0/5YkdFhCZAnfQdoFOjh/mkdJ6MiUzEnI81Zrc5osRkOj8dQkYzh7cqwyZ9sTsLz9QGqLElIn1z+6ozsKzEEj+JRePTeBJZcPu3Nrh8JPNFSiwrGuG9IJrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740603741; 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=yvzsom2F+5FwazjKq/uiqlqve/NsX1bjsUFFmfiKie8=; b=IHFqxXdofShR/nPCyjFmqtA1XaqrvU6XWvKVNobfmdB3P+bJbZG8B/BuLMRLDTgyhjuyUbtU/5mFSqBJS+L+k8PT3aWKygk5AkAjd8Ed1rABQR/HG71jJDwa2gKnGojyVy+UbPa8reGSsD8L4vxykDSEUWoh8IZrLHmIdllshvo= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1740603741887624.8089882084188; Wed, 26 Feb 2025 13:02:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tnOXo-0000MY-Qt; Wed, 26 Feb 2025 16:02:16 -0500 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 1tnOXj-0000CY-Lh; Wed, 26 Feb 2025 16:02:11 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tnOXh-00035E-Ou; Wed, 26 Feb 2025 16:02:11 -0500 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51QH74QK007093; Wed, 26 Feb 2025 21:02:08 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 451xnp3ugj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Feb 2025 21:02:08 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 51QJZtg9002570; Wed, 26 Feb 2025 21:02:07 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 44yu4jvm2b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Feb 2025 21:02:07 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 51QL261s9830998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2025 21:02:06 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C8D758059; Wed, 26 Feb 2025 21:02:06 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DAEB558053; Wed, 26 Feb 2025 21:02:04 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.46.135]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 26 Feb 2025 21:02:04 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=yvzsom2F+5FwazjKq /uiqlqve/NsX1bjsUFFmfiKie8=; b=XbubACf3ooOoBogAmEOpu7sIJ5u8AcWjY DWwPL8NIgcNOLDErbZk67OInmsYoLPaP21ngUT1abbUQiklt9X3KTCQGSdZdnSsG syI/h+IrnF+8JGJm2uGNV+WX2si0zzmphXOQMhN45luXMv8uFFGQ+kZFSFdPafph 98qPOumqm/r57DU8/Rnf3qswlc6dhlUiYGX3wLtyd2XKTS8NjyutqYcZx1wcRBpz idvfoPt8SWImwKyQBJNrHSxGS6iOY7UgXRVopHs7ZExzHAIfBb8aANBRHH+GVkNW gu5w6gjLFwDz8ChBpzMbrINW5VegPQsZXoMhuS+ZsyukLU9QIRf+w== From: Matthew Rosato To: qemu-s390x@nongnu.org Cc: farman@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, richard.henderson@linaro.org, david@redhat.com, iii@linux.ibm.com, clg@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 2/2] s390x/pci: add message for ISM without zPCI interpretation Date: Wed, 26 Feb 2025 16:02:01 -0500 Message-ID: <20250226210201.238489-3-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250226210201.238489-1-mjrosato@linux.ibm.com> References: <20250226210201.238489-1-mjrosato@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NUC3eW7FcMQI8keoIVAT3IXvkT1Ces7W X-Proofpoint-GUID: NUC3eW7FcMQI8keoIVAT3IXvkT1Ces7W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-26_06,2025-02-26_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=849 spamscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502100000 definitions=main-2502260163 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=148.163.158.5; envelope-from=mjrosato@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1740603742827019000 Content-Type: text/plain; charset="utf-8" Currently s390x does not support ISM passthrough without zPCI interpretation. This is already fenced, but the current message will not provide adequate information to explain to the end-user why ISM passthrough is not allowed. Add a proper message. Suggested-by: Thomas Huth Signed-off-by: Matthew Rosato --- hw/s390x/s390-pci-bus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 6cc0e7538a..c41c88f88e 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1147,6 +1147,12 @@ static void s390_pcihost_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, pbdev->forwarding_assist =3D false; } =20 + if (pbdev->pft =3D=3D ZPCI_PFT_ISM && !pbdev->interp) { + error_setg(errp, "zPCI interpretation is required for ISM devi= ce " + "passthrough"); + goto pbdev_cleanup; + } + if (s390_pci_msix_init(pbdev) && !pbdev->interp) { error_setg(errp, "MSI-X support is mandatory " "in the S390 architecture"); --=20 2.48.1