powerpc/eeh: Add RTAS-based error injection support on pSeries
Subsystems (2)
PATCH v3 1/5 powerpc/rtas: Handle ibm,open-errinjct return format
In reply to Narayana Murty NPAPR specifies that ibm,open-errinjct has a unique return-cell layout:
rets[0] = injection session token (output parameter) rets[1] = status code
This differs from every other RTAS call, where:
rets[0] = status code
rets[1..] = output parameters
As a result, the existing rtas_call() convention — return value is the RTAS status, outputs[] receives the non-status output values — must be preserved while correctly extracting status from rets[1] for this one call.
Add rtas_token_is_open_errinjct() and rtas_status_from_args() helpers. rtas_status_from_args() selects the correct status cell based on the token, and the output-copy loop in rtas_call() is updated so that for ibm,open-errinjct:
rtas_call() return = rets[1] (RTAS status)
outputs[0] = rets[0] (session token)
For all other calls the behaviour is unchanged: return value is rets[0] and outputs[] receives rets[1..nret-1].
The sys_rtas userspace path is not modified: copy_to_user() still copies raw RTAS return cells (rets[0..nret-1]) to userspace.
Callers passing a single output int (nret == 2) are safe because we write at most nret-1 values into outputs[], never all nret cells.
Also move the '/* A -1 return code...*/' comment to immediately precede the if (ret == -1) check it describes, and remove the redundant stale else branch that re-assigned ret.
Reference: OpenPOWER PAPR documentation
https://files.openpower.foundation/s/XFgfMaqLMD5Bcm8
--- arch/powerpc/kernel/rtas.c | 51 ++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-)
arch/powerpc/kernel/rtas.c +44 -7
@@ -1117,6 +1117,29 @@ static bool token_is_restricted_errinjct(s32 token) token ==rtas_function_token (RTAS_FN_IBM_ERRINJCT ); } +/** +* rtas_token_is_open_errinjct() - Test whether @token identifies ibm,open-errinjct. +*/ +static bool rtas_token_is_open_errinjct (int token) +{ +return token ==rtas_function_token (RTAS_FN_IBM_OPEN_ERRINJCT ); +} + +/** +* rtas_status_from_args() - Extract the RTAS status code from a completed +* call's return-cell array. +* +* For ibm,open-errinjct the status lives in rets[1]; for every other +* RTAS function it lives in rets[0]. +*/ +static int rtas_status_from_args (int token,struct rtas_args *args,int nret) +{ +if (rtas_token_is_open_errinjct (token) && nret >1 ) +return be32_to_cpu (args->rets[1 ]); + +return nret >0 ?be32_to_cpu (args->rets[0 ]) :0 ; +} +/** * rtas_call() - Invoke an RTAS firmware function. * @token: Identifies the function being invoked.
@@ -1213,15 +1236,29 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)va_rtas_call_unlocked (args, token, nargs, nret, list);va_end (list); -/* A -1 return code indicates that the last command couldn't -be completed due to a hardware error. */ -if (be32_to_cpu (args->rets[0 ]) ==-1 ) + ret =rtas_status_from_args (token, args, nret); + +/* +* A -1 return code indicates that the last command couldn't +* be completed due to a hardware error. +*/ +if (ret ==-1 ) buff_copy =__fetch_rtas_last_error (NULL ); -if (nret >1 && outputs !=NULL ) -for (i =0 ; i < nret-1 ; ++i) - outputs[i] =be32_to_cpu (args->rets[i +1 ]); - ret = (nret >0 ) ?be32_to_cpu (args->rets[0 ]) :0 ; +if (nret >1 && outputs !=NULL ) { +if (rtas_token_is_open_errinjct (token)) { +/* +* ibm,open-errinjct: rets[0]=session token, rets[1]=status. +* Expose session token in outputs[0]; skip rets[1] (status). +*/ + outputs[0 ] =be32_to_cpu (args->rets[0 ]); +for (i =1 ; i < nret -1 ; ++i) + outputs[i] =be32_to_cpu (args->rets[i +1 ]); + }else { +for (i =0 ; i < nret -1 ; ++i) + outputs[i] =be32_to_cpu (args->rets[i +1 ]); + } + }lockdep_unpin_lock (&rtas_lock, cookie);raw_spin_unlock_irqrestore (&rtas_lock, flags);
Signature · 1 line
2.54.0
PATCH v3 2/5 powerpc/rtas: Allocate ibm,errinjct buffer below RTAS limit
In reply to Narayana Murty Nibm,errinjct requires a caller-provided work buffer whose physical address is passed to RTAS firmware.
A static C array such as:
char rtas_errinjct_buf[1024] __aligned(SZ_1K);
only guarantees alignment, not physical placement. If the array lands above the RTAS-safe range (RTAS_INSTANTIATE_MAX, 1 GB) or above 4 GB, RTAS receives a truncated or invalid address and the injection call will fail silently or corrupt memory.
Instead, introduce rtas_errinjct_buf as a global unsigned long storing the physical address allocated during rtas_initialize() using memblock_phys_alloc_range() with the same rtas_region upper bound used for rtas_rmo_buf. This matches the existing placement model for RTAS-accessible buffers and guarantees the physical address fits in 32 bits.
Usage:
void *buf = __va(rtas_errinjct_buf); /* kernel VA to fill */
u32 buf_phys = lower_32_bits(rtas_errinjct_buf); /* PA for RTAS */
Always check upper_32_bits(rtas_errinjct_buf) == 0 before passing the lower 32 bits to RTAS.
Add rtas_errinjct_mutex to serialise the complete open-session / inject / close-session firmware call sequence. A mutex is required because the sequence involves multiple rtas_call() invocations with possible busy/extended-delay retries that may sleep.
--- arch/powerpc/include/asm/rtas.h | 26 ++++++++++++++++++++++++++ arch/powerpc/kernel/rtas.c | 17 +++++++++++++++++ 2 files changed, 43 insertions(+)
arch/powerpc/include/asm/rtas.h +26 -0
@@ -4,6 +4,7 @@#ifdef __KERNEL__#include <linux/mutex.h> +#include <linux/sizes.h> #include <linux/spinlock.h> #include <asm/page.h> #include <asm/rtas-types.h>
@@ -519,6 +520,31 @@ int rtas_get_error_log_max(void);extern spinlock_t rtas_data_buf_lock;extern char rtas_data_buf[RTAS_DATA_BUF_SIZE ]; +/* +* RTAS error-injection work buffer. +* +* ibm,errinjct requires a caller-provided work buffer whose physical +* address is passed to firmware. A static C array only guarantees +* alignment, not physical placement; if it lands above the RTAS-safe +* range or above 4 GB, RTAS receives a truncated or bogus address. +* +* rtas_errinjct_buf stores the physical address allocated during +* rtas_initialize() using memblock_phys_alloc_range() with the same +* rtas_region upper bound used for rtas_rmo_buf, matching the existing +* placement model for RTAS-accessible buffers. +* +* Use __va(rtas_errinjct_buf) to obtain the kernel virtual address for +* filling the buffer, and lower_32_bits(rtas_errinjct_buf) to pass the +* physical address to RTAS (after checking upper_32_bits() == 0). +* +* rtas_errinjct_mutex must be held across the complete +* ibm,open-errinjct / ibm,errinjct / ibm,close-errinjct sequence. +*/ +#define RTAS_ERRINJCT_BUF_SIZE SZ_1K + +extern unsigned long rtas_errinjct_buf; +extern struct mutex rtas_errinjct_mutex; +/* RMO buffer reserved for user-space RTAS use */ extern unsigned long rtas_rmo_buf;
arch/powerpc/kernel/rtas.c +17 -0
@@ -769,6 +769,17 @@ EXPORT_SYMBOL_GPL(rtas_data_buf);unsigned long rtas_rmo_buf; +/* +* Physical address of the ibm,errinjct work buffer. Allocated during +* rtas_initialize() using memblock_phys_alloc_range() below rtas_region +* so the address fits in 32 bits and is safe to pass to RTAS firmware. +*/ +unsigned long rtas_errinjct_buf; +EXPORT_SYMBOL_GPL (rtas_errinjct_buf); + +DEFINE_MUTEX (rtas_errinjct_mutex); +EXPORT_SYMBOL_GPL (rtas_errinjct_mutex); +/* * If non-NULL, this gets called when the kernel terminates. * This is done like this so rtas_flash can be a module.
@@ -2109,6 +2120,12 @@ void __init rtas_initialize(void)panic ("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n" ,PAGE_SIZE , &rtas_region); + rtas_errinjct_buf =memblock_phys_alloc_range (RTAS_ERRINJCT_BUF_SIZE , +SZ_1K ,0 , rtas_region); +if (!rtas_errinjct_buf) +panic ("ERROR: RTAS: Failed to allocate %lu bytes below %pa\n" , + (unsigned long )RTAS_ERRINJCT_BUF_SIZE , &rtas_region); +rtas_work_area_reserve_arena (rtas_region); }
Signature · 1 line
2.54.0
v3 cover powerpc/eeh: Add RTAS-based error injection support on pSeries
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, prepares the firmware work buffer, performs the requested injection, 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 now 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 current 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.
The series also handles the unusual return format of ibm,open-errinjct:
rets[0] = error-injection session token
rets[1] = RTAS status
rtas_call() now returns rets[1] as the status and places the session token in outputs[0], preserving the normal kernel rtas_call() convention.
sys_rtas() is intentionally unchanged because it exposes the raw RTAS return cells to userspace. Userspace therefore continues to receive the session token and status in their PAPR-defined positions.
The RTAS work buffer is allocated during RTAS initialization below:
min(ppc64_rma_size, RTAS_INSTANTIATE_MAX)
using the same accessible-memory limit used for rtas_rmo_buf. The kernel populates the buffer through its virtual mapping but passes its physical address 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. A session token value of zero is accepted, and session state is tracked independently from the token value.
The patches are organised as follows:
Handle the special ibm,open-errinjct return format in rtas_call(). Allocate an RTAS-accessible error-injection work buffer. Add pSeries RTAS parameter validation and buffer encoding helpers. Implement RTAS-based pSeries EEH error injection. 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 the corresponding QEMU support:
https://lore.kernel.org/qemu-devel/[email protected]/
Narayana Murty N (5):
powerpc/rtas: Handle ibm,open-errinjct return format powerpc/rtas: Allocate ibm,errinjct buffer below RTAS limit powerpc/pseries/eeh: Add RTAS error validation helpers powerpc/pseries/eeh: Implement RTAS-based EEH error injection powerpc/powernv/eeh: Map VFIO EEH error injection to OPAL
arch/powerpc/include/asm/rtas.h | 26 ++ arch/powerpc/include/uapi/asm/eeh.h | 24 +- arch/powerpc/kernel/rtas.c | 68 +++- arch/powerpc/platforms/powernv/eeh-powernv.c | 36 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 367 +++++++++++++++++-- 5 files changed, 483 insertions(+), 38 deletions(-)
Change Log:
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/[email protected]/
* 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/[email protected]/
* 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/[email protected]/
* Initial RFC implementation
Signature · 1 line
2.54.0
PATCH v3 3/5 powerpc/pseries/eeh: Add RTAS error validation helpers
Add validation helpers and buffer-preparation infrastructure used by the RTAS-based EEH error injection implementation.
Changes relative to the original submission:
- pr_fmt unconditionally defined at the top of the file, not wrapped in an #ifndef guard.
- RTAS error-type constants (RTAS_ERR_TYPE_*) are defined as file-local macros in eeh_pseries.c, not in the UAPI header. They are internal PAPR firmware type codes, not generic EEH ABI values.
- validate_corrupted_page() drops the unused 'pe' parameter entirely (no __maybe_unused). The mask value is silently accepted since it is not meaningful for this error type.
- validate_ioa_bus_error() is removed; callers invoke validate_addr_mask_in_pe() directly.
- validate_err_type() and validate_special_event() and validate_corrupted_page() are marked static inline.
- prepare_errinjct_buffer() takes an explicit 'void *buf' pointer (kernel virtual address) instead of accessing rtas_errinjct_buf directly, making it easier to test and keeping the global out of the helper.
- kernel-doc added for prepare_errinjct_buffer() including a Locking:
line stating the caller must hold rtas_errinjct_mutex.
--- arch/powerpc/include/uapi/asm/eeh.h | 24 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 250 +++++++++++++++++++ 2 files changed, 271 insertions(+), 3 deletions(-)
arch/powerpc/include/uapi/asm/eeh.h +21 -3
@@ -15,9 +15,27 @@#define EEH_PE_STATE_STOPPED_DMA 4/* Stopped DMA only */ #define EEH_PE_STATE_UNAVAIL 5/* Unavailable */ -/* EEH error types and functions */ -#define EEH_ERR_TYPE_32 0/* 32-bits error */ -#define EEH_ERR_TYPE_64 1/* 64-bits error */ +/* +* EEH error types. +* +* EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 are the original ABI values and must +* not be renumbered. The additional types below are generic identifiers for +* error-injection types supported by pSeries RTAS. Platform backends may +* return -EOPNOTSUPP for valid generic types that are not supported by their +* firmware. +*/ +#define EEH_ERR_TYPE_32 0/* 32-bits error */ +#define EEH_ERR_TYPE_64 1/* 64-bits error */ +#define EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT 0x03 +#define EEH_ERR_TYPE_CORRUPTED_PAGE 0x04 +#define EEH_ERR_TYPE_CORRUPTED_DCACHE_START 0x09 +#define EEH_ERR_TYPE_CORRUPTED_DCACHE_END 0x0a +#define EEH_ERR_TYPE_CORRUPTED_ICACHE_START 0x0b +#define EEH_ERR_TYPE_CORRUPTED_ICACHE_END 0x0c +#define EEH_ERR_TYPE_CORRUPTED_TLB_START 0x0d +#define EEH_ERR_TYPE_CORRUPTED_TLB_END 0x0e + +/* EEH error 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
arch/powerpc/platforms/pseries/eeh_pseries.c +250 -0
268 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v3 4/5 powerpc/pseries/eeh: Implement RTAS-based EEH error injection
In reply to Narayana Murty NReplace legacy MMIO error injection with full PAPR-compliant RTAS error injection supporting 14+ error types via
- ibm,open-errinjct
- ibm,errinjct
- ibm,close-errinjct.
Key features:
- Complete open-session-inject-close cycle management
- Special handling for ibm,open-errinjct output format (token,status)
- Comprehensive buffer preparation per PAPR layouts
- All pr_* logging uses pr_fmt("EEH: ") prefix
Tested with corresponding QEMU patches:
https://lore.kernel.org/all/[email protected]/
--- arch/powerpc/platforms/pseries/eeh_pseries.c | 121 +++++++++++++++---- 1 file changed, 95 insertions(+), 26 deletions(-)
arch/powerpc/platforms/pseries/eeh_pseries.c +95 -26
@@ -1037,40 +1037,109 @@ static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, }/** -* pseries_eeh_err_inject - Inject specified error to the indicated PE -* @pe: the indicated PE -* @type: error type -* @func: specific error type -* @addr: address -* @mask: address mask -* The routine is called to inject specified error, which is -* determined by @type and @func, to the indicated PE +* pseries_eeh_err_inject - Inject specified error into the indicated PE +* @pe: the indicated PE +* @type: generic EEH error type (EEH_ERR_TYPE_*) +* @func: error function selector (EEH_ERR_FUNC_*) +* @addr: target address, if applicable +* @mask: address mask, if applicable +* +* Implements the EEH error-injection callback for pseries using the RTAS +* ibm,open-errinjct / ibm,errinjct / ibm,close-errinjct firmware services. +* +* Generic EEH error types are translated to RTAS firmware type codes via +* pseries_eeh_type_to_rtas() before the injection session is opened. +* Unsupported generic types are rejected with -EINVAL before any RTAS call +* is made. Existing userspace is unaffected. +* +* Return: 0 on success, negative errno or RTAS error code on failure. */ static int pseries_eeh_err_inject (struct eeh_pe *pe,int type,int func,unsigned long addr,unsigned long mask) { -struct eeh_dev *pdev; - -/* Check on PCI error type */ -if (type !=EEH_ERR_TYPE_32 && type !=EEH_ERR_TYPE_64 ) -return -EINVAL ; +int open_token, errinjct_token, close_token; +int session_token =0 ; +bool session_open = false; +void *buf; +u32 buf_phys; +int rc; +int rtas_type; -switch (func) { -case EEH_ERR_FUNC_LD_MEM_ADDR : -case EEH_ERR_FUNC_LD_MEM_DATA : -case EEH_ERR_FUNC_ST_MEM_ADDR : -case EEH_ERR_FUNC_ST_MEM_DATA : -/* injects a MMIO error for all pdev's belonging to PE */ -pci_lock_rescan_remove (); -list_for_each_entry (pdev, &pe->edevs, entry) -eeh_pe_inject_mmio_error (pdev->pdev); -pci_unlock_rescan_remove (); -break ; -default : +/* Guard: buffer must fit in 32 bits for RTAS */ +if (WARN_ON_ONCE (upper_32_bits (rtas_errinjct_buf)))return -ERANGE ; + +/* Map generic EEH ABI to RTAS-internal error type */ + rtas_type =pseries_eeh_type_to_rtas (type); +if (rtas_type <0 ) { +pr_err ("unsupported EEH error type %#x\n" , type); +return rtas_type; } -return 0 ; +/* Verify all three RTAS tokens are available before touching firmware */ + open_token =rtas_function_token (RTAS_FN_IBM_OPEN_ERRINJCT ); + errinjct_token =rtas_function_token (RTAS_FN_IBM_ERRINJCT ); + close_token =rtas_function_token (RTAS_FN_IBM_CLOSE_ERRINJCT ); + +if (open_token ==RTAS_UNKNOWN_SERVICE || + errinjct_token ==RTAS_UNKNOWN_SERVICE || + close_token ==RTAS_UNKNOWN_SERVICE ) { +pr_err ("ibm,open/errinjct/close-errinjct not available\n" ); +return -ENODEV ; + } + + buf =__va (rtas_errinjct_buf); + buf_phys =lower_32_bits (rtas_errinjct_buf); + +mutex_lock (&rtas_errinjct_mutex); + +/* Step 1: open injection session */ +do { + rc =rtas_call (open_token,0 ,2 , &session_token); + }while (rtas_busy_delay (rc)); + +if (rc) { +pr_err ("ibm,open-errinjct failed: status=%d\n" , rc); + goto out_unlock; + } + session_open = true; + +/* Step 2: prepare the work buffer */ + rc =prepare_errinjct_buffer (buf, pe, rtas_type, func, addr, mask); +if (rc) { +pr_err ("failed to prepare errinjct buffer: rc=%d\n" , rc); + goto out_close; + } + +/* Step 3: inject the error */ +do { + rc =rtas_call (errinjct_token,3 ,1 ,NULL , + rtas_type, session_token, buf_phys); + }while (rtas_busy_delay (rc)); + +if (rc) +pr_err ("ibm,errinjct failed: status=%d\n" , rc); + +out_close: +/* Step 4: always close the session */ + { +int close_rc; + +if (session_open) { +do { + close_rc =rtas_call (close_token,1 ,1 ,NULL , + session_token); + }while (rtas_busy_delay (close_rc)); + +if (close_rc) +pr_warn ("ibm,close-errinjct failed: status=%d\n" , + close_rc); + } + } + +out_unlock: +mutex_unlock (&rtas_errinjct_mutex); +return rc; }static struct eeh_ops pseries_eeh_ops = {
Signature · 1 line
2.54.0
PATCH v3 5/5 powerpc/powernv/eeh: Map VFIO EEH error injection to OPAL
In reply to Narayana Murty NThe EEH error-injection interface passes the generic userspace ABI values EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 to the platform backend.
The PowerNV backend currently compares those generic values directly with OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR and OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64. Although the corresponding values are currently numerically identical, this implicitly couples the generic EEH ABI to the OPAL firmware encoding.
Explicitly translate the generic EEH error types to their OPAL equivalents in pnv_eeh_err_inject(). Keep the platform-specific encoding within the PowerNV backend and reject unsupported generic types with -EINVAL.
No userspace ABI values are changed.
--- arch/powerpc/platforms/powernv/eeh-powernv.c | 36 +++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powernv/eeh-powernv.c +32 -4
@@ -1169,11 +1169,39 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,struct pnv_phb *phb = hose->private_data;s64 rc; -if (type !=OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR && - type !=OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64 ) { -pr_warn ("%s: Invalid error type %d\n" , +/* +* Map generic EEH error-type ABI values to OPAL-specific type codes. +* EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 are the only types supported by +* OPAL. Additional generic types defined in the UAPI header are valid +* for pSeries RTAS but unsupported here; return -EOPNOTSUPP for those. +* Unknown or invalid values return -EINVAL. +* +* Note: currently OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR == 0 == +* EEH_ERR_TYPE_32 and OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64 == 1 == +* EEH_ERR_TYPE_64, but the explicit switch makes the coupling +* visible and allows the values to diverge independently. +*/ +switch (type) { +case EEH_ERR_TYPE_32 : + type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR ; +break ; +case EEH_ERR_TYPE_64 : + type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64 ; +break ; +case EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT : +case EEH_ERR_TYPE_CORRUPTED_PAGE : +case EEH_ERR_TYPE_CORRUPTED_DCACHE_START : +case EEH_ERR_TYPE_CORRUPTED_DCACHE_END : +case EEH_ERR_TYPE_CORRUPTED_ICACHE_START : +case EEH_ERR_TYPE_CORRUPTED_ICACHE_END : +case EEH_ERR_TYPE_CORRUPTED_TLB_START : +case EEH_ERR_TYPE_CORRUPTED_TLB_END : +pr_warn ("%s: EEH error type %d not supported by OPAL\n" , __func__, type); -return -ERANGE ; +return -EOPNOTSUPP ; +default : +pr_warn ("%s: unsupported EEH error type %d\n" , __func__, type); +return -EINVAL ; } if (func < OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR ||
Signature · 1 line
2.54.0
Re: [PATCH v3 1/5] powerpc/rtas: Handle ibm,open-errinjct return format
In reply to Narayana Murty NQuoted 49 lines · Narayana Murty N
PAPR specifies that ibm,open-errinjct has a unique return-cell layout:
rets[0] = injection session token (output parameter) rets[1] = status code
This differs from every other RTAS call, where:
rets[0] = status code
rets[1..] = output parametersAs a result, the existing
rtas_call()convention — return value is the RTAS status, outputs[] receives the non-status output values — must be preserved while correctly extracting status from rets[1] for this one call.Add
rtas_token_is_open_errinjct()andrtas_status_from_args()helpers.rtas_status_from_args()selects the correct status cell based on the token, and the output-copy loop inrtas_call()is updated so that for ibm,open-errinjct:
rtas_call()return = rets[1] (RTAS status)
outputs[0] = rets[0] (session token)For all other calls the behaviour is unchanged: return value is rets[0] and outputs[] receives rets[1..nret-1].
The
sys_rtasuserspace path is not modified:copy_to_user()still copies raw RTAS return cells (rets[0..nret-1]) to userspace.Callers passing a single output int (nret == 2) are safe because we write at most nret-1 values into outputs[], never all nret cells.
Also move the '/* A -1 return code...*/' comment to immediately precede the if (ret == -1) check it describes, and remove the redundant stale else branch that re-assigned ret.
Reference: OpenPOWER PAPR documentation
https://files.openpower.foundation/s/XFgfMaqLMD5Bcm8Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/kernel/rtas.c | 51 ++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-)arch/powerpc/kernel/rtas.c +0
-0
arch/powerpc/kernel/rtas.c static bool token_is_restricted_errinjct(s32 token) · line 1126
Quoted 10 lines
arch/powerpc/kernel/rtas.c +7
-0@@ -1117,6 +1117,29 @@ static bool token_is_restricted_errinjct(s32 token) token ==rtas_function_token (RTAS_FN_IBM_ERRINJCT ); } +/** +* rtas_token_is_open_errinjct() - Test whether @token identifies ibm,open-errinjct. +*/ +static bool rtas_token_is_open_errinjct (int token) +{ +return token ==rtas_function_token (RTAS_FN_IBM_OPEN_ERRINJCT ); +}
The above function is a god candidate for an inline function.
arch/powerpc/kernel/rtas.c static bool token_is_restricted_errinjct(s32 token) · line 1137
Quoted 11 lines
arch/powerpc/kernel/rtas.c +11
-0+ +/** +* rtas_status_from_args() - Extract the RTAS status code from a completed +* call's return-cell array. +* +* For ibm,open-errinjct the status lives in rets[1]; for every other +* RTAS function it lives in rets[0]. +*/ +static int rtas_status_from_args (int token,struct rtas_args *args,int nret) +{ +if (rtas_token_is_open_errinjct (token) && nret >1 )
Do we know what RTAS returns when nret is less than 2 for the ibm,open-errinjct RTAS call?
I assume RTAS treats this as a parameter error. However, since there is no rets buffer available to store the status code, I'm not sure how RTAS would convey the parameter error back to the kernel.
The way the RTAS status code is extracted when nret is less than 2 for the ibm,open-errinjct RTAS call seems problematic me, especially when nret == 1. When nret == 1, this function returns args->rets[0], which is supposed to contain the session token.
Are we sure that RTAS places the call status in rets[0] when nret == 1 for the ibm,open-errinjct RTAS call?
- Sourabh Jain
Quoted 45 lines
arch/powerpc/kernel/rtas.c +26
-7+return be32_to_cpu (args->rets[1 ]); + +return nret >0 ?be32_to_cpu (args->rets[0 ]) :0 ; +} +/** * rtas_call() - Invoke an RTAS firmware function. * @token: Identifies the function being invoked. @@ -1213,15 +1236,29 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)va_rtas_call_unlocked (args, token, nargs, nret, list);va_end (list); -/* A -1 return code indicates that the last command couldn't -be completed due to a hardware error. */ -if (be32_to_cpu (args->rets[0 ]) ==-1 ) + ret =rtas_status_from_args (token, args, nret); + +/* +* A -1 return code indicates that the last command couldn't +* be completed due to a hardware error. +*/ +if (ret ==-1 ) buff_copy =__fetch_rtas_last_error (NULL ); -if (nret >1 && outputs !=NULL ) -for (i =0 ; i < nret-1 ; ++i) - outputs[i] =be32_to_cpu (args->rets[i +1 ]); - ret = (nret >0 ) ?be32_to_cpu (args->rets[0 ]) :0 ; +if (nret >1 && outputs !=NULL ) { +if (rtas_token_is_open_errinjct (token)) { +/* +* ibm,open-errinjct: rets[0]=session token, rets[1]=status. +* Expose session token in outputs[0]; skip rets[1] (status). +*/ + outputs[0 ] =be32_to_cpu (args->rets[0 ]); +for (i =1 ; i < nret -1 ; ++i) + outputs[i] =be32_to_cpu (args->rets[i +1 ]); + }else { +for (i =0 ; i < nret -1 ; ++i) + outputs[i] =be32_to_cpu (args->rets[i +1 ]); + } + }lockdep_unpin_lock (&rtas_lock, cookie);raw_spin_unlock_irqrestore (&rtas_lock, flags);
Re: [PATCH v3 2/5] powerpc/rtas: Allocate ibm,errinjct buffer below RTAS limit
In reply to Narayana Murty NHello Narayana,
How about using the rtas_work_area_alloc() instead of allocating a new dedicated buffer for errinjct only?
Checkout Commit 43033bc62d34 ("powerpc/pseries: add RTAS work area allocator") for infrastructure to allocated working buffer.
Also checkout commit e27e14231eb5 ("powerpc/pseries/dlpar: use RTAS work area API") on how to use work area API.
- Sourabh Jain
Quoted 116 lines · Narayana Murty N
ibm,errinjct requires a caller-provided work buffer whose physical address is passed to RTAS firmware.
A static C array such as:
char rtas_errinjct_buf[1024] __aligned(SZ_1K);only guarantees alignment, not physical placement. If the array lands above the RTAS-safe range (
RTAS_INSTANTIATE_MAX, 1 GB) or above 4 GB, RTAS receives a truncated or invalid address and the injection call will fail silently or corrupt memory.Instead, introduce
rtas_errinjct_bufas a global unsigned long storing the physical address allocated duringrtas_initialize()usingmemblock_phys_alloc_range()with the samertas_regionupper bound used forrtas_rmo_buf. This matches the existing placement model for RTAS-accessible buffers and guarantees the physical address fits in 32 bits.Usage:
void *buf =__va(rtas_errinjct_buf); /* kernel VA to fill */
u32buf_phys=lower_32_bits(rtas_errinjct_buf); /* PA for RTAS */Always check
upper_32_bits(rtas_errinjct_buf)== 0 before passing the lower 32 bits to RTAS.Add
rtas_errinjct_mutexto serialise the complete open-session / inject / close-session firmware call sequence. A mutex is required because the sequence involves multiplertas_call()invocations with possible busy/extended-delay retries that may sleep.Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/include/asm/rtas.h | 26 ++++++++++++++++++++++++++ arch/powerpc/kernel/rtas.c | 17 +++++++++++++++++ 2 files changed, 43 insertions(+)arch/powerpc/include/asm/rtas.h +26
-0@@ -4,6 +4,7 @@#ifdef __KERNEL__#include <linux/mutex.h> +#include <linux/sizes.h> #include <linux/spinlock.h> #include <asm/page.h> #include <asm/rtas-types.h> @@ -519,6 +520,31 @@ int rtas_get_error_log_max(void);extern spinlock_t rtas_data_buf_lock;extern char rtas_data_buf[RTAS_DATA_BUF_SIZE ]; +/* +* RTAS error-injection work buffer. +* +* ibm,errinjct requires a caller-provided work buffer whose physical +* address is passed to firmware. A static C array only guarantees +* alignment, not physical placement; if it lands above the RTAS-safe +* range or above 4 GB, RTAS receives a truncated or bogus address. +* +* rtas_errinjct_buf stores the physical address allocated during +* rtas_initialize() using memblock_phys_alloc_range() with the same +* rtas_region upper bound used for rtas_rmo_buf, matching the existing +* placement model for RTAS-accessible buffers. +* +* Use __va(rtas_errinjct_buf) to obtain the kernel virtual address for +* filling the buffer, and lower_32_bits(rtas_errinjct_buf) to pass the +* physical address to RTAS (after checking upper_32_bits() == 0). +* +* rtas_errinjct_mutex must be held across the complete +* ibm,open-errinjct / ibm,errinjct / ibm,close-errinjct sequence. +*/ +#define RTAS_ERRINJCT_BUF_SIZE SZ_1K + +extern unsigned long rtas_errinjct_buf; +extern struct mutex rtas_errinjct_mutex; +/* RMO buffer reserved for user-space RTAS use */ extern unsigned long rtas_rmo_buf;arch/powerpc/kernel/rtas.c +17
-0@@ -769,6 +769,17 @@ EXPORT_SYMBOL_GPL(rtas_data_buf);unsigned long rtas_rmo_buf; +/* +* Physical address of the ibm,errinjct work buffer. Allocated during +* rtas_initialize() using memblock_phys_alloc_range() below rtas_region +* so the address fits in 32 bits and is safe to pass to RTAS firmware. +*/ +unsigned long rtas_errinjct_buf; +EXPORT_SYMBOL_GPL (rtas_errinjct_buf); + +DEFINE_MUTEX (rtas_errinjct_mutex); +EXPORT_SYMBOL_GPL (rtas_errinjct_mutex); +/* * If non-NULL, this gets called when the kernel terminates. * This is done like this so rtas_flash can be a module. @@ -2109,6 +2120,12 @@ void __init rtas_initialize(void)panic ("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n" ,PAGE_SIZE , &rtas_region); + rtas_errinjct_buf =memblock_phys_alloc_range (RTAS_ERRINJCT_BUF_SIZE , +SZ_1K ,0 , rtas_region); +if (!rtas_errinjct_buf) +panic ("ERROR: RTAS: Failed to allocate %lu bytes below %pa\n" , + (unsigned long )RTAS_ERRINJCT_BUF_SIZE , &rtas_region); +rtas_work_area_reserve_arena (rtas_region); }
Re: [PATCH v3 3/5] powerpc/pseries/eeh: Add RTAS error validation helpers
In reply to Narayana Murty NQuoted 1 line · Narayana Murty N
Add validation helpers
Can you provide more details about what these validation helpers are for?
Quoted 2 lines
and buffer-preparation infrastructure used by the RTAS-based EEH error injection implementation.
Can you explain what this buffer is and what it is used for?
Quoted 12 lines
Changes relative to the original submission:
-pr_fmtunconditionally defined at the top of the file, not wrapped in an #ifndef guard.
- RTAS error-type constants (RTAS_ERR_TYPE_*) are defined as file-local macros ineeh_pseries.c, not in the UAPI header. They are internal PAPR firmware type codes, not generic EEH ABI values.
-validate_corrupted_page()drops the unused 'pe' parameter entirely (no__maybe_unused). The mask value is silently accepted since it is not meaningful for this error type.
-validate_ioa_bus_error()is removed; callers invokevalidate_addr_mask_in_pe()directly.
Quoted 8 lines
-
validate_err_type()andvalidate_special_event()andvalidate_corrupted_page()are marked static inline.
-prepare_errinjct_buffer()takes an explicit 'void *buf' pointer (kernel virtual address) instead of accessingrtas_errinjct_bufdirectly, making it easier to test and keeping the global out of the helper.
- kernel-doc added forprepare_errinjct_buffer()including a Locking:
line stating the caller must holdrtas_errinjct_mutex.
Changelog shouldn't be part of commit message.
Quoted 87 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/include/uapi/asm/eeh.h | 24 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 250 +++++++++++++++++++ 2 files changed, 271 insertions(+), 3 deletions(-)arch/powerpc/include/uapi/asm/eeh.h +21
-3@@ -15,9 +15,27 @@#define EEH_PE_STATE_STOPPED_DMA 4/* Stopped DMA only */ #define EEH_PE_STATE_UNAVAIL 5/* Unavailable */ -/* EEH error types and functions */ -#define EEH_ERR_TYPE_32 0/* 32-bits error */ -#define EEH_ERR_TYPE_64 1/* 64-bits error */ +/* +* EEH error types. +* +* EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 are the original ABI values and must +* not be renumbered. The additional types below are generic identifiers for +* error-injection types supported by pSeries RTAS. Platform backends may +* return -EOPNOTSUPP for valid generic types that are not supported by their +* firmware. +*/ +#define EEH_ERR_TYPE_32 0/* 32-bits error */ +#define EEH_ERR_TYPE_64 1/* 64-bits error */ +#define EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT 0x03 +#define EEH_ERR_TYPE_CORRUPTED_PAGE 0x04 +#define EEH_ERR_TYPE_CORRUPTED_DCACHE_START 0x09 +#define EEH_ERR_TYPE_CORRUPTED_DCACHE_END 0x0a +#define EEH_ERR_TYPE_CORRUPTED_ICACHE_START 0x0b +#define EEH_ERR_TYPE_CORRUPTED_ICACHE_END 0x0c +#define EEH_ERR_TYPE_CORRUPTED_TLB_START 0x0d +#define EEH_ERR_TYPE_CORRUPTED_TLB_END 0x0e + +/* EEH error functions */ #define EEH_ERR_FUNC_MIN 0#define EEH_ERR_FUNC_LD_MEM_ADDR 0/* Memory load */ #define EEH_ERR_FUNC_LD_MEM_DATA 1arch/powerpc/platforms/pseries/eeh_pseries.c +21
-0@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0-or-later +#define pr_fmt (fmt) "EEH: " fmt/* * The file intends to implement the platform dependent EEH operations on pseries. * Actually, the pseries platform is built based on RTAS heavily. That means the @@ -31,8 +32,27 @@#include <asm/io.h> #include <asm/machdep.h> #include <asm/ppc-pci.h> +#include <linux/mutex.h> #include <asm/rtas.h> +/* +* PAPR RTAS firmware error-injection type codes. +* +* These are internal firmware encodings used by ibm,errinjct. They are +* NOT generic EEH ABI values. Only the types actually handled by +* prepare_errinjct_buffer() are defined here. +*/ +#define RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT 0x03 +#define RTAS_ERR_TYPE_CORRUPTED_PAGE 0x04 +#define RTAS_ERR_TYPE_IOA_BUS_ERROR 0x07 +#define RTAS_ERR_TYPE_CORRUPTED_DCACHE_START 0x09 +#define RTAS_ERR_TYPE_CORRUPTED_DCACHE_END 0x0a +#define RTAS_ERR_TYPE_CORRUPTED_ICACHE_START 0x0b +#define RTAS_ERR_TYPE_CORRUPTED_ICACHE_END 0x0c +#define RTAS_ERR_TYPE_CORRUPTED_TLB_START 0x0d +#define RTAS_ERR_TYPE_CORRUPTED_TLB_END 0x0e +#define RTAS_ERR_TYPE_IOA_BUS_ERROR_64 0x0f +/* RTAS tokens */ static int ibm_set_eeh_option;static int ibm_set_slot_reset;@@ -786,6 +806,236 @@ static int pseries_notify_resume(struct eeh_dev *edev) }#endif +/**
arch/powerpc/platforms/pseries/eeh_pseries.c static int pseries_notify_resume(struct eeh_dev *edev) · line 819
Quoted 10 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +10
-0+* validate_addr_mask_in_pe() - Validate that addr+mask fall within PE BARs +* @pe: EEH PE containing one or more PCI devices +* @addr: Address to validate +* @mask: Address mask to validate +* +* Checks that @addr is mapped into a BAR/MMIO region of any device +* belonging to the PE. If @mask is non-zero, ensures it is consistent +* with @addr. +* +* Return: 0 if valid, RTAS_INVALID_PARAMETER on failure.
Using RTAS error codes for kernel function may not be good idea. How about using -EINVAL?
Quoted 18 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +18
-0+*/ +static int validate_addr_mask_in_pe (struct eeh_pe *pe,unsigned long addr, +unsigned long mask) +{ +struct eeh_dev *edev, *tmp; +struct pci_dev *pdev; +int bar; +resource_size_t bar_start, bar_len; +bool valid = false; + +/* nothing to validate */ +if (addr ==0 && mask ==0 ) +return 0 ; + +eeh_pe_for_each_dev (pe, edev, tmp) { + pdev =eeh_dev_to_pci_dev (edev); +if (!pdev) +continue ;
arch/powerpc/platforms/pseries/eeh_pseries.c static int pseries_notify_resume(struct eeh_dev *edev) · line 847
Quoted 10 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +10
-0+ +for (bar =0 ; bar <PCI_NUM_RESOURCES ; bar++) { + bar_start =pci_resource_start (pdev, bar); + bar_len =pci_resource_len (pdev, bar); + +if (!bar_len) +continue ; + +if (addr >= bar_start && addr < (bar_start + bar_len)) { +if ((addr & mask) != addr) {
The check has nothing to do with device or the BAR. Then why this check is inside the loop?
For my understanding can you please explain what this check is all about?
arch/powerpc/platforms/pseries/eeh_pseries.c static int pseries_notify_resume(struct eeh_dev *edev) · line 856
Quoted 9 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +9
-0+pr_err ("Mask 0x%lx invalid for addr 0x%lx in BAR[%d] range 0x%llx-0x%llx\n" , + mask, addr, bar, + (unsigned long long )bar_start, + (unsigned long long )(bar_start + bar_len)); +return RTAS_INVALID_PARAMETER ; + } +pr_debug ("addr=0x%lx mask=0x%lx validated in BAR[%d] of %s\n" , + addr, mask, bar,pci_name (pdev)); + valid = true;
Once valid is set, the loop keeps scanning all remaining BARs/devices instead of breaking. Is it intentional?
arch/powerpc/platforms/pseries/eeh_pseries.c static int pseries_notify_resume(struct eeh_dev *edev) · line 864
Quoted 8 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +8
-0+ } + } + } + +if (!valid) { +pr_err ("addr=0x%lx not within any BAR of any device in PE\n" , + addr); +return RTAS_INVALID_PARAMETER ;
-EINVAL would be a better options for these helpers.
Quoted 177 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +174
-0+ } + +return 0 ; +} + +/** +* validate_special_event() - Validate parameters for special-event injection +* @addr: Address parameter (must be zero for this type) +* @mask: Mask parameter (must be zero for this type) +* +* Return: 0 if valid, RTAS_INVALID_PARAMETER otherwise. +*/ +static inline int validate_special_event (unsigned long addr,unsigned long mask) +{ +if (addr || mask) { +pr_err ("special-event injection must not specify addr/mask\n" ); +return RTAS_INVALID_PARAMETER ; + } +return 0 ; +} + +/** +* validate_corrupted_page() - Validate parameters for corrupted-page injection +* @addr: Physical page address (required, must be non-zero) +* +* The mask value is not meaningful for this error type and is ignored. +* +* Return: 0 if valid, RTAS_INVALID_PARAMETER otherwise. +*/ +static inline int validate_corrupted_page (unsigned long addr) +{ +if (!addr) { +pr_err ("corrupted-page injection requires non-zero addr\n" ); +return RTAS_INVALID_PARAMETER ; + } +return 0 ; +} + +/** +* pseries_eeh_type_to_rtas() - Map a generic EEH error type to its RTAS encoding. +* @type: Generic EEH error type (EEH_ERR_TYPE_*) +* +* Translates a userspace-visible generic EEH error type to the corresponding +* PAPR RTAS firmware type code. Every supported value appears as an explicit +* case; coincidental equality between generic EEH and RTAS values is not relied +* upon. +* +* Return: RTAS_ERR_TYPE_* value on success, -EINVAL for unsupported types. +*/ +static int pseries_eeh_type_to_rtas (int type) +{ +switch (type) { +case EEH_ERR_TYPE_32 : +return RTAS_ERR_TYPE_IOA_BUS_ERROR ; +case EEH_ERR_TYPE_64 : +return RTAS_ERR_TYPE_IOA_BUS_ERROR_64 ; +case EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT : +return RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT ; +case EEH_ERR_TYPE_CORRUPTED_PAGE : +return RTAS_ERR_TYPE_CORRUPTED_PAGE ; +case EEH_ERR_TYPE_CORRUPTED_DCACHE_START : +return RTAS_ERR_TYPE_CORRUPTED_DCACHE_START ; +case EEH_ERR_TYPE_CORRUPTED_DCACHE_END : +return RTAS_ERR_TYPE_CORRUPTED_DCACHE_END ; +case EEH_ERR_TYPE_CORRUPTED_ICACHE_START : +return RTAS_ERR_TYPE_CORRUPTED_ICACHE_START ; +case EEH_ERR_TYPE_CORRUPTED_ICACHE_END : +return RTAS_ERR_TYPE_CORRUPTED_ICACHE_END ; +case EEH_ERR_TYPE_CORRUPTED_TLB_START : +return RTAS_ERR_TYPE_CORRUPTED_TLB_START ; +case EEH_ERR_TYPE_CORRUPTED_TLB_END : +return RTAS_ERR_TYPE_CORRUPTED_TLB_END ; +default : +return -EINVAL ; + } +} + +/** +* prepare_errinjct_buffer() - Build ibm,errinjct work buffer +* @buf: RTAS error-injection work buffer (kernel virtual address) +* @pe: EEH PE associated with the injection target +* @rtas_type: PAPR firmware error-injection type after generic EEH-to-RTAS +* translation (RTAS_ERR_TYPE_*) +* @func: Error function selector +* @addr: Target address, if applicable +* @mask: Address mask, if applicable +* +* Zeroes @buf and populates it according to the PAPR layout for @rtas_type. +* Performs inline parameter validation for each error type. +* +* Locking: Caller must hold rtas_errinjct_mutex. +* +* Return: 0 on success, RTAS_INVALID_PARAMETER on invalid input. +*/ +static int prepare_errinjct_buffer (void *buf,struct eeh_pe *pe, +int rtas_type,int func, +unsigned long addr,unsigned long mask) +{ +__be64 *buf64 = (__be64 *)buf; +__be32 *buf32 = (__be32 *)buf; + +memset (buf,0 ,RTAS_ERRINJCT_BUF_SIZE ); + +switch (rtas_type) { +case RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT : +/* func: 1 = non-persistent, 2 = persistent */ +if (func <1 || func >2 ) +return RTAS_INVALID_PARAMETER ; +if (validate_special_event (addr, mask)) +return RTAS_INVALID_PARAMETER ; + buf32[0 ] =cpu_to_be32 (func); +break ; + +case RTAS_ERR_TYPE_CORRUPTED_PAGE : +if (validate_corrupted_page (addr)) +return RTAS_INVALID_PARAMETER ; + buf32[0 ] =cpu_to_be32 (upper_32_bits (addr)); + buf32[1 ] =cpu_to_be32 (lower_32_bits (addr)); +break ; + +case RTAS_ERR_TYPE_IOA_BUS_ERROR : +if (func <EEH_ERR_FUNC_LD_MEM_ADDR || func >EEH_ERR_FUNC_MAX ) +return RTAS_INVALID_PARAMETER ; +if (upper_32_bits (addr) ||upper_32_bits (mask)) { +pr_err ("32-bit IOA injection cannot encode addr=%#lx mask=%#lx\n" , + addr, mask); +return RTAS_INVALID_PARAMETER ; + } +if (validate_addr_mask_in_pe (pe, addr, mask)) +return RTAS_INVALID_PARAMETER ; + buf32[0 ] =cpu_to_be32 ((u32 )addr); + buf32[1 ] =cpu_to_be32 ((u32 )mask); + buf32[2 ] =cpu_to_be32 (pe->addr); + buf32[3 ] =cpu_to_be32 (BUID_HI (pe->phb->buid)); + buf32[4 ] =cpu_to_be32 (BUID_LO (pe->phb->buid)); + buf32[5 ] =cpu_to_be32 (func); +break ; + +case RTAS_ERR_TYPE_IOA_BUS_ERROR_64 : +if (func <EEH_ERR_FUNC_MIN || func >EEH_ERR_FUNC_MAX ) +return RTAS_INVALID_PARAMETER ; +if (validate_addr_mask_in_pe (pe, addr, mask)) +return RTAS_INVALID_PARAMETER ; + buf64[0 ] =cpu_to_be64 (addr); + buf64[1 ] =cpu_to_be64 (mask); + buf32[4 ] =cpu_to_be32 (pe->addr); + buf32[5 ] =cpu_to_be32 (BUID_HI (pe->phb->buid)); + buf32[6 ] =cpu_to_be32 (BUID_LO (pe->phb->buid)); + buf32[7 ] =cpu_to_be32 (func); +break ; + +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 : + buf32[0 ] =cpu_to_be32 (lower_32_bits (addr)); + buf32[1 ] =cpu_to_be32 (lower_32_bits (mask)); +break ; + +case RTAS_ERR_TYPE_CORRUPTED_TLB_START : +case RTAS_ERR_TYPE_CORRUPTED_TLB_END : + buf32[0 ] =cpu_to_be32 (lower_32_bits (addr)); +break ; + +default : +pr_err ("unsupported RTAS error injection type 0x%x\n" , rtas_type); +return RTAS_INVALID_PARAMETER ; + } + +pr_debug ("errinjct buffer ready: rtas_type=0x%x func=%d addr=0x%lx mask=0x%lx\n" , + rtas_type, func, addr, mask); +return 0 ; +} +/** * pseries_eeh_err_inject - Inject specified error to the indicated PE * @pe: the indicated PE
Re: [PATCH v3 4/5] powerpc/pseries/eeh: Implement RTAS-based EEH error injection
In reply to Narayana Murty NQuoted 80 lines · Narayana Murty N
Replace legacy MMIO error injection with full PAPR-compliant RTAS error injection supporting 14+ error types via
- ibm,open-errinjct
- ibm,errinjct
- ibm,close-errinjct.Key features:
- Complete open-session-inject-close cycle management
- Special handling for ibm,open-errinjct output format (token,status)
- Comprehensive buffer preparation per PAPR layouts
- All pr_* logging usespr_fmt("EEH: ")prefixTested with corresponding QEMU patches:
https://lore.kernel.org/all/[email protected]/Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/platforms/pseries/eeh_pseries.c | 121 +++++++++++++++---- 1 file changed, 95 insertions(+), 26 deletions(-)arch/powerpc/platforms/pseries/eeh_pseries.c +23
-24@@ -1037,40 +1037,109 @@ static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, }/** -* pseries_eeh_err_inject - Inject specified error to the indicated PE -* @pe: the indicated PE -* @type: error type -* @func: specific error type -* @addr: address -* @mask: address mask -* The routine is called to inject specified error, which is -* determined by @type and @func, to the indicated PE +* pseries_eeh_err_inject - Inject specified error into the indicated PE +* @pe: the indicated PE +* @type: generic EEH error type (EEH_ERR_TYPE_*) +* @func: error function selector (EEH_ERR_FUNC_*) +* @addr: target address, if applicable +* @mask: address mask, if applicable +* +* Implements the EEH error-injection callback for pseries using the RTAS +* ibm,open-errinjct / ibm,errinjct / ibm,close-errinjct firmware services. +* +* Generic EEH error types are translated to RTAS firmware type codes via +* pseries_eeh_type_to_rtas() before the injection session is opened. +* Unsupported generic types are rejected with -EINVAL before any RTAS call +* is made. Existing userspace is unaffected. +* +* Return: 0 on success, negative errno or RTAS error code on failure. */ static int pseries_eeh_err_inject (struct eeh_pe *pe,int type,int func,unsigned long addr,unsigned long mask) { -struct eeh_dev *pdev; - -/* Check on PCI error type */ -if (type !=EEH_ERR_TYPE_32 && type !=EEH_ERR_TYPE_64 ) -return -EINVAL ; +int open_token, errinjct_token, close_token; +int session_token =0 ; +bool session_open = false; +void *buf; +u32 buf_phys; +int rc; +int rtas_type; -switch (func) { -case EEH_ERR_FUNC_LD_MEM_ADDR : -case EEH_ERR_FUNC_LD_MEM_DATA : -case EEH_ERR_FUNC_ST_MEM_ADDR : -case EEH_ERR_FUNC_ST_MEM_DATA : -/* injects a MMIO error for all pdev's belonging to PE */ -pci_lock_rescan_remove (); -list_for_each_entry (pdev, &pe->edevs, entry) -eeh_pe_inject_mmio_error (pdev->pdev); -pci_unlock_rescan_remove (); -break ;
arch/powerpc/platforms/pseries/eeh_pseries.c static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, · line 1076
Quoted 10 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +8
-1-default : +/* Guard: buffer must fit in 32 bits for RTAS */ +if (WARN_ON_ONCE (upper_32_bits (rtas_errinjct_buf)))return -ERANGE ; + +/* Map generic EEH ABI to RTAS-internal error type */ + rtas_type =pseries_eeh_type_to_rtas (type); +if (rtas_type <0 ) { +pr_err ("unsupported EEH error type %#x\n" , type); +return rtas_type;
How about -EINVAL instead?
Quoted 41 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +38
-1} -return 0 ; +/* Verify all three RTAS tokens are available before touching firmware */ + open_token =rtas_function_token (RTAS_FN_IBM_OPEN_ERRINJCT ); + errinjct_token =rtas_function_token (RTAS_FN_IBM_ERRINJCT ); + close_token =rtas_function_token (RTAS_FN_IBM_CLOSE_ERRINJCT ); + +if (open_token ==RTAS_UNKNOWN_SERVICE || + errinjct_token ==RTAS_UNKNOWN_SERVICE || + close_token ==RTAS_UNKNOWN_SERVICE ) { +pr_err ("ibm,open/errinjct/close-errinjct not available\n" ); +return -ENODEV ; + } + + buf =__va (rtas_errinjct_buf); + buf_phys =lower_32_bits (rtas_errinjct_buf); + +mutex_lock (&rtas_errinjct_mutex); + +/* Step 1: open injection session */ +do { + rc =rtas_call (open_token,0 ,2 , &session_token); + }while (rtas_busy_delay (rc)); + +if (rc) { +pr_err ("ibm,open-errinjct failed: status=%d\n" , rc); + goto out_unlock; + } + session_open = true; + +/* Step 2: prepare the work buffer */ + rc =prepare_errinjct_buffer (buf, pe, rtas_type, func, addr, mask); +if (rc) { +pr_err ("failed to prepare errinjct buffer: rc=%d\n" , rc); + goto out_close; + } + +/* Step 3: inject the error */ + do { + rc = rtas_call(errinjct_token, 3, 1, NULL,
arch/powerpc/platforms/pseries/eeh_pseries.c static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, · line 1126
Quoted 10 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +10
-0+ rtas_type, session_token, buf_phys); + }while (rtas_busy_delay (rc)); + +if (rc) +pr_err ("ibm,errinjct failed: status=%d\n" , rc); + +out_close: +/* Step 4: always close the session */ + { +int close_rc;
Why are having separate rc variable for close close token call?
arch/powerpc/platforms/pseries/eeh_pseries.c static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, · line 1128
Quoted 2 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +2
-0+ +if (session_open) {
is session_open variable really needed?
Quoted 17 lines
arch/powerpc/platforms/pseries/eeh_pseries.c +14
-0+do { + close_rc =rtas_call (close_token,1 ,1 ,NULL , + session_token); + }while (rtas_busy_delay (close_rc)); + +if (close_rc) +pr_warn ("ibm,close-errinjct failed: status=%d\n" , + close_rc); + } + } + +out_unlock: +mutex_unlock (&rtas_errinjct_mutex); +return rc; }static struct eeh_ops pseries_eeh_ops = {
Re: [PATCH v3 5/5] powerpc/powernv/eeh: Map VFIO EEH error injection to OPAL
In reply to Narayana Murty NAs per the title this series is about RTAS-based error injection on pSeries.
Then why do we have powernv/opal patch part of this series?
- Sourabh Jain
Quoted 69 lines · Narayana Murty N
The EEH error-injection interface passes the generic userspace ABI values
EEH_ERR_TYPE_32andEEH_ERR_TYPE_64to the platform backend.The PowerNV backend currently compares those generic values directly with
OPAL_ERR_INJECT_TYPE_IOA_BUS_ERRandOPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64. Although the corresponding values are currently numerically identical, this implicitly couples the generic EEH ABI to the OPAL firmware encoding.Explicitly translate the generic EEH error types to their OPAL equivalents in
pnv_eeh_err_inject(). Keep the platform-specific encoding within the PowerNV backend and reject unsupported generic types with-EINVAL.No userspace ABI values are changed.
Signed-off-by Narayana Murty N <[email protected]>--- arch/powerpc/platforms/powernv/eeh-powernv.c | 36 +++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-)arch/powerpc/platforms/powernv/eeh-powernv.c +32
-4@@ -1169,11 +1169,39 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,struct pnv_phb *phb = hose->private_data;s64 rc; -if (type !=OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR && - type !=OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64 ) { -pr_warn ("%s: Invalid error type %d\n" , +/* +* Map generic EEH error-type ABI values to OPAL-specific type codes. +* EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 are the only types supported by +* OPAL. Additional generic types defined in the UAPI header are valid +* for pSeries RTAS but unsupported here; return -EOPNOTSUPP for those. +* Unknown or invalid values return -EINVAL. +* +* Note: currently OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR == 0 == +* EEH_ERR_TYPE_32 and OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64 == 1 == +* EEH_ERR_TYPE_64, but the explicit switch makes the coupling +* visible and allows the values to diverge independently. +*/ +switch (type) { +case EEH_ERR_TYPE_32 : + type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR ; +break ; +case EEH_ERR_TYPE_64 : + type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64 ; +break ; +case EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT : +case EEH_ERR_TYPE_CORRUPTED_PAGE : +case EEH_ERR_TYPE_CORRUPTED_DCACHE_START : +case EEH_ERR_TYPE_CORRUPTED_DCACHE_END : +case EEH_ERR_TYPE_CORRUPTED_ICACHE_START : +case EEH_ERR_TYPE_CORRUPTED_ICACHE_END : +case EEH_ERR_TYPE_CORRUPTED_TLB_START : +case EEH_ERR_TYPE_CORRUPTED_TLB_END : +pr_warn ("%s: EEH error type %d not supported by OPAL\n" , __func__, type); -return -ERANGE ; +return -EOPNOTSUPP ; +default : +pr_warn ("%s: unsupported EEH error type %d\n" , __func__, type); +return -EINVAL ; } if (func < OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR ||
Re: [PATCH v3 5/5] powerpc/powernv/eeh: Map VFIO EEH error injection to OPAL
Hi Sourabh,
Quoted 8 lines · Sourabh Jain
As per the title this series is about RTAS-based error injection on pSeries.
Then why do we have powernv/opal patch part of this series?
- Sourabh Jain
The guest running on povernv host also a pseries guest. VFIO will take care of translating the calls to respective platforms. So as a platform comparability the changes are made in this series.
Regards,
Narayana.
Quoted 75 lines · Narayana Murty N
Quoted 72 lines
The EEH error-injection interface passes the generic userspace ABI values
EEH_ERR_TYPE_32andEEH_ERR_TYPE_64to the platform backend.The PowerNV backend currently compares those generic values directly with
OPAL_ERR_INJECT_TYPE_IOA_BUS_ERRandOPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64. Although the corresponding values are currently numerically identical, this implicitly couples the generic EEH ABI to the OPAL firmware encoding.Explicitly translate the generic EEH error types to their OPAL equivalents in
pnv_eeh_err_inject(). Keep the platform-specific encoding within the PowerNV backend and reject unsupported generic types with-EINVAL.No userspace ABI values are changed.
Signed-off-by Narayana Murty N <[email protected]>---
arch/powerpc/platforms/powernv/eeh-powernv.c| 36 +++++++++++++++++---1 file changed, 32 insertions(+), 4 deletions(-)arch/powerpc/platforms/powernv/eeh-powernv.c +0
-0@@ -1169,11 +1169,39 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func, struct pnv_phb *phb = hose->private_data; s64 rc;- if (type !=
OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR&&
- type !=OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64) {
- pr_warn("%s: Invalid error type %d\n",
+ /*
+ * Map generic EEH error-type ABI values to OPAL-specific type codes.
+ *EEH_ERR_TYPE_32andEEH_ERR_TYPE_64are the only types supported by
+ * OPAL. Additional generic types defined in the UAPI header are valid
+ * for pSeries RTAS but unsupported here; return-EOPNOTSUPPfor those.
+ * Unknown or invalid values return-EINVAL.
+ *
+ * Note: currently OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR == 0 == + *EEH_ERR_TYPE_32andOPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64== 1 == + *EEH_ERR_TYPE_64, but the explicit switch makes the coupling + * visible and allows the values to diverge independently. + */
+ switch (type) {
+ caseEEH_ERR_TYPE_32:
+ type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR;
+ break;
+ caseEEH_ERR_TYPE_64:
+ type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64;
+ break;
+ caseEEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT:
+ caseEEH_ERR_TYPE_CORRUPTED_PAGE:
+ caseEEH_ERR_TYPE_CORRUPTED_DCACHE_START:
+ caseEEH_ERR_TYPE_CORRUPTED_DCACHE_END:
+ caseEEH_ERR_TYPE_CORRUPTED_ICACHE_START:
+ caseEEH_ERR_TYPE_CORRUPTED_ICACHE_END:
+ caseEEH_ERR_TYPE_CORRUPTED_TLB_START:
+ caseEEH_ERR_TYPE_CORRUPTED_TLB_END:
+pr_warn("%s: EEH error type %d not supported by OPAL\n", __func__, type);
- return-ERANGE;
+ return-EOPNOTSUPP;
+ default:
+pr_warn("%s: unsupported EEH error type %d\n", __func__, type); + return-EINVAL;
}
if (func <OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR||
Re: [PATCH v3 5/5] powerpc/powernv/eeh: Map VFIO EEH error injection to OPAL
Quoted 7 lines · Narayana Murty N
Hi Sourabh,
Quoted 4 lines · Sourabh Jain
As per the title this series is about RTAS-based error injection on pSeries.
Quoted 7 lines
Quoted 4 lines
Then why do we have powernv/opal patch part of this series?
- Sourabh Jain
The guest running on povernv host also a pseries guest. VFIO will take care of translating the calls to respective platforms. So as a platform comparability the changes are made in this series.
Oh, okay. These changes are for a pSeries guest running on a PowerNV platform. Thanks for the clarification.
- Sourabh Jain
Quoted 82 lines
Regards,
Narayana.Quoted 77 lines · Narayana Murty N
Quoted 74 lines
The EEH error-injection interface passes the generic userspace ABI values
EEH_ERR_TYPE_32andEEH_ERR_TYPE_64to the platform backend.The PowerNV backend currently compares those generic values directly with
OPAL_ERR_INJECT_TYPE_IOA_BUS_ERRandOPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64. Although the corresponding values are currently numerically identical, this implicitly couples the generic EEH ABI to the OPAL firmware encoding.Explicitly translate the generic EEH error types to their OPAL equivalents in
pnv_eeh_err_inject(). Keep the platform-specific encoding within the PowerNV backend and reject unsupported generic types with-EINVAL.No userspace ABI values are changed.
Signed-off-by Narayana Murty N <[email protected]>---
arch/powerpc/platforms/powernv/eeh-powernv.c| 36
+++++++++++++++++---1 file changed, 32 insertions(+), 4 deletions(-)arch/powerpc/platforms/powernv/eeh-powernv.c +0
-0@@ -1169,11 +1169,39 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func, struct pnv_phb *phb = hose->private_data; s64 rc;- if (type !=
OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR&&
- type !=OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64) {
- pr_warn("%s: Invalid error type %d\n",
+ /*
+ * Map generic EEH error-type ABI values to OPAL-specific type codes.
+ *EEH_ERR_TYPE_32andEEH_ERR_TYPE_64are the only types supported by
+ * OPAL. Additional generic types defined in the UAPI header are valid
+ * for pSeries RTAS but unsupported here; return-EOPNOTSUPPfor those.
+ * Unknown or invalid values return-EINVAL.
+ *
+ * Note: currently OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR == 0 == + *EEH_ERR_TYPE_32andOPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64== 1 == + *EEH_ERR_TYPE_64, but the explicit switch makes the coupling + * visible and allows the values to diverge independently. + */
+ switch (type) {
+ caseEEH_ERR_TYPE_32:
+ type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR;
+ break;
+ caseEEH_ERR_TYPE_64:
+ type =OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64;
+ break;
+ caseEEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT:
+ caseEEH_ERR_TYPE_CORRUPTED_PAGE:
+ caseEEH_ERR_TYPE_CORRUPTED_DCACHE_START:
+ caseEEH_ERR_TYPE_CORRUPTED_DCACHE_END:
+ caseEEH_ERR_TYPE_CORRUPTED_ICACHE_START:
+ caseEEH_ERR_TYPE_CORRUPTED_ICACHE_END:
+ caseEEH_ERR_TYPE_CORRUPTED_TLB_START:
+ caseEEH_ERR_TYPE_CORRUPTED_TLB_END:
+pr_warn("%s: EEH error type %d not supported by OPAL\n", __func__, type);
- return-ERANGE;
+ return-EOPNOTSUPP;
+ default:
+pr_warn("%s: unsupported EEH error type %d\n", __func__, type);
+ return-EINVAL;
}
if (func <OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR||
Re: [PATCH v3 4/5] powerpc/pseries/eeh: Implement RTAS-based EEH error injection
In reply to Narayana Murty Narch/powerpc/platforms/pseries/eeh_pseries.c static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, · line 1143
Quoted 4 lines · Narayana Murty N
arch/powerpc/platforms/pseries/eeh_pseries.c +3
-0+out_unlock: +mutex_unlock (&rtas_errinjct_mutex); +return rc; }
Hi Narayana,
Should we translate the raw RTAS return values held in rc into standard Linux error codes (like -EINVAL, -EIO, or -EPERM) before returning from pseries_eeh_err_inject()?
Thanks,
Nikhil
Quoted 118 lines · Narayana Murty N
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-errinjctThe implementation opens an RTAS error-injection session, prepares the firmware work buffer, performs the requested injection, and closes the session on both success and failure paths.
The existing EEH userspace ABI is preserved.
EEH_ERR_TYPE_32andEEH_ERR_TYPE_64continue 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 now 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 current 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.The series also handles the unusual return format of ibm,open-errinjct:
rets[0] = error-injection session token
rets[1] = RTAS status
rtas_call()now returns rets[1] as the status and places the session token in outputs[0], preserving the normal kernelrtas_call()convention.
sys_rtas()is intentionally unchanged because it exposes the raw RTAS return cells to userspace. Userspace therefore continues to receive the session token and status in their PAPR-defined positions.The RTAS work buffer is allocated during RTAS initialization below:
min(ppc64_rma_size, RTAS_INSTANTIATE_MAX)using the same accessible-memory limit used for
rtas_rmo_buf. The kernel populates the buffer through its virtual mapping but passes its physical address 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. A session token value of zero is accepted, and session state is tracked independently from the token value.
The patches are organised as follows:
Handle the special ibm,open-errinjct return format in
rtas_call(). Allocate an RTAS-accessible error-injection work buffer. Add pSeries RTAS parameter validation and buffer encoding helpers. Implement RTAS-based pSeries EEH error injection. 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 the corresponding QEMU support:
https://lore.kernel.org/qemu-devel/[email protected]/
Signed-off-by Narayana Murty N <[email protected]>Narayana Murty N (5):
powerpc/rtas: Handle ibm,open-errinjct return format powerpc/rtas: Allocate ibm,errinjct buffer below RTAS limit powerpc/pseries/eeh: Add RTAS error validation helpers powerpc/pseries/eeh: Implement RTAS-based EEH error injection powerpc/powernv/eeh: Map VFIO EEH error injection to OPALarch/powerpc/include/asm/rtas.h | 26 ++ arch/powerpc/include/uapi/asm/eeh.h | 24 +- arch/powerpc/kernel/rtas.c | 68 +++- arch/powerpc/platforms/powernv/eeh-powernv.c | 36 +- arch/powerpc/platforms/pseries/eeh_pseries.c | 367 +++++++++++++++++-- 5 files changed, 483 insertions(+), 38 deletions(-)Change Log:
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/[email protected]/
* Addressed all review comments from Sourabh Jain
- Removed unnecessary empty line inrtas_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_unusedparameter
- 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
Quoted 8 lines
RFC -> v1: https://lore.kernel.org/all/[email protected]/
* Initial 4-patch series
* Fixed PAPR ibm,open-errinjct output format (token,status order)
* Addedpr_fmthandling for EEH subsystem compatibility
* Implemented comprehensive validation helpersRFC: https://lore.kernel.org/all/[email protected]/
* Initial RFC implementation
Hi Narayana,
I have tested this patch along with the qemu patch series (https://lore.kernel.org/all/[email protected]/)
and I am still seeing the issue in which I am not able to trigger EEH on NVME Backplane device after passthroughing it to guest. I tried using location code with and without mask and address and EEH is not getting triggered.
1st command :
errinjct ioa-bus-error-64 -f 6 -p U2E4A.ND0.WZS0211-P1-C0 -a 0x88020000 -m 0xffffffffffff8000 -k 1
2nd command :
errinjct ioa-bus-error-64 -f 6 -p U2E4A.ND0.WZS0211-P1-C0 -m 0 -k 1
Getting the following issue everytime
errinjct: Could not open file /proc/device-tree/ibm,loc-code, No such file or directory
errinjct: Could not open file /proc/device-tree/ibm,platform-keystore/ibm,loc-code, No such file or directory
errinjct: Could not open file /proc/device-tree/memory@0/ibm,loc-code, No such file or directory
Injecting an ioa-bus-error...
errinjct: RTAS error injection failed!
errinjct: RTAS: ioa-bus-error: Argument error (-3)
This error may have occurred because error injection is disabled for this partition. Please check the FSP and ensure you have error injection enabled.
Please look into this.
Thank you,
Anushree Mathur
Hi Anushree,
Thanks for testing the series.
Quoted 154 lines · Anushree Mathur
Quoted 117 lines · Narayana Murty N
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-errinjctThe implementation opens an RTAS error-injection session, prepares the firmware work buffer, performs the requested injection, and closes the session on both success and failure paths.
The existing EEH userspace ABI is preserved.
EEH_ERR_TYPE_32andEEH_ERR_TYPE_64continue 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 now 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 current 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.The series also handles the unusual return format of ibm,open-errinjct:
rets[0] = error-injection session token
rets[1] = RTAS status
rtas_call()now returns rets[1] as the status and places the session token in outputs[0], preserving the normal kernelrtas_call()convention.
sys_rtas()is intentionally unchanged because it exposes the raw RTAS return cells to userspace. Userspace therefore continues to receive the session token and status in their PAPR-defined positions.The RTAS work buffer is allocated during RTAS initialization below:
min(ppc64_rma_size, RTAS_INSTANTIATE_MAX)using the same accessible-memory limit used for
rtas_rmo_buf. The kernel populates the buffer through its virtual mapping but passes its physical address 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. A session token value of zero is accepted, and session state is tracked independently from the token value.
The patches are organised as follows:
Handle the special ibm,open-errinjct return format in
rtas_call(). Allocate an RTAS-accessible error-injection work buffer. Add pSeries RTAS parameter validation and buffer encoding helpers. Implement RTAS-based pSeries EEH error injection. 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 the corresponding QEMU support:
https://lore.kernel.org/qemu-devel/20260520095446.64206-1- [email protected]/
Signed-off-by Narayana Murty N <[email protected]>Narayana Murty N (5):
powerpc/rtas: Handle ibm,open-errinjct return format powerpc/rtas: Allocate ibm,errinjct buffer below RTAS limit powerpc/pseries/eeh: Add RTAS error validation helpers powerpc/pseries/eeh: Implement RTAS-based EEH error injection powerpc/powernv/eeh: Map VFIO EEH error injection to OPALarch/powerpc/include/asm/rtas.h | 26 ++ arch/powerpc/include/uapi/asm/eeh.h | 24 +- arch/powerpc/kernel/rtas.c | 68 +++-
arch/powerpc/platforms/powernv/eeh-powernv.c| 36 +-arch/powerpc/platforms/pseries/eeh_pseries.c| 367 +++++++++++++++++--5 files changed, 483 insertions(+), 38 deletions(-)Change Log:
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- [email protected]/
* Addressed all review comments from Sourabh Jain
- Removed unnecessary empty line inrtas_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_unusedparameter
- 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 reviewQuoted 8 lines
RFC -> v1: https://lore.kernel.org/all/20251205094510.4671-1- [email protected]/
* Initial 4-patch series
* Fixed PAPR ibm,open-errinjct output format (token,status order)
* Addedpr_fmthandling for EEH subsystem compatibility
* Implemented comprehensive validation helpersRFC: https://lore.kernel.org/all/20251107091009.43034-1- [email protected]/
* Initial RFC implementationHi Narayana,
I have tested this patch along with the qemu patch series (https:// lore.kernel.org/all/[email protected]/) and I am still seeing the issue in which I am not able to trigger EEH on NVME Backplane device after passthroughing it to guest. I tried using location code with and without mask and address and EEH is not getting triggered.1st command :
errinjct ioa-bus-error-64 -f 6 -p U2E4A.ND0.WZS0211-P1-C0 -a
0x88020000-m0xffffffffffff8000-k 12nd command :
errinjct ioa-bus-error-64 -f 6 -p U2E4A.ND0.WZS0211-P1-C0 -m 0 -k 1
Getting the following issue everytime
errinjct: Could not open file
/proc/device-tree/ibm,loc-code, No such file or directoryerrinjct: Could not open file
/proc/device-tree/ibm,platform-keystore/ibm,loc-code, No such file or directoryerrinjct: Could not open file
/proc/device-tree/memory@0/ibm,loc-code, No such file or directoryInjecting an ioa-bus-error...
errinjct: RTAS error injection failed!errinjct: RTAS: ioa-bus-error: Argument error (-3)
Quoted 10 lines
This error may have occurred because error injection is disabled for this partition. Please check the FSP and ensure you have error injection enabled.
Please look into this.
Thank you,
Anushree Mathur
The commands shown below appear to be running the errinjct tool on the host. That path uses the host RTAS interface through sys_rtas() and therefore does not exercise the VFIO/QEMU passthrough error-injection path added by this kernel and QEMU series.
The intention of these patches is to allow an EEH error-injection request originating from the guest for a PCI device assigned through vfio-pci to be propagated through QEMU/VFIO to the host EEH backend.
Could you please retry the test from inside the guest after passing the NVMe backplane device through with vfio-pci?
The expected path for this test is roughly:
guest errinjct
→ guest ibm,open-errinjct / ibm,errinjct / ibm,close-errinjct → QEMU RTAS emulation
→ VFIO_EEH_PE_INJECT_ERR
→ host EEH/RTAS error-injection backend
In contrast, invoking errinjct directly on the host goes through sys_rtas() and talks directly to the host firmware. The /proc/device-tree/.../ibm,loc-code lookup failures and the RTAS Argument error (-3) reported in your log are therefore from that host-side errinjct path and are not testing the guest VFIO passthrough support provided by this series.
Please try the same error injection from the guest against the passed-through NVMe device and share the guest errinjct output together with the corresponding guest, QEMU, and host logs if it still fails.
Thanks,
Narayana
Re: [PATCH v3 1/5] powerpc/rtas: Handle ibm,open-errinjct return format
In reply to Sourabh JainHi Sourabh,
Thanks for the review.
Quoted 57 lines · Sourabh Jain
Quoted 54 lines · Narayana Murty N
PAPR specifies that ibm,open-errinjct has a unique return-cell layout:
rets[0] = injection session token (output parameter) rets[1] = status code
This differs from every other RTAS call, where:
rets[0] = status code
rets[1..] = output parametersAs a result, the existing
rtas_call()convention — return value is the RTAS status, outputs[] receives the non-status output values — must be preserved while correctly extracting status from rets[1] for this one call.Add
rtas_token_is_open_errinjct()andrtas_status_from_args()helpers.rtas_status_from_args()selects the correct status cell based on the token, and the output-copy loop inrtas_call()is updated so that for ibm,open-errinjct:
rtas_call()return = rets[1] (RTAS status)
outputs[0] = rets[0] (session token)For all other calls the behaviour is unchanged: return value is rets[0] and outputs[] receives rets[1..nret-1].
The
sys_rtasuserspace path is not modified:copy_to_user()still copies raw RTAS return cells (rets[0..nret-1]) to userspace.Callers passing a single output int (nret == 2) are safe because we write at most nret-1 values into outputs[], never all nret cells.
Also move the '/* A -1 return code...*/' comment to immediately precede the if (ret == -1) check it describes, and remove the redundant stale else branch that re-assigned ret.
Reference: OpenPOWER PAPR documentation
https://files.openpower.foundation/s/XFgfMaqLMD5Bcm8Signed-off-by Narayana Murty N <[email protected]>---
arch/powerpc/kernel/rtas.c| 51 ++++++++++++++++++++++++++++++++------1 file changed, 44 insertions(+), 7 deletions(-)arch/powerpc/kernel/rtas.c +2
-0@@ -1117,6 +1117,29 @@ static bool token_is_restricted_errinjct(s32 token) token == rtas_function_token(RTAS_FN_IBM_ERRINJCT); } +/** +* rtas_token_is_open_errinjct() - Test whether @token identifies
Quoted 8 lines
arch/powerpc/kernel/rtas.c static bool token_is_restricted_errinjct(s32 token) · line 1126
Quoted 6 lines
ibm,open-errinjct.
+ */arch/powerpc/kernel/rtas.c +4
-0+static bool rtas_token_is_open_errinjct (int token) +{ + return token == rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT); +}The above function is a god candidate for an inline function.
Agreed. I updated this in v4 and made the helper static inline.
Quoted 16 lines
Quoted 5 lines
arch/powerpc/kernel/rtas.c +3
-0+ +/** +* rtas_status_from_args() - Extract the RTAS status code from a completed
+ * call's return-cell array.Quoted 8 lines
+ *
+ * For ibm,open-errinjct the status lives in rets[1]; for every other
+ * RTAS function it lives in rets[0].
+ */
+static intrtas_status_from_args(int token, struct rtas_args *args, int nret)
+{
+ if (rtas_token_is_open_errinjct(token)&& nret > 1)Do we know what RTAS returns when nret is less than 2 for the ibm,open- errinjct RTAS call?
Quoted 9 lines
I assume RTAS treats this as a parameter error. However, since there is no rets buffer available to store the status code, I'm not sure how RTAS would convey the parameter error back to the kernel.
The way the RTAS status code is extracted when nret is less than 2 for the ibm,open-errinjct RTAS call seems problematic me, especially when nret == 1. When nret == 1, this function returns args->rets[0], which is supposed to contain the session token.
Are we sure that RTAS places the call status in rets[0] when nret == 1 for the ibm,open-errinjct RTAS call?
The rets[0] contains a status for
ibm,open-errinjct when fewer than two return cells are provided. For this RTAS call, rets[0] is the session token and rets[1] is the status. So if nret < 2, the kernel cannot reliably extract the status.
I fixed this in v4 by treating ibm,open-errinjct with nret < 2 as an invalid rtas_call() usage instead of falling back to rets[0]. That avoids mistaking a session token for a status code.
For normal callers using nret == 2, the behavior remains:
rtas_call() return value = rets[1] status
outputs[0] = rets[0] session token
The sys_rtas() path remains unchanged and continues to expose the raw RTAS return cells to userspace.
Quoted 38 lines
- Sourabh Jain
Quoted 36 lines
+ return
be32_to_cpu(args->rets[1]);arch/powerpc/kernel/rtas.c +4
-0+ + return nret > 0 ? be32_to_cpu(args->rets[0]) : 0; +} +/**
*rtas_call()- Invoke an RTAS firmware function.
* @token: Identifies the function being invoked.arch/powerpc/kernel/rtas.c +12
-7@@ -1213,15 +1236,29 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...) va_rtas_call_unlocked(args, token, nargs, nret, list); va_end(list); - /* A -1 return code indicates that the last command couldn't - be completed due to a hardware error. */ - if (be32_to_cpu(args->rets[0]) == -1) + ret = rtas_status_from_args(token, args, nret); + + /* + * A -1 return code indicates that the last command couldn't + * be completed due to a hardware error. + */ + if (ret == -1) buff_copy = __fetch_rtas_last_error(NULL); - if (nret > 1 && outputs != NULL) - for (i = 0; i < nret-1; ++i) - outputs[i] = be32_to_cpu(args->rets[i + 1]); - ret = (nret > 0) ? be32_to_cpu(args->rets[0]) : 0; + if (nret > 1 && outputs != NULL) { + if (rtas_token_is_open_errinjct(token)) { + /* +* ibm,open-errinjct: rets[0]=session token, rets[1]=status. +* Expose session token in outputs[0]; skip rets[1] (status).
+ */
+ outputs[0] =be32_to_cpu(args->rets[0]); + for (i = 1; i < nret - 1; ++i)
Quoted 9 lines
Quoted 8 lines
+ outputs[i] =
be32_to_cpu(args->rets[i + 1]); + } else {
+ for (i = 0; i < nret - 1; ++i)
+ outputs[i] =be32_to_cpu(args->rets[i + 1]); + }
+ }
lockdep_unpin_lock(&rtas_lock, cookie);raw_spin_unlock_irqrestore(&rtas_lock, flags);
Thanks,
Narayana
Re: [PATCH v3 2/5] powerpc/rtas: Allocate ibm,errinjct buffer below RTAS limit
In reply to Sourabh JainHi Sourabh,
Quoted 11 lines · Sourabh Jain
Hello Narayana,
How about using the
rtas_work_area_alloc()instead of allocating a new dedicated buffer for errinjct only?Checkout Commit
43033bc62d34("powerpc/pseries: add RTAS work area allocator") for infrastructure to allocated working buffer.Also checkout commit
e27e14231eb5("powerpc/pseries/dlpar: use RTAS work area API") on how to use work area API.
Agreed. I reworked this in v4 to use the RTAS work area allocator instead of adding a dedicated global rtas_errinjct_buf.
The v3 approach allocated a separate error-injection buffer during rtas_initialize(), but that is not necessary now that the RTAS work area allocator already provides the right infrastructure for RTAS-accessible working buffers.
In v4, the pseries error-injection path allocates a work area for the RTAS parameter buffer, fills it using the mapped kernel address, passes the RTAS-visible physical address to firmware, and frees the work area after the open/inject/close sequence.
This also removes the extra global buffer only for error injection.
Thanks,
Narayana
Quoted 114 lines
- Sourabh Jain
Quoted 110 lines · Narayana Murty N
ibm,errinjct requires a caller-provided work buffer whose physical address is passed to RTAS firmware.
A static C array such as:
char rtas_errinjct_buf[1024]
__aligned(SZ_1K);only guarantees alignment, not physical placement. If the array lands above the RTAS-safe range (
RTAS_INSTANTIATE_MAX, 1 GB) or above 4 GB, RTAS receives a truncated or invalid address and the injection call will fail silently or corrupt memory.Instead, introduce
rtas_errinjct_bufas a global unsigned long storing the physical address allocated duringrtas_initialize()usingmemblock_phys_alloc_range()with the samertas_regionupper bound used for rtas_rmo_buf. This matches the existing placement model for RTAS-accessible buffers and guarantees the physical address fits in 32 bits.Usage:
void *buf = __va(rtas_errinjct_buf); /* kernel VA to fill */ u32buf_phys=lower_32_bits(rtas_errinjct_buf); /* PA for RTAS */Always check
upper_32_bits(rtas_errinjct_buf)== 0 before passing the lower 32 bits to RTAS.Add
rtas_errinjct_mutexto serialise the complete open-session / inject / close-session firmware call sequence. A mutex is required because the sequence involves multiplertas_call()invocations with possible busy/extended-delay retries that may sleep.Signed-off-by Narayana Murty N <[email protected]>---
arch/powerpc/include/asm/rtas.h| 26 ++++++++++++++++++++++++++ arch/powerpc/kernel/rtas.c | 17 +++++++++++++++++2 files changed, 43 insertions(+)arch/powerpc/include/asm/rtas.h +26
-0@@ -4,6 +4,7 @@ #ifdef __KERNEL__ #include <linux/mutex.h> +#include <linux/sizes.h> #include <linux/spinlock.h> #include <asm/page.h> #include <asm/rtas-types.h>@@ -519,6 +520,31 @@ int rtas_get_error_log_max(void); extern spinlock_t rtas_data_buf_lock; extern char rtas_data_buf[RTAS_DATA_BUF_SIZE]; +/* +* RTAS error-injection work buffer. +* +* ibm,errinjct requires a caller-provided work buffer whose physical +* address is passed to firmware. A static C array only guarantees +* alignment, not physical placement; if it lands above the RTAS-safe +* range or above 4 GB, RTAS receives a truncated or bogus address. +* +* rtas_errinjct_buf stores the physical address allocated during +* rtas_initialize() using memblock_phys_alloc_range() with the same +* rtas_region upper bound used for rtas_rmo_buf, matching the existing +* placement model for RTAS-accessible buffers. +* +* Use __va(rtas_errinjct_buf) to obtain the kernel virtual address for +* filling the buffer, and lower_32_bits(rtas_errinjct_buf) to pass the +* physical address to RTAS (after checking upper_32_bits() == 0). +* +* rtas_errinjct_mutex must be held across the complete +* ibm,open-errinjct / ibm,errinjct / ibm,close-errinjct sequence. +*/ +#define RTAS_ERRINJCT_BUF_SIZE SZ_1K + +extern unsigned long rtas_errinjct_buf; +extern struct mutex rtas_errinjct_mutex; + /* RMO buffer reserved for user-space RTAS use */ extern unsigned long rtas_rmo_buf;arch/powerpc/kernel/rtas.c +17
-0@@ -769,6 +769,17 @@ EXPORT_SYMBOL_GPL(rtas_data_buf); unsigned long rtas_rmo_buf; +/* +* Physical address of the ibm,errinjct work buffer. Allocated during +* rtas_initialize() using memblock_phys_alloc_range() below rtas_region +* so the address fits in 32 bits and is safe to pass to RTAS firmware. +*/ +unsigned long rtas_errinjct_buf; +EXPORT_SYMBOL_GPL (rtas_errinjct_buf); + +DEFINE_MUTEX (rtas_errinjct_mutex); +EXPORT_SYMBOL_GPL (rtas_errinjct_mutex); + /** If non-NULL, this gets called when the kernel terminates. * This is done like this so rtas_flash can be a module. @@ -2109,6 +2120,12 @@ void __init rtas_initialize(void) panic("ERROR: RTAS: Failed to allocate %lx bytes below %pa\n", PAGE_SIZE, &rtas_region); + rtas_errinjct_buf =memblock_phys_alloc_range (RTAS_ERRINJCT_BUF_SIZE , + SZ_1K, 0, rtas_region); + if (!rtas_errinjct_buf) + panic("ERROR: RTAS: Failed to allocate %lu bytes below %pa\n", + (unsigned long)RTAS_ERRINJCT_BUF_SIZE, &rtas_region); + rtas_work_area_reserve_arena(rtas_region); }
Re: [PATCH v3 3/5] powerpc/pseries/eeh: Add RTAS error validation helpers
In reply to Sourabh JainHi Sourabh,
Quoted 7 lines · Sourabh Jain
Quoted 1 line · Narayana Murty N
Add validation helpers
Can you provide more details about what these validation helpers are for?
These helpers were intended to validate the userspace-provided EEH error injection parameters before encoding them into the ibm,errinjct RTAS work buffer. They check whether the requested generic EEH error type is supported by the pSeries RTAS backend, whether the function code is valid for the requested error type, and whether an address-scoped IOA error refers to an address that belongs to the target PE.
Quoted 5 lines
Quoted 2 lines
and buffer-preparation infrastructure used by the RTAS-based EEH error injection implementation.
Can you explain what this buffer is and what it is used for?
The buffer is the RTAS parameter/work buffer passed to ibm,errinjct. The kernel fills this buffer according to the PAPR layout for the requested error type, then passes the RTAS-visible physical address of the buffer to firmware.
In v4 this no longer uses a dedicated global rtas_errinjct_buf.
Quoted 22 lines
Quoted 13 lines
Changes relative to the original submission:
-pr_fmtunconditionally defined at the top of the file, not wrapped in an #ifndef guard.
- RTAS error-type constants (RTAS_ERR_TYPE_*) are defined as file-local macros ineeh_pseries.c, not in the UAPI header. They are internal PAPR firmware type codes, not generic EEH ABI values.
-validate_corrupted_page()drops the unused 'pe' parameter entirely (no __maybe_unused). The mask value is silently accepted since it is not meaningful for this error type.
-validate_ioa_bus_error()is removed; callers invokevalidate_addr_mask_in_pe()directly.Quoted 8 lines
-
validate_err_type()andvalidate_special_event()andvalidate_corrupted_page()are marked static inline.
-prepare_errinjct_buffer()takes an explicit 'void *buf' pointer (kernel virtual address) instead of accessingrtas_errinjct_bufdirectly, making it easier to test and keeping the global out of the helper.
- kernel-doc added forprepare_errinjct_buffer()including a Locking:
line stating the caller must holdrtas_errinjct_mutex.
Quoted 2 lines
Changelog shouldn't be part of commit message.
Agreed.
Quoted 95 lines
Quoted 95 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Narayana Murty N <[email protected]>---
arch/powerpc/include/uapi/asm/eeh.h | 24 +-arch/powerpc/platforms/pseries/eeh_pseries.c| 250 +++++++++++++++++++2 files changed, 271 insertions(+), 3 deletions(-)arch/powerpc/include/uapi/asm/eeh.h +4
-3@@ -15,9 +15,27 @@ #define EEH_PE_STATE_STOPPED_DMA 4 /* Stopped DMA only */ #define EEH_PE_STATE_UNAVAIL 5 /* Unavailable */ -/* EEH error types and functions */ -#define EEH_ERR_TYPE_32 0/* 32-bits error */ -#define EEH_ERR_TYPE_64 1/* 64-bits error */ +/* +* EEH error types. +* +* EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 are the original ABI values and must
+ * not be renumbered. The additional types below are generic identifiers for
+ * error-injection types supported by pSeries RTAS. Platform backends may
+ * return-EOPNOTSUPPfor valid generic types that are not supported by their
+ * firmware.
+ */arch/powerpc/include/uapi/asm/eeh.h +12
-0+#define EEH_ERR_TYPE_32 0/* 32-bits error */ +#define EEH_ERR_TYPE_64 1/* 64-bits error */ +#define EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT 0x03 +#define EEH_ERR_TYPE_CORRUPTED_PAGE 0x04 +#define EEH_ERR_TYPE_CORRUPTED_DCACHE_START 0x09 +#define EEH_ERR_TYPE_CORRUPTED_DCACHE_END 0x0a +#define EEH_ERR_TYPE_CORRUPTED_ICACHE_START 0x0b +#define EEH_ERR_TYPE_CORRUPTED_ICACHE_END 0x0c +#define EEH_ERR_TYPE_CORRUPTED_TLB_START 0x0d +#define EEH_ERR_TYPE_CORRUPTED_TLB_END 0x0e + +/* EEH error functions */ #define EEH_ERR_FUNC_MIN 0
#define EEH_ERR_FUNC_LD_MEM_ADDR 0 /* Memory load */ #define EEH_ERR_FUNC_LD_MEM_DATA 1arch/powerpc/platforms/pseries/eeh_pseries.c +22
-0@@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-or-later +#define pr_fmt (fmt) "EEH: " fmt /** The file intends to implement the platform dependent EEH operations on pseries. * Actually, the pseries platform is built based on RTAS heavily. That means the @@ -31,8 +32,27 @@ #include <asm/io.h> #include <asm/machdep.h> #include <asm/ppc-pci.h> +#include <linux/mutex.h> #include <asm/rtas.h> +/* +* PAPR RTAS firmware error-injection type codes. +* +* These are internal firmware encodings used by ibm,errinjct. They are +* NOT generic EEH ABI values. Only the types actually handled by +* prepare_errinjct_buffer() are defined here. +*/ +#define RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT 0x03 +#define RTAS_ERR_TYPE_CORRUPTED_PAGE 0x04 +#define RTAS_ERR_TYPE_IOA_BUS_ERROR 0x07 +#define RTAS_ERR_TYPE_CORRUPTED_DCACHE_START 0x09 +#define RTAS_ERR_TYPE_CORRUPTED_DCACHE_END 0x0a +#define RTAS_ERR_TYPE_CORRUPTED_ICACHE_START 0x0b +#define RTAS_ERR_TYPE_CORRUPTED_ICACHE_END 0x0c +#define RTAS_ERR_TYPE_CORRUPTED_TLB_START 0x0d +#define RTAS_ERR_TYPE_CORRUPTED_TLB_END 0x0e +#define RTAS_ERR_TYPE_IOA_BUS_ERROR_64 0x0f + /* RTAS tokens */ static int ibm_set_eeh_option; static int ibm_set_slot_reset;@@ -786,6 +806,236 @@ static int pseries_notify_resume(struct eeh_dev *edev) } #endif +/** +* validate_addr_mask_in_pe() - Validate that addr+mask fall within PE BARs
+ * @pe: EEH PE containing one or more PCI devices
+ * @addr: Address to validate
+ * @mask: Address mask to validate
+ *
Quoted 9 lines
Quoted 5 lines
+ * Checks that @addr is mapped into a BAR/MMIO region of any device
+ * belonging to the PE. If @mask is non-zero, ensures it is consistent
+ * with @addr.
+ *
+ * Return: 0 if valid,RTAS_INVALID_PARAMETERon failure.Using RTAS error codes for kernel function may not be good idea. How about using
-EINVAL?
Agreed. I changed the local helpers in v4 to return normal Linux error codes such as -EINVAL or -EOPNOTSUPP, instead of returning RTAS status codes directly.
Quoted 24 lines
Quoted 24 lines
+ */
+static int validate_addr_mask_in_pe(structeeh_pe*pe, unsigned long addr,
+ unsigned long mask)arch/powerpc/platforms/pseries/eeh_pseries.c +20
-0+{ + struct eeh_dev *edev, *tmp; + struct pci_dev *pdev; + int bar; + resource_size_t bar_start, bar_len; + bool valid = false; + + /* nothing to validate */ + if (addr == 0 && mask == 0) + return 0; + + eeh_pe_for_each_dev(pe, edev, tmp) { + pdev = eeh_dev_to_pci_dev(edev); + if (!pdev) + continue; + + for (bar = 0; bar < PCI_NUM_RESOURCES; bar++) { + bar_start = pci_resource_start(pdev, bar); + bar_len = pci_resource_len(pdev, bar); +
Quoted 8 lines
Quoted 5 lines
+ if (!bar_len)
+ continue;
+
+ if (addr >=bar_start&& addr < (bar_start+bar_len)) { + if ((addr & mask) != addr) {The check has nothing to do with device or the BAR. Then why this check is inside the loop?
That check was intended to reject an address/mask pair that did not preserve the requested address bits, but I agree it was not really a BAR membership check and did not belong inside the BAR scanning loop.
Quoted 15 lines
For my understanding can you please explain what this check is all about?
Quoted 11 lines
+ pr_err("Mask 0x%lx invalid for addr 0x%lx in BAR[%d] range 0x%llx-0x%llx\n",
+ mask, addr, bar,
+ (unsigned long long)bar_start,
+ (unsigned long long)(bar_start +bar_len)); + returnRTAS_INVALID_PARAMETER;
+ }
+ pr_debug("addr=0x%lx mask=0x%lx validated in BAR[%d] of %s\n",
+ addr, mask, bar,pci_name(pdev));
+ valid = true;
Quoted 2 lines
Once valid is set, the loop keeps scanning all remaining BARs/devices instead of breaking. Is it intentional?
No, that was not intentional. Once a matching BAR is found there is no need to keep scanning. I fixed this in v4 so the helper returns immediately after finding a valid BAR match.
Quoted 11 lines
Quoted 9 lines
+ }
+ }
+ }
+
+ if (!valid) {
+pr_err("addr=0x%lx not within any BAR of any device in PE\n", + addr);
+ returnRTAS_INVALID_PARAMETER;
-EINVALwould be a better options for these helpers.
Agreed.
Thanks,
Narayana
Quoted 192 lines
Quoted 191 lines
+ }
arch/powerpc/platforms/pseries/eeh_pseries.c +6
-0+ + return 0; +} + +/** +* validate_special_event() - Validate parameters for special-event injection
+ * @addr: Address parameter (must be zero for this type)
+ * @mask: Mask parameter (must be zero for this type)
+ *
+ * Return: 0 if valid,RTAS_INVALID_PARAMETERotherwise.
+ */
+static inline intvalidate_special_event(unsigned long addr, unsigned long mask)arch/powerpc/platforms/pseries/eeh_pseries.c +10
-0+{ + if (addr || mask) { + pr_err("special-event injection must not specify addr/mask\n"); + return RTAS_INVALID_PARAMETER; + } + return 0; +} + +/** +* validate_corrupted_page() - Validate parameters for corrupted-page injection
+ * @addr: Physical page address (required, must be non-zero)
+ *
+ * The mask value is not meaningful for this error type and is ignored.
+ *
+ * Return: 0 if valid,RTAS_INVALID_PARAMETERotherwise.
+ */arch/powerpc/platforms/pseries/eeh_pseries.c +11
-0+static inline int validate_corrupted_page (unsigned long addr) +{ + if (!addr) { + pr_err("corrupted-page injection requires non-zero addr\n"); + return RTAS_INVALID_PARAMETER; + } + return 0; +} + +/** +* pseries_eeh_type_to_rtas() - Map a generic EEH error type to its RTAS encoding.
+ * @type: Generic EEH error type (EEH_ERR_TYPE_*)
+ *
+ * Translates a userspace-visible generic EEH error type to the corresponding
+ * PAPR RTAS firmware type code. Every supported value appears as an explicit
+ * case; coincidental equality between generic EEH and RTAS values is not relied
+ * upon.
+ *
+ * Return: RTAS_ERR_TYPE_* value on success,-EINVALfor unsupported types.
+ */arch/powerpc/platforms/pseries/eeh_pseries.c +33
-0+static int pseries_eeh_type_to_rtas (int type) +{ + switch (type) { + case EEH_ERR_TYPE_32: + return RTAS_ERR_TYPE_IOA_BUS_ERROR; + case EEH_ERR_TYPE_64: + return RTAS_ERR_TYPE_IOA_BUS_ERROR_64; + case EEH_ERR_TYPE_RECOVERED_SPECIAL_EVENT: + return RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT; + case EEH_ERR_TYPE_CORRUPTED_PAGE: + return RTAS_ERR_TYPE_CORRUPTED_PAGE; + case EEH_ERR_TYPE_CORRUPTED_DCACHE_START: + return RTAS_ERR_TYPE_CORRUPTED_DCACHE_START; + case EEH_ERR_TYPE_CORRUPTED_DCACHE_END: + return RTAS_ERR_TYPE_CORRUPTED_DCACHE_END; + case EEH_ERR_TYPE_CORRUPTED_ICACHE_START: + return RTAS_ERR_TYPE_CORRUPTED_ICACHE_START; + case EEH_ERR_TYPE_CORRUPTED_ICACHE_END: + return RTAS_ERR_TYPE_CORRUPTED_ICACHE_END; + case EEH_ERR_TYPE_CORRUPTED_TLB_START: + return RTAS_ERR_TYPE_CORRUPTED_TLB_START; + case EEH_ERR_TYPE_CORRUPTED_TLB_END: + return RTAS_ERR_TYPE_CORRUPTED_TLB_END; + default: + return -EINVAL; + } +} + +/** +* prepare_errinjct_buffer() - Build ibm,errinjct work buffer +* @buf: RTAS error-injection work buffer (kernel virtual address) +* @pe: EEH PE associated with the injection target +* @rtas_type: PAPR firmware error-injection type after generic EEH- to-RTAS
+ * translation (RTAS_ERR_TYPE_*)
+ * @func: Error function selector
+ * @addr: Target address, if applicable
+ * @mask: Address mask, if applicable
+ *
+ * Zeroes @buf and populates it according to the PAPR layout for @rtas_type.
+ * Performs inline parameter validation for each error type.
+ *
+ * Locking: Caller must holdrtas_errinjct_mutex.
+ *
+ * Return: 0 on success,RTAS_INVALID_PARAMETERon invalid input.
+ */arch/powerpc/platforms/pseries/eeh_pseries.c +31
-0+static int prepare_errinjct_buffer (void *buf,struct eeh_pe *pe, + int rtas_type, int func, + unsigned long addr, unsigned long mask) +{ + __be64 *buf64 = (__be64 *)buf; + __be32 *buf32 = (__be32 *)buf; + + memset(buf, 0, RTAS_ERRINJCT_BUF_SIZE); + + switch (rtas_type) { + case RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT: + /* func: 1 = non-persistent, 2 = persistent */ + if (func < 1 || func > 2) + return RTAS_INVALID_PARAMETER; + if (validate_special_event(addr, mask)) + return RTAS_INVALID_PARAMETER; + buf32[0] = cpu_to_be32(func); + break; + + case RTAS_ERR_TYPE_CORRUPTED_PAGE: + if (validate_corrupted_page(addr)) + return RTAS_INVALID_PARAMETER; + buf32[0] = cpu_to_be32(upper_32_bits(addr)); + buf32[1] = cpu_to_be32(lower_32_bits(addr)); + break; + + case RTAS_ERR_TYPE_IOA_BUS_ERROR: + if (func < EEH_ERR_FUNC_LD_MEM_ADDR || func > EEH_ERR_FUNC_MAX) + return RTAS_INVALID_PARAMETER; + if (upper_32_bits(addr) || upper_32_bits(mask)) { + pr_err("32-bit IOA injection cannot encode addr=%#lxmask=%#lx\n",
+ addr, mask);
+ returnRTAS_INVALID_PARAMETER;
+ }
+ if (validate_addr_mask_in_pe(pe, addr, mask)) + returnRTAS_INVALID_PARAMETER;
+ buf32[0] = cpu_to_be32((u32)addr);
+ buf32[1] = cpu_to_be32((u32)mask);
+ buf32[2] =cpu_to_be32(pe->addr);
+ buf32[3] = cpu_to_be32(BUID_HI(pe->phb->buid)); + buf32[4] = cpu_to_be32(BUID_LO(pe->phb->buid)); + buf32[5] =cpu_to_be32(func);
+ break;arch/powerpc/platforms/pseries/eeh_pseries.c +29
-0+ + case RTAS_ERR_TYPE_IOA_BUS_ERROR_64: + if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX) + return RTAS_INVALID_PARAMETER; + if (validate_addr_mask_in_pe(pe, addr, mask)) + return RTAS_INVALID_PARAMETER; + buf64[0] = cpu_to_be64(addr); + buf64[1] = cpu_to_be64(mask); + buf32[4] = cpu_to_be32(pe->addr); + buf32[5] = cpu_to_be32(BUID_HI(pe->phb->buid)); + buf32[6] = cpu_to_be32(BUID_LO(pe->phb->buid)); + buf32[7] = cpu_to_be32(func); + break; + + 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: + buf32[0] = cpu_to_be32(lower_32_bits(addr)); + buf32[1] = cpu_to_be32(lower_32_bits(mask)); + break; + + case RTAS_ERR_TYPE_CORRUPTED_TLB_START: + case RTAS_ERR_TYPE_CORRUPTED_TLB_END: + buf32[0] = cpu_to_be32(lower_32_bits(addr)); + break; + + default: + pr_err("unsupported RTAS error injection type 0x%x\n",
rtas_type);
+ returnRTAS_INVALID_PARAMETER;
+ }
+
+ pr_debug("errinjct buffer ready: rtas_type=0x%x func=%d addr=0x%lx mask=0x%lx\n",
+rtas_type, func, addr, mask);
+ return 0;arch/powerpc/platforms/pseries/eeh_pseries.c +2
-0+} +/**
*pseries_eeh_err_inject- Inject specified error to the indicated PE
* @pe: the indicated PE
Re: [PATCH v3 4/5] powerpc/pseries/eeh: Implement RTAS-based EEH error injection
In reply to Sourabh JainHi Sourabh,
Thanks for the review.
Quoted 90 lines · Sourabh Jain
Quoted 87 lines · Narayana Murty N
Replace legacy MMIO error injection with full PAPR-compliant RTAS error injection supporting 14+ error types via
- ibm,open-errinjct
- ibm,errinjct
- ibm,close-errinjct.Key features:
- Complete open-session-inject-close cycle management
- Special handling for ibm,open-errinjct output format (token,status)
- Comprehensive buffer preparation per PAPR layouts
- All pr_* logging usespr_fmt("EEH: ")prefixTested with corresponding QEMU patches:
https://lore.kernel.org/all/20251029150618.186803-1- [email protected]/Signed-off-by Narayana Murty N <[email protected]>---
arch/powerpc/platforms/pseries/eeh_pseries.c| 121 +++++++++++++++----1 file changed, 95 insertions(+), 26 deletions(-)arch/powerpc/platforms/pseries/eeh_pseries.c +8
-8@@ -1037,40 +1037,109 @@ static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, } /** -* pseries_eeh_err_inject - Inject specified error to the indicated PE -* @pe: the indicated PE -* @type: error type -* @func: specific error type -* @addr: address -* @mask: address mask -* The routine is called to inject specified error, which is -* determined by @type and @func, to the indicated PE +* pseries_eeh_err_inject - Inject specified error into the indicated PE +* @pe: the indicated PE +* @type: generic EEH error type (EEH_ERR_TYPE_*) +* @func: error function selector (EEH_ERR_FUNC_*) +* @addr: target address, if applicable +* @mask: address mask, if applicable +* +* Implements the EEH error-injection callback for pseries using the RTAS
+ * ibm,open-errinjct / ibm,errinjct / ibm,close-errinjct firmware services.
+ *
+ * Generic EEH error types are translated to RTAS firmware type codes via
+ *pseries_eeh_type_to_rtas()before the injection session is opened.
+ * Unsupported generic types are rejected with-EINVALbefore any RTAS call
+ * is made. Existing userspace is unaffected.
+ *
+ * Return: 0 on success, negative errno or RTAS error code on failure. */
static intpseries_eeh_err_inject(struct eeh_pe *pe, int type, int func, unsigned long addr, unsigned long mask)
{
- struct eeh_dev *pdev;
-
- /* Check on PCI error type */
- if (type !=EEH_ERR_TYPE_32&& type !=EEH_ERR_TYPE_64)
- return-EINVAL;
+ intopen_token,errinjct_token,close_token;
+ intsession_token= 0;
+ boolsession_open= false;
+ void *buf;
+ u32buf_phys;
+ int rc;
+ intrtas_type;
- switch (func) {
- caseEEH_ERR_FUNC_LD_MEM_ADDR:
- caseEEH_ERR_FUNC_LD_MEM_DATA:
- caseEEH_ERR_FUNC_ST_MEM_ADDR:
- caseEEH_ERR_FUNC_ST_MEM_DATA:
- /* injects a MMIO error for all pdev's belonging to PE */ -pci_lock_rescan_remove();
-list_for_each_entry(pdev, &pe->edevs, entry)
-eeh_pe_inject_mmio_error(pdev->pdev);
-pci_unlock_rescan_remove();
- break;
- default:
+ /* Guard: buffer must fit in 32 bits for RTAS */
+ if (WARN_ON_ONCE(upper_32_bits(rtas_errinjct_buf))) return-ERANGE;
Quoted 8 lines
Quoted 6 lines
+
+ /* Map generic EEH ABI to RTAS-internal error type */ +rtas_type=pseries_eeh_type_to_rtas(type); + if (rtas_type< 0) {
+pr_err("unsupported EEH error type %#x\n", type); + returnrtas_type;How about
-EINVALinstead?
Agreed.
Quoted 46 lines
Quoted 46 lines
}
- return 0;
+ /* Verify all three RTAS tokens are available before touching firmware */
+ open_token =rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT); +errinjct_token=rtas_function_token(RTAS_FN_IBM_ERRINJCT); + close_token =rtas_function_token(RTAS_FN_IBM_CLOSE_ERRINJCT);arch/powerpc/platforms/pseries/eeh_pseries.c +38
-0+ + if (open_token == RTAS_UNKNOWN_SERVICE || + errinjct_token == RTAS_UNKNOWN_SERVICE || + close_token == RTAS_UNKNOWN_SERVICE) { + pr_err("ibm,open/errinjct/close-errinjct not available\n"); + return -ENODEV; + } + + buf = __va(rtas_errinjct_buf); + buf_phys = lower_32_bits(rtas_errinjct_buf); + + mutex_lock(&rtas_errinjct_mutex); + + /* Step 1: open injection session */ + do { + rc = rtas_call(open_token, 0, 2, &session_token); + } while (rtas_busy_delay(rc)); + + if (rc) { + pr_err("ibm,open-errinjct failed: status=%d\n", rc); + goto out_unlock; + } + session_open = true; + + /* Step 2: prepare the work buffer */ + rc = prepare_errinjct_buffer(buf, pe, rtas_type, func, addr, mask); + if (rc) { + pr_err("failed to prepare errinjct buffer: rc=%d\n", rc); + goto out_close; + } + + /* Step 3: inject the error */ + do { + rc = rtas_call(errinjct_token, 3, 1, NULL, + rtas_type, session_token, buf_phys); + } while (rtas_busy_delay(rc)); + + if (rc)
Quoted 9 lines
arch/powerpc/platforms/pseries/eeh_pseries.c static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe, · line 1126
Quoted 6 lines
+
pr_err("ibm,errinjct failed: status=%d\n", rc);arch/powerpc/platforms/pseries/eeh_pseries.c +5
-0+ +out_close: + /* Step 4: always close the session */ + { + int close_rc;Why are having separate rc variable for close close token call?
The intent was to preserve the original inject failure status while still attempting to close the error-injection session. If ibm,errinjct fails and ibm,close-errinjct also fails, returning the close status would hide the original injection failure.
So close_rc is used only to report close failure with pr_warn(), while the function returns the status from the open/prepare/inject path.
Quoted 4 lines
Quoted 2 lines
+
+ if (session_open) {is
session_openvariable really needed?
It is mostly defensive. It avoids calling ibm,close-errinjct if ibm,open-errinjct failed before a valid session was established.
In v4, I simplified the flow so the close path is only used after a successful open. That makes the control flow clearer and avoids carrying unnecessary state.
Regards,
Narayana.
Quoted 18 lines
Quoted 17 lines
+ do {
+close_rc=rtas_call(close_token, 1, 1, NULL, + session_token);
+ } while (rtas_busy_delay(close_rc));arch/powerpc/platforms/pseries/eeh_pseries.c +10
-0+ + if (close_rc) + pr_warn("ibm,close-errinjct failed: status=%d\n", + close_rc); + } + } + +out_unlock: + mutex_unlock(&rtas_errinjct_mutex); + return rc;}
static structeeh_opspseries_eeh_ops= {
Greetings,
I have tested this patch on my KVM guest environment. I am able to inject EEH errors from host console using location code for a VFIO passthrough device.
Thank you
Tasmiya