From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, thuth@redhat.com, aik@ozlabs.ru,
Gavin Shan <gwshan@linux.vnet.ibm.com>,
qemu-ppc@nongnu.org, david@gibson.dropbear.id.au
Subject: [Qemu-devel] [PATCH v6 7/8] sPAPR: Support RTAS call ibm, {open, close}-errinjct
Date: Mon, 24 Aug 2015 22:03:28 +1000 [thread overview]
Message-ID: <1440417809-21069-8-git-send-email-gwshan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1440417809-21069-1-git-send-email-gwshan@linux.vnet.ibm.com>
This supports RTAS calls "ibm,{open,close}-errinjct" to manupliate
the token, which is passed to RTAS call "ibm,errinjct" to indicate
the valid context for error injection. Each VM is permitted to have
only one token at once and we simply have sequential number for that.
It's notable that the least bit of the token is reserved to indicate
if the token has been opened, meaning the valid token should be always
odd.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
hw/ppc/spapr.c | 6 ++++-
hw/ppc/spapr_rtas.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr.h | 9 +++++++-
3 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 06d000d..591a1a7 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1191,7 +1191,7 @@ static bool version_before_3(void *opaque, int version_id)
static const VMStateDescription vmstate_spapr = {
.name = "spapr",
- .version_id = 3,
+ .version_id = 4,
.minimum_version_id = 1,
.post_load = spapr_post_load,
.fields = (VMStateField[]) {
@@ -1202,6 +1202,10 @@ static const VMStateDescription vmstate_spapr = {
VMSTATE_UINT64_TEST(rtc_offset, sPAPRMachineState, version_before_3),
VMSTATE_PPC_TIMEBASE_V(tb, sPAPRMachineState, 2),
+
+ /* Error injection token */
+ VMSTATE_UINT32_V(errinjct_token, sPAPRMachineState, 4),
+
VMSTATE_END_OF_LIST()
},
};
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index e99e25f..64924c6 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -604,6 +604,62 @@ out:
rtas_st(rets, 0, rc);
}
+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)
+{
+ int32_t ret;
+
+ /* Sanity check on number of arguments */
+ if (nargs != 0 || nret != 2) {
+ ret = RTAS_OUT_PARAM_ERROR;
+ goto out;
+ }
+
+ /* Check if we already had token */
+ if (spapr->errinjct_token & 1) {
+ ret = RTAS_OUT_TOKEN_OPENED;
+ goto out;
+ }
+
+ /* Grab the token */
+ rtas_st(rets, 0, ++spapr->errinjct_token);
+ ret = RTAS_OUT_SUCCESS;
+out:
+ rtas_st(rets, 1, ret);
+}
+
+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 open_token;
+ int32_t ret;
+
+ /* Sanity check on number of arguments */
+ if (nargs != 1 || nret != 1) {
+ ret = RTAS_OUT_PARAM_ERROR;
+ goto out;
+ }
+
+ /* Match with the passed token */
+ open_token = rtas_ld(args, 0);
+ if (!(spapr->errinjct_token & 1) ||
+ spapr->errinjct_token != open_token) {
+ ret = RTAS_OUT_CLOSE_ERROR;
+ goto out;
+ }
+
+ spapr->errinjct_token++;
+ ret = RTAS_OUT_SUCCESS;
+out:
+ rtas_st(rets, 0, ret);
+}
+
static struct rtas_call {
const char *name;
spapr_rtas_fn fn;
@@ -754,6 +810,10 @@ static void core_rtas_register_types(void)
rtas_get_sensor_state);
spapr_rtas_register(RTAS_IBM_CONFIGURE_CONNECTOR, "ibm,configure-connector",
rtas_ibm_configure_connector);
+ 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);
}
type_init(core_rtas_register_types)
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index c75cc5e..7931e18 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -73,6 +73,9 @@ struct sPAPRMachineState {
int htab_fd;
bool htab_fd_stale;
+ /* Error injection token */
+ uint32_t errinjct_token;
+
/* RTAS state */
QTAILQ_HEAD(, sPAPRConfigureConnectorState) ccs_list;
@@ -412,6 +415,8 @@ int spapr_allocate_irq_block(int num, bool lsi, bool msi);
#define RTAS_OUT_BUSY -2
#define RTAS_OUT_PARAM_ERROR -3
#define RTAS_OUT_NOT_SUPPORTED -3
+#define RTAS_OUT_TOKEN_OPENED -4
+#define RTAS_OUT_CLOSE_ERROR -4
#define RTAS_OUT_NOT_AUTHORIZED -9002
/* RTAS tokens */
@@ -455,8 +460,10 @@ int spapr_allocate_irq_block(int num, bool lsi, bool msi);
#define RTAS_IBM_SET_SLOT_RESET (RTAS_TOKEN_BASE + 0x23)
#define RTAS_IBM_CONFIGURE_PE (RTAS_TOKEN_BASE + 0x24)
#define RTAS_IBM_SLOT_ERROR_DETAIL (RTAS_TOKEN_BASE + 0x25)
+#define RTAS_IBM_OPEN_ERRINJCT (RTAS_TOKEN_BASE + 0x26)
+#define RTAS_IBM_CLOSE_ERRINJCT (RTAS_TOKEN_BASE + 0x27)
-#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x26)
+#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x28)
/* RTAS ibm,get-system-parameter token values */
#define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20
--
2.1.0
next prev parent reply other threads:[~2015-08-24 12:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 12:03 [Qemu-devel] [PATCH v6 0/8] sPAPR: Support EEH Error Injection Gavin Shan
2015-08-24 12:03 ` [Qemu-devel] [PATCH v6 1/8] scripts: Allow include "stdint.h" in virtio headers Gavin Shan
2015-08-25 13:49 ` Thomas Huth
2015-08-24 12:03 ` [Qemu-devel] [PATCH v6 2/8] scripts: Include arch/powerpc/include/uapi/asm/eeh.h Gavin Shan
2015-08-24 12:03 ` [Qemu-devel] [PATCH v6 3/8] scripts: Submit changes while updating linux headers Gavin Shan
2015-08-24 14:08 ` Peter Maydell
2015-08-24 23:58 ` Gavin Shan
2015-08-25 15:09 ` Peter Maydell
2015-08-25 23:46 ` Gavin Shan
2015-09-01 8:05 ` Peter Maydell
2015-08-24 14:13 ` Peter Maydell
2015-08-24 23:15 ` Gavin Shan
2015-08-24 12:03 ` [Qemu-devel] [PATCH v6 4/8] Sync Linux headers from kernel 4.2.0-rc8 Gavin Shan
2015-08-24 12:03 ` [Qemu-devel] [PATCH v6 5/8] Obsolete PCI_MSIX_FLAGS_BIRMASK Gavin Shan
2015-08-24 12:03 ` [Qemu-devel] [PATCH v6 6/8] sPAPR: Introduce rtas_ldq() Gavin Shan
2015-08-25 13:55 ` Thomas Huth
2015-08-24 12:03 ` Gavin Shan [this message]
2015-08-25 14:07 ` [Qemu-devel] [PATCH v6 7/8] sPAPR: Support RTAS call ibm, {open, close}-errinjct Thomas Huth
2015-08-26 0:00 ` [Qemu-devel] [Qemu-ppc] " Gavin Shan
2015-08-24 12:03 ` [Qemu-devel] [PATCH v6 8/8] sPAPR: Support RTAS call ibm,errinjct Gavin Shan
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=1440417809-21069-8-git-send-email-gwshan@linux.vnet.ibm.com \
--to=gwshan@linux.vnet.ibm.com \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=thuth@redhat.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;
as well as URLs for NNTP newsgroup(s).