From nobody Sat Nov 15 03:03:57 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=1756157207; cv=none; d=zohomail.com; s=zohoarc; b=IqviYuDPAqAADNGHCqiWaOhdLSBoyL3N/mJMc9YYaDd2j7WLYsjr/wf12q3iPP7t1A+WNbP4I+obH80SHQLehPpLIUwD4q9sSHZsWUmnFE5a5ANys3DaC57DbcHw+ED62AKMoyhOIaGd85VMCtSU6xLzW0EfoDrIHEfGzEq8nCU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756157207; 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=kF1kZFzyDG+5PD7DTlxH/PXLN/jetaApw70t+rGVNhk=; b=fHBcj9YEHdHu4x0e6lINtChXvPDeJ8gbKUXIv3MbMH297JuQh4y5Ua1eW1f43P56uNRsV6O3fQvkBtK+cN2G5EnSnjdxSNJTW1NOQ26zwWz0ToOKVvmnJ4OQw0omvwSWLg4j+wo9DwQEohHkyVPiIBc2w7iogqxygr/p+0eva8M= 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 1756157207572439.41211493272215; Mon, 25 Aug 2025 14:26:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uqeh2-0002Nj-Lu; Mon, 25 Aug 2025 17:25: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 1uqegc-0001zR-CS; Mon, 25 Aug 2025 17:25:06 -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 1uqegK-0001qs-7Q; Mon, 25 Aug 2025 17:25:05 -0400 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 57PCBKdw012769; Mon, 25 Aug 2025 21:24:38 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 48q5hpu3uf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:37 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 57PHre1b002531; Mon, 25 Aug 2025 21:24:37 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 48qrypft07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:37 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 57PLOZjv4260468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Aug 2025 21:24:35 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCC9558059; Mon, 25 Aug 2025 21:24:35 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36A0458043; Mon, 25 Aug 2025 21:24:35 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.253]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 25 Aug 2025 21:24:35 +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=kF1kZFzyDG+5PD7DT lxH/PXLN/jetaApw70t+rGVNhk=; b=q6cjQxL0KBX8ZsiQ+jUatv33mTnhH8iRA en6l6ZESe7nDKGnGlrqLb3Q08VmN4F7EJX/q9UFZEPDOxPKMbGUGrMa38ypvcrn7 6JnLmKih0g/Z9cBjjVUsMXHsAx8d57mHu7yXwOSQPKvB9KN/Tk3jsieoPl37sdWn A/SXNOmAsLxy3JnUTg0zgPaYqDnLy18E0jQMYFbw2HLeskYFFpw1q+27dcPiVS0e SZ0FCaid33h7Jph9s16VdIb7u/H1+DbCLljIFqoawULoFSDyQjUyrn3+zPAgxqQb PiLSeK92JRg6qrn+HSJtQDfou4l54CLTG8pDGuI9NmraNOtB9icJg== From: Farhan Ali To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Cc: alifm@linux.ibm.com, mjrosato@linux.ibm.com, thuth@redhat.com, alex.williamson@redhat.com, clg@redhat.com Subject: [PATCH v2 1/4] [NOTFORMERGE] linux-headers: Update for zpci vfio device Date: Mon, 25 Aug 2025 14:24:30 -0700 Message-ID: <20250825212434.2255-2-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825212434.2255-1-alifm@linux.ibm.com> References: <20250825212434.2255-1-alifm@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODIzMDAyMSBTYWx0ZWRfX/fjnOPlw+EF6 lfzHWTRZhxeDJjCRr00wT/Z6VnKca53qBWyLD1sljB6kdMc2bJoowD/qerTRb5dOWgmytqZOs3R IrqtbOcg2sUVmHTUVmO2vUu0ORaTQYFONQZ8Jw2Vvz15ecoLof05RqL1nvRHyHRvdcrqCvs4Muq XQXSipvXLVVdMyrKHEB7u4VdqyemCbvoFXM2HeMQsKjJFPG76XDNOe6+IQe9kHzaOBs00Zkv+3q HnTkv3W8tarolHKvicHy6dhHOmrtakl4qXX+y0kstI1IsFtxSZD+w67mx8Ow+J7AKQXma9FOfRO UeJIjD722QlFevntitQgv52uJmxDP2GoamsexImBQ0x50txTQvew297CiXyYG0p8TE6mq7D9KVp 3huLUZDN X-Proofpoint-ORIG-GUID: I0tJDyh7ZMlWDaN5BSKUdM_N_L3ynF5Q X-Proofpoint-GUID: I0tJDyh7ZMlWDaN5BSKUdM_N_L3ynF5Q X-Authority-Analysis: v=2.4 cv=Ndbm13D4 c=1 sm=1 tr=0 ts=68acd495 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=2OwXVqhp2XgA:10 a=VnNF1IyMAAAA:8 a=Ef7EkEwsYO5O5uvjYS4A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-25_10,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1015 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508230021 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=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_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1756157209172124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Farhan Ali --- linux-headers/linux/vfio.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index 79bf8c0cc5..ef2cae92f5 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -1468,6 +1468,20 @@ struct vfio_device_feature_bus_master { }; #define VFIO_DEVICE_FEATURE_BUS_MASTER 10 =20 +/** + * VFIO_DEVICE_FEATURE_ZPCI_ERROR feature provides PCI error information to + * userspace for vfio-pci devices on s390x. On s390x PCI error recovery in= volves + * platform firmware and notification to operating system is done by + * architecture specific mechanism. Exposing this information to userspace + * allows userspace to take appropriate actions to handle an error on the + * device. + */ +struct vfio_device_feature_zpci_err { + __u16 pec; + int pending_errors; +}; +#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 11 + /* -------- API for Type1 VFIO IOMMU -------- */ =20 /** --=20 2.43.0 From nobody Sat Nov 15 03:03:57 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=1756157227; cv=none; d=zohomail.com; s=zohoarc; b=P/AmfVWVIadfQVKphbdLhWbX0utp8FE/Re+YBBcTQiVkp1oWuTh+fVzIKmJ4I+ouRSVpQX24G83cEMVgFEQz3ipajNsBZMHHmOMY5InsJQY1kLTg/+wCDL1PKc0MYuSWBZE3mpTOSvzrAEFfOdkd4UXcSGPctpCypJomEhf5YZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756157227; 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=CKaNldD39gux0n5zru7jawIwcYcN6/uuiAt/GMnnGvk=; b=bcRzNKpmTSj7afiVO9+bW9SDttn5pw4DZXNdXtkV/UE5NkinxQ7e6jj1Ki7Fr//2BY142WPrVRQBaOVNSRGpiuOODZIgdoDMYKRUOj681xDraF/fIa4xQ/tB8/GIi6SFsmPAdwncrmHzYRPdAaG3OnfdnIGkzqkbL0fFktPzU4k= 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 1756157227502259.5333349960449; Mon, 25 Aug 2025 14:27:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uqegs-0002AN-4d; Mon, 25 Aug 2025 17:25:24 -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 1uqegf-00023N-1e; Mon, 25 Aug 2025 17:25:09 -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 1uqegI-0001qm-2E; Mon, 25 Aug 2025 17:25:07 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57PKkf5T006750; Mon, 25 Aug 2025 21:24:38 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 48q42huaad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:38 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 57PIqBuM017993; Mon, 25 Aug 2025 21:24:37 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 48qtp37gk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:37 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 57PLOaVl8455408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Aug 2025 21:24:36 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 955DA58043; Mon, 25 Aug 2025 21:24:36 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED0985805E; Mon, 25 Aug 2025 21:24:35 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.253]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 25 Aug 2025 21:24:35 +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=CKaNldD39gux0n5zr u7jawIwcYcN6/uuiAt/GMnnGvk=; b=ZqTs8bffCdKmEeQWfrwR5FwTcYroaUKMG Q/51VBcVP41051/xU0Ynmixc4ru2GD3sF4oMAs3+AXK0ZE7F7s4TBRip+1dsX/nT Lu7BTTBRR7UMb8o2P2ENGugQVNK6OV/6bXltDIrYIZgas0aOMAQ/mlpO3jTgbuyG DbezAA3J16JV0+qdI6QZfwycUjAu1qD+/NfzRcjd4UVdUMkolkNht9rpfGxS1h08 /N8Ope3Ebo6jDBUI+K+EwWMMTTd5BxyhkJx/5CtKIkOkSe2jPda11XVE9F61jmSi EHNn6mGl6nWTaAxu6tSc77SDFtIHL6Xb8PPBw9TsxbpGsQk6jNiiw== From: Farhan Ali To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Cc: alifm@linux.ibm.com, mjrosato@linux.ibm.com, thuth@redhat.com, alex.williamson@redhat.com, clg@redhat.com Subject: [PATCH v2 2/4] vfio/pci: Add an architecture specific error handler Date: Mon, 25 Aug 2025 14:24:31 -0700 Message-ID: <20250825212434.2255-3-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825212434.2255-1-alifm@linux.ibm.com> References: <20250825212434.2255-1-alifm@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODIzMDAxMCBTYWx0ZWRfX7UGMwpj1PVIQ CDREaVJm3cFjDOJ2DpNXjUSYmgsczhuAbS/5PM6UbhaeG3Yk8szeOfk9VsRx25nm2kgP31kOO1+ W1pp0w7CMneC/ZpU6LfBbAdSWlwXkd8G8PyRI9TCRSoC+EGSCuBFs+2cYZ5oW4em+OO9XM+qI/m Gw5PBzlkpr/8fqsXQK5VnzjZqlVAV+mWSB5AyKn8pm7U2hYZV74NtMQeuiloSjCCAiu6gAp/vT4 HB6HwH540HulZ/JSTpdXh604crnEjfoZjzlbi0gBs5Gijyn+qsBP/UsowcZglCR5VwuXEjpYeYt Lr3tOG+Na8a99Y93zm1BTM3E05dIIHhlC/P1NoikKmma8Ft9bes71h4otXpcRvtbnvpPJ9XLlH7 wqdexRZJ X-Proofpoint-ORIG-GUID: yFcyvvTyou-BThCj3p-15iCxFyLn3-7l X-Proofpoint-GUID: yFcyvvTyou-BThCj3p-15iCxFyLn3-7l X-Authority-Analysis: v=2.4 cv=evffzppX c=1 sm=1 tr=0 ts=68acd496 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=2OwXVqhp2XgA:10 a=VnNF1IyMAAAA:8 a=muFhjd4W0z0y0MAsxxIA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-25_10,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508230010 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=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_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1756157229059116600 Content-Type: text/plain; charset="utf-8" Provide a architecture specific error handling callback, that can be used by platforms to handle PCI errors for passthrough devices. Signed-off-by: Farhan Ali --- hw/vfio/pci.c | 5 +++++ hw/vfio/pci.h | 1 + 2 files changed, 6 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 07257d0fa0..3c71d19306 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3026,6 +3026,11 @@ static void vfio_err_notifier_handler(void *opaque) return; } =20 + if (vdev->arch_err_handler) { + vdev->arch_err_handler(vdev); + return; + } + /* * TBD. Retrieve the error details and decide what action * needs to be taken. One of the actions could be to pass diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 810a842f4a..45d4405e47 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -145,6 +145,7 @@ struct VFIOPCIDevice { EventNotifier err_notifier; EventNotifier req_notifier; int (*resetfn)(struct VFIOPCIDevice *); + void (*arch_err_handler)(struct VFIOPCIDevice *); uint32_t vendor_id; uint32_t device_id; uint32_t sub_vendor_id; --=20 2.43.0 From nobody Sat Nov 15 03:03:57 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=1756157192; cv=none; d=zohomail.com; s=zohoarc; b=NbNVwm0JdRLQdU/on/UTMl1FFEC2u0cJY0FgqgsWcvqhks6fzZ+Xk729S5fBK9kUEId6KZp4g8vuJrR7qU4KBPYuOkVRiR99vhPOQ7cK1ugn0Qk0vBliSqclocS5xQ0gZYwHG0qnpGBVRVr4tHeTIW3RWzC78+9hwO8Z1/0bkMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756157192; 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=mE3qJAivminB5MrLqinfqvAmlvPJ3NNgZIEw4ZxYtQI=; b=JmuWVNllSlUeu1/TePMihzAItBAvOCSeicnhyflCJsmfe0hru4h6sBecNRyE1mDsQJLKRZlkKaM8j9RP/36tydGx8Cyith1m0Bs95FNPqjwksKqnq4k7P38az4WuAEHujR6PRJBSyEX+FVDXEg4bRzHhOISp/IL2RtU3NiqMjFA= 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 1756157192488994.0496292142451; Mon, 25 Aug 2025 14:26:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uqego-00029h-Dz; Mon, 25 Aug 2025 17:25:20 -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 1uqega-0001xz-KP; Mon, 25 Aug 2025 17:25:05 -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 1uqegI-0001r5-Mg; Mon, 25 Aug 2025 17:25:03 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 57PKDSMs028933; Mon, 25 Aug 2025 21:24:40 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 48q32vbfsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:40 +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 57PINS0V002612; Mon, 25 Aug 2025 21:24:39 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 48qt6m7juu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:39 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 57PLObbA24576496 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Aug 2025 21:24:37 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5029D58043; Mon, 25 Aug 2025 21:24:37 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B47195805E; Mon, 25 Aug 2025 21:24:36 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.253]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 25 Aug 2025 21:24:36 +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=mE3qJAivminB5MrLq infqvAmlvPJ3NNgZIEw4ZxYtQI=; b=gghQol3z6x2dyNOnZA57soTclGUSlGmBN lcExQSMCjGSDaCr8PqUouZrkk6X13jJvShxp+PD1VJTepDN5broZ33qRaznC8KCo oyDfopsUphrFZ28lIEkPvmaVq3a8Q5pv/xbS2lXvyYMXXihDiLSoHrr9pi530NUB EqKkU0g8e9ErrFlT9okt0TOu2vosT3k2XNTHV+nT/clSoP6W+yIPTzvdVxjHfr8C gxfHhi03TFoJqYu0vAIZwR08WKcPIrCop5nLCqRq6vNsnEDzQzZ1BdzVB7+FVhkc 9jFt5aNtR3KIzS0ngMOY8jSsFnNzh8y81xAauPQqzR/Sw+lwEvytQ== From: Farhan Ali To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Cc: alifm@linux.ibm.com, mjrosato@linux.ibm.com, thuth@redhat.com, alex.williamson@redhat.com, clg@redhat.com Subject: [PATCH v2 3/4] s390x/pci: Add PCI error handling for vfio pci devices Date: Mon, 25 Aug 2025 14:24:32 -0700 Message-ID: <20250825212434.2255-4-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825212434.2255-1-alifm@linux.ibm.com> References: <20250825212434.2255-1-alifm@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: OQMMLRmGiEyZif6qtqs4iIJ_o7fP6o-a X-Proofpoint-GUID: OQMMLRmGiEyZif6qtqs4iIJ_o7fP6o-a X-Authority-Analysis: v=2.4 cv=AfSxH2XG c=1 sm=1 tr=0 ts=68acd498 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=2OwXVqhp2XgA:10 a=VnNF1IyMAAAA:8 a=jSCLr9NRB7a5bD1T82IA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODIzMDAwMCBTYWx0ZWRfX9mjzghsiUw8g +LFLQVYQs32RQPimAksp32Sx7KT47RKKwA+nfaGc3cihDBtYmdeWesrHCq/7MPFMd/XAo5lU/P7 qsAkEkWCoxbRgVJoWawEYpYHbiB+FPUjJzzyBf944DdhP6Jr/LKNZUcpmiNjy8wYOM60Gk3y7ng a353Z38s3hoJf0hKzPSY/T0PesXK4mR/iMYWDKg78q1T+x+Aupy8EOMdREcwNNpTW+dN/jIl81p ls3Hvc4Jyq1f9cFCVAnioklgHKx3yuzQuAEUo8WtPAucTEv5KHH0NKpWTkE6p+roTJvWzb36wH6 KjRdPTyxUIuYgALPy04cXHO3r1vThAKg+r8QtKQUdQVBF59IwmvgIdHSsojrBLGxzJ8z1O3L0Hy e1+gJpb6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-25_10,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 spamscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508230000 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=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_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: 1756157193153124100 Content-Type: text/plain; charset="utf-8" Add an s390x specific callback for vfio error handling. For s390x pci devic= es, we have platform specific error information. We need to retrieve this error information for passthrough devices. This is done via a memory region 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 --- hw/s390x/s390-pci-bus.c | 5 +++ hw/s390x/s390-pci-vfio.c | 76 ++++++++++++++++++++++++++++++++ include/hw/s390x/s390-pci-bus.h | 1 + include/hw/s390x/s390-pci-vfio.h | 2 + 4 files changed, 84 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index f87d2748b6..af42eb9938 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -158,6 +158,8 @@ static void s390_pci_perform_unplug(S390PCIBusDevice *p= bdev) { HotplugHandler *hotplug_ctrl; =20 + qemu_mutex_destroy(&pbdev->err_handler_lock); + if (pbdev->pft =3D=3D ZPCI_PFT_ISM) { notifier_remove(&pbdev->shutdown_notifier); } @@ -1140,6 +1142,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, pbdev->iommu->pbdev =3D pbdev; pbdev->state =3D ZPCI_FS_DISABLED; set_pbdev_info(pbdev); + qemu_mutex_init(&pbdev->err_handler_lock); =20 if (object_dynamic_cast(OBJECT(dev), "vfio-pci")) { /* @@ -1164,6 +1167,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, 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 */ + s390_pci_setup_err_handler(pbdev); 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.c b/hw/s390x/s390-pci-vfio.c index aaf91319b4..87ecd06a81 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 @@ -103,6 +104,60 @@ void s390_pci_end_dma_count(S390pciState *s, S390PCIDM= ACount *cnt) } } =20 +static int s390_pci_get_feature_err(VFIOPCIDevice *vfio_pci, + struct vfio_device_feature_zpci_err *e= rr) +{ + int ret; + uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + + sizeof(struct vfio_device_feature_zpci_err), + 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_GET | VFIO_DEVICE_FEATURE_ZPCI_= ERROR; + ret =3D vfio_pci->vbasedev.io_ops->device_feature(&vfio_pci->vbasedev, + feature); + + if (ret) { + error_report("Failed feature get VFIO_DEVICE_FEATURE_ZPCI_ERROR" + " (rc=3D%d)", ret); + return ret; + } + + memcpy(err, (struct vfio_device_feature_zpci_err *) feature->data, + sizeof(struct vfio_device_feature_zpci_err)); + return 0; +} + +static void s390_pci_err_handler(VFIOPCIDevice *vfio_pci) +{ + S390PCIBusDevice *pbdev; + struct vfio_device_feature_zpci_err err; + int ret; + + pbdev =3D s390_pci_find_dev_by_target(s390_get_phb(), + DEVICE(&vfio_pci->pdev)->id); + + QEMU_LOCK_GUARD(&pbdev->err_handler_lock); + + ret =3D s390_pci_get_feature_err(vfio_pci, &err); + if (ret) { + return; + } + + pbdev->state =3D ZPCI_FS_ERROR; + s390_pci_generate_error_event(err.pec, pbdev->fh, pbdev->fid, 0, 0); + + while (err.pending_errors) { + ret =3D s390_pci_get_feature_err(vfio_pci, &err); + if (ret) { + return; + } + s390_pci_generate_error_event(err.pec, pbdev->fh, pbdev->fid, 0, 0= ); + } + return; +} + static void s390_pci_read_base(S390PCIBusDevice *pbdev, struct vfio_device_info *info) { @@ -369,3 +424,24 @@ void s390_pci_get_clp_info(S390PCIBusDevice *pbdev) s390_pci_read_util(pbdev, info); s390_pci_read_pfip(pbdev, info); } + +void s390_pci_setup_err_handler(S390PCIBusDevice *pbdev) +{ + int ret; + VFIOPCIDevice *vfio_pci =3D container_of(pbdev->pdev, VFIOPCIDevice, = 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_pci->vbasedev.io_ops->device_feature(&vfio_pci->vbasedev, + feature); + + if (ret) { + info_report("Automated error recovery not available for passthroug= h device"); + return; + } + vfio_pci->arch_err_handler =3D s390_pci_err_handler; +} diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 04944d4fed..3795e0bbfc 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -364,6 +364,7 @@ struct S390PCIBusDevice { bool forwarding_assist; bool aif; bool rtr_avail; + QemuMutex err_handler_lock; 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 ae1b126ff7..66b274293c 100644 --- a/include/hw/s390x/s390-pci-vfio.h +++ b/include/hw/s390x/s390-pci-vfio.h @@ -22,6 +22,7 @@ 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); +void s390_pci_setup_err_handler(S390PCIBusDevice *pbdev); #else static inline bool s390_pci_update_dma_avail(int fd, unsigned int *avail) { @@ -39,6 +40,7 @@ static inline bool s390_pci_get_host_fh(S390PCIBusDevice = *pbdev, uint32_t *fh) return false; } static inline void s390_pci_get_clp_info(S390PCIBusDevice *pbdev) { } +static inline void s390_pci_setup_err_handler(S390PCIBusDevice *pbdev) { } #endif =20 #endif --=20 2.43.0 From nobody Sat Nov 15 03:03:57 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=1756157181; cv=none; d=zohomail.com; s=zohoarc; b=K4BWNpW3g2ixsUPxgkknugxjG7MYx/zmHOLbh+Fsc3YQIgMkjH9qNDW//xL/kxsFnzCNnfOgeqG9FobN8C9zXg1FIIatLp95mNj7Mn6nqZV2k+IOwPkQ7aFxCaIIEstuEC46ItWKTDzdPdHlijiWp/0O4vW1Ly37v+c8PzlWVZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756157181; 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=KPf82vw/8oEiIJA5+H5k6bSmA5+UulS3EUMUpwaiZeI=; b=LAW155pZJCUAKhEL9DoKwi5mSVEOgwPgJFioPDIQ+PMYqqHBNAJmqXMfYj26M4uFDArMAmho+jI5p2J3yoYkvyn4bqBMGSiTgSNn2xr471m8YHoQf1oNil7I19jwOEqP/GZffW9CTDu9uja3m2Cwp/rsPZwLLeVV00DP90U8nOc= 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 1756157181319351.2730371497722; Mon, 25 Aug 2025 14:26:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uqegf-00022e-Ko; Mon, 25 Aug 2025 17:25:13 -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 1uqegZ-0001xW-0C; Mon, 25 Aug 2025 17:25:04 -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 1uqegI-0001qz-No; Mon, 25 Aug 2025 17:25:02 -0400 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 57PH1WpE012568; Mon, 25 Aug 2025 21:24:40 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 48q5hpu3ug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:39 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 57PLBgcj007458; Mon, 25 Aug 2025 21:24:38 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 48qqyu80gd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Aug 2025 21:24:38 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 57PLOce625100946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Aug 2025 21:24:38 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C89758043; Mon, 25 Aug 2025 21:24:38 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FF5358059; Mon, 25 Aug 2025 21:24:37 +0000 (GMT) Received: from IBM-D32RQW3.ibm.com (unknown [9.61.255.253]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 25 Aug 2025 21:24:37 +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=KPf82vw/8oEiIJA5+ H5k6bSmA5+UulS3EUMUpwaiZeI=; b=cHRsnZ0Uei4Iwj6DnY03UQWLYCr55WxX5 nV+jKZk0nEA6Os4QjK90T5hYj4zOrTpoXFn4tS2VSZmLou7/GOQlGdGAkjTDyP/0 SpZv8FEoeuL67vErcZ5vxeylYfgD6+6zlqKJ8wjbYqoP0PF/Jw1XYY7fMdPfNW5/ U3+ECvu/eX/jShlnVFzKnISwzXJcYsFI49trlDzrzupJljaVNAP6CijtRjEf+Mkh QaOwFG2xHdkq6KAOrSS3eZ8pav1tUv9dugWjkWs8O5GDnnrVK4HvXgBMD0PDRlsY +8a8/lHgH8K0c1dkPvnhEkF8yHf+fnYAUkiNOuqeNCutJnNZD5xmA== From: Farhan Ali To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Cc: alifm@linux.ibm.com, mjrosato@linux.ibm.com, thuth@redhat.com, alex.williamson@redhat.com, clg@redhat.com Subject: [PATCH v2 4/4] s390x/pci: Reset a device in error state Date: Mon, 25 Aug 2025 14:24:33 -0700 Message-ID: <20250825212434.2255-5-alifm@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825212434.2255-1-alifm@linux.ibm.com> References: <20250825212434.2255-1-alifm@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwODIzMDAyMSBTYWx0ZWRfX3yNmuHlS3tZd 2wano0kaUJ1vMKsS5veCWPhb6sUajzV4qjUTHEbNzXh20Jo00+l8abGDzRKJXPw9JghGBEpN3sG YXwxuJWPtAgL3cduolQNpXg07b0ikPppe0WQKkJtHGA9Wf1TeAmpbgFLNsjMT/wLvJX9uHyTyp+ TntLRNubG0k4Zvlq4NqHkp7Y4UCvA0WUkhq5UOawLrhg4h+o+IMBwjQi/3Uw0xxMQWbW8O/AxWP 1ILMD/VrYZymMicBhgL0kn4MRFX3FMJcZ3nVVwuvZOr9J+IePk0GpdZtmftm2JyBkTdm4OYWtMM jSVlMQl+oOIdVY3ZJM1mVTWpBcsbTd+gIWR2XUA1AjsX27ZlJap5XVJ0hKSGYxdRpnXMZHmCF9w QJpP7HfS X-Proofpoint-ORIG-GUID: 3b4i2HD6k8c-F_VsKhAZ6wM0Io-jbRZP X-Proofpoint-GUID: 3b4i2HD6k8c-F_VsKhAZ6wM0Io-jbRZP X-Authority-Analysis: v=2.4 cv=Ndbm13D4 c=1 sm=1 tr=0 ts=68acd497 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=2OwXVqhp2XgA:10 a=VnNF1IyMAAAA:8 a=A6rq8h5Md1LYvE6mRIYA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-08-25_10,2025-08-20_03,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1015 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2508230021 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=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_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1756157185005124100 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 --- hw/s390x/s390-pci-bus.c | 7 +++++++ hw/s390x/s390-pci-vfio.c | 6 ++++++ include/hw/s390x/s390-pci-vfio.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index af42eb9938..c9c2d775f0 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1493,6 +1493,8 @@ static void s390_pci_device_reset(DeviceState *dev) return; case ZPCI_FS_STANDBY: break; + case ZPCI_FS_ERROR: + break; default: pbdev->fh &=3D ~FH_MASK_ENABLE; pbdev->state =3D ZPCI_FS_DISABLED; @@ -1505,6 +1507,11 @@ static void s390_pci_device_reset(DeviceState *dev) } else if (pbdev->summary_ind) { pci_dereg_irqs(pbdev); } + + if (pbdev->state =3D=3D ZPCI_FS_ERROR) { + s390_pci_reset(pbdev); + } + if (pbdev->iommu->enabled) { pci_dereg_ioat(pbdev->iommu); } diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 87ecd06a81..a11ec770a7 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -158,6 +158,12 @@ static void s390_pci_err_handler(VFIOPCIDevice *vfio_p= ci) return; } =20 +void s390_pci_reset(S390PCIBusDevice *pbdev) +{ + VFIOPCIDevice *vfio_pci =3D container_of(pbdev->pdev, VFIOPCIDevice, p= dev); + ioctl(vfio_pci->vbasedev.fd, VFIO_DEVICE_RESET); +} + static void s390_pci_read_base(S390PCIBusDevice *pbdev, struct vfio_device_info *info) { diff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-v= fio.h index 66b274293c..c28dafeed8 100644 --- a/include/hw/s390x/s390-pci-vfio.h +++ b/include/hw/s390x/s390-pci-vfio.h @@ -23,6 +23,7 @@ void s390_pci_end_dma_count(S390pciState *s, S390PCIDMACo= unt *cnt); bool s390_pci_get_host_fh(S390PCIBusDevice *pbdev, uint32_t *fh); void s390_pci_get_clp_info(S390PCIBusDevice *pbdev); void s390_pci_setup_err_handler(S390PCIBusDevice *pbdev); +void s390_pci_reset(S390PCIBusDevice *pbdev); #else static inline bool s390_pci_update_dma_avail(int fd, unsigned int *avail) { @@ -41,6 +42,7 @@ static inline bool s390_pci_get_host_fh(S390PCIBusDevice = *pbdev, uint32_t *fh) } static inline void s390_pci_get_clp_info(S390PCIBusDevice *pbdev) { } static inline void s390_pci_setup_err_handler(S390PCIBusDevice *pbdev) { } +void s390_pci_reset(S390PCIBusDevice *pbdev) { } #endif =20 #endif --=20 2.43.0