From nobody Mon Nov 23 04:43:54 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=1792427199; cv=none; d=zohomail.com; s=zohoarc; b=lKSgjLh3iKtcHNCFl+U4INOZAbJcoWApZcUcNhp9+1sMlSxCCip7Bj9Exi05k87unyk6eRHOgqKj8pmMVuuWPingZ1vYGJZOX7DsOZsH4L5NskWXj6XlLdxMTn2LsibFj8WO1AOg7oCuu8EsIjlxLeuqxQ2IWf0MZjnpk7D2Mjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792427199; 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=BVPZoSKGUK733gFC89wDtVmSRlA5eE/ouVcW+R4JSs8=; b=Qs+xbOrLHt1teU85CMlPAI8/S5wrjUo8xLXZYedBmCnm3jxeRy97SzJzM2i1Pp6Wduhk5bfLNPqpyAlssDbSOke7t3zWlkkIgeaGQuB1cEp0qMA9KsS8Ay46RUQwNVbjXbTTWFUadv7SyddiQUvJMI/ngV2h/C30C+1EwaH0AXQ= 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 1792427199790157.48556001686802; Mon, 19 Oct 2026 09:26:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIqBr-0001rs-Bu; Mon, 19 Oct 2026 12:26:23 -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 1xIqBn-0001pP-0b; Mon, 19 Oct 2026 12:26:19 -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 1xIqBk-0001TC-UM; Mon, 19 Oct 2026 12:26:18 -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 69JFijYF019505; Mon, 19 Oct 2026 16:26:15 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 4hc0nvuf6w-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:15 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69JFZ5I23125157; Mon, 19 Oct 2026 16:26:14 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hcnjgxb42-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:14 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69JGQ8hp48562438 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Oct 2026 16:26:08 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A1C022004D; Mon, 19 Oct 2026 16:26:08 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0CB02004B; Mon, 19 Oct 2026 16:26:03 +0000 (GMT) Received: from Narayanas-MacBook-Pro.ibm.com (unknown [9.124.217.62]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 19 Oct 2026 16:26: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=BVPZoSKGUK733gFC8 9wDtVmSRlA5eE/ouVcW+R4JSs8=; b=Ep8RlflbG/xMCVS0R3GwHNrrJB6spuwfq e2n8FlHc9ANnLYMwGnVR87XxgpB9TiMAXHY7ypDPduiexofsDY4Fkl6AlOyVINQ8 ts0n3lmIVeG0BKPYku31gadrWEIMDA7gc3yJnTgfapGF1Ikv/u4oSToxBTNie+E7 M5n5ClLTkz9k5PJH75fHl/InfRBZmsURuMZwtyoL4WjU1qgcfoJJetrDMoZpNsYd +zX05tkZZmVghJJDjXAI83nb2SEqwS2XomRKKDSFGG9FmK2tqf+hw/HMeM6pMYC6 kJwRV0usEX1R7MMVfdBv0SPv0ItfOcPKNjcHGI448q2pmHlcAS5ug== From: Narayana Murty N To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Mahesh J Salgaonkar , Sourabh Bhat , anushree.mathur@linux.vnet.ibm.com, clg@redhat.com, Sourabh Jain , adityag@linux.ibm.com, nikhilks@linux.ibm.com Cc: pierrick.bouvier@oss.qualcomm.com, rathc@linux.ibm.com, Nicholas Piggin , harshpb@linux.ibm.com, amachhiw@linux.ibm.com, hbathini@linux.ibm.com, shivangu@linux.ibm.com Subject: [PATCH v6 1/6] ppc/spapr: Add VFIO EEH error injection backend Date: Mon, 19 Oct 2026 21:55:35 +0530 Message-ID: <20261019162541.68440-2-nnmlinux@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261019162541.68440-1-nnmlinux@linux.ibm.com> References: <20261019162541.68440-1-nnmlinux@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfXyFaC1KyvWYBv xLABgdGriwDLgqkk2svIVHgZw7spAgKteZZI+r0n2ZDkU7560kWX4udim8cTvudkbaYtVPnKAMq kSx4WSppUP78gzY0Fik5TbAaGkjaH3s= X-Proofpoint-ORIG-GUID: UwZlQhvIkf7uy4OQAsDZllcRhIoRInBX X-Proofpoint-GUID: H9-CNNDpE48SG8BilaYMIDO6V5i3wYQN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX039CkCgKSpEm R7y2FjDvZ9BUWock60k/eM9pH+vDP9Z74gxK+41r6JQ5l0c32a2+uW4aSy+R8HGMSrqaqvL4jeK LwRuoEA8SS0Prh6BqBAj7r6R73c7KxCslJWBGbvmmKoHMhZGlTD8d9w/+sYWDrfVI8nfC/2CJB3 +GPM4DVAr9x1oKlfxzfJ5EuFpOEwLiMOYYKTIUP2nIoI97qDnZrqjEl+2dgBqcQ2BuO42w5HFVQ HzgkR/zwbjjIXXS8zqnjr588dO4y6AYatT7axWUxShYpkjaqzhXM2vUmwRaBPV5T7MxDG1nMpnu OO7A8+xHj5MhLgYT0NXmvYxWbbd1HoTMTs2MUHlUwEN/ZbtinBbRaqd0o7CJULjZyMoIoTvf4ql hl36bkwgPNXr6MFP4DDUitS7WAsMx6nHkpLus412DWb5ed/Bm/l9kml7iV7XUMczty73V0aTnKV BOrRabF4vjCJAzeXSvg== X-Authority-Analysis: v=2.4 cv=MY35KJ/f c=1 sm=1 tr=0 ts=6ad644a7 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=0fC1r5mNT4k1lSFpsBYA:9 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-19_05,2026-10-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 bulkscore=0 priorityscore=1501 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610190064 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=nnmlinux@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: 1792427201597158500 Content-Type: text/plain; charset="utf-8" Add spapr_phb_vfio_errinjct() to the VFIO EEH backend in spapr_pci_vfio.c. The function maps guest RTAS IOA bus-error types to the corresponding VFIO EEH ioctl error types: RTAS_ERR_TYPE_IOA_BUS_ERROR -> EEH_ERR_TYPE_32 RTAS_ERR_TYPE_IOA_BUS_ERROR_64 -> EEH_ERR_TYPE_64 EEH_ERR_TYPE_32 / EEH_ERR_TYPE_64 are imported from the powerpc UAPI EEH header where available; fallback numeric definitions are provided to guard against older build environments. The backend consumes type, func, addr, and mask from the caller. It does not accept or interpret config_addr; PHB/PE selection is the caller's responsibility via the sphb pointer. Supporting type definitions are added to include/hw/ppc/spapr.h: - EEH_ERR_FUNC_* and EEH_ERR_FUNC_MAX - EEH_ERR_TYPE_32 / EEH_ERR_TYPE_64 (with #ifndef guards) - enum rtas_err_type (RTAS ibm,errinjct error token values) - RTAS_IBM_ERRINJCT token The function prototype is added to include/hw/pci-host/spapr.h inside the CONFIG_LINUX ifdef block alongside the other EEH hooks. Signed-off-by: Narayana Murty N Reviewed-by: Nikhil Kumar Singh Reported-by: Tasmiya Nalatwad Tested-by: Tasmiya Nalatwad --- include/hw/pci-host/spapr.h | 8 ++++ include/hw/ppc/spapr.h | 60 ++++++++++++++++++++++++++- hw/ppc/spapr_pci_vfio.c | 81 +++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 0db87f1281..24109409f4 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -125,6 +125,8 @@ int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, i= nt *state); int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option); int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb); void spapr_phb_vfio_reset(DeviceState *qdev); +int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, + uint32_t func, uint64_t addr, uint64_t mask); #else static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb) { @@ -151,6 +153,12 @@ static inline int spapr_phb_vfio_eeh_configure(SpaprPh= bState *sphb) static inline void spapr_phb_vfio_reset(DeviceState *qdev) { } +static inline int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t ty= pe, + uint32_t func, uint64_t addr, + uint64_t mask) +{ + return RTAS_OUT_NOT_SUPPORTED; +} #endif =20 void spapr_phb_dma_reset(SpaprPhbState *sphb); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 9acda15d4f..253dc0e862 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -682,6 +682,63 @@ void push_sregs_to_kvm_pr(SpaprMachineState *spapr); #define RTAS_EEH_PE_UNAVAIL_INFO 1000 #define RTAS_EEH_PE_RECOVER_INFO 0 =20 +/* EEH error injection types and functions */ +#define EEH_ERR_FUNC_MIN 0 +#define EEH_ERR_FUNC_LD_MEM_ADDR 0 /* Memory load */ +#define EEH_ERR_FUNC_LD_MEM_DATA 1 +#define EEH_ERR_FUNC_LD_IO_ADDR 2 /* IO load */ +#define EEH_ERR_FUNC_LD_IO_DATA 3 +#define EEH_ERR_FUNC_LD_CFG_ADDR 4 /* Config load */ +#define EEH_ERR_FUNC_LD_CFG_DATA 5 +#define EEH_ERR_FUNC_ST_MEM_ADDR 6 /* Memory store */ +#define EEH_ERR_FUNC_ST_MEM_DATA 7 +#define EEH_ERR_FUNC_ST_IO_ADDR 8 /* IO store */ +#define EEH_ERR_FUNC_ST_IO_DATA 9 +#define EEH_ERR_FUNC_ST_CFG_ADDR 10 /* Config store */ +#define EEH_ERR_FUNC_ST_CFG_DATA 11 +#define EEH_ERR_FUNC_DMA_RD_ADDR 12 /* DMA read */ +#define EEH_ERR_FUNC_DMA_RD_DATA 13 +#define EEH_ERR_FUNC_DMA_RD_MASTER 14 +#define EEH_ERR_FUNC_DMA_RD_TARGET 15 +#define EEH_ERR_FUNC_DMA_WR_ADDR 16 /* DMA write */ +#define EEH_ERR_FUNC_DMA_WR_DATA 17 +#define EEH_ERR_FUNC_DMA_WR_MASTER 18 +#define EEH_ERR_FUNC_DMA_WR_TARGET 19 +#define EEH_ERR_FUNC_MAX EEH_ERR_FUNC_DMA_WR_TARGET + +/* + * RTAS ibm,errinjct error type byte values. These are RTAS ABI token + * numbers, not the same as the VFIO EEH ABI type values consumed by + * VFIO_EEH_PE_INJECT_ERR. An explicit mapping is required. + */ +/* Use powerpc EEH UAPI constants where available; define locally otherwis= e. */ +#ifndef EEH_ERR_TYPE_32 +#define EEH_ERR_TYPE_32 0 +#endif +#ifndef EEH_ERR_TYPE_64 +#define EEH_ERR_TYPE_64 1 +#endif + +/* RTAS PCI Error Injection Token Types */ +enum rtas_err_type { + RTAS_ERR_TYPE_FATAL =3D 0x1, + RTAS_ERR_TYPE_RECOVERED_RANDOM_EVENT =3D 0x2, + RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT =3D 0x3, + RTAS_ERR_TYPE_CORRUPTED_PAGE =3D 0x4, + RTAS_ERR_TYPE_CORRUPTED_SLB =3D 0x5, + RTAS_ERR_TYPE_TRANSLATOR_FAILURE =3D 0x6, + RTAS_ERR_TYPE_IOA_BUS_ERROR =3D 0x7, + RTAS_ERR_TYPE_PLATFORM_SPECIFIC =3D 0x8, + RTAS_ERR_TYPE_CORRUPTED_DCACHE_START =3D 0x9, + RTAS_ERR_TYPE_CORRUPTED_DCACHE_END =3D 0xA, + RTAS_ERR_TYPE_CORRUPTED_ICACHE_START =3D 0xB, + RTAS_ERR_TYPE_CORRUPTED_ICACHE_END =3D 0xC, + RTAS_ERR_TYPE_CORRUPTED_TLB_START =3D 0xD, + RTAS_ERR_TYPE_CORRUPTED_TLB_END =3D 0xE, + RTAS_ERR_TYPE_IOA_BUS_ERROR_64 =3D 0xF, + RTAS_ERR_TYPE_UPSTREAM_IO_ERROR =3D 0x10 +}; + /* ibm,set-slot-reset */ #define RTAS_SLOT_RESET_DEACTIVATE 0 #define RTAS_SLOT_RESET_HOT 1 @@ -764,8 +821,9 @@ void push_sregs_to_kvm_pr(SpaprMachineState *spapr); #define RTAS_IBM_NMI_REGISTER (RTAS_TOKEN_BASE + 0x2B) #define RTAS_IBM_NMI_INTERLOCK (RTAS_TOKEN_BASE + 0x2C) #define RTAS_CONFIGURE_KERNEL_DUMP (RTAS_TOKEN_BASE + 0x2D) +#define RTAS_IBM_ERRINJCT (RTAS_TOKEN_BASE + 0x2E) =20 -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2E) +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2F) =20 /* RTAS ibm,get-system-parameter token values */ #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20 diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index a748a0bf4c..b151e9138c 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -26,6 +26,7 @@ #include "hw/pci/pci_device.h" #include "hw/vfio/vfio-container-legacy.h" #include "qemu/error-report.h" +#include "hw/vfio/pci.h" #include CONFIG_DEVICES /* CONFIG_VFIO_PCI */ =20 /* @@ -317,6 +318,80 @@ int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) return RTAS_OUT_SUCCESS; } =20 +static int spapr_vfio_errinjct_rtas_type_to_vfio(uint32_t rtas_type) +{ + switch (rtas_type) { + case RTAS_ERR_TYPE_IOA_BUS_ERROR: + return EEH_ERR_TYPE_32; + case RTAS_ERR_TYPE_IOA_BUS_ERROR_64: + return EEH_ERR_TYPE_64; + default: + return -1; + } +} + +static bool spapr_vfio_errinjct_func_valid(uint32_t func) +{ + return func <=3D EEH_ERR_FUNC_MAX; +} + +int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, + uint32_t func, uint64_t addr, uint64_t mask) +{ + VFIOLegacyContainer *container; + struct vfio_eeh_pe_op op =3D { + .op =3D VFIO_EEH_PE_INJECT_ERR, + .argsz =3D sizeof(op), + }; + int vfio_type; + + if (!sphb) { + return RTAS_OUT_PARAM_ERROR; + } + + if (!spapr_vfio_errinjct_func_valid(func)) { + return RTAS_OUT_PARAM_ERROR; + } + + vfio_type =3D spapr_vfio_errinjct_rtas_type_to_vfio(type); + if (vfio_type < 0) { + return RTAS_OUT_NOT_SUPPORTED; + } + + container =3D vfio_eeh_as_container(&sphb->iommu_as); + if (!container) { + error_report("vfio/eeh errinjct: no VFIO EEH container for PHB"); + return RTAS_OUT_NOT_SUPPORTED; + } + + /* Enforce exactly one group per container check matching other EEH op= s */ + if (!vfio_eeh_container_ok(container)) { + error_report("vfio: requires a container with exactly one group"); + return RTAS_OUT_HW_ERROR; + } + + op.err.type =3D vfio_type; + op.err.func =3D func; + op.err.addr =3D addr; + op.err.mask =3D mask; + + if (ioctl(container->fd, VFIO_EEH_PE_OP, &op) < 0) { + error_report("vfio/eeh errinjct: VFIO_EEH_PE_OP failed: %s", + strerror(errno)); + switch (errno) { + case EINVAL: + return RTAS_OUT_PARAM_ERROR; + case ENOTTY: + case EOPNOTSUPP: + return RTAS_OUT_NOT_SUPPORTED; + default: + return RTAS_OUT_HW_ERROR; + } + } + + return RTAS_OUT_SUCCESS; +} + #else =20 bool spapr_phb_eeh_available(SpaprPhbState *sphb) @@ -349,4 +424,10 @@ int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) return RTAS_OUT_NOT_SUPPORTED; } =20 +int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, + uint32_t func, uint64_t addr, uint64_t mask) +{ + return RTAS_OUT_NOT_SUPPORTED; +} + #endif /* CONFIG_VFIO_PCI */ --=20 2.51.1 From nobody Mon Nov 23 04:43:54 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=1792427227; cv=none; d=zohomail.com; s=zohoarc; b=I3rycr71q23AjEdEYRWhIiy4I+k0byf8H4AGoGqnhJXWEEPo3Tpxx7nBr0fJ2ZUsDAJ194Y9TdPC1Ld1djzDpluvn6lcvgXRlk+pm9j6pUP5mbBvkkzcz7yPVPhKyP6jmRZFAUdvCxe8k4f/MFiN8/p50goX/TnpLq7nmafnzLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792427227; 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=SYthdHRl4BKS5rjNcMD1xIptLcBF/00aeZ4kph6MpLA=; b=M05lS3wEjny74C3qWDOtQDvOgWZfmLwtY7Ses+dl7uO1hQBbPjKfzdFr7MEIy1lR+SCX5Cl8Hj+g+Xp+27TW1WCWxRVVfxtNM8xf9Ms1iZCFSm6j74mc1iZgBlXTMoH9y56Lkg0PYVcqwoO5iZr7k+y0ZT+mZ5X/Bi6pq5y8u6g= 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 1792427227138241.8244142057306; Mon, 19 Oct 2026 09:27:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIqCT-0002GM-U3; Mon, 19 Oct 2026 12:27:01 -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 1xIqCA-00021y-SR; Mon, 19 Oct 2026 12:26:43 -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 1xIqBu-0001Tn-Ov; Mon, 19 Oct 2026 12:26:34 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69JFiXb4123280; Mon, 19 Oct 2026 16:26:25 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 4hc0h5ccrh-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:24 +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 69JFZ5ct081542; Mon, 19 Oct 2026 16:26:23 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hcmbjxgcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:23 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69JGQDqd39911750 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Oct 2026 16:26:13 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCB6220043; Mon, 19 Oct 2026 16:26:12 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10E5B20040; Mon, 19 Oct 2026 16:26:09 +0000 (GMT) Received: from Narayanas-MacBook-Pro.ibm.com (unknown [9.124.217.62]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 19 Oct 2026 16:26:08 +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=SYthdHRl4BKS5rjNc MD1xIptLcBF/00aeZ4kph6MpLA=; b=GeHUY8LT4aXDN7YcDrWj9evnWR7nWTfLj GW9CvIC0AhS549+FArmuyGhIGKQasjP3eCeDObtibZ3FJ8kdObt8u+k7doO52s2w 9gSvOnP1K2PdRrQmRVE0TclAstTTc1KETsWcbSIJDaiXu195iHEXIA8XGprTUDMA IVXb65iiP6LU0Kw5/Kxp3X3LOW38IG83ws+S2VgfwCXjFzN3At/KxHXfpZdzEoWh flhHmu+iFRdNaJXtw0NGsNTAzUUD1+54MWpjyvvtGklXTbwQ74sgjPQR2+Fnfd5a QAgxD7dD5Y3Fww2N+tpj+BQRyv7iEnirA92RvRwYBssKsZ1Q7ApWg== From: Narayana Murty N To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Mahesh J Salgaonkar , Sourabh Bhat , anushree.mathur@linux.vnet.ibm.com, clg@redhat.com, Sourabh Jain , adityag@linux.ibm.com, nikhilks@linux.ibm.com Cc: pierrick.bouvier@oss.qualcomm.com, rathc@linux.ibm.com, Nicholas Piggin , harshpb@linux.ibm.com, amachhiw@linux.ibm.com, hbathini@linux.ibm.com, shivangu@linux.ibm.com Subject: [PATCH v6 2/6] ppc/spapr: Add ibm,errinjct RTAS call handler Date: Mon, 19 Oct 2026 21:55:36 +0530 Message-ID: <20261019162541.68440-3-nnmlinux@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261019162541.68440-1-nnmlinux@linux.ibm.com> References: <20261019162541.68440-1-nnmlinux@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfXw4rBBu3a283/ MFRsHy89ooy9voTl5nTNisHc7TRU1QD4paG//dxHkBDOYKK6ig2dvhRftnjBCDzodrcgew2uIP3 kBilaMW1vgkxQOt2QY/8utTPmDhZTDw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX6WRhPMB8/oGu x5P0YQYUnFkkKSpeqVOzm4tbZaXLTGaw87dJbkh5CAaEh4ms8G3tOq+afuWdnWzGtu4Wp9v99kt u8L3nlyXCKEhT4B0AzgRQoXdsS1dg+WR7eZ1YsQWlpoqVO6AJxA/6HCqDBVZCo54hUBKw2LkPHz l+Id+7PuU5iYErrbRjzlRagwjIcmF2bKaraB3qY12t8WXPUoFTpi0iBIKAaGqshdlqof+iUX+jU +P/97dnCbN1dWTl3xGDmFAvVZGezIGSeiGtT4wTU9RYAGC+cRSPu1YUDxaCSEB6+vn7v4GJZoST AwCffjoNiNwRuOaHOHixRGQxSmLz4NrHo9aUPfQmmW5P7rsjq2l76CeRfuvcF5GM2Bkyvo65c4A 8+X/Tlq3UJtmVDEeJJSw0PFsjI6wjLkxuflZBT0F0+m+y/A1LW0/p6DRJrWaOL8fttBeZch4fl9 DhjKEaT51QAJfd+aqoA== X-Proofpoint-ORIG-GUID: hORIlvMbFKtpO5WykDpOkVhvI6dJ2JiM X-Proofpoint-GUID: z-Z5zI7zvkb7vLynEgfwHmVHNAyneqhF X-Authority-Analysis: v=2.4 cv=KujYSmWN c=1 sm=1 tr=0 ts=6ad644b1 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=ckvBqbd_4HPzd86GAI0A:9 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-19_05,2026-10-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610190064 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=nnmlinux@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: 1792427228147158500 Content-Type: text/plain; charset="utf-8" Implement the 'ibm,errinjct' RTAS call for PHB-level PCI error injection via firmware. The handler decodes the RTAS parameter buffer, validates arguments, selects the target PHB by BUID, and delegates the injection to the VFIO EEH backend. IOA bus-error injection (types 0x7 and 0xF) is fully supported: - The BUID field in the RTAS parameter block selects the target PHB via spapr_pci_find_phb(); - For addr !=3D 0 or mask !=3D 0 the guest BAR address is translated to the corresponding host resource base address before calling the VFIO backend. Translation matches the guest BAR layout under the selected PHB, computes offset =3D guest_addr - guest_bar, reads the host sysfs resource file for the matching BAR, and yields host_addr =3D host_bar + offset. - For addr =3D=3D 0 and mask =3D=3D 0 translation is skipped and zero addr/mask are forwarded directly (powerpc-utils errinjct -a 0 -m 0). Non-IOA error types (corrupted-page, dcache, icache, tlb, recovered-special-event) are decoded and validated, then rejected with RTAS_OUT_NOT_SUPPORTED because their RTAS work buffers do not carry a BUID, making safe VFIO PHB/PE selection impossible. The translation helpers added to spapr_pci_vfio.c: - spapr_phb_vfio_translate_errinjct_addr() - public entry point - spapr_vfio_errinjct_find_bar_cb() - per-device BAR scan - spapr_vfio_errinjct_get_host_bar() - host sysfs BAR reader config_addr is retained as a logging/debug parameter only; PHB selection relies on BUID. Signed-off-by: Narayana Murty N Reviewed-by: Nikhil Kumar Singh Reported-by: Tasmiya Nalatwad Tested-by: Tasmiya Nalatwad --- include/hw/pci-host/spapr.h | 11 ++ include/hw/ppc/spapr.h | 3 + hw/ppc/spapr_pci.c | 135 ++++++++++++++++++++++++ hw/ppc/spapr_pci_vfio.c | 203 ++++++++++++++++++++++++++++++++++++ 4 files changed, 352 insertions(+) diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 24109409f4..492f66e1ef 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -127,6 +127,10 @@ int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb); void spapr_phb_vfio_reset(DeviceState *qdev); int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, uint32_t func, uint64_t addr, uint64_t mask); +int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, + uint32_t config_addr, + uint64_t guest_addr, + uint64_t *host_pci_bus_addr); #else static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb) { @@ -159,6 +163,13 @@ static inline int spapr_phb_vfio_errinjct(SpaprPhbStat= e *sphb, uint32_t type, { return RTAS_OUT_NOT_SUPPORTED; } +static inline int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sp= hb, + uint32_t config_a= ddr, + uint64_t guest_ad= dr, + uint64_t *host_ad= dr) +{ + return -ENOTSUP; +} #endif =20 void spapr_phb_dma_reset(SpaprPhbState *sphb); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 253dc0e862..47791c71bd 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -274,6 +274,9 @@ struct SpaprMachineState { bool fadump_registered; bool fadump_dump_active; FadumpMemStruct registered_fdm; + + /* ibm,errinjct session token (0 =3D no session open) */ + uint32_t errinjct_token; }; =20 #define H_SUCCESS 0 diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index f7fc544d35..fa555f1092 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -704,6 +704,138 @@ param_error_exit: rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); } =20 +static int spapr_errinjct_parse_ioa_bus_error(target_ulong param_buf, + bool is_64bit, + uint64_t *addr, uint64_t *ma= sk, + uint32_t *config_addr, + uint64_t *buid, uint32_t *fu= nc) +{ + if (is_64bit) { + *addr =3D ((uint64_t)rtas_ld(param_buf, 0) << 32) | + rtas_ld(param_buf, 1); + *mask =3D ((uint64_t)rtas_ld(param_buf, 2) << 32) | + rtas_ld(param_buf, 3); + *config_addr =3D rtas_ld(param_buf, 4); + *buid =3D ((uint64_t)rtas_ld(param_buf, 5) << 32) | + rtas_ld(param_buf, 6); + *func =3D rtas_ld(param_buf, 7); + } else { + *addr =3D rtas_ld(param_buf, 0); + *mask =3D rtas_ld(param_buf, 1); + *config_addr =3D rtas_ld(param_buf, 2); + *buid =3D ((uint64_t)rtas_ld(param_buf, 3) << 32) | + rtas_ld(param_buf, 4); + *func =3D rtas_ld(param_buf, 5); + } + return RTAS_OUT_SUCCESS; +} + +/* + * Non-IOA RTAS error types (page corrupt, dcache, icache, tlb, special + * event) are validated but not supported for VFIO injection. VFIO EEH + * is PE/PHB-scoped and those work buffers do not carry a BUID, so QEMU + * cannot select the right VFIO container safely. + */ +static void spapr_errinjct_return_non_ioa_unsupported(target_ulong rets) +{ + rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); +} + +static void rtas_ibm_errinjct(PowerPCCPU *cpu, SpaprMachineState *spapr, + uint32_t token, uint32_t nargs, + target_ulong args, uint32_t nret, + target_ulong rets) +{ + SpaprPhbState *sphb =3D NULL; + target_ulong param_buf; + uint64_t addr =3D 0, mask =3D 0, buid =3D 0; + uint64_t inject_addr =3D 0; + uint32_t config_addr =3D 0; + uint32_t func =3D 0; + uint32_t type, o_token; + bool is_64bit; + int ret; + + if (nargs !=3D 3 || nret !=3D 1) { + goto param_error_exit; + } + + type =3D rtas_ld(args, 0); + o_token =3D rtas_ld(args, 1); + param_buf =3D rtas_ld(args, 2); + + if (!param_buf) { + goto param_error_exit; + } + + if (!spapr->errinjct_token || o_token !=3D spapr->errinjct_token) { + goto param_error_exit; + } + + switch (type) { + case RTAS_ERR_TYPE_IOA_BUS_ERROR: + case RTAS_ERR_TYPE_IOA_BUS_ERROR_64: + is_64bit =3D (type =3D=3D RTAS_ERR_TYPE_IOA_BUS_ERROR_64); + ret =3D spapr_errinjct_parse_ioa_bus_error(param_buf, is_64bit, + &addr, &mask, + &config_addr, &buid, &fun= c); + if (ret !=3D RTAS_OUT_SUCCESS) { + goto param_error_exit; + } + break; + + case RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT: + case RTAS_ERR_TYPE_CORRUPTED_PAGE: + case RTAS_ERR_TYPE_CORRUPTED_DCACHE_START: + case RTAS_ERR_TYPE_CORRUPTED_DCACHE_END: + case RTAS_ERR_TYPE_CORRUPTED_ICACHE_START: + case RTAS_ERR_TYPE_CORRUPTED_ICACHE_END: + case RTAS_ERR_TYPE_CORRUPTED_TLB_START: + case RTAS_ERR_TYPE_CORRUPTED_TLB_END: + spapr_errinjct_return_non_ioa_unsupported(rets); + return; + + default: + goto param_error_exit; + } + + /* IOA path: BUID selects the target PHB */ + if (!buid) { + goto param_error_exit; + } + + sphb =3D spapr_pci_find_phb(spapr, buid); + if (!sphb) { + error_report("ibm,errinjct: no PHB for BUID=3D0x%016" PRIx64, buid= ); + rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); + return; + } + + inject_addr =3D addr; + + /* + * addr=3D0, mask=3D0 means a non-address-scoped IOA injection. This + * matches powerpc-utils errinjct -a 0 -m 0 behaviour; skip translation + * and forward addr/mask as zero. + */ + if (addr || mask) { + ret =3D spapr_phb_vfio_translate_errinjct_addr(sphb, config_addr, + addr, &inject_addr); + if (ret) { + rtas_st(rets, 0, ret =3D=3D -EOPNOTSUPP ? RTAS_OUT_NOT_SUPPORT= ED + : RTAS_OUT_PARAM_ERROR); + return; + } + } + + ret =3D spapr_phb_vfio_errinjct(sphb, type, func, inject_addr, mask); + rtas_st(rets, 0, ret); + return; + +param_error_exit: + rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); +} + static void pci_spapr_set_irq(void *opaque, int irq_num, int level) { /* @@ -2380,6 +2512,9 @@ void spapr_pci_rtas_init(void) spapr_rtas_register(RTAS_IBM_SLOT_ERROR_DETAIL, "ibm,slot-error-detail", rtas_ibm_slot_error_detail); + spapr_rtas_register(RTAS_IBM_ERRINJCT, + "ibm,errinjct", + rtas_ibm_errinjct); } =20 static void spapr_pci_register_types(void) diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index b151e9138c..fe89fb4ca3 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -318,6 +318,201 @@ int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) return RTAS_OUT_SUCCESS; } =20 +typedef struct SpaprVFIOErrinjctBarMatch { + uint64_t guest_addr; + + PCIDevice *pdev; + VFIOPCIDevice *vdev; + int bar; + + uint64_t guest_bar_start; + uint64_t bar_size; + uint64_t offset; +} SpaprVFIOErrinjctBarMatch; + +static VFIOPCIDevice *spapr_vfio_errinjct_pci_to_vfio(PCIDevice *pdev) +{ + if (!object_dynamic_cast(OBJECT(pdev), TYPE_VFIO_PCI)) { + return NULL; + } + + return container_of(pdev, VFIOPCIDevice, parent_obj); +} + +static void spapr_vfio_errinjct_find_bar_cb(PCIBus *bus, + PCIDevice *pdev, + void *opaque) +{ + SpaprVFIOErrinjctBarMatch *ctx =3D opaque; + VFIOPCIDevice *vdev; + int bar; + + if (ctx->pdev) { + return; + } + + vdev =3D spapr_vfio_errinjct_pci_to_vfio(pdev); + if (!vdev) { + return; + } + + for (bar =3D 0; bar < PCI_STD_NUM_BARS; bar++) { + pcibus_t guest_bar_start; + uint64_t bar_size; + uint64_t offset; + + bar_size =3D vdev->bars[bar].region.size; + if (!bar_size) { + continue; + } + + guest_bar_start =3D pci_get_bar_addr(pdev, bar); + if (guest_bar_start =3D=3D PCI_BAR_UNMAPPED) { + continue; + } + + if (ctx->guest_addr < guest_bar_start || + ctx->guest_addr - guest_bar_start >=3D bar_size) { + if (vdev->bars[bar].mem64) { + bar++; + } + continue; + } + + offset =3D ctx->guest_addr - guest_bar_start; + + ctx->pdev =3D pdev; + ctx->vdev =3D vdev; + ctx->bar =3D bar; + ctx->guest_bar_start =3D guest_bar_start; + ctx->bar_size =3D bar_size; + ctx->offset =3D offset; + + return; + } +} + +static int spapr_vfio_errinjct_get_host_bar(VFIOPCIDevice *vdev, + int bar, + uint64_t *host_bar_start) +{ + g_autofree char *path =3D NULL; + g_autofree char *contents =3D NULL; + char *line; + char *saveptr =3D NULL; + unsigned long long start; + unsigned long long end; + unsigned long long flags; + int i; + + if (!vdev || !host_bar_start || bar < 0 || bar >=3D PCI_STD_NUM_BARS) { + return -EINVAL; + } + + /* + * Read the host Linux sysfs resource file for the BAR. Do not use a + * VFIO PCI config-space read because that may return the + * guest-programmed BAR value rather than the host resource address. + */ + path =3D g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%u/resou= rce", + vdev->host.domain, + vdev->host.bus, + vdev->host.slot, + vdev->host.function); + + if (!g_file_get_contents(path, &contents, NULL, NULL)) { + error_report("vfio/eeh errinjct: failed to read %s", path); + return -ENOENT; + } + + line =3D strtok_r(contents, "\n", &saveptr); + + for (i =3D 0; line; i++, line =3D strtok_r(NULL, "\n", &saveptr)) { + if (i !=3D bar) { + continue; + } + + if (sscanf(line, "%llx %llx %llx", &start, &end, &flags) !=3D 3) { + error_report("vfio/eeh errinjct: malformed %s BAR%d", + path, bar); + return -EINVAL; + } + + if (!start || end < start) { + error_report("vfio/eeh errinjct: invalid host resource BAR%d " + "start=3D0x%llx end=3D0x%llx flags=3D0x%llx", + bar, start, end, flags); + return -EINVAL; + } + + *host_bar_start =3D start; + return 0; + } + + return -EINVAL; +} + +int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, + uint32_t config_addr, + uint64_t guest_addr, + uint64_t *host_pci_bus_addr) +{ + PCIHostState *phb; + SpaprVFIOErrinjctBarMatch ctx =3D { + .guest_addr =3D guest_addr, + .pdev =3D NULL, + .vdev =3D NULL, + .bar =3D -1, + }; + uint64_t host_bar_start; + int rc; + + if (!sphb || !host_pci_bus_addr) { + return -EINVAL; + } + + phb =3D PCI_HOST_BRIDGE(sphb); + + /* + * BUID has already selected @sphb before this helper is called. + * config_addr is retained for logging/debug only. Do not rely on it + * to find the target device; some RTAS IOA buffers may not carry a + * valid guest BDF-style config address. Scan VFIO BARs under this + * PHB and match guest_addr against the guest BAR layout instead. + */ + pci_for_each_device_under_bus(phb->bus, + spapr_vfio_errinjct_find_bar_cb, + &ctx); + + if (!ctx.pdev) { + error_report("vfio/eeh errinjct: guest addr 0x%" PRIx64 + " not within any VFIO BAR under BUID=3D0x%016" PRIx64 + " config_addr=3D0x%08x", + guest_addr, sphb->buid, config_addr); + return -ENODEV; + } + + rc =3D spapr_vfio_errinjct_get_host_bar(ctx.vdev, ctx.bar, &host_bar_s= tart); + if (rc) { + error_report("vfio/eeh errinjct: failed to get host BAR%d for " + "dev=3D%s BUID=3D0x%016" PRIx64 " config_addr=3D0x%08= x rc=3D%d", + ctx.bar, ctx.pdev->name, sphb->buid, config_addr, rc); + return rc; + } + + if (host_bar_start =3D=3D ctx.guest_bar_start) { + error_report("vfio/eeh errinjct: refusing guest BAR as host BAR: " + "dev=3D%s BAR%d guest_bar=3D0x%" PRIx64 + " host_bar=3D0x%" PRIx64, + ctx.pdev->name, ctx.bar, + ctx.guest_bar_start, host_bar_start); + return -EOPNOTSUPP; + } + + *host_pci_bus_addr =3D host_bar_start + ctx.offset; + return 0; +} + static int spapr_vfio_errinjct_rtas_type_to_vfio(uint32_t rtas_type) { switch (rtas_type) { @@ -430,4 +625,12 @@ int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint3= 2_t type, return RTAS_OUT_NOT_SUPPORTED; } =20 +int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, + uint32_t config_addr, + uint64_t guest_addr, + uint64_t *host_pci_bus_addr) +{ + return -ENOTSUP; +} + #endif /* CONFIG_VFIO_PCI */ --=20 2.51.1 From nobody Mon Nov 23 04:43:54 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=1792427241; cv=none; d=zohomail.com; s=zohoarc; b=GHcibRzadkCZg7Z32CnA8Y0091C8woSVPYZ6KURmvam029zX3SYqw5iCiM+8wUD1oPt6VXpThZn4NZ38EQsmNvSjyNv+eDo9VXdUP+hv1C+Y/p3uPibrykIMmtfdCg1b41yavC1mvrs5i2d1G0w/rSQkGvw57dOnvzLyaPdNQXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792427241; 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=eCDl7inp1C2c6XtfCjZgHJftpWzTq5gX/EzI99Sh/Qw=; b=lC5WPaUilSHOqxir5e1QrHWRJvpukVIsGfh5AxwrI2s3MCjBJwaep6J1118sGhaZfIQOlSxIItWN+Mau+ZrCgW7j1HBHtE2Wscnr1dMZuvX+Q3VNXNnfu+iSo6CZSjGNArn5BCDdrg487XTnTMcy2AgesF58gZyO4jwiCg3Afc4= 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 1792427241614723.3540104996347; Mon, 19 Oct 2026 09:27:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIqCf-0002Th-8r; Mon, 19 Oct 2026 12:27:13 -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 1xIqCA-00021z-SV; Mon, 19 Oct 2026 12:26:43 -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 1xIqBv-0001U3-HB; Mon, 19 Oct 2026 12:26:34 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69JFiFqO4115679; Mon, 19 Oct 2026 16:26:26 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 4hbxehuvxu-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:25 +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 69JFZ6mi081550; Mon, 19 Oct 2026 16:26:25 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hcmbjxgcu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:25 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69JGQHNR17629450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Oct 2026 16:26:17 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30CD220043; Mon, 19 Oct 2026 16:26:17 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 548E820040; Mon, 19 Oct 2026 16:26:13 +0000 (GMT) Received: from Narayanas-MacBook-Pro.ibm.com (unknown [9.124.217.62]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 19 Oct 2026 16:26:13 +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=eCDl7inp1C2c6XtfC jZgHJftpWzTq5gX/EzI99Sh/Qw=; b=qt9E/24ETZZKUE5//h2uFbzefrRfQipUU IX8YCMTp4PUCXQecyi3TjKInF3GmoAvX9wM+EIroWZOfCawHyI+nW9shLBP4NRoN m0+zEDAZ/IAKm6te7+bFUjIxN6IyMj99NOURMD+SGyj7RHZOMFoO44+kqTWhN987 6dStPlUe+q76G9Uf6t4nE+44Rf1vAHGRXgg49MQ5x6NbinVbU0H+yM9bTlgKzEr6 J5ni24ZsSTKwgLPo6gqSpVO4lVLHl+h2BWNGxa2/mMEiva3IwyUH7J76d0LBbmuP er6KF+Xrlk+CC/42swn/IGhXJAfWUaA+6lQAWa9y0nKConhq0QEzA== From: Narayana Murty N To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Mahesh J Salgaonkar , Sourabh Bhat , anushree.mathur@linux.vnet.ibm.com, clg@redhat.com, Sourabh Jain , adityag@linux.ibm.com, nikhilks@linux.ibm.com Cc: pierrick.bouvier@oss.qualcomm.com, rathc@linux.ibm.com, Nicholas Piggin , harshpb@linux.ibm.com, amachhiw@linux.ibm.com, hbathini@linux.ibm.com, shivangu@linux.ibm.com Subject: [PATCH v6 3/6] ppc/spapr: Add support for ibm, open-errinjct and ibm, close-errinjct Date: Mon, 19 Oct 2026 21:55:37 +0530 Message-ID: <20261019162541.68440-4-nnmlinux@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261019162541.68440-1-nnmlinux@linux.ibm.com> References: <20261019162541.68440-1-nnmlinux@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX9iaFb3JhGr9O oTI94YyF7SdSL8LJ6j0D4eRgJZ5rZVE2tVNTHsH1Vhfj21VXK8C7M5M72kxYo3kNXGnbPr9qFji ZdiETzJj+TGtraV4zxLzYLybPjYzbBapBez5sxgjGOHB1s+yDTlZSe6KSGf2DPdPrTvFqqsvyO6 nowWbevLO5MAaApIgNmCsdC+UqfvMFMPy+sxxnN5g8j5++2zqRPFKXJwhhhNQ/NHT13pM4mhptv QEZ4szn6z7QlD+gQ0oJDnXzkCRdhnwYxY/7X1EXB+BKS4l8xjVlcnO0LuQzEssc5fBgHz6p4lGp Tqn+sYYLmxmMptC8FEZiM1CCEPwppXmltWdsa8ZLppoKlY5WPqOwWdYaIOQsLfmPucI0YONjC/U LRxM94vnL+ySERbUdeP3KqQqsjHmfU15TKVsG+K2FbGU0ycgZAxdTeQa7dnH/d8w+XxBlPYtY3v KkAPJWlE5d7TU9QU7uA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfXwsbOXKoo7MkQ dEasSWoB8UYHxuwvruhXYSsB0d9R2T+ZCyjkIXPXvyCTZ/xugE9lnG1isdwSfLrxg2mRA78df9V 7V66CqwrSOe0bcMf16ITAvAJkrrxLx0= X-Proofpoint-GUID: fAcoCrlTKUhr5DiJr5ZJbT_O_EP9O1Jn X-Proofpoint-ORIG-GUID: Gscc1Ynd_32Qm99TKcqDQabt9d6t5cTV X-Authority-Analysis: v=2.4 cv=OZQNnRTY c=1 sm=1 tr=0 ts=6ad644b2 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=iw8L5VQ-6e4m0g-3eYQA:9 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-19_05,2026-10-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 suspectscore=0 phishscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610190064 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=nnmlinux@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: 1792427242222158500 Content-Type: text/plain; charset="utf-8" Add RTAS handlers for ibm,open-errinjct and ibm,close-errinjct. These calls manage exclusive access to the error-injection facility through a simple session token mechanism: only one session may be open at a time. ibm,open-errinjct (nargs=3D0, nret=3D2): Returns rets[0]=3Dtoken, rets[1]=3Dstatus. On success: token=3D1, status=3DRTAS_OUT_SUCCESS. Already-open: token=3D0, status=3DRTAS_OUT_ALREADY_OPEN. Bad args: token=3D0, status=3DRTAS_OUT_PARAM_ERROR. ibm,close-errinjct (nargs=3D1, nret=3D1): Takes the session token in args[0]. Returns RTAS_OUT_SUCCESS on a matching open token. Returns RTAS_OUT_NOT_OPEN if the token is invalid or no session exists. RTAS_IBM_OPEN_ERRINJCT and RTAS_IBM_CLOSE_ERRINJCT token values and RTAS_OUT_ALREADY_OPEN / RTAS_OUT_NOT_OPEN return codes are added to include/hw/ppc/spapr.h. Signed-off-by: Narayana Murty N Reviewed-by: Nikhil Kumar Singh Reported-by: Tasmiya Nalatwad Tested-by: Tasmiya Nalatwad --- include/hw/ppc/spapr.h | 8 +++++- hw/ppc/spapr_pci.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 47791c71bd..bcb1da5fab 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -825,8 +825,14 @@ enum rtas_err_type { #define RTAS_IBM_NMI_INTERLOCK (RTAS_TOKEN_BASE + 0x2C) #define RTAS_CONFIGURE_KERNEL_DUMP (RTAS_TOKEN_BASE + 0x2D) #define RTAS_IBM_ERRINJCT (RTAS_TOKEN_BASE + 0x2E) +#define RTAS_IBM_OPEN_ERRINJCT (RTAS_TOKEN_BASE + 0x2F) +#define RTAS_IBM_CLOSE_ERRINJCT (RTAS_TOKEN_BASE + 0x30) =20 -#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2F) +#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x31) + +/* ibm,open-errinjct/ibm,close-errinjct return codes */ +#define RTAS_OUT_ALREADY_OPEN -4 +#define RTAS_OUT_NOT_OPEN -5 =20 /* RTAS ibm,get-system-parameter token values */ #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20 diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index fa555f1092..ec9f6284c7 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -836,6 +836,57 @@ param_error_exit: rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); } =20 +static void rtas_ibm_open_errinjct(PowerPCCPU *cpu, SpaprMachineState *spa= pr, + uint32_t token, uint32_t nargs, + target_ulong args, uint32_t nret, + target_ulong rets) +{ + if (nargs !=3D 0 || nret !=3D 2) { + rtas_st(rets, 0, 0); + rtas_st(rets, 1, RTAS_OUT_PARAM_ERROR); + return; + } + + if (spapr->errinjct_token) { + /* Session already open: return token=3D0, status=3DALREADY_OPEN */ + rtas_st(rets, 0, 0); + rtas_st(rets, 1, RTAS_OUT_ALREADY_OPEN); + return; + } + + spapr->errinjct_token =3D 1; + + /* + * ibm,open-errinjct has an unusual return convention: rets[0] is the + * session token and rets[1] is the status code. + */ + rtas_st(rets, 0, spapr->errinjct_token); + rtas_st(rets, 1, RTAS_OUT_SUCCESS); +} + +static void rtas_ibm_close_errinjct(PowerPCCPU *cpu, SpaprMachineState *sp= apr, + uint32_t token, uint32_t nargs, + target_ulong args, uint32_t nret, + target_ulong rets) +{ + uint32_t o_token; + + if (nargs !=3D 1 || nret !=3D 1) { + rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); + return; + } + + o_token =3D rtas_ld(args, 0); + + if (!spapr->errinjct_token || o_token !=3D spapr->errinjct_token) { + rtas_st(rets, 0, RTAS_OUT_NOT_OPEN); + return; + } + + spapr->errinjct_token =3D 0; + rtas_st(rets, 0, RTAS_OUT_SUCCESS); +} + static void pci_spapr_set_irq(void *opaque, int irq_num, int level) { /* @@ -2515,6 +2566,12 @@ void spapr_pci_rtas_init(void) spapr_rtas_register(RTAS_IBM_ERRINJCT, "ibm,errinjct", rtas_ibm_errinjct); + spapr_rtas_register(RTAS_IBM_OPEN_ERRINJCT, + "ibm,open-errinjct", + rtas_ibm_open_errinjct); + spapr_rtas_register(RTAS_IBM_CLOSE_ERRINJCT, + "ibm,close-errinjct", + rtas_ibm_close_errinjct); } =20 static void spapr_pci_register_types(void) --=20 2.51.1 From nobody Mon Nov 23 04:43:54 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=1792427256; cv=none; d=zohomail.com; s=zohoarc; b=jnvamdC6zzIoR6lmKfcjxC48UVwg0of7Frs5ovpg9FD/MHnmdgS8emSoeWEJHnN1EWKI3K87+JhD3H1uNKRAxQSw2hBvLYFj9N6R91yDJzhx6UTDxtW6/Esu/v3uSS1GH9pa4GmJb4d6dZNwZEGl6lfL9KbH1Cfnw5KXPIy77NE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792427256; 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=xADp2Ssvv2t4fnFKS1R2JvkoCpkDDw0qXSxMDua+T9s=; b=JPkl2mMlUdIU79qmYzC/akg4hdnNEXmWiJQrjL06VuXr+lwDioNa/UN3t8IBQVy0FGjUwu8RklHOaUsGH1k28L5i96pZYq0JhSw1l+59mOHMVsMNbqTnrfnGaAr9h8085TaNUSgIlNhoqOrH3dCOAVTHlV5EGYkmUMnrQWHRsYk= 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 1792427256899374.51157847966556; Mon, 19 Oct 2026 09:27:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIqCm-0002ao-D5; Mon, 19 Oct 2026 12:27:21 -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 1xIqCM-0002Fb-Hm; Mon, 19 Oct 2026 12:26:56 -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 1xIqCC-0001UN-8a; Mon, 19 Oct 2026 12:26:47 -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 69JFiCwM006330; Mon, 19 Oct 2026 16:26:28 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hc0r7mbf0-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:28 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69JFo6hB122115; Mon, 19 Oct 2026 16:26:27 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hckqvekq4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:27 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69JGQLFI32047442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Oct 2026 16:26:21 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68B6E20040; Mon, 19 Oct 2026 16:26:21 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9678B2004D; Mon, 19 Oct 2026 16:26:17 +0000 (GMT) Received: from Narayanas-MacBook-Pro.ibm.com (unknown [9.124.217.62]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 19 Oct 2026 16:26:17 +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=xADp2Ssvv2t4fnFKS 1R2JvkoCpkDDw0qXSxMDua+T9s=; b=R37rxlD+SFpZQz58Bjh7JiJrKolpR2KI6 Vr3MHnNhOdPJ712UVdoogg3vco97K2lr5rKok8FVuwT/lOnOTTW95Z7YQ4HHyzkg aSlJ/mNsTVwOvFq8r1iGUZOzoLTsm1qlZcIoqehmqqLIcxyPRlHESQpnK254Fb76 iLsuwSRdHo/nv52zMxJ9Owc6sl6NiUyt1UK/gJjUxeXLAI9zhwNAqy2kkiokxfER G86V791uaB5EvIB0hksNX+FP6vHvc5qMCH/rUbLX+4I0AY9B+QU24u0Nm8m5Gt0q rpeUrM09nqPEvHmd8wBBUnpROVWyA/QUXBvxcTW0fYJvM/dyrE9dg== From: Narayana Murty N To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Mahesh J Salgaonkar , Sourabh Bhat , anushree.mathur@linux.vnet.ibm.com, clg@redhat.com, Sourabh Jain , adityag@linux.ibm.com, nikhilks@linux.ibm.com Cc: pierrick.bouvier@oss.qualcomm.com, rathc@linux.ibm.com, Nicholas Piggin , harshpb@linux.ibm.com, amachhiw@linux.ibm.com, hbathini@linux.ibm.com, shivangu@linux.ibm.com Subject: [PATCH v6 4/6] ppc/spapr: Advertise RTAS error injection call support via FDT property Date: Mon, 19 Oct 2026 21:55:38 +0530 Message-ID: <20261019162541.68440-5-nnmlinux@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261019162541.68440-1-nnmlinux@linux.ibm.com> References: <20261019162541.68440-1-nnmlinux@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX5/aYpRYuZlnq +Tp87RExIyFBvRuweNngR5Y+Jb4iw93gD0YWH8QiZrXyTkH77GGhSjgwX/EdU73cv9cJdEEJqxr og4RBqlkCHSUWoac9ren1dSVM1wVryA= X-Authority-Analysis: v=2.4 cv=PrUG/AM3 c=1 sm=1 tr=0 ts=6ad644b4 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=llslmTbBPWc8O3lW6jAA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX6Ka8+NpKmi4B TsHW3rxgex59siw4TvZMCUrebVJOFs4S0OFDOckl/zOknZl/U6RyP1Gwf5oYKreUdiRuuEaMBGd mfOnLgJatd08SS3WpkEmw7aygqg5LcoZI8M7NePPDHAfbuVuHoPVJeoGt8BksjQHpL37LyiK/yD 1Nz5JyEQ1be0chS3qv3V4yXlNZBVXP5am1e/u7L6OSI6NNb32b1noBjcZng7o4WfNmpwP5E8zRb mKx97lvI4xdHiAQL+3yOkO1ckBt78z+034vVeMv+KOsJ8WzAr5rngY1QhllTwG/VzvmJgwWkmAo lbuqoXb0vbGWadbTGmahglHnUoK6qeGNMuYFbqKZ6FSNtrGuGzbO2wCK/qxL8CVwXgrOH+TSXhv Vq9XdSZTAIc7H4VaAyFw73zcgx56rMKO8IR5OeEJ0ahj2SWxJlzQI/LsaAKK5UZYdDsoNu8lSpn uSbknKhV3mdzH41MLEQ== X-Proofpoint-GUID: thkxDJhto16AmHjOqLqyUoQ7GwyW5aeQ X-Proofpoint-ORIG-GUID: 6-4-rKNzS3vkUaneI0I7P3K1_UgdaMTi 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-19_05,2026-10-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610190064 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=nnmlinux@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: 1792427258426158500 Content-Type: text/plain; charset="utf-8" Advertise the supported ibm,errinjct token types to the guest through the "ibm,errinjct-tokens" property under the RTAS node in the device tree. The property blob is built directly from a QEMU-side static table. No host /proc/device-tree/rtas/ibm,errinjct-tokens probing is done QEMU presents the same token set regardless of the host platform, which avoids host-specific dependencies. Each entry in the blob is a NUL-terminated token name string followed by a big-endian uint32 type value, matching the PAPR specification for ibm,errinjct-tokens. Signed-off-by: Narayana Murty N Reviewed-by: Nikhil Kumar Singh Reported-by: Tasmiya Nalatwad Tested-by: Tasmiya Nalatwad --- hw/ppc/spapr.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6d99464486..22724d6afd 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -116,6 +116,8 @@ =20 #define PHANDLE_INTC 0x00001111 =20 +#define ERRINJCT_BLOB_MAX 512 + /* These two functions implement the VCPU id numbering: one to compute them * all and one to identify thread 0 of a VCORE. Any change to the first one * is likely to have an impact on the second one, so let's keep them close. @@ -1081,6 +1083,61 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, = void *fdt) */ _FDT(fdt_setprop(fdt, rtas, "ibm,extended-os-term", NULL, 0)); =20 + /* + * Advertise supported ibm,errinjct token types to the guest via the + * "ibm,errinjct-tokens" RTAS FDT property. The blob is built locally + * from the QEMU-side token table; no /proc/device-tree probing is don= e. + * Each entry is: NUL-terminated name string || big-endian uint32 type. + */ + { + static const struct { + const char *name; + uint32_t type; + } tok_table[] =3D { + { "recovered-special-event", + RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT }, + { "corrupted-page", RTAS_ERR_TYPE_CORRUPTED_PAGE = }, + { "ioa-bus-error", RTAS_ERR_TYPE_IOA_BUS_ERROR = }, + { "corrupted-dcache-start", + RTAS_ERR_TYPE_CORRUPTED_DCACHE_START }, + { "corrupted-dcache-end", + RTAS_ERR_TYPE_CORRUPTED_DCACHE_END }, + { "corrupted-icache-start", + RTAS_ERR_TYPE_CORRUPTED_ICACHE_START }, + { "corrupted-icache-end", + RTAS_ERR_TYPE_CORRUPTED_ICACHE_END }, + { "corrupted-tlb-start", + RTAS_ERR_TYPE_CORRUPTED_TLB_START }, + { "corrupted-tlb-end", RTAS_ERR_TYPE_CORRUPTED_TLB_END = }, + { "ioa-bus-error-64", RTAS_ERR_TYPE_IOA_BUS_ERROR_64 = }, + }; + g_autofree char *errinject_tokens =3D NULL; + uint8_t blob[ERRINJCT_BLOB_MAX]; + size_t blen =3D 0; + bool ok =3D true; + + for (int i =3D 0; i < G_N_ELEMENTS(tok_table) && ok; i++) { + size_t slen =3D strlen(tok_table[i].name) + 1; + uint32_t be_type; + + if (blen + slen + sizeof(be_type) > ERRINJCT_BLOB_MAX) { + ok =3D false; + break; + } + memcpy(blob + blen, tok_table[i].name, slen); + blen +=3D slen; + be_type =3D cpu_to_be32(tok_table[i].type); + memcpy(blob + blen, &be_type, sizeof(be_type)); + blen +=3D sizeof(be_type); + } + + if (ok) { + errinject_tokens =3D g_memdup2(blob, blen); + _FDT(fdt_setprop(fdt, rtas, "ibm,errinjct-tokens", + errinject_tokens, blen)); + } + } + _FDT(fdt_setprop(fdt, rtas, "ibm,lrdr-capacity", lrdr_capacity, sizeof(lrdr_capacity))); =20 --=20 2.51.1 From nobody Mon Nov 23 04:43:54 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=1792427259; cv=none; d=zohomail.com; s=zohoarc; b=RaH4fi+peE0xmLpdm1QKpUx0sYrH41ZGyKNE38brTTQth/EhkuFlDgOEBI8KDTEfjwwJ5D7vGsYZj+UWwwCB0yd3qvqRiGwj8hxWBlclF9evkyZRbbdf9kgrgYCsK6qdE4GUTD16xbCoGNXzd56zCiRcZfXWHyX2iHx58O949N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792427259; 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=UOMd9CVNx6dvNjr9hprNeFYyPSEZBOznzi8OH53vv+g=; b=GIDYNpx1+zpDCpWA/9saX1HDpBcuS9CqSppsuCxBOc024k/RLfChxdfcJXzjP7YnRfK98bOLHz2bObqzyLc6wKoDfJ/yGGWFo8Tgx67mliUF0QFtacIheinJnb3Pc79IaTWJQKcFLow12/bS18HymiLz7Oxjx5DTYYFPmU1AP90= 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 1792427258993182.18219407683398; Mon, 19 Oct 2026 09:27:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIqCo-0002iT-Lx; Mon, 19 Oct 2026 12:27:22 -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 1xIqCM-0002Fl-J2; Mon, 19 Oct 2026 12:26:56 -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 1xIqCC-0001Ue-8a; Mon, 19 Oct 2026 12:26:49 -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 69JFil7k008615; Mon, 19 Oct 2026 16:26:36 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 4hc0r7mbfq-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:35 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69JFZ54Y171070; Mon, 19 Oct 2026 16:26:34 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hcp1ye7ux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:34 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69JGQPEJ27066650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Oct 2026 16:26:27 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A7D6F2004D; Mon, 19 Oct 2026 16:26:25 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D11A720040; Mon, 19 Oct 2026 16:26:21 +0000 (GMT) Received: from Narayanas-MacBook-Pro.ibm.com (unknown [9.124.217.62]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 19 Oct 2026 16:26:21 +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=UOMd9CVNx6dvNjr9h prNeFYyPSEZBOznzi8OH53vv+g=; b=Xjq/G9+bkQg+4ANwBr9jm7QyLDGBZaABN C8wjzZCAV2xCDJfzWcIIMDU590p+Unyd+zyVfjAv93zka/pjXAswgELE2rC2Edbu oTqrpnjF3UIDF+gPtjziH605qExUUZwFgegmrlRp5OUZqBU/RTbeUEG4zT3NUw0m uBgCqQ4r2/akT9g2xqOSKM7FncaCJbeqy3T/TXJ5keLJ3+lwIl9S+iScnHszwiwD YEUFLezGBTn7poqYLvEmi+oHHbUjFBGnuC43xNa/AdVxeQimlhEPXYT/JYgMSVn5 /1h4G2TyYBGRhji12cfHszoF6yjbqUoK8pamzseuJ2zmLDzUPiFCA== From: Narayana Murty N To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Mahesh J Salgaonkar , Sourabh Bhat , anushree.mathur@linux.vnet.ibm.com, clg@redhat.com, Sourabh Jain , adityag@linux.ibm.com, nikhilks@linux.ibm.com Cc: pierrick.bouvier@oss.qualcomm.com, rathc@linux.ibm.com, Nicholas Piggin , harshpb@linux.ibm.com, amachhiw@linux.ibm.com, hbathini@linux.ibm.com, shivangu@linux.ibm.com Subject: [PATCH v6 5/6] ppc/spapr: Split VFIO EEH support from general VFIO code Date: Mon, 19 Oct 2026 21:55:39 +0530 Message-ID: <20261019162541.68440-6-nnmlinux@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261019162541.68440-1-nnmlinux@linux.ibm.com> References: <20261019162541.68440-1-nnmlinux@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX4a1zIXZfCkOp g+6sVuqvOksXTWNSDJSnw5wYxErJ7APItR3vOTVpQWzKuYOHJkZCUT1AELJbjhHQjdPdel94PWU SbLgcYLugfe+/R/pPBNxBUEaSWef0+o= X-Authority-Analysis: v=2.4 cv=PrUG/AM3 c=1 sm=1 tr=0 ts=6ad644bc cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=mDV3o1hIAAAA:8 a=EUspDBNiAAAA:8 a=VnNF1IyMAAAA:8 a=Ny_MO5XXa0bEUqU1V1wA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfXygQnFWSct1PG LVJLwnm9k7UckWlNBnYKSMr1tF0vfbMFqxG1/6AAvPS7ghEWSFXIMyhhBnNeVahdzAsSpWJZdmw eWzoOqCmLU5xfvn0kxdk6XB4IroO17N7uP0UwH3ozkgXFGWbgR+FL6aktoaH9XTklb2frt1mPbA SBZHhv80gRFIz71/z1lAZ75Iuoe7OEpnt14KKAOzSSnaq0ZoQtByHpFdqm2/imqt4U4y2ju1PWs VBAeU+XmRbRJSbRAIt5zRkGZKG5zyLYdxAZ/X+6jmfeT/vT2U+BdbGv6o/lR1Ykv6o24LPHGi4y iYQFsgv3ZFvcMiKUfYk+7nVpkugR2rhoEDRpboUmnfUea7x4SCx1ovmgMdhCvCrVaT3u+JMP9HC AhONkr9gwgGuRaKYD+Gejb2JR3ZqjOadtguTIVKOIIdLSyl7sW/ckNR8B1Fs+lNJbBVA2N1it3K OOWRw2WAaQQOpnT+apw== X-Proofpoint-GUID: HENDOjCoUoFmWrcvtK-0xCvXpSWmsjYy X-Proofpoint-ORIG-GUID: l7WaUijpcYvvhvc6_oPoKM_FQbr2VNut 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-19_05,2026-10-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610190064 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=nnmlinux@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: 1792427260574158500 Content-Type: text/plain; charset="utf-8" Move all EEH and error-injection functions from spapr_pci_vfio.c into a dedicated hw/ppc/spapr_eeh.c. spapr_eeh.c is compiled only when CONFIG_VFIO_PCI is enabled. spapr_pci_vfio.c is retained as a stub-only file compiled on Linux when CONFIG_VFIO_PCI is not available, providing the non-functional fallback implementations needed for Linux/pseries builds that do not include VFIO PCI. meson.build: replace the single spapr_pci_vfio.c entry with an if_true/if_false pair keyed on CONFIG_VFIO_PCI: CONFIG_VFIO_PCI=3Dy -> spapr_eeh.c (real implementation) CONFIG_VFIO_PCI=3Dn -> stubs/spapr_pci_vfio-stubs.c (stubs) No functional change to the EEH state machine. Reviewed-by: Pierrick Bouvier Reviewed-by: Nikhil Kumar Singh Signed-off-by: Narayana Murty N Reported-by: Tasmiya Nalatwad Tested-by: Tasmiya Nalatwad --- include/hw/pci-host/spapr.h | 56 +--- include/hw/ppc/spapr_vfio.h | 31 ++ hw/ppc/spapr_eeh.c | 577 +++++++++++++++++++++++++++++++++ hw/ppc/spapr_pci.c | 1 + hw/ppc/spapr_pci_vfio.c | 597 +---------------------------------- stubs/spapr_phb_vfio-stubs.c | 62 ++++ hw/ppc/Kconfig | 2 +- hw/ppc/meson.build | 1 + stubs/meson.build | 1 + 9 files changed, 676 insertions(+), 652 deletions(-) create mode 100644 include/hw/ppc/spapr_vfio.h create mode 100644 hw/ppc/spapr_eeh.c create mode 100644 stubs/spapr_phb_vfio-stubs.c diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h index 492f66e1ef..d2bc90a3d2 100644 --- a/include/hw/pci-host/spapr.h +++ b/include/hw/pci-host/spapr.h @@ -116,61 +116,7 @@ void spapr_phb_remove_pci_device_cb(DeviceState *dev); int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr, void *fdt, int *fdt_start_offset, Error **errp); =20 -/* VFIO EEH hooks */ -#ifdef CONFIG_LINUX -bool spapr_phb_eeh_available(SpaprPhbState *sphb); -int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb, - unsigned int addr, int option); -int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state); -int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option); -int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb); -void spapr_phb_vfio_reset(DeviceState *qdev); -int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, - uint32_t func, uint64_t addr, uint64_t mask); -int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, - uint32_t config_addr, - uint64_t guest_addr, - uint64_t *host_pci_bus_addr); -#else -static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb) -{ - return false; -} -static inline int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb, - unsigned int addr, int opt= ion) -{ - return RTAS_OUT_HW_ERROR; -} -static inline int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, - int *state) -{ - return RTAS_OUT_HW_ERROR; -} -static inline int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option) -{ - return RTAS_OUT_HW_ERROR; -} -static inline int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) -{ - return RTAS_OUT_HW_ERROR; -} -static inline void spapr_phb_vfio_reset(DeviceState *qdev) -{ -} -static inline int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t ty= pe, - uint32_t func, uint64_t addr, - uint64_t mask) -{ - return RTAS_OUT_NOT_SUPPORTED; -} -static inline int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sp= hb, - uint32_t config_a= ddr, - uint64_t guest_ad= dr, - uint64_t *host_ad= dr) -{ - return -ENOTSUP; -} -#endif +/* VFIO EEH hooks - see hw/ppc/spapr_vfio.h for declarations */ =20 void spapr_phb_dma_reset(SpaprPhbState *sphb); =20 diff --git a/include/hw/ppc/spapr_vfio.h b/include/hw/ppc/spapr_vfio.h new file mode 100644 index 0000000000..5aabb262f2 --- /dev/null +++ b/include/hw/ppc/spapr_vfio.h @@ -0,0 +1,31 @@ +/* + * sPAPR VFIO EEH Header + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef HW_PPC_SPAPR_VFIO_H +#define HW_PPC_SPAPR_VFIO_H + +/* + * Forward declarations to avoid pulling in full spapr headers + * This allows stubs and other files to compile without libfdt dependencies + */ +typedef struct SpaprPhbState SpaprPhbState; +typedef struct DeviceState DeviceState; + +/* VFIO EEH function declarations */ +bool spapr_phb_eeh_available(SpaprPhbState *sphb); +int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb, + unsigned int addr, int option); +int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state); +int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option); +int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb); +void spapr_phb_vfio_reset(DeviceState *qdev); +void spapr_phb_vfio_eeh_reenable(SpaprPhbState *sphb); +int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, + uint32_t func, uint64_t addr, uint64_t mask); +int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, + uint32_t config_addr, + uint64_t guest_addr, + uint64_t *host_pci_bus_addr); +#endif /* HW_PPC_SPAPR_VFIO_H */ diff --git a/hw/ppc/spapr_eeh.c b/hw/ppc/spapr_eeh.c new file mode 100644 index 0000000000..41c509728a --- /dev/null +++ b/hw/ppc/spapr_eeh.c @@ -0,0 +1,577 @@ +/* + * QEMU sPAPR PCI host for VFIO + * + * Copyright (c) 2011-2014 Alexey Kardashevskiy, IBM Corporation. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include +#include +#include "hw/ppc/spapr.h" +#include "hw/pci-host/spapr.h" +#include "hw/pci/msix.h" +#include "hw/pci/pci_device.h" +#include "hw/vfio/vfio-container-legacy.h" +#include "qemu/error-report.h" +#include "hw/vfio/pci.h" +#include "hw/ppc/spapr_vfio.h" + +/* + * Interfaces for IBM EEH (Enhanced Error Handling) + */ +static bool vfio_eeh_container_ok(VFIOLegacyContainer *container) +{ + /* + * As of 2016-03-04 (linux-4.5) the host kernel EEH/VFIO + * implementation is broken if there are multiple groups in a + * container. The hardware works in units of Partitionable + * Endpoints (=3D=3D IOMMU groups) and the EEH operations naively + * iterate across all groups in the container, without any logic + * to make sure the groups have their state synchronized. For + * certain operations (ENABLE) that might be ok, until an error + * occurs, but for others (GET_STATE) it's clearly broken. + */ + + /* + * XXX Once fixed kernels exist, test for them here + */ + + if (QLIST_EMPTY(&container->group_list)) { + return false; + } + + if (QLIST_NEXT(QLIST_FIRST(&container->group_list), container_next)) { + return false; + } + + return true; +} + +static int vfio_eeh_container_op(VFIOLegacyContainer *container, uint32_t = op) +{ + struct vfio_eeh_pe_op pe_op =3D { + .argsz =3D sizeof(pe_op), + .op =3D op, + }; + int ret; + + if (!vfio_eeh_container_ok(container)) { + error_report("vfio/eeh: EEH_PE_OP 0x%x: " + "kernel requires a container with exactly one group",= op); + return -EPERM; + } + + ret =3D ioctl(container->fd, VFIO_EEH_PE_OP, &pe_op); + if (ret < 0) { + error_report("vfio/eeh: EEH_PE_OP 0x%x failed: %m", op); + return -errno; + } + + return ret; +} + +static VFIOLegacyContainer *vfio_eeh_as_container(AddressSpace *as) +{ + VFIOAddressSpace *space =3D vfio_address_space_get(as); + VFIOContainer *bcontainer =3D NULL; + + if (QLIST_EMPTY(&space->containers)) { + /* No containers to act on */ + goto out; + } + + bcontainer =3D QLIST_FIRST(&space->containers); + + if (QLIST_NEXT(bcontainer, next)) { + /* + * We don't yet have logic to synchronize EEH state across + * multiple containers + */ + bcontainer =3D NULL; + goto out; + } + +out: + vfio_address_space_put(space); + return VFIO_IOMMU_LEGACY(bcontainer); +} + +static bool vfio_eeh_as_ok(AddressSpace *as) +{ + VFIOLegacyContainer *container =3D vfio_eeh_as_container(as); + + return (container !=3D NULL) && vfio_eeh_container_ok(container); +} + +static int vfio_eeh_as_op(AddressSpace *as, uint32_t op) +{ + VFIOLegacyContainer *container =3D vfio_eeh_as_container(as); + + if (!container) { + return -ENODEV; + } + return vfio_eeh_container_op(container, op); +} + +bool spapr_phb_eeh_available(SpaprPhbState *sphb) +{ + return vfio_eeh_as_ok(&sphb->iommu_as); +} + +void spapr_phb_vfio_eeh_reenable(SpaprPhbState *sphb) +{ + vfio_eeh_as_op(&sphb->iommu_as, VFIO_EEH_PE_ENABLE); +} + +static void spapr_eeh_pci_find_device(PCIBus *bus, PCIDevice *pdev, + void *opaque) +{ + bool *found =3D opaque; + + if (object_dynamic_cast(OBJECT(pdev), "vfio-pci")) { + *found =3D true; + } +} + +int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb, + unsigned int addr, int option) +{ + uint32_t op; + int ret; + + switch (option) { + case RTAS_EEH_DISABLE: + op =3D VFIO_EEH_PE_DISABLE; + break; + case RTAS_EEH_ENABLE: { + PCIHostState *phb; + bool found =3D false; + + /* + * The EEH functionality is enabled per sphb level instead of + * per PCI device. We have already identified this specific sphb + * based on buid passed as argument to ibm,set-eeh-option rtas + * call. Now we just need to check the validity of the PCI + * pass-through devices (vfio-pci) under this sphb bus. + * We have already validated that all the devices under this sphb + * are from same iommu group (within same PE) before coming here. + * + * Prior to linux commit 98ba956f6a389 ("powerpc/pseries/eeh: + * Rework device EEH PE determination") kernel would call + * eeh-set-option for each device in the PE using the device's + * config_address as the argument rather than the PE address. + * Hence if we check validity of supplied config_addr whether + * it matches to this PHB will cause issues with older kernel + * versions v5.9 and older. If we return an error from + * eeh-set-option when the argument isn't a valid PE address + * then older kernels (v5.9 and older) will interpret that as + * EEH not being supported. + */ + phb =3D PCI_HOST_BRIDGE(sphb); + pci_for_each_device(phb->bus, (addr >> 16) & 0xFF, + spapr_eeh_pci_find_device, &found); + + if (!found) { + return RTAS_OUT_PARAM_ERROR; + } + + op =3D VFIO_EEH_PE_ENABLE; + break; + } + case RTAS_EEH_THAW_IO: + op =3D VFIO_EEH_PE_UNFREEZE_IO; + break; + case RTAS_EEH_THAW_DMA: + op =3D VFIO_EEH_PE_UNFREEZE_DMA; + break; + default: + return RTAS_OUT_PARAM_ERROR; + } + + ret =3D vfio_eeh_as_op(&sphb->iommu_as, op); + if (ret < 0) { + return RTAS_OUT_HW_ERROR; + } + + return RTAS_OUT_SUCCESS; +} + +int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state) +{ + int ret; + + ret =3D vfio_eeh_as_op(&sphb->iommu_as, VFIO_EEH_PE_GET_STATE); + if (ret < 0) { + return RTAS_OUT_PARAM_ERROR; + } + + *state =3D ret; + return RTAS_OUT_SUCCESS; +} + +static void spapr_phb_vfio_eeh_clear_dev_msix(PCIBus *bus, + PCIDevice *pdev, + void *opaque) +{ + /* Check if the device is VFIO PCI device */ + if (!object_dynamic_cast(OBJECT(pdev), "vfio-pci")) { + return; + } + + /* + * The MSIx table will be cleaned out by reset. We need + * disable it so that it can be reenabled properly. Also, + * the cached MSIx table should be cleared as it's not + * reflecting the contents in hardware. + */ + if (msix_enabled(pdev)) { + uint16_t flags; + + flags =3D pci_host_config_read_common(pdev, + pdev->msix_cap + PCI_MSIX_FLAG= S, + pci_config_size(pdev), 2); + flags &=3D ~PCI_MSIX_FLAGS_ENABLE; + pci_host_config_write_common(pdev, + pdev->msix_cap + PCI_MSIX_FLAGS, + pci_config_size(pdev), flags, 2); + } + + msix_reset(pdev); +} + +static void spapr_phb_vfio_eeh_clear_bus_msix(PCIBus *bus, void *opaque) +{ + pci_for_each_device_under_bus(bus, spapr_phb_vfio_eeh_clear_dev_msi= x, + NULL); +} + +static void spapr_phb_vfio_eeh_pre_reset(SpaprPhbState *sphb) +{ + PCIHostState *phb =3D PCI_HOST_BRIDGE(sphb); + + pci_for_each_bus(phb->bus, spapr_phb_vfio_eeh_clear_bus_msix, NULL); +} + +int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option) +{ + uint32_t op; + int ret; + + switch (option) { + case RTAS_SLOT_RESET_DEACTIVATE: + op =3D VFIO_EEH_PE_RESET_DEACTIVATE; + break; + case RTAS_SLOT_RESET_HOT: + spapr_phb_vfio_eeh_pre_reset(sphb); + op =3D VFIO_EEH_PE_RESET_HOT; + break; + case RTAS_SLOT_RESET_FUNDAMENTAL: + spapr_phb_vfio_eeh_pre_reset(sphb); + op =3D VFIO_EEH_PE_RESET_FUNDAMENTAL; + break; + default: + return RTAS_OUT_PARAM_ERROR; + } + + ret =3D vfio_eeh_as_op(&sphb->iommu_as, op); + if (ret < 0) { + return RTAS_OUT_HW_ERROR; + } + + return RTAS_OUT_SUCCESS; +} + +int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) +{ + int ret; + + ret =3D vfio_eeh_as_op(&sphb->iommu_as, VFIO_EEH_PE_CONFIGURE); + if (ret < 0) { + return RTAS_OUT_PARAM_ERROR; + } + + return RTAS_OUT_SUCCESS; +} + +typedef struct SpaprVFIOErrinjctBarMatch { + uint64_t guest_addr; + + PCIDevice *pdev; + VFIOPCIDevice *vdev; + int bar; + + uint64_t guest_bar_start; + uint64_t bar_size; + uint64_t offset; +} SpaprVFIOErrinjctBarMatch; + +static VFIOPCIDevice *spapr_vfio_errinjct_pci_to_vfio(PCIDevice *pdev) +{ + if (!object_dynamic_cast(OBJECT(pdev), TYPE_VFIO_PCI)) { + return NULL; + } + + return container_of(pdev, VFIOPCIDevice, parent_obj); +} + +static void spapr_vfio_errinjct_find_bar_cb(PCIBus *bus, + PCIDevice *pdev, + void *opaque) +{ + SpaprVFIOErrinjctBarMatch *ctx =3D opaque; + VFIOPCIDevice *vdev; + int bar; + + if (ctx->pdev) { + return; + } + + vdev =3D spapr_vfio_errinjct_pci_to_vfio(pdev); + if (!vdev) { + return; + } + + for (bar =3D 0; bar < PCI_STD_NUM_BARS; bar++) { + pcibus_t guest_bar_start; + uint64_t bar_size; + uint64_t offset; + + bar_size =3D vdev->bars[bar].region.size; + if (!bar_size) { + continue; + } + + guest_bar_start =3D pci_get_bar_addr(pdev, bar); + if (guest_bar_start =3D=3D PCI_BAR_UNMAPPED) { + continue; + } + + if (ctx->guest_addr < guest_bar_start || + ctx->guest_addr - guest_bar_start >=3D bar_size) { + if (vdev->bars[bar].mem64) { + bar++; + } + continue; + } + + offset =3D ctx->guest_addr - guest_bar_start; + + ctx->pdev =3D pdev; + ctx->vdev =3D vdev; + ctx->bar =3D bar; + ctx->guest_bar_start =3D guest_bar_start; + ctx->bar_size =3D bar_size; + ctx->offset =3D offset; + + return; + } +} + +static int spapr_vfio_errinjct_get_host_bar(VFIOPCIDevice *vdev, + int bar, + uint64_t *host_bar_start) +{ + g_autofree char *path =3D NULL; + g_autofree char *contents =3D NULL; + char *line; + char *saveptr =3D NULL; + unsigned long long start; + unsigned long long end; + unsigned long long flags; + int i; + + if (!vdev || !host_bar_start || bar < 0 || bar >=3D PCI_STD_NUM_BARS) { + return -EINVAL; + } + + /* + * Read the host Linux sysfs resource file for the BAR. Do not use a + * VFIO PCI config-space read because that may return the + * guest-programmed BAR value rather than the host resource address. + */ + path =3D g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%u/resou= rce", + vdev->host.domain, + vdev->host.bus, + vdev->host.slot, + vdev->host.function); + + if (!g_file_get_contents(path, &contents, NULL, NULL)) { + error_report("vfio/eeh errinjct: failed to read %s", path); + return -ENOENT; + } + + line =3D strtok_r(contents, "\n", &saveptr); + + for (i =3D 0; line; i++, line =3D strtok_r(NULL, "\n", &saveptr)) { + if (i !=3D bar) { + continue; + } + + if (sscanf(line, "%llx %llx %llx", &start, &end, &flags) !=3D 3) { + error_report("vfio/eeh errinjct: malformed %s BAR%d", + path, bar); + return -EINVAL; + } + + if (!start || end < start) { + error_report("vfio/eeh errinjct: invalid host resource BAR%d " + "start=3D0x%llx end=3D0x%llx flags=3D0x%llx", + bar, start, end, flags); + return -EINVAL; + } + + *host_bar_start =3D start; + return 0; + } + + return -EINVAL; +} + +int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, + uint32_t config_addr, + uint64_t guest_addr, + uint64_t *host_pci_bus_addr) +{ + PCIHostState *phb; + SpaprVFIOErrinjctBarMatch ctx =3D { + .guest_addr =3D guest_addr, + .pdev =3D NULL, + .vdev =3D NULL, + .bar =3D -1, + }; + uint64_t host_bar_start; + int rc; + + if (!sphb || !host_pci_bus_addr) { + return -EINVAL; + } + + phb =3D PCI_HOST_BRIDGE(sphb); + + /* + * BUID has already selected @sphb before this helper is called. + * config_addr is retained for logging/debug only. Do not rely on it + * to find the target device; some RTAS IOA buffers may not carry a + * valid guest BDF-style config address. Scan VFIO BARs under this + * PHB and match guest_addr against the guest BAR layout instead. + */ + pci_for_each_device_under_bus(phb->bus, + spapr_vfio_errinjct_find_bar_cb, + &ctx); + + if (!ctx.pdev) { + error_report("vfio/eeh errinjct: guest addr 0x%" PRIx64 + " not within any VFIO BAR under BUID=3D0x%016" PRIx64 + " config_addr=3D0x%08x", + guest_addr, sphb->buid, config_addr); + return -ENODEV; + } + + rc =3D spapr_vfio_errinjct_get_host_bar(ctx.vdev, ctx.bar, &host_bar_s= tart); + if (rc) { + error_report("vfio/eeh errinjct: failed to get host BAR%d for " + "dev=3D%s BUID=3D0x%016" PRIx64 " config_addr=3D0x%08= x rc=3D%d", + ctx.bar, ctx.pdev->name, sphb->buid, config_addr, rc); + return rc; + } + + if (host_bar_start =3D=3D ctx.guest_bar_start) { + error_report("vfio/eeh errinjct: refusing guest BAR as host BAR: " + "dev=3D%s BAR%d guest_bar=3D0x%" PRIx64 + " host_bar=3D0x%" PRIx64, + ctx.pdev->name, ctx.bar, + ctx.guest_bar_start, host_bar_start); + return -EOPNOTSUPP; + } + + *host_pci_bus_addr =3D host_bar_start + ctx.offset; + return 0; +} + +static int spapr_vfio_errinjct_rtas_type_to_vfio(uint32_t rtas_type) +{ + switch (rtas_type) { + case RTAS_ERR_TYPE_IOA_BUS_ERROR: + return EEH_ERR_TYPE_32; + case RTAS_ERR_TYPE_IOA_BUS_ERROR_64: + return EEH_ERR_TYPE_64; + default: + return -1; + } +} + +static bool spapr_vfio_errinjct_func_valid(uint32_t func) +{ + return func <=3D EEH_ERR_FUNC_MAX; +} + +int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, + uint32_t func, uint64_t addr, uint64_t mask) +{ + VFIOLegacyContainer *container; + struct vfio_eeh_pe_op op =3D { + .op =3D VFIO_EEH_PE_INJECT_ERR, + .argsz =3D sizeof(op), + }; + int vfio_type; + + if (!sphb) { + return RTAS_OUT_PARAM_ERROR; + } + + if (!spapr_vfio_errinjct_func_valid(func)) { + return RTAS_OUT_PARAM_ERROR; + } + + vfio_type =3D spapr_vfio_errinjct_rtas_type_to_vfio(type); + if (vfio_type < 0) { + return RTAS_OUT_NOT_SUPPORTED; + } + + container =3D vfio_eeh_as_container(&sphb->iommu_as); + if (!container) { + error_report("vfio/eeh errinjct: no VFIO EEH container for PHB"); + return RTAS_OUT_NOT_SUPPORTED; + } + + /* Enforce exactly one group per container check matching other EEH op= s */ + if (!vfio_eeh_container_ok(container)) { + error_report("vfio: requires a container with exactly one group"); + return RTAS_OUT_HW_ERROR; + } + + op.err.type =3D vfio_type; + op.err.func =3D func; + op.err.addr =3D addr; + op.err.mask =3D mask; + + if (ioctl(container->fd, VFIO_EEH_PE_OP, &op) < 0) { + error_report("vfio/eeh errinjct: VFIO_EEH_PE_OP failed: %s", + strerror(errno)); + switch (errno) { + case EINVAL: + return RTAS_OUT_PARAM_ERROR; + case ENOTTY: + case EOPNOTSUPP: + return RTAS_OUT_NOT_SUPPORTED; + default: + return RTAS_OUT_HW_ERROR; + } + } + + return RTAS_OUT_SUCCESS; +} + diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index ec9f6284c7..2c85d8595d 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -33,6 +33,7 @@ #include "hw/pci/msix.h" #include "hw/pci/pci_host.h" #include "hw/ppc/spapr.h" +#include "hw/ppc/spapr_vfio.h" #include "hw/pci-host/spapr.h" #include #include "trace.h" diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c index fe89fb4ca3..e6ecc3f1ee 100644 --- a/hw/ppc/spapr_pci_vfio.c +++ b/hw/ppc/spapr_pci_vfio.c @@ -22,120 +22,12 @@ #include #include "hw/ppc/spapr.h" #include "hw/pci-host/spapr.h" +#include "hw/ppc/spapr_vfio.h" #include "hw/pci/msix.h" #include "hw/pci/pci_device.h" #include "hw/vfio/vfio-container-legacy.h" #include "qemu/error-report.h" #include "hw/vfio/pci.h" -#include CONFIG_DEVICES /* CONFIG_VFIO_PCI */ - -/* - * Interfaces for IBM EEH (Enhanced Error Handling) - */ -#ifdef CONFIG_VFIO_PCI -static bool vfio_eeh_container_ok(VFIOLegacyContainer *container) -{ - /* - * As of 2016-03-04 (linux-4.5) the host kernel EEH/VFIO - * implementation is broken if there are multiple groups in a - * container. The hardware works in units of Partitionable - * Endpoints (=3D=3D IOMMU groups) and the EEH operations naively - * iterate across all groups in the container, without any logic - * to make sure the groups have their state synchronized. For - * certain operations (ENABLE) that might be ok, until an error - * occurs, but for others (GET_STATE) it's clearly broken. - */ - - /* - * XXX Once fixed kernels exist, test for them here - */ - - if (QLIST_EMPTY(&container->group_list)) { - return false; - } - - if (QLIST_NEXT(QLIST_FIRST(&container->group_list), container_next)) { - return false; - } - - return true; -} - -static int vfio_eeh_container_op(VFIOLegacyContainer *container, uint32_t = op) -{ - struct vfio_eeh_pe_op pe_op =3D { - .argsz =3D sizeof(pe_op), - .op =3D op, - }; - int ret; - - if (!vfio_eeh_container_ok(container)) { - error_report("vfio/eeh: EEH_PE_OP 0x%x: " - "kernel requires a container with exactly one group",= op); - return -EPERM; - } - - ret =3D ioctl(container->fd, VFIO_EEH_PE_OP, &pe_op); - if (ret < 0) { - error_report("vfio/eeh: EEH_PE_OP 0x%x failed: %m", op); - return -errno; - } - - return ret; -} - -static VFIOLegacyContainer *vfio_eeh_as_container(AddressSpace *as) -{ - VFIOAddressSpace *space =3D vfio_address_space_get(as); - VFIOContainer *bcontainer =3D NULL; - - if (QLIST_EMPTY(&space->containers)) { - /* No containers to act on */ - goto out; - } - - bcontainer =3D QLIST_FIRST(&space->containers); - - if (QLIST_NEXT(bcontainer, next)) { - /* - * We don't yet have logic to synchronize EEH state across - * multiple containers - */ - bcontainer =3D NULL; - goto out; - } - -out: - vfio_address_space_put(space); - return VFIO_IOMMU_LEGACY(bcontainer); -} - -static bool vfio_eeh_as_ok(AddressSpace *as) -{ - VFIOLegacyContainer *container =3D vfio_eeh_as_container(as); - - return (container !=3D NULL) && vfio_eeh_container_ok(container); -} - -static int vfio_eeh_as_op(AddressSpace *as, uint32_t op) -{ - VFIOLegacyContainer *container =3D vfio_eeh_as_container(as); - - if (!container) { - return -ENODEV; - } - return vfio_eeh_container_op(container, op); -} - -bool spapr_phb_eeh_available(SpaprPhbState *sphb) -{ - return vfio_eeh_as_ok(&sphb->iommu_as); -} - -static void spapr_phb_vfio_eeh_reenable(SpaprPhbState *sphb) -{ - vfio_eeh_as_op(&sphb->iommu_as, VFIO_EEH_PE_ENABLE); -} =20 void spapr_phb_vfio_reset(DeviceState *qdev) { @@ -147,490 +39,3 @@ void spapr_phb_vfio_reset(DeviceState *qdev) */ spapr_phb_vfio_eeh_reenable(SPAPR_PCI_HOST_BRIDGE(qdev)); } - -static void spapr_eeh_pci_find_device(PCIBus *bus, PCIDevice *pdev, - void *opaque) -{ - bool *found =3D opaque; - - if (object_dynamic_cast(OBJECT(pdev), "vfio-pci")) { - *found =3D true; - } -} - -int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb, - unsigned int addr, int option) -{ - uint32_t op; - int ret; - - switch (option) { - case RTAS_EEH_DISABLE: - op =3D VFIO_EEH_PE_DISABLE; - break; - case RTAS_EEH_ENABLE: { - PCIHostState *phb; - bool found =3D false; - - /* - * The EEH functionality is enabled per sphb level instead of - * per PCI device. We have already identified this specific sphb - * based on buid passed as argument to ibm,set-eeh-option rtas - * call. Now we just need to check the validity of the PCI - * pass-through devices (vfio-pci) under this sphb bus. - * We have already validated that all the devices under this sphb - * are from same iommu group (within same PE) before coming here. - * - * Prior to linux commit 98ba956f6a389 ("powerpc/pseries/eeh: - * Rework device EEH PE determination") kernel would call - * eeh-set-option for each device in the PE using the device's - * config_address as the argument rather than the PE address. - * Hence if we check validity of supplied config_addr whether - * it matches to this PHB will cause issues with older kernel - * versions v5.9 and older. If we return an error from - * eeh-set-option when the argument isn't a valid PE address - * then older kernels (v5.9 and older) will interpret that as - * EEH not being supported. - */ - phb =3D PCI_HOST_BRIDGE(sphb); - pci_for_each_device(phb->bus, (addr >> 16) & 0xFF, - spapr_eeh_pci_find_device, &found); - - if (!found) { - return RTAS_OUT_PARAM_ERROR; - } - - op =3D VFIO_EEH_PE_ENABLE; - break; - } - case RTAS_EEH_THAW_IO: - op =3D VFIO_EEH_PE_UNFREEZE_IO; - break; - case RTAS_EEH_THAW_DMA: - op =3D VFIO_EEH_PE_UNFREEZE_DMA; - break; - default: - return RTAS_OUT_PARAM_ERROR; - } - - ret =3D vfio_eeh_as_op(&sphb->iommu_as, op); - if (ret < 0) { - return RTAS_OUT_HW_ERROR; - } - - return RTAS_OUT_SUCCESS; -} - -int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state) -{ - int ret; - - ret =3D vfio_eeh_as_op(&sphb->iommu_as, VFIO_EEH_PE_GET_STATE); - if (ret < 0) { - return RTAS_OUT_PARAM_ERROR; - } - - *state =3D ret; - return RTAS_OUT_SUCCESS; -} - -static void spapr_phb_vfio_eeh_clear_dev_msix(PCIBus *bus, - PCIDevice *pdev, - void *opaque) -{ - /* Check if the device is VFIO PCI device */ - if (!object_dynamic_cast(OBJECT(pdev), "vfio-pci")) { - return; - } - - /* - * The MSIx table will be cleaned out by reset. We need - * disable it so that it can be reenabled properly. Also, - * the cached MSIx table should be cleared as it's not - * reflecting the contents in hardware. - */ - if (msix_enabled(pdev)) { - uint16_t flags; - - flags =3D pci_host_config_read_common(pdev, - pdev->msix_cap + PCI_MSIX_FLAG= S, - pci_config_size(pdev), 2); - flags &=3D ~PCI_MSIX_FLAGS_ENABLE; - pci_host_config_write_common(pdev, - pdev->msix_cap + PCI_MSIX_FLAGS, - pci_config_size(pdev), flags, 2); - } - - msix_reset(pdev); -} - -static void spapr_phb_vfio_eeh_clear_bus_msix(PCIBus *bus, void *opaque) -{ - pci_for_each_device_under_bus(bus, spapr_phb_vfio_eeh_clear_dev_msi= x, - NULL); -} - -static void spapr_phb_vfio_eeh_pre_reset(SpaprPhbState *sphb) -{ - PCIHostState *phb =3D PCI_HOST_BRIDGE(sphb); - - pci_for_each_bus(phb->bus, spapr_phb_vfio_eeh_clear_bus_msix, NULL); -} - -int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option) -{ - uint32_t op; - int ret; - - switch (option) { - case RTAS_SLOT_RESET_DEACTIVATE: - op =3D VFIO_EEH_PE_RESET_DEACTIVATE; - break; - case RTAS_SLOT_RESET_HOT: - spapr_phb_vfio_eeh_pre_reset(sphb); - op =3D VFIO_EEH_PE_RESET_HOT; - break; - case RTAS_SLOT_RESET_FUNDAMENTAL: - spapr_phb_vfio_eeh_pre_reset(sphb); - op =3D VFIO_EEH_PE_RESET_FUNDAMENTAL; - break; - default: - return RTAS_OUT_PARAM_ERROR; - } - - ret =3D vfio_eeh_as_op(&sphb->iommu_as, op); - if (ret < 0) { - return RTAS_OUT_HW_ERROR; - } - - return RTAS_OUT_SUCCESS; -} - -int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) -{ - int ret; - - ret =3D vfio_eeh_as_op(&sphb->iommu_as, VFIO_EEH_PE_CONFIGURE); - if (ret < 0) { - return RTAS_OUT_PARAM_ERROR; - } - - return RTAS_OUT_SUCCESS; -} - -typedef struct SpaprVFIOErrinjctBarMatch { - uint64_t guest_addr; - - PCIDevice *pdev; - VFIOPCIDevice *vdev; - int bar; - - uint64_t guest_bar_start; - uint64_t bar_size; - uint64_t offset; -} SpaprVFIOErrinjctBarMatch; - -static VFIOPCIDevice *spapr_vfio_errinjct_pci_to_vfio(PCIDevice *pdev) -{ - if (!object_dynamic_cast(OBJECT(pdev), TYPE_VFIO_PCI)) { - return NULL; - } - - return container_of(pdev, VFIOPCIDevice, parent_obj); -} - -static void spapr_vfio_errinjct_find_bar_cb(PCIBus *bus, - PCIDevice *pdev, - void *opaque) -{ - SpaprVFIOErrinjctBarMatch *ctx =3D opaque; - VFIOPCIDevice *vdev; - int bar; - - if (ctx->pdev) { - return; - } - - vdev =3D spapr_vfio_errinjct_pci_to_vfio(pdev); - if (!vdev) { - return; - } - - for (bar =3D 0; bar < PCI_STD_NUM_BARS; bar++) { - pcibus_t guest_bar_start; - uint64_t bar_size; - uint64_t offset; - - bar_size =3D vdev->bars[bar].region.size; - if (!bar_size) { - continue; - } - - guest_bar_start =3D pci_get_bar_addr(pdev, bar); - if (guest_bar_start =3D=3D PCI_BAR_UNMAPPED) { - continue; - } - - if (ctx->guest_addr < guest_bar_start || - ctx->guest_addr - guest_bar_start >=3D bar_size) { - if (vdev->bars[bar].mem64) { - bar++; - } - continue; - } - - offset =3D ctx->guest_addr - guest_bar_start; - - ctx->pdev =3D pdev; - ctx->vdev =3D vdev; - ctx->bar =3D bar; - ctx->guest_bar_start =3D guest_bar_start; - ctx->bar_size =3D bar_size; - ctx->offset =3D offset; - - return; - } -} - -static int spapr_vfio_errinjct_get_host_bar(VFIOPCIDevice *vdev, - int bar, - uint64_t *host_bar_start) -{ - g_autofree char *path =3D NULL; - g_autofree char *contents =3D NULL; - char *line; - char *saveptr =3D NULL; - unsigned long long start; - unsigned long long end; - unsigned long long flags; - int i; - - if (!vdev || !host_bar_start || bar < 0 || bar >=3D PCI_STD_NUM_BARS) { - return -EINVAL; - } - - /* - * Read the host Linux sysfs resource file for the BAR. Do not use a - * VFIO PCI config-space read because that may return the - * guest-programmed BAR value rather than the host resource address. - */ - path =3D g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%u/resou= rce", - vdev->host.domain, - vdev->host.bus, - vdev->host.slot, - vdev->host.function); - - if (!g_file_get_contents(path, &contents, NULL, NULL)) { - error_report("vfio/eeh errinjct: failed to read %s", path); - return -ENOENT; - } - - line =3D strtok_r(contents, "\n", &saveptr); - - for (i =3D 0; line; i++, line =3D strtok_r(NULL, "\n", &saveptr)) { - if (i !=3D bar) { - continue; - } - - if (sscanf(line, "%llx %llx %llx", &start, &end, &flags) !=3D 3) { - error_report("vfio/eeh errinjct: malformed %s BAR%d", - path, bar); - return -EINVAL; - } - - if (!start || end < start) { - error_report("vfio/eeh errinjct: invalid host resource BAR%d " - "start=3D0x%llx end=3D0x%llx flags=3D0x%llx", - bar, start, end, flags); - return -EINVAL; - } - - *host_bar_start =3D start; - return 0; - } - - return -EINVAL; -} - -int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, - uint32_t config_addr, - uint64_t guest_addr, - uint64_t *host_pci_bus_addr) -{ - PCIHostState *phb; - SpaprVFIOErrinjctBarMatch ctx =3D { - .guest_addr =3D guest_addr, - .pdev =3D NULL, - .vdev =3D NULL, - .bar =3D -1, - }; - uint64_t host_bar_start; - int rc; - - if (!sphb || !host_pci_bus_addr) { - return -EINVAL; - } - - phb =3D PCI_HOST_BRIDGE(sphb); - - /* - * BUID has already selected @sphb before this helper is called. - * config_addr is retained for logging/debug only. Do not rely on it - * to find the target device; some RTAS IOA buffers may not carry a - * valid guest BDF-style config address. Scan VFIO BARs under this - * PHB and match guest_addr against the guest BAR layout instead. - */ - pci_for_each_device_under_bus(phb->bus, - spapr_vfio_errinjct_find_bar_cb, - &ctx); - - if (!ctx.pdev) { - error_report("vfio/eeh errinjct: guest addr 0x%" PRIx64 - " not within any VFIO BAR under BUID=3D0x%016" PRIx64 - " config_addr=3D0x%08x", - guest_addr, sphb->buid, config_addr); - return -ENODEV; - } - - rc =3D spapr_vfio_errinjct_get_host_bar(ctx.vdev, ctx.bar, &host_bar_s= tart); - if (rc) { - error_report("vfio/eeh errinjct: failed to get host BAR%d for " - "dev=3D%s BUID=3D0x%016" PRIx64 " config_addr=3D0x%08= x rc=3D%d", - ctx.bar, ctx.pdev->name, sphb->buid, config_addr, rc); - return rc; - } - - if (host_bar_start =3D=3D ctx.guest_bar_start) { - error_report("vfio/eeh errinjct: refusing guest BAR as host BAR: " - "dev=3D%s BAR%d guest_bar=3D0x%" PRIx64 - " host_bar=3D0x%" PRIx64, - ctx.pdev->name, ctx.bar, - ctx.guest_bar_start, host_bar_start); - return -EOPNOTSUPP; - } - - *host_pci_bus_addr =3D host_bar_start + ctx.offset; - return 0; -} - -static int spapr_vfio_errinjct_rtas_type_to_vfio(uint32_t rtas_type) -{ - switch (rtas_type) { - case RTAS_ERR_TYPE_IOA_BUS_ERROR: - return EEH_ERR_TYPE_32; - case RTAS_ERR_TYPE_IOA_BUS_ERROR_64: - return EEH_ERR_TYPE_64; - default: - return -1; - } -} - -static bool spapr_vfio_errinjct_func_valid(uint32_t func) -{ - return func <=3D EEH_ERR_FUNC_MAX; -} - -int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, - uint32_t func, uint64_t addr, uint64_t mask) -{ - VFIOLegacyContainer *container; - struct vfio_eeh_pe_op op =3D { - .op =3D VFIO_EEH_PE_INJECT_ERR, - .argsz =3D sizeof(op), - }; - int vfio_type; - - if (!sphb) { - return RTAS_OUT_PARAM_ERROR; - } - - if (!spapr_vfio_errinjct_func_valid(func)) { - return RTAS_OUT_PARAM_ERROR; - } - - vfio_type =3D spapr_vfio_errinjct_rtas_type_to_vfio(type); - if (vfio_type < 0) { - return RTAS_OUT_NOT_SUPPORTED; - } - - container =3D vfio_eeh_as_container(&sphb->iommu_as); - if (!container) { - error_report("vfio/eeh errinjct: no VFIO EEH container for PHB"); - return RTAS_OUT_NOT_SUPPORTED; - } - - /* Enforce exactly one group per container check matching other EEH op= s */ - if (!vfio_eeh_container_ok(container)) { - error_report("vfio: requires a container with exactly one group"); - return RTAS_OUT_HW_ERROR; - } - - op.err.type =3D vfio_type; - op.err.func =3D func; - op.err.addr =3D addr; - op.err.mask =3D mask; - - if (ioctl(container->fd, VFIO_EEH_PE_OP, &op) < 0) { - error_report("vfio/eeh errinjct: VFIO_EEH_PE_OP failed: %s", - strerror(errno)); - switch (errno) { - case EINVAL: - return RTAS_OUT_PARAM_ERROR; - case ENOTTY: - case EOPNOTSUPP: - return RTAS_OUT_NOT_SUPPORTED; - default: - return RTAS_OUT_HW_ERROR; - } - } - - return RTAS_OUT_SUCCESS; -} - -#else - -bool spapr_phb_eeh_available(SpaprPhbState *sphb) -{ - return false; -} - -void spapr_phb_vfio_reset(DeviceState *qdev) -{ -} - -int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb, - unsigned int addr, int option) -{ - return RTAS_OUT_NOT_SUPPORTED; -} - -int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state) -{ - return RTAS_OUT_NOT_SUPPORTED; -} - -int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option) -{ - return RTAS_OUT_NOT_SUPPORTED; -} - -int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) -{ - return RTAS_OUT_NOT_SUPPORTED; -} - -int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, - uint32_t func, uint64_t addr, uint64_t mask) -{ - return RTAS_OUT_NOT_SUPPORTED; -} - -int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, - uint32_t config_addr, - uint64_t guest_addr, - uint64_t *host_pci_bus_addr) -{ - return -ENOTSUP; -} - -#endif /* CONFIG_VFIO_PCI */ diff --git a/stubs/spapr_phb_vfio-stubs.c b/stubs/spapr_phb_vfio-stubs.c new file mode 100644 index 0000000000..4d86d9000e --- /dev/null +++ b/stubs/spapr_phb_vfio-stubs.c @@ -0,0 +1,62 @@ +/* + * Stubs for sPAPR PCI VFIO EEH + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/ppc/spapr_vfio.h" + +/* RTAS return codes */ +#define RTAS_OUT_NOT_SUPPORTED (-3) + + +bool spapr_phb_eeh_available(SpaprPhbState *sphb) +{ + return false; +} + +int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb, + unsigned int addr, int option) +{ + return RTAS_OUT_NOT_SUPPORTED; +} + +int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state) +{ + return RTAS_OUT_NOT_SUPPORTED; +} + +int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option) +{ + return RTAS_OUT_NOT_SUPPORTED; +} + +int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb) +{ + return RTAS_OUT_NOT_SUPPORTED; +} + +void spapr_phb_vfio_reset(DeviceState *qdev) +{ +} + +void spapr_phb_vfio_eeh_reenable(SpaprPhbState *sphb) +{ +} + +int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type, + uint32_t func, uint64_t addr, uint64_t mask) +{ + return RTAS_OUT_NOT_SUPPORTED; +} + +int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb, + uint32_t config_addr, + uint64_t guest_addr, + uint64_t *host_pci_bus_addr) +{ + return -ENOTSUP; +} + + diff --git a/hw/ppc/Kconfig b/hw/ppc/Kconfig index 347dcce690..3714d708d9 100644 --- a/hw/ppc/Kconfig +++ b/hw/ppc/Kconfig @@ -6,7 +6,7 @@ config PSERIES imply PCI_DEVICES imply TEST_DEVICES imply VIRTIO_VGA - imply VFIO_PCI if LINUX # needed by spapr_pci_vfio.c + imply VFIO_PCI if LINUX # needed by spapr_pci_vfio.c and spapr_eeh.c select NVDIMM select DIMM select PCI diff --git a/hw/ppc/meson.build b/hw/ppc/meson.build index 37aa535db2..4e03973440 100644 --- a/hw/ppc/meson.build +++ b/hw/ppc/meson.build @@ -36,6 +36,7 @@ ppc_ss.add(when: 'CONFIG_SPAPR_RNG', if_true: files('spap= r_rng.c')) if host_os =3D=3D 'linux' ppc_ss.add(when: 'CONFIG_PSERIES', if_true: files( 'spapr_pci_vfio.c', + 'spapr_eeh.c', )) endif =20 diff --git a/stubs/meson.build b/stubs/meson.build index dcb67ce529..122f1f85b3 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -101,6 +101,7 @@ if have_system stub_ss.add(files('hmp-cmds-hw-s390x.c')) stub_ss.add(files('hmp-cmds-target-i386.c')) endif + stub_ss.add(files('spapr_phb_vfio-stubs.c')) endif =20 if have_system or have_user --=20 2.51.1 From nobody Mon Nov 23 04:43:54 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=1792427263; cv=none; d=zohomail.com; s=zohoarc; b=jdEKHZhg6MnqE4mu5kSevi4gZjx7fCcgW+oOmnD4G0X5V15s/44uxsCmedPUbbJ8cOf1FyRAcjP+AhlvCfODeZyNn7duMwhZJWyUz6v/dhOfvun6nr1F2dkLpkg6ZXaebVkvYb1mpsYLrF5MxVW1ZSjuTfbUOsFVP54/MWQhbIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792427263; 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=Q839harI6NKWSta2poavzM2yxDm6fPJKONc0aFAObcs=; b=PMX0h+Zb9WBT6Rf8xDWFTkczpyIjYntdBC43fXlxY7V6AVuhWfDNZwh6GsZjfA/2eUWsWY4qtE7Y6sSQPicPhgcA5uts19cePJGBh1QpV+9CecwJLruslBiIWfOots9NCGvFCxdnkUEFzChLYEiNMwz+75Dx1qtNBoBrLRyrAVE= 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 1792427263112194.6361490412038; Mon, 19 Oct 2026 09:27:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xIqCZ-0002Mr-37; Mon, 19 Oct 2026 12:27:07 -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 1xIqCE-00029Z-Mh; Mon, 19 Oct 2026 12:26:47 -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 1xIqCC-0001Un-8X; Mon, 19 Oct 2026 12:26:45 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69JFj31A3042775; Mon, 19 Oct 2026 16:26:38 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 4hbyepunv0-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:38 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69JFZ5j0121764; Mon, 19 Oct 2026 16:26:37 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hckbq6nr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Oct 2026 16:26:37 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69JGQTH447382792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Oct 2026 16:26:30 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C449F2004E; Mon, 19 Oct 2026 16:26:29 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1730F20040; Mon, 19 Oct 2026 16:26:26 +0000 (GMT) Received: from Narayanas-MacBook-Pro.ibm.com (unknown [9.124.217.62]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 19 Oct 2026 16:26:25 +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=Q839harI6NKWSta2p oavzM2yxDm6fPJKONc0aFAObcs=; b=k4Tt+ULSDVYcq0eLxUqS7maVAm0Aqbn1q W7J4MKroDuotKq2cwTIZBMqqSAUrp5tMvuYcorvfBBrnB5DMOn7lgDJ0+y/hFAwF vejPC7LXMWr+ZOzSmTnMmsYVXwrIC571gHXmdNHIoElW2mkHc6XVFcK2nkZ+UG2z S05eopPCqlsL/UpmjT/6GrTOGKM7VK1gO72p+gxQ7h5neR3QzXKVmzdXXUDOrpoA 1Y7O8MYrqXcfkDvepX0hehAZJT2nNPtaHuKMIBZTBJ9uG2Az3lVBQav8DvCWus/B JdYUDMUHwzqd69KVhd6lKzo7t18HPaRcm+ISQ4Fzx9dv3EB2PGY2Q== From: Narayana Murty N To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Mahesh J Salgaonkar , Sourabh Bhat , anushree.mathur@linux.vnet.ibm.com, clg@redhat.com, Sourabh Jain , adityag@linux.ibm.com, nikhilks@linux.ibm.com Cc: pierrick.bouvier@oss.qualcomm.com, rathc@linux.ibm.com, Nicholas Piggin , harshpb@linux.ibm.com, amachhiw@linux.ibm.com, hbathini@linux.ibm.com, shivangu@linux.ibm.com Subject: [PATCH v6 6/6] MAINTAINERS: Add self as sPAPR EEH reviewer under PPC RAS Date: Mon, 19 Oct 2026 21:55:40 +0530 Message-ID: <20261019162541.68440-7-nnmlinux@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261019162541.68440-1-nnmlinux@linux.ibm.com> References: <20261019162541.68440-1-nnmlinux@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX3M0hxi0AsjYW vjOTfKYeelWQzbt6wTyc9xehdQsreita1uhT3CSszX3xSxqp+s/iHExPTNpe4wxonGe+yBPLh1u I6LXJVfs6vowXYDQtHO1p5ZdCXrFBK0= X-Authority-Analysis: v=2.4 cv=Z4R5j3RA c=1 sm=1 tr=0 ts=6ad644be cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=69wJf7TsAAAA:8 a=uPrgHAJC8kndP_WudMUA:9 a=Fg1AiH1G6rFz08G2ETeA:22 X-Proofpoint-ORIG-GUID: DXhjiqsAs1Xdz_u8iebLYN10kThmEzWI X-Proofpoint-GUID: C-BCSZIXXjWR5JTM4Gbg2fmKk1hnkmiU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDE5MDA2NCBTYWx0ZWRfX0AXq899gPp+Y AIhm1Sz7L9qmJMzQm6ajOq+efuSMyO5RlU6ppMS0T6qENUsMQuNKWocabGdxndEemOOngykt/u6 I1RDL2C19BYVFF6VoSQFO+tltKnhFBOnpoLk85Co+n6PRcGWkTeJ2HkSVgY7wowhU//lrJe1guB EhVyW+JDcr2x1YgQ+8ZYoJQhN0J4zpm5XZrEyiaDguo+YkElrZHfsXyecV8EBYH1v7te8b2QTJW OA020Mn0jbqTDg/94KPK7p9jaPP34i3vaJ8btSjaPwo0ilCcPLjnknpnRcuXTVbvJlcJ6vlTSlt Fxh4vx6TnsflkPJz9cYcVfXO2JWabe4Wb1WAz3nDWHPe69z2YO0tHg+gAhbUykxKLpvZZeGQ7uR lQo2I7SK2CbEKvG80V5zYpszLZyK8U/sboJhxMZMD0DLQfzNGv3TyUjTr8xOOvM9txmCWvnRJBI L/pVlz0epN7xHF+CZdQ== 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-19_05,2026-10-14_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=0 phishscore=0 clxscore=1011 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610190064 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=nnmlinux@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: 1792427264519158500 Content-Type: text/plain; charset="utf-8" Adding self as reviewer for the sPAPR EEH under PPC RAS. Updating the EEH specific file name as got updated in previous patches. Signed-off-by: Narayana Murty N Reported-by: Tasmiya Nalatwad Tested-by: Tasmiya Nalatwad --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 33b4f7c259..337d402fa6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1775,11 +1775,13 @@ M: Aditya Gupta R: Sourabh Jain R: Hari Bathini R: Shivang Upadhyay +R: Narayana Murty N L: qemu-ppc@nongnu.org S: Maintained F: hw/ppc/spapr_events.c F: hw/ppc/spapr_fadump.c F: hw/ppc/spapr_pci_vfio.c +F: hw/ppc/spapr_eeh.c F: hw/ppc/spapr_rtas.c F: hw/ppc/pnv_mpipl.c F: include/hw/ppc/spapr_fadump.h --=20 2.51.1