From nobody Mon Nov 23 05:00:06 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1791222262; cv=none; d=zohomail.com; s=zohoarc; b=gh9IGgoa/okTT2CTyEqHLxQVhu7t7pRvCfy35AaNWzGk7mLRsVcWwP2Ia1xmqgRfbvnSv9kQWdk9lTTjhha9W+x03v/J7u4i6ngJVVgGSbichAgQ4TEw+EXfa6Au6Yn+sZmv5rlKqHnZ3h8gtKM9krnGG0etCFJKcMSu5813zcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791222262; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TLje78fEW1eM4RRDPweAwBsLLVyoQQgZHJF8jJnZoN4=; b=AAkBcmtZHReqrYBrxsvxEQGX/Rl1mXAe6+2axhM9eJpjtUg1oPrKZuEm2kWJgsn2AnncxX9WP3M8X+V/Ql4hnzBPrAZ0os9fH5bHTxW38Uq4jWFavFC/f/UCUFkpd0D/U1qOE+vA2g0g5wAkWcUGRvZzywsHV7CAaojnrz5xReM= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791222262166284.85334569153633; Mon, 5 Oct 2026 10:44:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xDmin-0001ML-TE; Mon, 05 Oct 2026 13:43:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xDmij-0001Kg-4V; Mon, 05 Oct 2026 13:43:25 -0400 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 1xDmig-0007Xy-FW; Mon, 05 Oct 2026 13:43:24 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 695HZbcU1276504; Mon, 5 Oct 2026 17:43:18 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4h2sbv2u9n-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 05 Oct 2026 17:43:18 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 695HN2Ol3214862; Mon, 5 Oct 2026 17:43:18 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4h3d1jpffu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Oct 2026 17:43:18 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 695HhGsu59179362 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Oct 2026 17:43:17 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B336558056; Mon, 5 Oct 2026 17:43:16 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02CE35803F; Mon, 5 Oct 2026 17:43:16 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.253.223]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 5 Oct 2026 17:43:15 +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=TLje78fEW1eM4RRDP weAwBsLLVyoQQgZHJF8jJnZoN4=; b=dJSqvPR77VA7UOeX9LmjE2Q1jrb8FjMNI /jnz/QMhbgRFXlSB5W1HKmOsIzOI98g9mqkDgDZOD5aeEYznqa+GF6Qf4JNFFDm9 5zyZA/47dnPxVGsGBHIVZboird1n9/VMZOCoeR7c4e04DfOwOx6W5bqKTBsgWlwP 5PM/Fw+m/VDWLHb5BKc2Io6qKAxjVNLO6ie+ps/8iMuU2r1BvaFGvcCkj8NlFHVr 0NxR77qZ3M22DZgT3JStgvJdcepN4xD2r7fKFGFse3Tc8t3F5ZHmEVUdFPHQVMhb A+obPwAytysdoZeVWljj4Aei8kVpsEexWRPnzZSlh08hA0lWGmDsA== From: Farhan Ali To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: alifm@linux.ibm.com, mjrosato@linux.ibm.com, farman@linux.ibm.com, cohuck@redhat.com, alex@shazbot.org, clg@redhat.com Subject: [PATCH v7 1/2] s390x/pci: Add PCI error handling for vfio pci devices Date: Mon, 5 Oct 2026 10:43:13 -0700 Message-ID: <20261005174314.871-2-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005174314.871-1-alifm@linux.ibm.com> References: <20261005174314.871-1-alifm@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 70LhK2NTUUmgQ0xtAcPwjXykcZGhDRTN X-Authority-Analysis: v=2.4 cv=KJHPn1Fo c=1 sm=1 tr=0 ts=6ac3e1b6 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=Km_DOyaihBi-3fC5N0UA:9 X-Proofpoint-GUID: 70LhK2NTUUmgQ0xtAcPwjXykcZGhDRTN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDA1MDA2OSBTYWx0ZWRfX8l3SACSs2LLA kZkDYFv6bXbAnWE9QTItRNiojuvzIAiOHsgzKojwr6Pf5ZPbl5d33P9MOB0EdxuSfey3/kq4Md7 E1f1h8pL+nMR7LA0xDsAaJEeXU8gcwq9Ht6m+LmJQ8DRsV8hHogzjRJrBX8nzy3qFMrCMWgmP1Q 6wsMlFzTd99t61sc4ldXB8V9xIP/jwQHr8eU0a3ufjgz4kOo6izfdznawpiEdc6ZqnT5Fh6mB+H ZoHAyNymnvYxioAtRryjetomp/4nNOAPeDLF/Yh0ZQ63k9DLnG7BQlmZ6s3YtUY8VSVgxm3z3h2 UHhVXCoPccZlmZCrZDzLLcFjJgjg2CcmHmQhu9pllmx731qX4x79g1NRWNqMAPKLGO/vosIyHQM rMq8pSangb8mZj7WvM+hJz/jxRxVjyChAuKKpEA6sNCim7II/Mc4vGKjJxRST+MxhhFj1EXG4qB E5K2CuSD3Mmn9hgougw== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDA1MDA2OSBTYWx0ZWRfX6GDRgRyZBrIO 5A0or3JXfNGfTYwzHZk6xtZmGaUek+zR5IvyLo3Fm4LaL1tM2bDGAxbXZ5LGju4Vp3Ti2Dl197P 59e8vcNmPPNN8AUgPsLsEsgXC2DrOog= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-05_05,2026-10-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 impostorscore=0 adultscore=0 clxscore=1015 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2610050069 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=alifm@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_H3=0.001, RCVD_IN_MSPIKE_WL=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: 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 @ibm.com) X-ZM-MESSAGEID: 1791222263841158500 Content-Type: text/plain; charset="utf-8" Add an s390x specific handler for vfio error notifier. For s390x pci device= s, we have platform specific error information. We need to retrieve this error information for passthrough devices. This is done via a VFIO_DEVICE_FEATURE ioctl which exposes that information. Once this error information is retrieved we can then inject an error into the guest, and let the guest drive the recovery. Signed-off-by: Farhan Ali Reviewed-by: Matthew Rosato --- hw/s390x/s390-pci-bus.c | 6 ++ hw/s390x/s390-pci-vfio-stubs.c | 6 ++ hw/s390x/s390-pci-vfio.c | 123 +++++++++++++++++++++++++++++++ include/hw/s390x/s390-pci-bus.h | 1 + include/hw/s390x/s390-pci-vfio.h | 1 + 5 files changed, 137 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 2eb4e8cec4..b2967dacba 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1085,6 +1085,7 @@ static void s390_pcihost_plug(const HotplugHandler *h= otplug_dev, DeviceState *de S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); PCIDevice *pdev =3D NULL; S390PCIBusDevice *pbdev =3D NULL; + Error *local_err =3D NULL; int rc; =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { @@ -1175,6 +1176,11 @@ static void s390_pcihost_plug(const HotplugHandler *= hotplug_dev, DeviceState *de pbdev->iommu->dma_limit =3D s390_pci_start_dma_count(s, pbdev); /* Fill in CLP information passed via the vfio region */ s390_pci_get_clp_info(pbdev); + /* Setup error handler for error recovery */ + if (!s390_pci_setup_err_handler(pbdev, &local_err)) { + warn_report_err(local_err); + } + if (!pbdev->interp) { /* Do vfio passthrough but intercept for I/O */ pbdev->fh |=3D FH_SHM_VFIO; diff --git a/hw/s390x/s390-pci-vfio-stubs.c b/hw/s390x/s390-pci-vfio-stubs.c index d9882b7aad..9fc84ca135 100644 --- a/hw/s390x/s390-pci-vfio-stubs.c +++ b/hw/s390x/s390-pci-vfio-stubs.c @@ -30,3 +30,9 @@ bool s390_pci_get_host_fh(S390PCIBusDevice *pbdev, uint32= _t *fh) void s390_pci_get_clp_info(S390PCIBusDevice *pbdev) { } + +bool s390_pci_setup_err_handler(S390PCIBusDevice *pbdev, Error **errp) +{ + error_setg(errp, "VFIO not available, cannot setup error handler"); + return false; +} diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index db6de00bd2..0153faae86 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -10,6 +10,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" =20 #include #include @@ -105,6 +106,80 @@ void s390_pci_end_dma_count(S390pciState *s, S390PCIDM= ACount *cnt) } } =20 +static int s390_pci_get_feature_err(VFIOPCIDevice *vfio_pci, + PciCcdfErr *ccdf, + uint32_t ccdf_err_length, + Error **errp) +{ + ERRP_GUARD(); + int ret; + size_t total_size; + struct vfio_device_feature_zpci_err *err; + g_autofree void *buf =3D NULL; + g_autofree struct vfio_device_feature *feature =3D NULL; + + total_size =3D sizeof(*feature) + sizeof(*err); + feature =3D g_malloc(total_size); + feature->argsz =3D total_size; + feature->flags =3D VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_ZPCI_= ERROR; + + buf =3D g_malloc(ccdf_err_length); + err =3D (void *)feature->data; + err->data =3D (uint64_t)buf; + ret =3D vfio_device_get_feature(&vfio_pci->vbasedev, feature); + + if (ret) { + if (ret =3D=3D -ENOMSG) { + return 0; + } + error_setg(errp, "Failed feature get VFIO_DEVICE_FEATURE_ZPCI_ERRO= R" + " (rc=3D%d)", ret); + return ret; + } + + memcpy(ccdf, buf, ccdf_err_length); + + return 1; +} + +static void s390_pci_err_handler(void *opaque) +{ + VFIOPCIDevice *vfio_pci; + S390PCIBusDevice *pbdev; + Error *local_err =3D NULL; + PciCcdfErr ccdf; + int ret =3D 0; + + vfio_pci =3D opaque; + if (!event_notifier_test_and_clear(&vfio_pci->err_notifier)) { + return; + } + + pbdev =3D s390_pci_find_dev_by_pci(s390_get_phb(), PCI_DEVICE(vfio_pci= )); + + if (!pbdev) { + error_report("No matching zpci device found"); + return; + } + pbdev->state =3D ZPCI_FS_ERROR; + + do { + ret =3D s390_pci_get_feature_err(vfio_pci, &ccdf, + pbdev->ccdf_err_length, &local_err); + if (ret < 0) { + error_report_err(local_err); + break; + } + + if (ret > 0) { + s390_pci_generate_error_event(ccdf.pec, pbdev->fh, pbdev->fid, + ccdf.faddr, ccdf.e); + } + } while (ret > 0); + + return; +} + static void s390_pci_read_base(S390PCIBusDevice *pbdev, struct vfio_device_info *info) { @@ -134,6 +209,10 @@ static void s390_pci_read_base(S390PCIBusDevice *pbdev, /* Store function type separately for type-specific behavior */ pbdev->pft =3D cap->pft; =20 + if (hdr->version >=3D 3) { + pbdev->ccdf_err_length =3D cap->ccdf_err_length; + } + /* * If the device is a passthrough ISM device, disallow relaxed * translation. @@ -371,3 +450,47 @@ void s390_pci_get_clp_info(S390PCIBusDevice *pbdev) s390_pci_read_util(pbdev, info); s390_pci_read_pfip(pbdev, info); } + +bool s390_pci_setup_err_handler(S390PCIBusDevice *pbdev, Error **errp) +{ + int ret; + int32_t fd; + VFIOPCIDevice *vfio_pci =3D VFIO_PCI_DEVICE(pbdev->pdev); + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature), + sizeof(uint64_t))] =3D {}; + struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; + + feature->argsz =3D sizeof(buf); + feature->flags =3D VFIO_DEVICE_FEATURE_PROBE | VFIO_DEVICE_FEATURE_ZPC= I_ERROR; + + ret =3D vfio_device_get_feature(&vfio_pci->vbasedev, feature); + + if (ret !=3D 0) { + if (ret =3D=3D -ENOTTY) { + error_setg(errp, "Automated error recovery unavailable for dev= ice"); + } else { + error_setg(errp, + "Failed to probe for VFIO_DEVICE_FEATURE_ZPCI_ERROR= (ret=3D%d)", + ret); + } + return false; + } + + if (sizeof(PciCcdfErr) !=3D pbdev->ccdf_err_length) { + error_setg(errp, + "CCDF size mismatch expected size=3D%zu, provided size= =3D%d", + sizeof(PciCcdfErr), pbdev->ccdf_err_length); + return false; + } + + if (!vfio_pci->pci_aer) { + error_setg(errp, "%s: VFIO error notifier not registered for devic= e", + vfio_pci->vbasedev.name); + return false; + } + + fd =3D event_notifier_get_fd(&vfio_pci->err_notifier); + qemu_set_fd_handler(fd, s390_pci_err_handler, NULL, vfio_pci); + + return true; +} diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index f182bab246..63cf2b7222 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -365,6 +365,7 @@ struct S390PCIBusDevice { bool forwarding_assist; bool aif; bool rtr_avail; + uint32_t ccdf_err_length; QTAILQ_ENTRY(S390PCIBusDevice) link; }; =20 diff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-v= fio.h index f7d6149daf..c7886b63ea 100644 --- a/include/hw/s390x/s390-pci-vfio.h +++ b/include/hw/s390x/s390-pci-vfio.h @@ -20,5 +20,6 @@ S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s, void s390_pci_end_dma_count(S390pciState *s, S390PCIDMACount *cnt); bool s390_pci_get_host_fh(S390PCIBusDevice *pbdev, uint32_t *fh); void s390_pci_get_clp_info(S390PCIBusDevice *pbdev); +bool s390_pci_setup_err_handler(S390PCIBusDevice *pbdev, Error **errp); =20 #endif --=20 2.43.0 From nobody Mon Nov 23 05:00:06 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=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1791222256; cv=none; d=zohomail.com; s=zohoarc; b=DvrZclpqFp6HbnoyjvdVcTp/YGp6ZKb6ZTf1ezDvHtRMwGgnpyXD8isZrR7WMglO7DQvqxH+sBbAtZBAq6kVDiWvS/6Z9gBKnj3Ytp9LKd9MSD/iCegpETXRlPqrL3DyYm+SH9K8KuIezSiWFfUGQhD5cl8r8S1y2PCKWoSBcc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1791222256; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K3e3zL8kBO4quMbIDCYCTuLs2hTd7jJl1EXMPtlluG0=; b=PCFNu3VPt2L4KGqp2XfmYrtsQEpHySzUuCnuq/UEQbIZFkAiATMq1OLZmQv+2aAIfD9QZBTrLt143SAvhxmF2//uVwji3vBENNJ8tQatHJj6oph9lY85sgRW/mSSI86RBLFI0dzd0uOu+89FkRH/MQgJC9OCvgelDNFn38aSqC0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1791222256671788.062788855907; Mon, 5 Oct 2026 10:44:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xDmiq-0001My-Jy; Mon, 05 Oct 2026 13:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xDmij-0001Ky-SA; Mon, 05 Oct 2026 13:43:26 -0400 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 1xDmih-0007YJ-8z; Mon, 05 Oct 2026 13:43:25 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 695HZrQq1257970; Mon, 5 Oct 2026 17:43:20 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4h2se5bmbq-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 05 Oct 2026 17:43:19 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 695HMYDR3214609; Mon, 5 Oct 2026 17:43:19 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4h3d1jpffv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Oct 2026 17:43:19 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 695HhHsB66519302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Oct 2026 17:43:17 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7944F58056; Mon, 5 Oct 2026 17:43:17 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2B315803F; Mon, 5 Oct 2026 17:43:16 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.253.223]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 5 Oct 2026 17:43:16 +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=K3e3zL8kBO4quMbID CYCTuLs2hTd7jJl1EXMPtlluG0=; b=BBNTvTsiBjKEuZW8LQ3UynLHoHGNPlQ+7 fTIFt78JIAF7QCYXaQfHkhZS4Eji7QXGFZq/O3fHaFjYB6VNsRTlAPrvehzJkwVy /Q1vDGcylycxTkH6TnCtGeuyRiDcfI5RE/6Rmt4ZeczC6mxSNSDGMHciykSfu8A2 Qy+TW9Wss2ZmJ98aSvWgpgMR1//nzAj9gMnWxhmzg+S9kKc5pWkUxisr+0/NQJf/ l+qf3ybKPhMMTHHKtsnhRD1V5C/S9BNas8fR6gUsmROUAH3fcka6Nadw1mIwbFWN UdEbBv8IA4/Uj/uSrsJtpbhOra0x9bjFmZ7QOiZy4r6YoYiSkMIfw== From: Farhan Ali To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: alifm@linux.ibm.com, mjrosato@linux.ibm.com, farman@linux.ibm.com, cohuck@redhat.com, alex@shazbot.org, clg@redhat.com Subject: [PATCH v7 2/2] s390x/pci: Reset a device in error state Date: Mon, 5 Oct 2026 10:43:14 -0700 Message-ID: <20261005174314.871-3-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005174314.871-1-alifm@linux.ibm.com> References: <20261005174314.871-1-alifm@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDA1MDA2OSBTYWx0ZWRfX9i9nUHiEyHu2 knDAJkVZS1UU7NlgUVKeJAZKS5DAKAMhXyWkOaKiiozUGnmEE7EBvh0+Cf5PBkFjTFbvhAjwrKN m9lRRlxzZBXygeiTX4qLHnmkUor0CAs= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDA1MDA2OSBTYWx0ZWRfX8ghIqwF1C3s5 dCjxdQ/M2Y5ZOen6CxvP/bhOc8mUfhrE5v9o+nsrl7SqMmAp434nQCsaMTz/KZbaiR9HpO8g7Df 7hqgXOxCGlKjPfx6Mgv0fqoFznHXx1EhfXq08P/1C1UiUVag0xiguxSKifcVQ9AIoNbdI/QZyrA QNaZgdNsCy30TlesVQz4WYhLHmptWV5sbJJDbhVyXKnvkNNJH6mmLHVjam3F5W2gq8KOJR7P90x zpiLo84VOyiFU5GrS0/BI6v0io5v7TCs6x/RLChIC59f9l13/lod3eMsyzyRRwtAXRnwp+Ize1L XWUmpQjBo5VKnA4vEwulzFZGqhZs8GTh6Uj+FTgbfV5l7SfGVKa1Tr3pcEHB7gl5DbT6GgXQ7E3 evkiesu9KkQLGxKuy+DBcFdc/YeqOb4juUtjeHdSArLRdz/bR5P+q/2C6G1gHjRoHd8aLgcEqXm iok3FVL9vyEOM5qn1xw== X-Proofpoint-GUID: yHCYHp6zUU9nW3N5AtYJkxX81cc1cZea X-Authority-Analysis: v=2.4 cv=UNRIjyfy c=1 sm=1 tr=0 ts=6ac3e1b7 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=FuZLNSxbJke2QbDKExoA:9 X-Proofpoint-ORIG-GUID: yHCYHp6zUU9nW3N5AtYJkxX81cc1cZea X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-05_05,2026-10-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2610050069 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=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=alifm@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_H4=0.001, RCVD_IN_MSPIKE_WL=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: 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 @ibm.com) X-ZM-MESSAGEID: 1791222257922158500 Content-Type: text/plain; charset="utf-8" For passthrough devices in error state, for a guest driven reset of the device we can attempt a reset to recover the device. A reset of the device will trigger a CLP disable/enable cycle on the host to bring the device into a recovered state. Signed-off-by: Farhan Ali Reviewed-by: Matthew Rosato --- hw/s390x/s390-pci-bus.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index b2967dacba..6557ec4240 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1505,6 +1505,21 @@ static void s390_pci_device_reset(DeviceState *dev) return; case ZPCI_FS_STANDBY: break; + case ZPCI_FS_ERROR: + /* + * Attempt a reset to recover the device. A device in ERROR state + * can be transitioned to ENABLED or DISABLED state via guest + * driven actions. Since this code path is also executed on + * subsystem_reset() and the expected state of a configured device + * after subsystem_reset() is to be in a DISABLED state, we need to + * transition from ERROR to DISABLED. + * + * Linux guests drive the state transition from ERROR to DISABLED + * via CLP_SET_DISABLE_PCI_FN. So it should be safe to transition + * from ERROR to DISABLED state. + */ + pci_device_reset(pbdev->pdev); + /* fallthrough */ default: pbdev->fh &=3D ~FH_MASK_ENABLE; pbdev->state =3D ZPCI_FS_DISABLED; --=20 2.43.0