* [Qemu-devel] [PATCH v3 0/3] sPAPR: Support EEH Error Injection
@ 2015-08-07 3:33 Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 1/3] linux-headers: Add eeh.h Gavin Shan
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Gavin Shan @ 2015-08-07 3:33 UTC (permalink / raw)
To: qemu-devel; +Cc: aik, qemu-ppc, Gavin Shan, david
The patchset depends on below Linux upstream commits:
commit ed3e81f ("powerpc/eeh: Move PE state constants around")
commit ec33d36 ("powerpc/eeh: Introduce eeh_pe_inject_err()")
According to PAPR specification 2.7, there're 3 RTAS calls relevent to error
injection: "ibm,open-errinjct", "ibm,close-errinjct", "ibm,errinjct". The
userland utility "errinjct" running on guest utilizes those 3 RTAS calls like
this way: Call "ibm,open-errinjct" that returns open-token, which is passed to
"ibm,errinjct" together with error specific arguments to do error injection.
Finally, to return the open-token by calling "ibm,close-errinject".
"ibm,errinjct" can be used to inject various errors, not limited to EEH errors.
However, this patchset is going to support injecting EEH errors only for VFIO
PCI devices.
=========
Changelog
=========
v2 -> v3:
* Replace random token number with incremental counter. Another boolean
variable to track if it's opened. Both of them are added to migration
stream.
* The return value from sPAPRPHBClass::eeh_inject_error() can be passed
to user directly. No need to do conversion.
* Corrected error code to RTAS_OUT_CLOSE_ERROR in rtas_ibm_errinjct().
* Don't expose error injection tokens for unsupported types.
v1 -> v2:
* Rebased to git://github.com/dgibson/qemu.git (branch: spapr-next)
* Remove specific PCI error types in hw/ppc/spapr.h. Use those macros
asm-powerpc/eeh.h instead.
Gavin Shan (3):
linux-headers: Add eeh.h
sPAPR: Support RTAS call ibm, {open, close}-errinjct
sPAPR: Support RTAS call ibm,errinjct
hw/ppc/spapr.c | 5 ++
hw/ppc/spapr_pci.c | 36 ++++++++++
hw/ppc/spapr_pci_vfio.c | 56 ++++++++++++++++
hw/ppc/spapr_rtas.c | 143 ++++++++++++++++++++++++++++++++++++++++
include/hw/pci-host/spapr.h | 2 +
include/hw/ppc/spapr.h | 17 ++++-
linux-headers/asm-powerpc/eeh.h | 56 ++++++++++++++++
7 files changed, 314 insertions(+), 1 deletion(-)
create mode 100644 linux-headers/asm-powerpc/eeh.h
--
2.1.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v3 1/3] linux-headers: Add eeh.h
2015-08-07 3:33 [Qemu-devel] [PATCH v3 0/3] sPAPR: Support EEH Error Injection Gavin Shan
@ 2015-08-07 3:33 ` Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 3/3] sPAPR: Support RTAS call ibm,errinjct Gavin Shan
2 siblings, 0 replies; 10+ messages in thread
From: Gavin Shan @ 2015-08-07 3:33 UTC (permalink / raw)
To: qemu-devel; +Cc: aik, qemu-ppc, Gavin Shan, david
The header file was introduced by following Linux upstream commits:
commit ed3e81f ("powerpc/eeh: Move PE state constants around")
commit ec33d36 ("powerpc/eeh: Introduce eeh_pe_inject_err()")
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
| 56 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 linux-headers/asm-powerpc/eeh.h
--git a/linux-headers/asm-powerpc/eeh.h b/linux-headers/asm-powerpc/eeh.h
new file mode 100644
index 0000000..291b7d1
--- /dev/null
+++ b/linux-headers/asm-powerpc/eeh.h
@@ -0,0 +1,56 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2015
+ *
+ * Authors: Gavin Shan <gwshan@linux.vnet.ibm.com>
+ */
+
+#ifndef _ASM_POWERPC_EEH_H
+#define _ASM_POWERPC_EEH_H
+
+/* PE states */
+#define EEH_PE_STATE_NORMAL 0 /* Normal state */
+#define EEH_PE_STATE_RESET 1 /* PE reset asserted */
+#define EEH_PE_STATE_STOPPED_IO_DMA 2 /* Frozen PE */
+#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 */
+#define EEH_ERR_FUNC_MIN 0
+#define EEH_ERR_FUNC_LD_MEM_ADDR 0 /* Memory load */
+#define EEH_ERR_FUNC_LD_MEM_DATA 1
+#define EEH_ERR_FUNC_LD_IO_ADDR 2 /* IO load */
+#define EEH_ERR_FUNC_LD_IO_DATA 3
+#define EEH_ERR_FUNC_LD_CFG_ADDR 4 /* Config load */
+#define EEH_ERR_FUNC_LD_CFG_DATA 5
+#define EEH_ERR_FUNC_ST_MEM_ADDR 6 /* Memory store */
+#define EEH_ERR_FUNC_ST_MEM_DATA 7
+#define EEH_ERR_FUNC_ST_IO_ADDR 8 /* IO store */
+#define EEH_ERR_FUNC_ST_IO_DATA 9
+#define EEH_ERR_FUNC_ST_CFG_ADDR 10 /* Config store */
+#define EEH_ERR_FUNC_ST_CFG_DATA 11
+#define EEH_ERR_FUNC_DMA_RD_ADDR 12 /* DMA read */
+#define EEH_ERR_FUNC_DMA_RD_DATA 13
+#define EEH_ERR_FUNC_DMA_RD_MASTER 14
+#define EEH_ERR_FUNC_DMA_RD_TARGET 15
+#define EEH_ERR_FUNC_DMA_WR_ADDR 16 /* DMA write */
+#define EEH_ERR_FUNC_DMA_WR_DATA 17
+#define EEH_ERR_FUNC_DMA_WR_MASTER 18
+#define EEH_ERR_FUNC_DMA_WR_TARGET 19
+#define EEH_ERR_FUNC_MAX 19
+
+#endif /* _ASM_POWERPC_EEH_H */
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct
2015-08-07 3:33 [Qemu-devel] [PATCH v3 0/3] sPAPR: Support EEH Error Injection Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 1/3] linux-headers: Add eeh.h Gavin Shan
@ 2015-08-07 3:33 ` Gavin Shan
2015-08-07 16:04 ` Alexey Kardashevskiy
2015-08-10 12:24 ` David Gibson
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 3/3] sPAPR: Support RTAS call ibm,errinjct Gavin Shan
2 siblings, 2 replies; 10+ messages in thread
From: Gavin Shan @ 2015-08-07 3:33 UTC (permalink / raw)
To: qemu-devel; +Cc: aik, qemu-ppc, Gavin Shan, david
The patch 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 one
random number for that.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
hw/ppc/spapr.c | 5 ++++
hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr.h | 10 +++++++-
3 files changed, 80 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index dfd808f..1ebd0b2 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1225,6 +1225,11 @@ 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_BOOL(is_errinjct_opened, sPAPRMachineState),
+ VMSTATE_UINT32(errinjct_next_token, sPAPRMachineState),
+
VMSTATE_END_OF_LIST()
},
};
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index e99e25f..f1b92ca 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -604,6 +604,68 @@ 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->is_errinjct_opened) {
+ ret = RTAS_OUT_TOKEN_OPENED;
+ goto out;
+ }
+
+ /* Grab the token */
+ spapr->is_errinjct_opened = true;
+ rtas_st(rets, 0, spapr->errinjct_next_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;
+ }
+
+ /* Check if we had opened token */
+ if (!spapr->is_errinjct_opened) {
+ ret = RTAS_OUT_CLOSE_ERROR;
+ goto out;
+ }
+
+ /* Match with the passed token */
+ open_token = rtas_ld(args, 0);
+ if (spapr->errinjct_next_token != (open_token + 1)) {
+ ret = RTAS_OUT_CLOSE_ERROR;
+ goto out;
+ }
+
+ spapr->is_errinjct_opened = false;
+ ret = RTAS_OUT_SUCCESS;
+out:
+ rtas_st(rets, 0, ret);
+}
+
static struct rtas_call {
const char *name;
spapr_rtas_fn fn;
@@ -754,6 +816,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 b6cb0d0..8ecf127 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -73,6 +73,10 @@ struct sPAPRMachineState {
int htab_fd;
bool htab_fd_stale;
+ /* Error injection token */
+ bool is_errinjct_opened;
+ uint32_t errinjct_next_token;
+
/* RTAS state */
QTAILQ_HEAD(, sPAPRConfigureConnectorState) ccs_list;
@@ -412,6 +416,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 +461,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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v3 3/3] sPAPR: Support RTAS call ibm,errinjct
2015-08-07 3:33 [Qemu-devel] [PATCH v3 0/3] sPAPR: Support EEH Error Injection Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 1/3] linux-headers: Add eeh.h Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct Gavin Shan
@ 2015-08-07 3:33 ` Gavin Shan
2 siblings, 0 replies; 10+ messages in thread
From: Gavin Shan @ 2015-08-07 3:33 UTC (permalink / raw)
To: qemu-devel; +Cc: aik, qemu-ppc, Gavin Shan, david
The patch supports RTAS call "ibm,errinjct" to allow injecting
EEH errors to VFIO PCI devices. The implementation is similiar
to EEH support for VFIO PCI devices: The RTAS request is captured
by QEMU and routed to sPAPRPHBClass::eeh_inject_error() where the
request is translated to VFIO container IOCTL command to be handled
by the host.
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
hw/ppc/spapr_pci.c | 36 +++++++++++++++++++++
hw/ppc/spapr_pci_vfio.c | 56 +++++++++++++++++++++++++++++++++
hw/ppc/spapr_rtas.c | 77 +++++++++++++++++++++++++++++++++++++++++++++
include/hw/pci-host/spapr.h | 2 ++
include/hw/ppc/spapr.h | 9 +++++-
5 files changed, 179 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index cfd3b7b..050c3ea 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -682,6 +682,42 @@ param_error_exit:
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
}
+int spapr_rtas_errinjct_ioa(sPAPRMachineState *spapr,
+ target_ulong param_buf,
+ bool is_64bits)
+{
+ sPAPRPHBState *sphb;
+ sPAPRPHBClass *spc;
+ uint64_t buid, addr, mask;
+ uint32_t func;
+
+ if (is_64bits) {
+ addr = ((uint64_t)rtas_ld(param_buf, 0) << 32) | rtas_ld(param_buf, 1);
+ mask = ((uint64_t)rtas_ld(param_buf, 2) << 32) | rtas_ld(param_buf, 3);
+ buid = ((uint64_t)rtas_ld(param_buf, 5) << 32) | rtas_ld(param_buf, 6);
+ func = rtas_ld(param_buf, 7);
+ } else {
+ addr = rtas_ld(param_buf, 0);
+ mask = rtas_ld(param_buf, 1);
+ buid = ((uint64_t)rtas_ld(param_buf, 3) << 32) | rtas_ld(param_buf, 4);
+ func = rtas_ld(param_buf, 5);
+ }
+
+ /* Find PHB */
+ sphb = spapr_pci_find_phb(spapr, buid);
+ if (!sphb) {
+ return RTAS_OUT_PARAM_ERROR;
+ }
+
+ spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
+ if (!spc->eeh_inject_error) {
+ return RTAS_OUT_PARAM_ERROR;
+ }
+
+ /* Handle the request */
+ return spc->eeh_inject_error(sphb, func, addr, mask, is_64bits);
+}
+
static int pci_spapr_swizzle(int slot, int pin)
{
return (slot + pin) % PCI_NUM_PINS;
diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
index cca45ed..a3674ee 100644
--- a/hw/ppc/spapr_pci_vfio.c
+++ b/hw/ppc/spapr_pci_vfio.c
@@ -17,6 +17,8 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <asm/eeh.h>
+
#include "hw/ppc/spapr.h"
#include "hw/pci-host/spapr.h"
#include "hw/pci/msix.h"
@@ -250,6 +252,59 @@ static int spapr_phb_vfio_eeh_configure(sPAPRPHBState *sphb)
return RTAS_OUT_SUCCESS;
}
+static int spapr_phb_vfio_eeh_inject_error(sPAPRPHBState *sphb,
+ uint32_t func, uint64_t addr,
+ uint64_t mask, bool is_64bits)
+{
+ sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
+ struct vfio_eeh_pe_op op = {
+ .op = VFIO_EEH_PE_INJECT_ERR,
+ .argsz = sizeof(op)
+ };
+ int ret = RTAS_OUT_SUCCESS;
+
+ op.err.type = is_64bits ? EEH_ERR_TYPE_64 : EEH_ERR_TYPE_32;
+ op.err.addr = addr;
+ op.err.mask = mask;
+
+ switch (func) {
+ case EEH_ERR_FUNC_LD_MEM_ADDR:
+ case EEH_ERR_FUNC_LD_MEM_DATA:
+ case EEH_ERR_FUNC_LD_IO_ADDR:
+ case EEH_ERR_FUNC_LD_IO_DATA:
+ case EEH_ERR_FUNC_LD_CFG_ADDR:
+ case EEH_ERR_FUNC_LD_CFG_DATA:
+ case EEH_ERR_FUNC_ST_MEM_ADDR:
+ case EEH_ERR_FUNC_ST_MEM_DATA:
+ case EEH_ERR_FUNC_ST_IO_ADDR:
+ case EEH_ERR_FUNC_ST_IO_DATA:
+ case EEH_ERR_FUNC_ST_CFG_ADDR:
+ case EEH_ERR_FUNC_ST_CFG_DATA:
+ case EEH_ERR_FUNC_DMA_RD_ADDR:
+ case EEH_ERR_FUNC_DMA_RD_DATA:
+ case EEH_ERR_FUNC_DMA_RD_MASTER:
+ case EEH_ERR_FUNC_DMA_RD_TARGET:
+ case EEH_ERR_FUNC_DMA_WR_ADDR:
+ case EEH_ERR_FUNC_DMA_WR_DATA:
+ case EEH_ERR_FUNC_DMA_WR_MASTER:
+ op.err.func = func;
+ break;
+ default:
+ ret = RTAS_OUT_PARAM_ERROR;
+ goto out;
+ }
+
+ if (vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
+ VFIO_EEH_PE_OP, &op) < 0) {
+ ret = RTAS_OUT_HW_ERROR;
+ goto out;
+ }
+
+ ret = RTAS_OUT_SUCCESS;
+out:
+ return ret;
+}
+
static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -262,6 +317,7 @@ static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data)
spc->eeh_get_state = spapr_phb_vfio_eeh_get_state;
spc->eeh_reset = spapr_phb_vfio_eeh_reset;
spc->eeh_configure = spapr_phb_vfio_eeh_configure;
+ spc->eeh_inject_error = spapr_phb_vfio_eeh_inject_error;
}
static const TypeInfo spapr_phb_vfio_info = {
diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index f1b92ca..a32bbbd 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -632,6 +632,54 @@ out:
rtas_st(rets, 1, ret);
}
+static void rtas_ibm_errinjct(PowerPCCPU *cpu,
+ sPAPRMachineState *spapr,
+ uint32_t token, uint32_t nargs,
+ target_ulong args, uint32_t nret,
+ target_ulong rets)
+{
+ target_ulong param_buf;
+ uint32_t type, open_token;
+ int32_t ret;
+
+ /* Sanity check on number of arguments */
+ if ((nargs != 3) || (nret != 1)) {
+ ret = RTAS_OUT_PARAM_ERROR;
+ goto out;
+ }
+
+ /* Check if we have opened token */
+ open_token = rtas_ld(args, 1);
+ if (!spapr->is_errinjct_opened ||
+ spapr->errinjct_next_token != (open_token + 1)) {
+ ret = RTAS_OUT_CLOSE_ERROR;
+ goto out;
+ }
+
+ /* The parameter buffer should be 1KB aligned */
+ param_buf = rtas_ld(args, 2);
+ if (param_buf & 0x3ff) {
+ ret = RTAS_OUT_PARAM_ERROR;
+ goto out;
+ }
+
+ /* Check the error type */
+ type = rtas_ld(args, 0);
+ switch (type) {
+ case RTAS_ERRINJCT_TYPE_IOA_BUS_ERROR:
+ ret = spapr_rtas_errinjct_ioa(spapr, param_buf, false);
+ break;
+ case RTAS_ERRINJCT_TYPE_IOA_BUS_ERROR64:
+ ret = spapr_rtas_errinjct_ioa(spapr, param_buf, true);
+ break;
+ default:
+ ret = RTAS_OUT_PARAM_ERROR;
+ }
+
+out:
+ rtas_st(rets, 0, ret);
+}
+
static void rtas_ibm_close_errinjct(PowerPCCPU *cpu,
sPAPRMachineState *spapr,
uint32_t token, uint32_t nargs,
@@ -723,6 +771,33 @@ int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr,
int i;
uint32_t lrdr_capacity[5];
MachineState *machine = MACHINE(qdev_get_machine());
+ char errinjct_tokens[1024];
+ int fdt_offset, offset;
+ const int tokens[] = {
+ RTAS_ERRINJCT_TYPE_IOA_BUS_ERROR,
+ RTAS_ERRINJCT_TYPE_IOA_BUS_ERROR64
+ };
+ const char *token_strings[] = {
+ "ioa-bus-error",
+ "ioa-bus-error-64"
+ };
+
+ /* ibm,errinjct-tokens */
+ offset = 0;
+ for (i = 0; i < ARRAY_SIZE(tokens); i++) {
+ offset += sprintf(errinjct_tokens + offset, "%s", token_strings[i]);
+ errinjct_tokens[offset++] = '\0';
+ *(int *)(&errinjct_tokens[offset]) = tokens[i];
+ offset += sizeof(int);
+ }
+
+ fdt_offset = fdt_path_offset(fdt, "/rtas");
+ ret = fdt_setprop(fdt, fdt_offset, "ibm,errinjct-tokens",
+ errinjct_tokens, offset);
+ if (ret < 0) {
+ fprintf(stderr, "Couldn't add ibm,errinjct-tokens\n");
+ return ret;
+ }
ret = fdt_add_mem_rsv(fdt, rtas_addr, rtas_size);
if (ret < 0) {
@@ -818,6 +893,8 @@ static void core_rtas_register_types(void)
rtas_ibm_configure_connector);
spapr_rtas_register(RTAS_IBM_OPEN_ERRINJCT, "ibm,open-errinjct",
rtas_ibm_open_errinjct);
+ spapr_rtas_register(RTAS_IBM_ERRINJCT, "ibm,errinjct",
+ rtas_ibm_errinjct);
spapr_rtas_register(RTAS_IBM_CLOSE_ERRINJCT, "ibm,close-errinjct",
rtas_ibm_close_errinjct);
}
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index 5322b56..069300d 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -53,6 +53,8 @@ struct sPAPRPHBClass {
int (*eeh_get_state)(sPAPRPHBState *sphb, int *state);
int (*eeh_reset)(sPAPRPHBState *sphb, int option);
int (*eeh_configure)(sPAPRPHBState *sphb);
+ int (*eeh_inject_error)(sPAPRPHBState *sphb, uint32_t func,
+ uint64_t addr, uint64_t mask, bool is_64bits);
};
typedef struct spapr_pci_msi {
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 8ecf127..10a960e 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -409,6 +409,10 @@ int spapr_allocate_irq_block(int num, bool lsi, bool msi);
#define RTAS_SLOT_TEMP_ERR_LOG 1
#define RTAS_SLOT_PERM_ERR_LOG 2
+/* ibm,errinjct */
+#define RTAS_ERRINJCT_TYPE_IOA_BUS_ERROR 7
+#define RTAS_ERRINJCT_TYPE_IOA_BUS_ERROR64 8
+
/* RTAS return codes */
#define RTAS_OUT_SUCCESS 0
#define RTAS_OUT_NO_ERRORS_FOUND 1
@@ -463,8 +467,9 @@ int spapr_allocate_irq_block(int num, bool lsi, bool msi);
#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_IBM_ERRINJCT (RTAS_TOKEN_BASE + 0x28)
-#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x28)
+#define RTAS_TOKEN_MAX (RTAS_TOKEN_BASE + 0x29)
/* RTAS ibm,get-system-parameter token values */
#define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS 20
@@ -596,6 +601,8 @@ int spapr_dma_dt(void *fdt, int node_off, const char *propname,
int spapr_tcet_dma_dt(void *fdt, int node_off, const char *propname,
sPAPRTCETable *tcet);
void spapr_pci_switch_vga(bool big_endian);
+int spapr_rtas_errinjct_ioa(sPAPRMachineState *spapr,
+ target_ulong param_buf, bool is_64bits);
void spapr_hotplug_req_add_event(sPAPRDRConnector *drc);
void spapr_hotplug_req_remove_event(sPAPRDRConnector *drc);
--
2.1.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct Gavin Shan
@ 2015-08-07 16:04 ` Alexey Kardashevskiy
2015-08-09 12:08 ` Gavin Shan
2015-08-10 12:24 ` David Gibson
1 sibling, 1 reply; 10+ messages in thread
From: Alexey Kardashevskiy @ 2015-08-07 16:04 UTC (permalink / raw)
To: Gavin Shan, qemu-devel; +Cc: qemu-ppc, david
On 08/07/2015 01:33 PM, Gavin Shan wrote:
> The patch 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 one
> random number for that.
>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
> hw/ppc/spapr.c | 5 ++++
> hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
> include/hw/ppc/spapr.h | 10 +++++++-
> 3 files changed, 80 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index dfd808f..1ebd0b2 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1225,6 +1225,11 @@ 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_BOOL(is_errinjct_opened, sPAPRMachineState),
> + VMSTATE_UINT32(errinjct_next_token, sPAPRMachineState),
> +
> VMSTATE_END_OF_LIST()
> },
> };
> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
> index e99e25f..f1b92ca 100644
> --- a/hw/ppc/spapr_rtas.c
> +++ b/hw/ppc/spapr_rtas.c
> @@ -604,6 +604,68 @@ 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->is_errinjct_opened) {
> + ret = RTAS_OUT_TOKEN_OPENED;
> + goto out;
> + }
> +
> + /* Grab the token */
> + spapr->is_errinjct_opened = true;
> + rtas_st(rets, 0, spapr->errinjct_next_token++);
If you did "++spapr->errinjct_next_token" (or just moved to a separate line
before rtas_st())...
> + 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;
> + }
> +
> + /* Check if we had opened token */
> + if (!spapr->is_errinjct_opened) {
> + ret = RTAS_OUT_CLOSE_ERROR;
> + goto out;
> + }
> +
> + /* Match with the passed token */
> + open_token = rtas_ld(args, 0);
> + if (spapr->errinjct_next_token != (open_token + 1)) {
... you would not need "+ 1" here.
> + ret = RTAS_OUT_CLOSE_ERROR;
> + goto out;
> + }
> +
> + spapr->is_errinjct_opened = false;
> + ret = RTAS_OUT_SUCCESS;
> +out:
> + rtas_st(rets, 0, ret);
> +}
> +
> static struct rtas_call {
> const char *name;
> spapr_rtas_fn fn;
> @@ -754,6 +816,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 b6cb0d0..8ecf127 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -73,6 +73,10 @@ struct sPAPRMachineState {
> int htab_fd;
> bool htab_fd_stale;
>
> + /* Error injection token */
> + bool is_errinjct_opened;
> + uint32_t errinjct_next_token;
> +
> /* RTAS state */
> QTAILQ_HEAD(, sPAPRConfigureConnectorState) ccs_list;
>
> @@ -412,6 +416,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 +461,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
>
--
Alexey
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct
2015-08-07 16:04 ` Alexey Kardashevskiy
@ 2015-08-09 12:08 ` Gavin Shan
0 siblings, 0 replies; 10+ messages in thread
From: Gavin Shan @ 2015-08-09 12:08 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: david, qemu-ppc, Gavin Shan, qemu-devel
On Sat, Aug 08, 2015 at 02:04:17AM +1000, Alexey Kardashevskiy wrote:
>On 08/07/2015 01:33 PM, Gavin Shan wrote:
>>The patch 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 one
>>random number for that.
>>
>>Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>>---
>> hw/ppc/spapr.c | 5 ++++
>> hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
>> include/hw/ppc/spapr.h | 10 +++++++-
>> 3 files changed, 80 insertions(+), 1 deletion(-)
>>
>>diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>>index dfd808f..1ebd0b2 100644
>>--- a/hw/ppc/spapr.c
>>+++ b/hw/ppc/spapr.c
>>@@ -1225,6 +1225,11 @@ 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_BOOL(is_errinjct_opened, sPAPRMachineState),
>>+ VMSTATE_UINT32(errinjct_next_token, sPAPRMachineState),
>>+
>> VMSTATE_END_OF_LIST()
>> },
>> };
>>diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
>>index e99e25f..f1b92ca 100644
>>--- a/hw/ppc/spapr_rtas.c
>>+++ b/hw/ppc/spapr_rtas.c
>>@@ -604,6 +604,68 @@ 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->is_errinjct_opened) {
>>+ ret = RTAS_OUT_TOKEN_OPENED;
>>+ goto out;
>>+ }
>>+
>>+ /* Grab the token */
>>+ spapr->is_errinjct_opened = true;
>>+ rtas_st(rets, 0, spapr->errinjct_next_token++);
>
>
>If you did "++spapr->errinjct_next_token" (or just moved to a separate line
>before rtas_st())...
>
>
>
>>+ 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;
>>+ }
>>+
>>+ /* Check if we had opened token */
>>+ if (!spapr->is_errinjct_opened) {
>>+ ret = RTAS_OUT_CLOSE_ERROR;
>>+ goto out;
>>+ }
>>+
>>+ /* Match with the passed token */
>>+ open_token = rtas_ld(args, 0);
>>+ if (spapr->errinjct_next_token != (open_token + 1)) {
>
>
>... you would not need "+ 1" here.
>
Ok. Then it should be renamed to "errinject_current_token", or just
"errinjct_token". I prefer later one. In that case, the token will
start from 1, not 0.
Thanks,
Gavin
>
>>+ ret = RTAS_OUT_CLOSE_ERROR;
>>+ goto out;
>>+ }
>>+
>>+ spapr->is_errinjct_opened = false;
>>+ ret = RTAS_OUT_SUCCESS;
>>+out:
>>+ rtas_st(rets, 0, ret);
>>+}
>>+
>> static struct rtas_call {
>> const char *name;
>> spapr_rtas_fn fn;
>>@@ -754,6 +816,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 b6cb0d0..8ecf127 100644
>>--- a/include/hw/ppc/spapr.h
>>+++ b/include/hw/ppc/spapr.h
>>@@ -73,6 +73,10 @@ struct sPAPRMachineState {
>> int htab_fd;
>> bool htab_fd_stale;
>>
>>+ /* Error injection token */
>>+ bool is_errinjct_opened;
>>+ uint32_t errinjct_next_token;
>>+
>> /* RTAS state */
>> QTAILQ_HEAD(, sPAPRConfigureConnectorState) ccs_list;
>>
>>@@ -412,6 +416,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 +461,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
>>
>
>
>--
>Alexey
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct Gavin Shan
2015-08-07 16:04 ` Alexey Kardashevskiy
@ 2015-08-10 12:24 ` David Gibson
2015-08-11 0:57 ` Gavin Shan
1 sibling, 1 reply; 10+ messages in thread
From: David Gibson @ 2015-08-10 12:24 UTC (permalink / raw)
To: Gavin Shan; +Cc: aik, qemu-ppc, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]
On Fri, Aug 07, 2015 at 01:33:32PM +1000, Gavin Shan wrote:
> The patch 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 one
> random number for that.
>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
> hw/ppc/spapr.c | 5 ++++
> hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
> include/hw/ppc/spapr.h | 10 +++++++-
> 3 files changed, 80 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index dfd808f..1ebd0b2 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1225,6 +1225,11 @@ 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_BOOL(is_errinjct_opened, sPAPRMachineState),
> + VMSTATE_UINT32(errinjct_next_token, sPAPRMachineState),
Because you're adding fields to the vmstate you'll need to define a
new version number and make these fields only considered in the new
version.
Technically you only need to transfer whether the token is open, and
*if* it is open the current token value. Not sure if it's worth
restricting to that though.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct
2015-08-10 12:24 ` David Gibson
@ 2015-08-11 0:57 ` Gavin Shan
2015-08-11 1:54 ` Alexey Kardashevskiy
0 siblings, 1 reply; 10+ messages in thread
From: Gavin Shan @ 2015-08-11 0:57 UTC (permalink / raw)
To: David Gibson; +Cc: aik, qemu-ppc, Gavin Shan, qemu-devel
On Mon, Aug 10, 2015 at 10:24:56PM +1000, David Gibson wrote:
>On Fri, Aug 07, 2015 at 01:33:32PM +1000, Gavin Shan wrote:
>> The patch 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 one
>> random number for that.
>>
>> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>> ---
>> hw/ppc/spapr.c | 5 ++++
>> hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
>> include/hw/ppc/spapr.h | 10 +++++++-
>> 3 files changed, 80 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index dfd808f..1ebd0b2 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -1225,6 +1225,11 @@ 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_BOOL(is_errinjct_opened, sPAPRMachineState),
>> + VMSTATE_UINT32(errinjct_next_token, sPAPRMachineState),
>
>Because you're adding fields to the vmstate you'll need to define a
>new version number and make these fields only considered in the new
>version.
>
Agree, do we have an example for me to refer to?
>Technically you only need to transfer whether the token is open, and
>*if* it is open the current token value. Not sure if it's worth
>restricting to that though.
>
It would be fine to transfer the token even it's closed, I think.
Thanks,
Gavin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct
2015-08-11 0:57 ` Gavin Shan
@ 2015-08-11 1:54 ` Alexey Kardashevskiy
2015-08-13 1:00 ` Gavin Shan
0 siblings, 1 reply; 10+ messages in thread
From: Alexey Kardashevskiy @ 2015-08-11 1:54 UTC (permalink / raw)
To: Gavin Shan, David Gibson; +Cc: qemu-ppc, qemu-devel
On 08/11/2015 10:57 AM, Gavin Shan wrote:
> On Mon, Aug 10, 2015 at 10:24:56PM +1000, David Gibson wrote:
>> On Fri, Aug 07, 2015 at 01:33:32PM +1000, Gavin Shan wrote:
>>> The patch 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 one
>>> random number for that.
>>>
>>> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>>> ---
>>> hw/ppc/spapr.c | 5 ++++
>>> hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>> include/hw/ppc/spapr.h | 10 +++++++-
>>> 3 files changed, 80 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>>> index dfd808f..1ebd0b2 100644
>>> --- a/hw/ppc/spapr.c
>>> +++ b/hw/ppc/spapr.c
>>> @@ -1225,6 +1225,11 @@ 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_BOOL(is_errinjct_opened, sPAPRMachineState),
>>> + VMSTATE_UINT32(errinjct_next_token, sPAPRMachineState),
>>
>> Because you're adding fields to the vmstate you'll need to define a
>> new version number and make these fields only considered in the new
>> version.
>>
>
> Agree, do we have an example for me to refer to?
Technically it is enough to send a token which is "not opened" when it is
zero. The chunk below demonstrates versions use.
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index e046265..e568d41 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1213,17 +1213,21 @@ 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[]) {
/* used to be @next_irq */
VMSTATE_UNUSED_BUFFER(version_before_3, 0, 4),
+
/* RTC offset */
VMSTATE_UINT64_TEST(rtc_offset, sPAPRMachineState, version_before_3),
VMSTATE_PPC_TIMEBASE_V(tb, sPAPRMachineState, 2),
+
+ /* Error injection token */
+ VMSTATE_UINT32_V(errinjct_next_token, sPAPRMachineState, 4),
VMSTATE_END_OF_LIST()
},
};
>> Technically you only need to transfer whether the token is open, and
>> *if* it is open the current token value. Not sure if it's worth
>> restricting to that though.
>>
>
> It would be fine to transfer the token even it's closed, I think.
--
Alexey
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct
2015-08-11 1:54 ` Alexey Kardashevskiy
@ 2015-08-13 1:00 ` Gavin Shan
0 siblings, 0 replies; 10+ messages in thread
From: Gavin Shan @ 2015-08-13 1:00 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: qemu-devel, qemu-ppc, Gavin Shan, David Gibson
On Tue, Aug 11, 2015 at 11:54:08AM +1000, Alexey Kardashevskiy wrote:
>On 08/11/2015 10:57 AM, Gavin Shan wrote:
>>On Mon, Aug 10, 2015 at 10:24:56PM +1000, David Gibson wrote:
>>>On Fri, Aug 07, 2015 at 01:33:32PM +1000, Gavin Shan wrote:
>>>>The patch 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 one
>>>>random number for that.
>>>>
>>>>Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>>>>---
>>>> hw/ppc/spapr.c | 5 ++++
>>>> hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>>> include/hw/ppc/spapr.h | 10 +++++++-
>>>> 3 files changed, 80 insertions(+), 1 deletion(-)
>>>>
>>>>diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>>>>index dfd808f..1ebd0b2 100644
>>>>--- a/hw/ppc/spapr.c
>>>>+++ b/hw/ppc/spapr.c
>>>>@@ -1225,6 +1225,11 @@ 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_BOOL(is_errinjct_opened, sPAPRMachineState),
>>>>+ VMSTATE_UINT32(errinjct_next_token, sPAPRMachineState),
>>>
>>>Because you're adding fields to the vmstate you'll need to define a
>>>new version number and make these fields only considered in the new
>>>version.
>>>
>>
>>Agree, do we have an example for me to refer to?
>
>
>Technically it is enough to send a token which is "not opened" when it is
>zero. The chunk below demonstrates versions use.
>
Agree. we don't have to track the token is opened or not. It's fine to
have "not opened" state in the target VM. I'll integrate this piece of
code into next revision. Thanks!
>diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>index e046265..e568d41 100644
>--- a/hw/ppc/spapr.c
>+++ b/hw/ppc/spapr.c
>@@ -1213,17 +1213,21 @@ 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[]) {
> /* used to be @next_irq */
> VMSTATE_UNUSED_BUFFER(version_before_3, 0, 4),
>
>+
> /* RTC offset */
> VMSTATE_UINT64_TEST(rtc_offset, sPAPRMachineState, version_before_3),
>
> VMSTATE_PPC_TIMEBASE_V(tb, sPAPRMachineState, 2),
>+
>+ /* Error injection token */
>+ VMSTATE_UINT32_V(errinjct_next_token, sPAPRMachineState, 4),
> VMSTATE_END_OF_LIST()
> },
> };
>
>
>
>>>Technically you only need to transfer whether the token is open, and
>>>*if* it is open the current token value. Not sure if it's worth
>>>restricting to that though.
>>>
>>
>>It would be fine to transfer the token even it's closed, I think.
>
Thanks,
Gavin
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-08-13 1:08 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-07 3:33 [Qemu-devel] [PATCH v3 0/3] sPAPR: Support EEH Error Injection Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 1/3] linux-headers: Add eeh.h Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 2/3] sPAPR: Support RTAS call ibm, {open, close}-errinjct Gavin Shan
2015-08-07 16:04 ` Alexey Kardashevskiy
2015-08-09 12:08 ` Gavin Shan
2015-08-10 12:24 ` David Gibson
2015-08-11 0:57 ` Gavin Shan
2015-08-11 1:54 ` Alexey Kardashevskiy
2015-08-13 1:00 ` Gavin Shan
2015-08-07 3:33 ` [Qemu-devel] [PATCH v3 3/3] sPAPR: Support RTAS call ibm,errinjct Gavin Shan
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).