mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Narayana Murty N <nnmlinux@linux.ibm.com>
To: Mahesh J Salgaonkar <mahesh@linux.ibm.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	"Oliver O'Halloran" <oohall@gmail.com>,
	Timothy Pearson <tpearson@raptorengineering.com>,
	Alex Williamson <alex@shazbot.org>
Cc: sourabhjain@linux.ibm.com, Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Christophe Leroy <chleroy@kernel.org>,
	Ritesh Harjani <ritesh.list@gmail.com>,
	Shrikanth Hegde <sshegde@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, sbhat@linux.ibm.com, harshpb@linux.ibm.com
Subject: Re: [PATCH v6 0/5] powerpc: Add RTAS based error injection support for pSeries
Date: Mon, 23 Nov 2026 15:55:30 +0530	[thread overview]
Message-ID: <871f6da6-6fbe-4971-93e6-d66776e3ad6c@linux.ibm.com> (raw)
In-Reply-To: <20261023073642.59657-1-nnmlinux@linux.ibm.com>

HI All,
     Thank you for the valuable feedback, I addressed the all review
comments in v7 (ressend) posted.

https://lore.kernel.org/all/20261123102237.95860-6-nnmlinux@linux.ibm.com/

Thanks,
Narayana Murty

On 23/10/26 1:06 PM, Narayana Murty N wrote:
> 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 <nnmlinux@linux.ibm.com>
> ---
> 
> Change Log:
> 
> 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 <asm/rtas-work-area.h> 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 (5):
>    powerpc/rtas: Handle ibm,open-errinjct return format
>    powerpc/pseries/eeh: Add RTAS error injection helpers
>    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               |   2 -
>   arch/powerpc/kernel/eeh.c                    |  10 +-
>   arch/powerpc/kernel/rtas.c                   |  78 +++-
>   arch/powerpc/platforms/powernv/eeh-powernv.c |  22 +-
>   arch/powerpc/platforms/pseries/eeh_pseries.c | 375 ++++++++++++++++++-
>   drivers/vfio/vfio_iommu_spapr_tce.c          | 140 +++++++
>   6 files changed, 585 insertions(+), 42 deletions(-)
> 


      parent reply	other threads:[~2026-11-23 10:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  7:36 Narayana Murty N
2026-10-23  7:36 ` [PATCH v6 1/5] powerpc/rtas: Handle ibm,open-errinjct return format Narayana Murty N
2026-11-18 11:13   ` Sourabh Jain
2026-11-20  4:36     ` Narayana Murty N
2026-10-23  7:36 ` [PATCH v6 2/5] powerpc/pseries/eeh: Add RTAS error injection helpers Narayana Murty N
2026-11-18 16:43   ` Sourabh Jain
2026-11-20  7:19     ` Narayana Murty N
2026-10-23  7:36 ` [PATCH v6 3/5] powerpc/pseries/eeh: Implement RTAS-based EEH error injection Narayana Murty N
2026-11-18 19:14   ` Sourabh Jain
2026-11-20  7:32     ` Narayana Murty N
2026-10-23  7:36 ` [PATCH v6 4/5] vfio/spapr_tce: Normalize EEH IOA error injection addresses Narayana Murty N
2026-11-18 19:35   ` Sourabh Jain
2026-11-20  7:36     ` Narayana Murty N
2026-10-23  7:36 ` [PATCH v6 5/5] powerpc/powernv/eeh: Map generic EEH error types to OPAL Narayana Murty N
2026-11-18 19:41   ` Sourabh Jain
2026-11-20  7:39     ` Narayana Murty N
2026-11-23  6:41       ` Narayana Murty N
2026-11-23  6:52       ` Sourabh Jain
2026-11-10 19:21 ` [PATCH v6 0/5] powerpc: Add RTAS based error injection support for pSeries tasmiya
2026-11-20  7:40   ` Narayana Murty N
2026-11-23  8:46 ` [PATCH v7 0/4] " Narayana Murty N
2026-11-23  8:46 ` [PATCH v7 1/4] powerpc/rtas: Handle ibm,open-errinjct return format Narayana Murty N
2026-11-23  8:47 ` [PATCH v7 2/4] powerpc/pseries/eeh: Implement RTAS-based EEH error injection Narayana Murty N
2026-11-23  8:47 ` [PATCH v7 3/4] vfio/spapr_tce: Normalize EEH IOA error injection addresses Narayana Murty N
2026-11-23  8:47 ` [PATCH v7 4/4] powerpc/powernv/eeh: Map generic EEH error types to OPAL Narayana Murty N
2026-11-23 10:25 ` Narayana Murty N [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871f6da6-6fbe-4971-93e6-d66776e3ad6c@linux.ibm.com \
    --to=nnmlinux@linux.ibm.com \
    --cc=alex@shazbot.org \
    --cc=chleroy@kernel.org \
    --cc=harshpb@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mahesh@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=oohall@gmail.com \
    --cc=ritesh.list@gmail.com \
    --cc=sbhat@linux.ibm.com \
    --cc=sourabhjain@linux.ibm.com \
    --cc=sshegde@linux.ibm.com \
    --cc=tpearson@raptorengineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®