From: Narayana Murty N <nnmlinux@linux.ibm.com>
To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, mahesh@linux.ibm.com,
sbhat@linux.ibm.com, anushree.mathur@linux.vnet.ibm.com,
clg@redhat.com, sourabhjain@linux.ibm.com, adityag@linux.ibm.com,
nikhilks@linux.ibm.com
Cc: pierrick.bouvier@oss.qualcomm.com, rathc@linux.ibm.com,
npiggin@gmail.com, harshpb@linux.ibm.com,
amachhiw@linux.ibm.com, hbathini@linux.ibm.com,
shivangu@linux.ibm.com
Subject: [PATCH v5 3/6] ppc/spapr: Add support for ibm, open-errinjct and ibm, close-errinjct
Date: Tue, 1 Sep 2026 23:11:07 +0530 [thread overview]
Message-ID: <20260901174110.45356-4-nnmlinux@linux.ibm.com> (raw)
In-Reply-To: <20260901174110.45356-1-nnmlinux@linux.ibm.com>
Add RTAS handlers for ibm,open-errinjct and ibm,close-errinjct. These
calls manage exclusive access to the error-injection facility through a
simple session token mechanism: only one session may be open at a time.
ibm,open-errinjct (nargs=0, nret=2):
Returns rets[0]=token, rets[1]=status.
On success: token=1, status=RTAS_OUT_SUCCESS.
Already-open: token=0, status=RTAS_OUT_ALREADY_OPEN.
Bad args: token=0, status=RTAS_OUT_PARAM_ERROR.
ibm,close-errinjct (nargs=1, nret=1):
Takes the session token in args[0].
Returns RTAS_OUT_SUCCESS on a matching open token.
Returns RTAS_OUT_NOT_OPEN if the token is invalid or no session exists.
RTAS_IBM_OPEN_ERRINJCT and RTAS_IBM_CLOSE_ERRINJCT token values and
RTAS_OUT_ALREADY_OPEN / RTAS_OUT_NOT_OPEN return codes are added to
include/hw/ppc/spapr.h.
Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
---
include/hw/ppc/spapr.h | 8 +++++-
hw/ppc/spapr_pci.c | 57 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 47791c71bd..bcb1da5fab 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -825,8 +825,14 @@ enum rtas_err_type {
#define RTAS_IBM_NMI_INTERLOCK (RTAS_TOKEN_BASE + 0x2C)
#define RTAS_CONFIGURE_KERNEL_DUMP (RTAS_TOKEN_BASE + 0x2D)
#define RTAS_IBM_ERRINJCT (RTAS_TOKEN_BASE + 0x2E)
+#define RTAS_IBM_OPEN_ERRINJCT (RTAS_TOKEN_BASE + 0x2F)
+#define RTAS_IBM_CLOSE_ERRINJCT (RTAS_TOKEN_BASE + 0x30)
-#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x2F)
+#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x31)
+
+/* ibm,open-errinjct/ibm,close-errinjct return codes */
+#define RTAS_OUT_ALREADY_OPEN -4
+#define RTAS_OUT_NOT_OPEN -5
/* RTAS ibm,get-system-parameter token values */
#define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index cff12ef268..20cb913f12 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -836,6 +836,57 @@ param_error_exit:
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
}
+static void rtas_ibm_open_errinjct(PowerPCCPU *cpu, SpaprMachineState *spapr,
+ uint32_t token, uint32_t nargs,
+ target_ulong args, uint32_t nret,
+ target_ulong rets)
+{
+ if (nargs != 0 || nret != 2) {
+ rtas_st(rets, 0, 0);
+ rtas_st(rets, 1, RTAS_OUT_PARAM_ERROR);
+ return;
+ }
+
+ if (spapr->errinjct_token) {
+ /* Session already open: return token=0, status=ALREADY_OPEN */
+ rtas_st(rets, 0, 0);
+ rtas_st(rets, 1, RTAS_OUT_ALREADY_OPEN);
+ return;
+ }
+
+ spapr->errinjct_token = 1;
+
+ /*
+ * ibm,open-errinjct has an unusual return convention: rets[0] is the
+ * session token and rets[1] is the status code.
+ */
+ rtas_st(rets, 0, spapr->errinjct_token);
+ rtas_st(rets, 1, RTAS_OUT_SUCCESS);
+}
+
+static void rtas_ibm_close_errinjct(PowerPCCPU *cpu, SpaprMachineState *spapr,
+ uint32_t token, uint32_t nargs,
+ target_ulong args, uint32_t nret,
+ target_ulong rets)
+{
+ uint32_t o_token;
+
+ if (nargs != 1 || nret != 1) {
+ rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
+ return;
+ }
+
+ o_token = rtas_ld(args, 0);
+
+ if (!spapr->errinjct_token || o_token != spapr->errinjct_token) {
+ rtas_st(rets, 0, RTAS_OUT_NOT_OPEN);
+ return;
+ }
+
+ spapr->errinjct_token = 0;
+ rtas_st(rets, 0, RTAS_OUT_SUCCESS);
+}
+
static void pci_spapr_set_irq(void *opaque, int irq_num, int level)
{
/*
@@ -2515,6 +2566,12 @@ void spapr_pci_rtas_init(void)
spapr_rtas_register(RTAS_IBM_ERRINJCT,
"ibm,errinjct",
rtas_ibm_errinjct);
+ spapr_rtas_register(RTAS_IBM_OPEN_ERRINJCT,
+ "ibm,open-errinjct",
+ rtas_ibm_open_errinjct);
+ spapr_rtas_register(RTAS_IBM_CLOSE_ERRINJCT,
+ "ibm,close-errinjct",
+ rtas_ibm_close_errinjct);
}
static void spapr_pci_register_types(void)
--
2.51.1
next prev parent reply other threads:[~2026-09-01 17:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 17:41 [PATCH v5 0/6] ppc/spapr: Add RTAS error injection support for VFIO EEH Narayana Murty N
2026-09-01 17:41 ` [PATCH v5 1/6] ppc/spapr: Add VFIO EEH error injection backend Narayana Murty N
2026-09-01 17:41 ` [PATCH v5 2/6] ppc/spapr: Add ibm,errinjct RTAS call handler Narayana Murty N
2026-09-01 17:41 ` Narayana Murty N [this message]
2026-09-01 17:41 ` [PATCH v5 4/6] ppc/spapr: Advertise RTAS error injection call support via FDT property Narayana Murty N
2026-09-01 17:41 ` [PATCH v5 5/6] ppc/spapr: Split VFIO EEH support from general VFIO code Narayana Murty N
2026-09-01 17:41 ` [PATCH v5 6/6] MAINTAINERS: Add self as sPAPR EEH reviewer under PPC RAS 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=20260901174110.45356-4-nnmlinux@linux.ibm.com \
--to=nnmlinux@linux.ibm.com \
--cc=adityag@linux.ibm.com \
--cc=amachhiw@linux.ibm.com \
--cc=anushree.mathur@linux.vnet.ibm.com \
--cc=clg@redhat.com \
--cc=harshpb@linux.ibm.com \
--cc=hbathini@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=nikhilks@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rathc@linux.ibm.com \
--cc=sbhat@linux.ibm.com \
--cc=shivangu@linux.ibm.com \
--cc=sourabhjain@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.