From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795429406; b=gYodRtPf3EOV7Wnkgzd7syAtUiZZDKDP+6MxeYRbixI9xJcMkRQgGtdJ6X4jxxHVt2Kr j9IX9fupdwkazMDmvc17ZEbNofOZm8DFI6W0s40NsS+s2NBuD4RuzUEuGlAEW09Rpy0j6 CLmieNjzzkK/NcWDs4yiEO1NAkzade5Hiq5ATuAYXlqdKMxqQ+tQDSO2D4rjpKRWyegFo Pp9Zgf5mq0pHf82RvXnJUY0ZS9ndjKRPSvbzmxc3Li8L9mDKl/OEn/9mnqi2vT8s+diw7 1zOUoxKeeJXrm08Uxf+ND/mqLGG3TYooa/BmUU5fb1kDZYU6LssJsooiCq9jLg64tDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795429406; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-TM-AS-GCONF:X-Proofpoint-Reinject:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Info:X-Proofpoint-GUID:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=w/FloF71PqPncE48SnnJDYXHzjDRo1RDPQwmXlXtCPI=; b=mZG3NYvgiRM3CPtDk7XBkGhmNfqCUScONb1A3Yf4SjDm3Xx9ZWIOaAf5MNkRfHNgPTea 2pLLYDBIWe3WHUsolJziT8K6lGvVJOPayfFCdV0A5YUPdKFDv+iDB/DwctdckMZSvMz70 ytBqMq2RCUcLZw00yHsgxufebSlBJm3MX6iqltu+VCi2M5+BwJRw6lb0r+d8idm1cyi0a taPs9Xvs35sh7W3hUHN3i/P5fYXGwUrv8e1DnJJ0uEa4GlKBPhqNhNLKWTs35GYSNncXc 45GCY6l5D4D9gPl9z2qNzDTgLFpQRO2eN/PepT6i88piysJBj446mtFN+yeAP/0b9Iw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=UMhqaAZR; arc=none smtp.remote-ip=148.163.158.5 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 978ED606A335; Mon, 23 Nov 2026 10:23:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 978ED606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=UMhqaAZR 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 6AN9Z2T43253419; Mon, 23 Nov 2026 10:22:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=w/FloF71PqPncE48SnnJDYXHzjDRo1RDPQwmXlXtC PI=; b=UMhqaAZRBNaQvK4691QLmk+tAuxOZklJ4z9M0xiwv0MSXcQYIHlAu7DWZ k+tEC//BBGi4CQK6bUpsuZAZNjrrfA5F6RwnCe+mG1N0WCWQ1aFN6dlRpG8tzAHe 2sw0WyGrVxWzF6/bI705fzvPXYQf86j72jdq/sCDHesTGxRQXNytbJDHWsdCfwyv 7ybvXQC52uk+TMUabJ+ATOMfd94nfMMx+29RAexSNOQMJ3kzAnD/uugY/JuebdH4 L1oSYqrsBH9YYEboDiUo3cbytQ/7htt2uava96y6PQ2B6HiBkqkKPIjK60SrqbTC m1svXVCRSf6JNS/Sm5JYQtwv256lA== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j34g12a58-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 23 Nov 2026 10:22:58 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AN9JMjE2758554; Mon, 23 Nov 2026 10:22:57 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j3q4h686y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Nov 2026 10:22:57 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6ANAMrMA50135354 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Nov 2026 10:22:53 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 480C92004B; Mon, 23 Nov 2026 10:22:53 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E18220043; Mon, 23 Nov 2026 10:22:50 +0000 (GMT) Received: from Narayanas-MacBook-Pro.bl1-in.ibm.com (unknown [9.123.4.64]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 23 Nov 2026 10:22:50 +0000 (GMT) From: Narayana Murty N To: Madhavan Srinivasan , "Oliver O'Halloran" , Timothy Pearson , Alex Williamson , sourabhjain@linux.ibm.com Cc: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Ritesh Harjani , Shrikanth Hegde , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, sbhat@linux.ibm.com, harshpb@linux.ibm.com Subject: [PATCH v7 0/4] powerpc: Add RTAS based error injection support for pSeries Date: Mon, 23 Nov 2026 15:52:38 +0530 Message-ID: <20261123102237.95860-6-nnmlinux@linux.ibm.com> X-Mailer: git-send-email 2.54.0 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-ORIG-GUID: s9GX12eypfE68urR-puDqCSVSW1kDfsE X-Proofpoint-Spam-Info: AW1haW4tMjYxMTIzMDA0MCBTYWx0ZWRfX+mo/hFL2pia3 89x7vllkhIPwxnCO2pDloT+fKyswrh92FVWcRZInPxv0mgtRp8VYBecxS9UXTApYaULZ9/076Qh gbKwXYCFLzgWDu6/iw6y9hkZoge0U3g= X-Proofpoint-GUID: gxEjslDgQ27B19COxJJoYtcTexK3rAdq X-Authority-Analysis: v=2.4 cv=c8M+0h9l c=1 sm=1 tr=0 ts=6b041402 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=eQh78yOvtJ_np8nwV1cA:9 a=WTyuFNfg86g-an66:21 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTIzMDA0MCBTYWx0ZWRfX0J4C01qGybaM 2IBECUQNeIIfHaQJN80qhhXDuDGHStQOTcncrTrWiDr/nb8+YnMxu5og6D1MXHRKtWSbw64RDe5 hROnvWCjmEm1f5K1hll0w9iDomg2hwV93pjjHX8NcBi+QtSTOXhDBs+cgd4yO3/dXtJq31aaCTT XiM8ay0Xxy/eNCN/b2rTeLxRt098WqOHBmuFIrXAWf0cTag6B2Jzm6q9wU7abL3SDwfjDZ3S2cq OsxZxM0s3KGN0PKZjbkrCI7JhujENUFKHjUeu1BAkzbVcY462HEQ4DuDOw/osaOJryoH55hq1qH 1OqHKIwEam+1yF9Pxi7KrSWC6izm69AtPQ0q1TuwCyKHhY8gWps/VB+jW2Szkf7lL3K80Mq4uGk 2j54SE+sOEdFRvS064GwviuH1bYDGXMUciVXk7qoOSwOz5+qpUm1zUa6gJHZ5Q5NCa2CTGX/KuH EV+NdPiVqK3I/hGI62g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-23_02,2026-11-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 suspectscore=0 bulkscore=0 priorityscore=1501 phishscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611230040 The pSeries EEH error-injection backend currently implements a limited software-generated MMIO failure and does not use the error-injection services provided by RTAS. This series replaces that implementation with the PAPR-defined RTAS workflow based on: - ibm,open-errinjct - ibm,errinjct - ibm,close-errinjct The implementation opens an RTAS error-injection session, allocates and prepares an RTAS-accessible work area, performs the requested injection, releases the work area, and closes the session on both success and failure paths. The existing EEH userspace ABI is preserved. EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 continue to represent generic 32-bit and 64-bit IOA bus-error injection requests. The pSeries backend maps these values to the corresponding RTAS error types, while the PowerNV backend explicitly maps them to the corresponding OPAL types. Additional generic EEH error types (EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT, EEH_ERR_TYPE_CORRUPTED_PAGE, and the cache/TLB corruption types) are defined in the UAPI header and mapped explicitly to RTAS firmware encodings by the pSeries backend. Platform backends that do not support a valid generic type return -EOPNOTSUPP. No existing userspace ABI values are changed. The injection path can be exercised for VFIO-assigned devices through VFIO_EEH_PE_INJECT_ERR. The guest or userspace VFIO application continues to use the same generic EEH type and function values, independent of whether the host platform uses RTAS or OPAL. For IOA bus-error injection, the VFIO sPAPR path normalizes a Linux BAR resource address to the corresponding PCI bus address before dispatching the request to the platform EEH backend. Address normalization is restricted to memory and IO load/store functions whose addr argument is a BAR-backed PCI address. Config-space and DMA functions are passed through without translation because their addr arguments represent PCI config register offsets and IOVA/TCE addresses respectively. The no-address form is represented by both address and mask being zero. The series also handles the unusual return format of ibm,open-errinjct: rets[0] = error-injection session token rets[1] = RTAS status rtas_call() returns rets[1] as the status and places the session token in outputs[0], preserving the normal kernel rtas_call() convention. sys_rtas() continues to expose the raw RTAS return cells to userspace. For ibm,open-errinjct, it validates that at least two return cells were requested before entering RTAS and uses the RTAS status cell for last-error handling. Userspace therefore continues to receive the session token and status in their PAPR-defined positions. The pSeries backend uses the existing RTAS work-area allocator for the error-injection parameter buffer. The work area is allocated only after ibm,open-errinjct succeeds and is released before ibm,close-errinjct. RTAS work areas reside below RTAS_INSTANTIATE_MAX, so the physical address fits in the 32-bit RTAS argument passed to firmware. The complete open, inject, and close sequence is serialized with a mutex. RTAS busy and extended-delay return values are handled for all three calls. Once a session has been opened, ibm,close-errinjct is attempted even when parameter preparation or error injection fails. The patches are organized as follows: 1. Handle the special ibm,open-errinjct return format in rtas_call(). 2. Add pSeries RTAS error-injection validation and buffer helpers. 3. Implement RTAS-based pSeries EEH error injection. 4. Normalize VFIO sPAPR IOA error-injection addresses. 5. Explicitly map generic EEH error types to OPAL types on PowerNV. Testing was performed on PowerVM with firmware providing the RTAS error-injection services and with corresponding QEMU support. The corresponding QEMU v6 series is posted here: https://lore.kernel.org/qemu-devel/20261019162541.68440-1-nnmlinux@linux.ibm.com/ Signed-off-by: Narayana Murty N --- Change Log: V6 -> V7: Changes since v6: https://lore.kernel.org/all/20261023073642.59657-1-nnmlinux@linux.ibm.com/ - Address review comments from Sourabh Jain and Sashiko. - Merge the pSeries RTAS helper and implementation patches to keep related functionality together. (Sourabh Jain, Sashiko) - Fix RTAS return-cell handling, tracing and documentation. (Sourabh Jain, Sashiko) - Obtain error-injection class tokens from the device tree instead of using hardcoded values. (Sashiko) - Improve pSeries BAR validation and RTAS error handling. (Sourabh Jain, Sashiko) - Refine VFIO address normalization using IOMMU group iteration, with pSeries-specific handling and correct BAR resource matching. (Sourabh Jain, Sashiko) - Retain the PowerNV error-type mapping from v6 without functional changes, and clarify its relationship to the pSeries RTAS patches. Both backends translate generic EEH types to firmware-specific RTAS or OPAL values. (Sourabh Jain) V5 -> V6: https://lore.kernel.org/all/20261019101813.45085-1-nnmlinux@linux.ibm.com/ * Addressed v5 review comments from Sashiko. * Patch 1: - No changes. * Patch 2: - Fix false BAR matches against unassigned or disabled BARs in validate_addr_mask_in_pe(): use pci_resource_len() instead of resource_size() (which returns 1 for zero-initialized BARs), and explicitly reject BARs with IORESOURCE_UNSET or IORESOURCE_DISABLED. - Move validate_errinjct_args() and prepare_errinjct_buffer() to Patch 3 alongside their callers so each intermediate commit builds cleanly with CONFIG_WERROR=y without unused-function warnings. * Patch 3: - Include for the RTAS work-area API used by the pSeries error-injection implementation. - Introduce validate_errinjct_args() and prepare_errinjct_buffer() here alongside their callers (moved from Patch 2). - Fix eeh_break_device() visibility: keep it under #ifdef CONFIG_DEBUG_FS to prevent unused-function compiler warnings when CONFIG_DEBUG_FS=n. - Add pseries_eeh_func_needs_bar_addr() to identify error functions whose addr argument is a BAR-backed MMIO/IO address. Guard validate_addr_mask_in_pe() in prepare_errinjct_buffer() with this predicate so config offsets and DMA/IOVA addresses bypass BAR membership validation. - Demote the validate_addr_mask_in_pe() diagnostic message from pr_err() to pr_debug() since invalid user-supplied inputs do not represent internal kernel errors. - Update prepare_errinjct_buffer() kernel-doc comments to document function-specific addr semantics (MEM/IO = BAR, CFG = offset, DMA = IOVA). * Patch 4: - Restrict address normalization to error functions carrying BAR-backed PCI MMIO/IO addresses (memory and IO load/store). Config-space and DMA functions bypass normalization rather than incorrectly returning -EINVAL. - Fix false matches against unassigned/disabled BARs in vfio_spapr_eeh_normalize_addr() using pci_resource_len() and checking IORESOURCE_UNSET / IORESOURCE_DISABLED. - Remove the misleading ", injection may fail" suffix from the pr_debug() message since the caller returns -EINVAL immediately. - Update commit description to accurately reflect function-specific address domains. * Patch 5: - No changes. V4 -> V5: https://lore.kernel.org/all/20260831065441.48654-1-nnmlinux@linux.ibm.com/ * Addressed v4 review comments from Sourabh Jain. * Return -EINVAL when ibm,open-errinjct is used with an invalid return-cell count. * Validate the ibm,open-errinjct return-cell count in sys_rtas() before entering RTAS and use the common status helper for last-error handling. * Rework the pSeries helper description to describe validation and RTAS parameter-buffer construction first. * Rename rtas_type to rtas_err_type to distinguish the mapped RTAS type from the generic EEH type. * Keep common error-function validation in validate_errinjct_args() and remove duplicate check from prepare_errinjct_buffer(). * Protect PE device and BAR traversal with pci_rescan_remove_lock. * Rename pseries_errinjct_mutex to errinjct_mutex. * Allocate RTAS work area only after ibm,open-errinjct succeeds and release it before ibm,close-errinjct. * Ensure ibm,close-errinjct is attempted after a successful open when parameter preparation or error injection subsequently fails. * Remove caller-side RTAS work-area address check and truncation, relying on RTAS work-area allocation guarantees for the 32-bit RTAS argument. * Remove unnecessary error message for unencodable 32-bit IOA address or mask and retain the buffer-ready debug message. * Remove eeh_pe_inject_mmio_error() and its declaration after removing its last caller. * Reorder the VFIO address-normalization patch after the pSeries RTAS implementation. * Remove the one-use VFIO error-type helper and check IOA error types directly at call site. * Treat only addr == 0 && mask == 0 as a no-address IOA injection. * Limit address matching to standard PCI BARs and add debug message when supplied address does not match a BAR. * Expand PowerNV commit message to explain generic EEH-to-OPAL type mapping and rename opal_type to opal_err_type. * Preserve -ERANGE for unsupported PowerNV error types. V3 -> V4: https://lore.kernel.org/all/20260831065441.48654-1-nnmlinux@linux.ibm.com/ * Use the RTAS work area allocator instead of adding a dedicated global error-injection buffer. * Keep sys_rtas() raw return-cell semantics unchanged while handling the special ibm,open-errinjct return format in rtas_call(). * Treat ibm,open-errinjct with fewer than two return cells as invalid rtas_call() usage instead of interpreting rets[0] as status. * Use normal Linux errno values in internal validation helpers instead of RTAS status values. * Simplify the pSeries RTAS open/inject/close flow. * Keep close-session failure as cleanup reporting without overwriting the primary operation status. * Add VFIO sPAPR-side address normalization before dispatching IOA error injection to the platform EEH backend. * Normalize IOA addresses based on the IOA error type, not only selected function codes. * Keep the generic EEH ABI values unchanged and keep pSeries RTAS and PowerNV OPAL mappings explicit. V2 -> V3: * Fixed ibm,open-errinjct return handling to correctly process firmware responses. * Allocate the error-injection buffer in RTAS-accessible memory instead of general kernel memory. * Pass the physical address of the error-injection buffer to firmware (previously incorrect address type). * Accept session token zero as a valid token (previously rejected erroneously). * Handle RTAS busy and extended-delay return codes for open, inject, and close calls. * Simplified the validation helper -- reduced complexity and removed redundant checks. * Simplified the buffer-preparation helper for cleaner, more maintainable code. * Validate that all required RTAS tokens are present before attempting to open a session. * Added explicit generic EEH-to-OPAL error-type mapping for the PowerNV platform. v1 -> v2: https://lore.kernel.org/all/20260527072433.94510-1-nnmlinux@linux.ibm.com/ * Addressed all review comments from Sourabh Jain * Removed unnecessary empty line in rtas_call() * Enhanced comment to explain PAPR specification requirements * Corrected misleading comment about output handling * Improved else block comment for better code clarity * Fixed kernel test robot warnings * Fixed kernel-doc warning for __maybe_unused parameter * Confirmed sparse warnings are false positives (correct endianness handling) * Added PowerNV platform abstraction layer (new Patch 5) * Maps EEH error types to OPAL-specific types * Simplifies type handling by direct variable update * Improved code comments and documentation throughout * Added Reported-by tags for kernel test robot findings * Split into logical 5-patch series for better review RFC -> v1: https://lore.kernel.org/all/20251205094510.4671-1-nnmlinux@linux.ibm.com/ * Initial 4-patch series * Fixed PAPR ibm,open-errinjct output format (token,status order) * Added pr_fmt handling for EEH subsystem compatibility * Implemented comprehensive validation helpers RFC: https://lore.kernel.org/all/20251107091009.43034-1-nnmlinux@linux.ibm.com/ * Initial RFC implementation Narayana Murty N (4): powerpc/rtas: Handle ibm,open-errinjct return format powerpc/pseries/eeh: Implement RTAS-based EEH error injection vfio/spapr_tce: Normalize EEH IOA error injection addresses powerpc/powernv/eeh: Map generic EEH error types to OPAL arch/powerpc/include/asm/eeh.h | 26 +- arch/powerpc/include/asm/trace.h | 26 +- arch/powerpc/kernel/eeh.c | 10 +- arch/powerpc/kernel/rtas.c | 83 ++++- arch/powerpc/platforms/powernv/eeh-powernv.c | 22 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 334 +++++++++++++++++-- drivers/vfio/vfio_iommu_spapr_tce.c | 131 +++++++- 7 files changed, 573 insertions(+), 59 deletions(-) -- 2.54.0