sPAPR: Support EEH Error Injection
v4 cover sPAPR: Support EEH Error Injection
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
=========
v3 -> v4:
* To record currently opened token, not next one as suggested by Alexey.
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
Signature · 1 line
2.1.0
PATCH v4 1/3 linux-headers: Add eeh.h
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()")
--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.h
linux-headers/asm-powerpc/eeh.h new file +56 -0
@@ -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 <[email protected]> +*/ + +#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 */
Signature · 1 line
2.1.0
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
Quoted 10 lines · Gavin Shan
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 <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.h
Shouldn't this be added by updating scripts/update-linux-headers.sh and then doing a plain "synchronize headers against kernel version $X" ? Otherwise you won't get any future changes to this file.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Gavin Shan
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()")
Quoted 8 lines
Quoted 5 lines
Signed-off-by Gavin Shan <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)create mode 100644
linux-headers/asm-powerpc/eeh.hShouldn't this be added by updating
scripts/update-linux-headers.shand then doing a plain "synchronize headers against kernel version $X" ?
I also thought this is the protocol but then I looked into the git history and discovered this is not always the case :)
Quoted 5 lines
Otherwise you won't get any future changes to this file.
thanks
-- PMM
Signature · 1 line
Alexey
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
Quoted 13 lines · Alexey Kardashevskiy
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Gavin Shan
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 <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.h
Quoted 8 lines
Quoted 2 lines
Shouldn't this be added by updating
scripts/update-linux-headers.shand then doing a plain "synchronize headers against kernel version $X" ?I also thought this is the protocol but then I looked into the git history and discovered this is not always the case :)
So should I use scripts/update-linux-headers.sh or what I had is fine?
Quoted 2 lines
Quoted 2 lines
Otherwise you won't get any future changes to this file.
Thanks,
Gavin
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
Quoted 18 lines · Gavin Shan
Quoted 17 lines · Alexey Kardashevskiy
Quoted 14 lines · Peter Maydell
Quoted 10 lines · Gavin Shan
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 <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.hShouldn't this be added by updating
scripts/update-linux-headers.shand then doing a plain "synchronize headers against kernel version $X" ?
Quoted 7 lines
Quoted 4 lines
I also thought this is the protocol but then I looked into the git history and discovered this is not always the case :)
So should I use
scripts/update-linux-headers.shor what I had is fine?
Please use update-linux-headers.sh - and make sure you also update the script itself (if necessary) so it will pull in future updates to eeh.h
Signature · 4 lines
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
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
Quoted 24 lines · David Gibson
Quoted 23 lines · Gavin Shan
Quoted 21 lines · Alexey Kardashevskiy
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Gavin Shan
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()")Quoted 8 lines
Quoted 5 lines
Signed-off-by Gavin Shan <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.hShouldn't this be added by updating
scripts/update-linux-headers.shand then doing a plain "synchronize headers against kernel version $X" ?I also thought this is the protocol but then I looked into the git history and discovered this is not always the case :)
Quoted 7 lines
Quoted 2 lines
So should I use
scripts/update-linux-headers.shor what I had is fine?Please use
update-linux-headers.sh- and make sure you also update the script itself (if necessary) so it will pull in future updates toeeh.h
Sure, thanks, David. It will be covered in next revision.
Thanks,
Gavin
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
In reply to Peter MaydellQuoted 12 lines · Peter Maydell
Quoted 10 lines · Gavin Shan
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 <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.h
Quoted 3 lines
Shouldn't this be added by updating
scripts/update-linux-headers.shand then doing a plain "synchronize headers against kernel version $X" ? Otherwise you won't get any future changes to this file.
Indeed it should.
Signature · 4 lines
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
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
In reply to Peter MaydellQuoted 12 lines · Peter Maydell
Quoted 10 lines · Gavin Shan
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 <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.h
Quoted 4 lines
Shouldn't this be added by updating
scripts/update-linux-headers.shand then doing a plain "synchronize headers against kernel version $X" ? Otherwise you won't get any future changes to this file.
When I started to sync header files with 4.2.0-rc2 kernel, I found lots of changes existing in the Linux kernel wasn't updated to QEMU source tree. Some changes were introduced into the kernel in 2013, for example commit 24bc69da ("PCI: Clean up MSI/MSI-X capability #defines"). Is there any reason why the header file wasn't updated in time?
Also, "struct virtio_pci_cfg_cap" has been removed from 4.2.0-rc2 kernel, but QEMU is still using it. If all header files are sync'ed with this kernel, then the source code should be adjusted as well. I'm not sure it's reasonable for someone who (like me) is unfamiliar with VFIO to do so? :-)
Thanks,
Gavin
Re: [Qemu-devel] [PATCH v4 1/3] linux-headers: Add eeh.h
Quoted 18 lines · Gavin Shan
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Gavin Shan
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 <[email protected]>--- linux-headers/asm-powerpc/eeh.h | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 linux-headers/asm-powerpc/eeh.hQuoted 4 lines
Shouldn't this be added by updating
scripts/update-linux-headers.shand then doing a plain "synchronize headers against kernel version $X" ? Otherwise you won't get any future changes to this file.
Quoted 6 lines
When I started to sync header files with 4.2.0-rc2 kernel, I found lots of changes existing in the Linux kernel wasn't updated to QEMU source tree. Some changes were introduced into the kernel in 2013, for example commit
24bc69da("PCI: Clean up MSI/MSI-X capability #defines"). Is there any reason why the header file wasn't updated in time?
Anyway, I'll sync all headers with 4.2.rc8 and change the source code accordingly to use those macros valid in 4.2.rc8.
Quoted 5 lines
Also, "struct
virtio_pci_cfg_cap" has been removed from 4.2.0-rc2 kernel, but QEMU is still using it. If all header files are sync'ed with this kernel, then the source code should be adjusted as well. I'm not sure it's reasonable for someone who (like me) is unfamiliar with VFIO to do so? :-)
Please ignore this question. I was using wrong Linux git repository. After switching to Linux upstream (mainline), I didn't find this issue.
Thanks,
Gavin
PATCH v4 2/3 sPAPR: Support RTAS call ibm, {open, close}-errinjct
In reply to Gavin ShanThe 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.
--- hw/ppc/spapr.c | 5 ++++ hw/ppc/spapr_rtas.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 10 +++++++- 3 files changed, 80 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +5 -0
@@ -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_token, sPAPRMachineState), +VMSTATE_END_OF_LIST () }, };
hw/ppc/spapr_rtas.c +66 -0
78 lines not on this page · raw message
include/hw/ppc/spapr.h +9 -1
@@ -73,6 +73,10 @@ struct sPAPRMachineState {int htab_fd;bool htab_fd_stale; +/* Error injection token */ +bool is_errinjct_opened; +uint32_t errinjct_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
Signature · 1 line
2.1.0
PATCH v4 3/3 sPAPR: Support RTAS call ibm,errinjct
In reply to Gavin ShanThe 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.
--- 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(-)
hw/ppc/spapr_pci.c +36 -0
@@ -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 ;
hw/ppc/spapr_pci_vfio.c +56 -0
74 lines not on this page · raw message
hw/ppc/spapr_rtas.c +77 -0
95 lines not on this page · raw message
include/hw/pci-host/spapr.h +2 -0
@@ -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 {
include/hw/ppc/spapr.h +8 -1
@@ -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);
Signature · 1 line
2.1.0