From: Narayana Murty N <nnmlinux@linux.ibm.com>
To: Sourabh Jain <sourabhjain@linux.ibm.com>,
mahesh@linux.ibm.com, maddy@linux.ibm.com, mpe@ellerman.id.au,
christophe.leroy@csgroup.eu, gregkh@linuxfoundation.org,
oohall@gmail.com, npiggin@gmail.com
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
tyreld@linux.ibm.com, vaibhav@linux.ibm.com, sbhat@linux.ibm.com,
ganeshgr@linux.ibm.com, haren@linux.ibm.com, thuth@redhat.com
Subject: Re: [PATCH v2 2/5] powerpc/pseries: Add RTAS error injection buffer infrastructure
Date: Tue, 4 Aug 2026 11:27:24 +0530 [thread overview]
Message-ID: <8eda9bd3-d58c-41a0-a144-d02cb7d72a25@linux.ibm.com> (raw)
In-Reply-To: <fd32da15-9952-4d46-9c28-5c2aa87fad0c@linux.ibm.com>
On 10/06/26 8:57 AM, Sourabh Jain wrote:
>
>
> On 27/05/26 12:54, Narayana Murty N wrote:
>> Adds global infrastructure required by the injection engine:
>> - a 1KB aligned RTAS working buffer in rtas.c
>> - a spinlock to serialize buffer access
>> - UAPI definitions for error-injection tokens (added to eeh.h)
>>
>> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
>> ---
>> arch/powerpc/include/asm/rtas.h | 21 +++++++++++++++++++++
>> arch/powerpc/include/uapi/asm/eeh.h | 18 ++++++++++++++++++
>> arch/powerpc/kernel/rtas.c | 12 ++++++++++++
>> 3 files changed, 51 insertions(+)
>>
>> diff --git a/arch/powerpc/include/asm/rtas.h
>> b/arch/powerpc/include/asm/rtas.h
>> index d046bbd5017d..82512f822c7a 100644
>> --- a/arch/powerpc/include/asm/rtas.h
>> +++ b/arch/powerpc/include/asm/rtas.h
>> @@ -519,6 +519,27 @@ 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 Buffer (PAPR-compliant)
>> + * ============================================
>> + *
>> + * 1KB aligned, zero-initialized buffer for ibm,errinjct RTAS work
>> area.
>> + * Protected by rtas_errinjct_buf_lock for concurrent access safety.
>> + *
>> + * PAPR Requirement: ibm,errinjct requires a caller-allocated buffer
>> passed
>> + * via physical address. Buffer must accommodate largest error type
>> layouts:
>> + * - IOA bus error (64-bit): 8x32-bit words (32 bytes)
>> + * - All other types: <=4x32-bit words (16 bytes)
>> + *
>> + * Usage:
>> + * prepare_errinjct_buffer() -> spin_lock() -> rtas_call() ->
>> spin_unlock()
>> + *
>> + * Alignment: SZ_1K ensures PAPR firmware requirements and
>> cache-line safety.
>> + */
>> +#define RTAS_ERRINJCT_BUF_SIZE 1024
>> +extern spinlock_t rtas_errinjct_buf_lock;
>> +extern char rtas_errinjct_buf[RTAS_ERRINJCT_BUF_SIZE];
>
> The kernel has a similar buffer for userspace (named rtas_rmo_buf),
> which is allocated in the range (0, min(ppc64_rma_size,
> RTAS_INSTANTIATE_MAX)).
>
> Whereas, the base address of the statically allocated
> rtas_errinjct_buf array
> depends on the location at which the kernel is loaded, which could be
> higher than
> RTAS_INSTANTIATE_MAX.
>
> Also, things will break if the base address of rtas_errinjct_buf is
> greater than
> 4 GB. In that case, the kernel will send a truncated address, and RTAS
> may
> corrupt memory as a result.
>
> Why don't we allocate rtas_errinjct_buf in the same range where
> rtas_rmo_buf is allocated?
Yes, I do agree for the design direction and is addressed in V3 patch
https://lore.kernel.org/all/20260721033815.5300-1-nnmlinux@linux.ibm.com/
>> +
>> /* RMO buffer reserved for user-space RTAS use */
>> extern unsigned long rtas_rmo_buf;
>> diff --git a/arch/powerpc/include/uapi/asm/eeh.h
>> b/arch/powerpc/include/uapi/asm/eeh.h
>> index 3b5c47ff3fc4..86645cab2827 100644
>> --- a/arch/powerpc/include/uapi/asm/eeh.h
>> +++ b/arch/powerpc/include/uapi/asm/eeh.h
>> @@ -41,4 +41,22 @@
>> #define EEH_ERR_FUNC_DMA_WR_TARGET 19
>> #define EEH_ERR_FUNC_MAX 19
>> +/* RTAS PCI Error Injection Token Types */
>> +#define RTAS_ERR_TYPE_FATAL 0x1
>> +#define RTAS_ERR_TYPE_RECOVERED_RANDOM_EVENT 0x2
>> +#define RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT 0x3
>> +#define RTAS_ERR_TYPE_CORRUPTED_PAGE 0x4
>> +#define RTAS_ERR_TYPE_CORRUPTED_SLB 0x5
>> +#define RTAS_ERR_TYPE_TRANSLATOR_FAILURE 0x6
>> +#define RTAS_ERR_TYPE_IOA_BUS_ERROR 0x7
>> +#define RTAS_ERR_TYPE_PLATFORM_SPECIFIC 0x8
>> +#define RTAS_ERR_TYPE_CORRUPTED_DCACHE_START 0x9
>> +#define RTAS_ERR_TYPE_CORRUPTED_DCACHE_END 0xA
>> +#define RTAS_ERR_TYPE_CORRUPTED_ICACHE_START 0xB
>> +#define RTAS_ERR_TYPE_CORRUPTED_ICACHE_END 0xC
>> +#define RTAS_ERR_TYPE_CORRUPTED_TLB_START 0xD
>> +#define RTAS_ERR_TYPE_CORRUPTED_TLB_END 0xE
>> +#define RTAS_ERR_TYPE_IOA_BUS_ERROR_64 0xF
>> +#define RTAS_ERR_TYPE_UPSTREAM_IO_ERROR 0x10
>> +
>> #endif /* _ASM_POWERPC_EEH_H */
>> diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
>> index a2dd94eed9d0..c110965ea1d9 100644
>> --- a/arch/powerpc/kernel/rtas.c
>> +++ b/arch/powerpc/kernel/rtas.c
>> @@ -769,6 +769,18 @@ EXPORT_SYMBOL_GPL(rtas_data_buf);
>> unsigned long rtas_rmo_buf;
>> +/*
>> + * RTAS Error Injection Buffer - Global Definitions
>> + * Global 1KB buffer and spinlock for ibm,errinjct RTAS service.
>> + * Exported for pseries EEH error injection usage.
>> + */
>> +
>> +DEFINE_SPINLOCK(rtas_errinjct_buf_lock);
>> +EXPORT_SYMBOL_GPL(rtas_errinjct_buf_lock);
>> +
>> +char rtas_errinjct_buf[1024] __aligned(SZ_1K);
>> +EXPORT_SYMBOL_GPL(rtas_errinjct_buf);
>> +
>> /*
>> * If non-NULL, this gets called when the kernel terminates.
>> * This is done like this so rtas_flash can be a module.
>
Thanks,
Narayana
next prev parent reply other threads:[~2026-08-04 5:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 7:24 [PATCH v2 0/5] powerpc/pseries: Add full RTAS-based error injection support Narayana Murty N
2026-05-27 7:24 ` [PATCH v2 1/5] powerpc/rtas: Handle special return format for RTAS_FN_IBM_OPEN_ERRINJCT Narayana Murty N
2026-06-07 11:19 ` Sourabh Jain
2026-08-04 5:54 ` Narayana Murty N
2026-05-27 7:24 ` [PATCH v2 2/5] powerpc/pseries: Add RTAS error injection buffer infrastructure Narayana Murty N
2026-06-10 3:27 ` Sourabh Jain
2026-08-04 5:57 ` Narayana Murty N [this message]
2026-05-27 7:24 ` [PATCH v2 3/5] powerpc/pseries: Add RTAS error injection validation helpers Narayana Murty N
2026-06-07 12:17 ` Sourabh Jain
2026-08-04 6:07 ` Narayana Murty N
2026-05-27 7:24 ` [PATCH v2 4/5] powerpc/pseries: Implement RTAS error injection via pseries_eeh_err_inject Narayana Murty N
2026-06-07 13:35 ` Sourabh Jain
2026-08-04 6:30 ` Narayana Murty N
2026-06-10 3:45 ` Sourabh Jain
2026-08-04 6:37 ` Narayana Murty N
2026-05-27 7:24 ` [PATCH v2 5/5] powerpc/powernv: Map EEH error types to OPAL error injection types Narayana Murty N
2026-06-07 13:46 ` Sourabh Jain
2026-08-04 6:42 ` Narayana Murty N
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8eda9bd3-d58c-41a0-a144-d02cb7d72a25@linux.ibm.com \
--to=nnmlinux@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=ganeshgr@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=haren@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=oohall@gmail.com \
--cc=sbhat@linux.ibm.com \
--cc=sourabhjain@linux.ibm.com \
--cc=thuth@redhat.com \
--cc=tyreld@linux.ibm.com \
--cc=vaibhav@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox