Skip to contentSkip to conversation

ppc/spapr: Add RTAS error injection support for VFIO EEH

PATCH In review Narayana Murty N 2 participants 8 messages Oct 19 – Nov 3 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v6 cover ppc/spapr: Add RTAS error injection support for VFIO EEH

This patch series implements comprehensive RTAS-based error injection support for VFIO EEH (Enhanced Error Handling) on PowerPC sPAPR platforms. The implementation enables guest-initiated PCI error injection for improved testing and diagnostics of EEH recovery mechanisms.

## Background

EEH is a critical feature on PowerPC platforms that provides error detection, isolation, and recovery for PCI devices. Testing EEH recovery paths requires the ability to inject various types of errors into the system. While physical hardware supports error injection through firmware interfaces, QEMU's VFIO implementation previously lacked this capability.

This series bridges that gap by implementing the IBM RTAS error injection interface, allowing guests to inject PCI errors through the same firmware calls used on physical hardware. This enables comprehensive testing of device drivers' EEH recovery code paths in virtualized environments.

## Implementation Overview

The patch series introduces three new RTAS calls:

* ibm,open-errinjct: Opens an error injection session
* ibm,errinjct: Injects a specific error type
* ibm,close-errinjct: Closes the error injection session

The implementation supports IOA bus errors with 32-bit and 64-bit addressing.

For IOA bus-error types, QEMU uses the BUID from the RTAS parameter buffer to select the target PHB. For address-scoped IOA injections, QEMU translates the guest BAR address to the corresponding host resource address before invoking the VFIO EEH backend.

RTAS IOA error types are converted to the EEH type values expected by VFIO_EEH_PE_INJECT_ERR:

* RTAS_ERR_TYPE_IOA_BUS_ERROR -> EEH_ERR_TYPE_32
* RTAS_ERR_TYPE_IOA_BUS_ERROR_64 -> EEH_ERR_TYPE_64

Requests with addr=0 and mask=0 are treated as non-address-scoped IOA injections and are forwarded without address translation.

Non-IOA RTAS error types are recognized but return RTAS_OUT_NOT_SUPPORTED in this series because their RTAS work buffers do not carry enough target information to safely select a VFIO PE.

Tested on pseries and PowerNV hosts with KVM guests using the powerpc-utils errinjct tool, together with the corresponding host kernel EEH RTAS error injection patches:
https://lore.kernel.org/all/[email protected]/

## Patch Organization

Patch 1: Adds the VFIO backend for error injection Patch 2: Implements the ibm,errinjct RTAS call handler Patch 3: Adds session management (open/close) RTAS calls Patch 4: Advertises capabilities via the device tree Patch 5: Splits VFIO EEH support from general VFIO code Patch 6: Updates MAINTAINERS

Changelog:

v6:

* Add the missing vfio_eeh_container_ok() check before issuing VFIO_EEH_PE_INJECT_ERR.
* Remove the redundant ibm,open-errinjct and ibm,close-errinjct string properties from the RTAS device-tree node.
* Clarify that unsupported non-IOA error types are recognized and return RTAS_OUT_NOT_SUPPORTED.
* Update commit messages to match the implementation.
* Retain Reviewed-by tags from v5 where the reviewed code remains unchanged.
https://lore.kernel.org/qemu-devel/[email protected]/
v5:

* Added the missing files in patch 5.
* Moved the VFIO EEH stubs into a separate stub file.
* Keep spapr_pci_vfio.c as the Linux/non-VFIO fallback path and build the real EEH implementation from spapr_eeh.c when CONFIG_VFIO_PCI is enabled.
https://lore.kernel.org/qemu-devel/[email protected]/
v4:

* Removed the first-PHB assumption in ibm,errinjct.
* Use BUID from the IOA RTAS parameter buffer to select the target PHB.
* Added guest BAR to host resource address translation for address-scoped IOA injections.
* Skip address translation for addr=0 and mask=0 IOA requests.
* Convert RTAS IOA error types to VFIO EEH type values before issuing VFIO_EEH_PE_INJECT_ERR.
* Keep spapr_phb_vfio_errinjct() signature unchanged.
* Validate non-IOA RTAS error types but return RTAS_OUT_NOT_SUPPORTED.
* Removed host /proc/device-tree/rtas/ibm,errinjct-tokens probing.
* Always build the guest-facing ibm,errinjct-tokens blob in QEMU.
* Fixed ibm,open-errinjct return-cell layout on error paths.
* Fixed ibm,close-errinjct token validation when no session is open.
* Initialized errinject_tokens to NULL.
* Removed stale CONFIG_DEVICES include after dropping the associated ifdefs.
* Renamed the split EEH file to hw/ppc/spapr_eeh.c.
* Added Pierrick's Reviewed-by tag on the refactor patch.
* Added sPAPR VFIO EEH reviewer entry in MAINTAINERS.
https://lore.kernel.org/qemu-devel/[email protected]/
v3:

* Fixed the build failure reported at
https://github.com/p-b-o/qemu-ci/actions/runs/26094993976
* Also fixed a GitLab CI breakage in patch 2 (qemu_log_mask LOG_UNIMP).

v2:

* Addressed refactor suggestions from Cedric and Pierrick.

v1:
https://lore.kernel.org/all/[email protected]/

Narayana Murty N (6):
ppc/spapr: Add VFIO EEH error injection backend
ppc/spapr: Add ibm,errinjct RTAS call handler
ppc/spapr: Add support for ibm, open-errinjct and ibm, close-errinjct ppc/spapr: Advertise RTAS error injection call support via FDT
property
ppc/spapr: Split VFIO EEH support from general VFIO code
MAINTAINERS: Add self as sPAPR EEH reviewer under PPC RAS

 include/hw/pci-host/spapr.h  |  37 +--
 include/hw/ppc/spapr.h       |  69 ++++-
 include/hw/ppc/spapr_vfio.h  |  31 ++
 hw/ppc/spapr.c               |  57 ++++
 hw/ppc/spapr_eeh.c           | 577 +++++++++++++++++++++++++++++++++++
 hw/ppc/spapr_pci.c           | 193 ++++++++++++
 hw/ppc/spapr_pci_vfio.c      | 315 +------------------
 stubs/spapr_phb_vfio-stubs.c |  62 ++++
 MAINTAINERS                  |   2 +
 hw/ppc/Kconfig               |   2 +-
 hw/ppc/meson.build           |   1 +
 stubs/meson.build            |   1 +
 12 files changed, 996 insertions(+), 351 deletions(-)
 create mode 100644 include/hw/ppc/spapr_vfio.h
 create mode 100644 hw/ppc/spapr_eeh.c
 create mode 100644 stubs/spapr_phb_vfio-stubs.c
Signature · 1 line
2.51.1
#1 lore raw

PATCH v6 1/6 ppc/spapr: Add VFIO EEH error injection backend

Add spapr_phb_vfio_errinjct() to the VFIO EEH backend in spapr_pci_vfio.c. The function maps guest RTAS IOA bus-error types to the corresponding VFIO EEH ioctl error types:

RTAS_ERR_TYPE_IOA_BUS_ERROR -> EEH_ERR_TYPE_32
RTAS_ERR_TYPE_IOA_BUS_ERROR_64 -> EEH_ERR_TYPE_64

EEH_ERR_TYPE_32 / EEH_ERR_TYPE_64 are imported from the powerpc UAPI EEH header where available; fallback numeric definitions are provided to guard against older build environments.

The backend consumes type, func, addr, and mask from the caller. It does not accept or interpret config_addr; PHB/PE selection is the caller's responsibility via the sphb pointer.

Supporting type definitions are added to include/hw/ppc/spapr.h:
- EEH_ERR_FUNC_* and EEH_ERR_FUNC_MAX
- EEH_ERR_TYPE_32 / EEH_ERR_TYPE_64 (with #ifndef guards)
- enum rtas_err_type (RTAS ibm,errinjct error token values)
- RTAS_IBM_ERRINJCT token

The function prototype is added to include/hw/pci-host/spapr.h inside the CONFIG_LINUX ifdef block alongside the other EEH hooks.

---
 include/hw/pci-host/spapr.h |  8 ++++
 include/hw/ppc/spapr.h      | 60 ++++++++++++++++++++++++++-
 hw/ppc/spapr_pci_vfio.c     | 81 +++++++++++++++++++++++++++++++++++++
 3 files changed, 148 insertions(+), 1 deletion(-)
include/hw/pci-host/spapr.h +8 -0
index 0db87f1281..24109409f4 100644
@@ -125,6 +125,8 @@ int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state);
 int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option);
 int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb);
 void spapr_phb_vfio_reset(DeviceState *qdev);
+int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type,
+                            uint32_t func, uint64_t addr, uint64_t mask);
 #else
 static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb)
 {
@@ -151,6 +153,12 @@ static inline int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb)
 static inline void spapr_phb_vfio_reset(DeviceState *qdev)
 {
 }
+static inline int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type,
+                                          uint32_t func, uint64_t addr,
+                                          uint64_t mask)
+{
+    return RTAS_OUT_NOT_SUPPORTED;
+}
 #endif
 
 void spapr_phb_dma_reset(SpaprPhbState *sphb);
include/hw/ppc/spapr.h +59 -1

73 lines not on this page · raw message

hw/ppc/spapr_pci_vfio.c +81 -0

97 lines not on this page · raw message

Signature · 1 line
2.51.1
#2 lore raw

PATCH v6 2/6 ppc/spapr: Add ibm,errinjct RTAS call handler

In reply to Narayana Murty N

Implement the 'ibm,errinjct' RTAS call for PHB-level PCI error injection via firmware. The handler decodes the RTAS parameter buffer, validates arguments, selects the target PHB by BUID, and delegates the injection to the VFIO EEH backend.

IOA bus-error injection (types 0x7 and 0xF) is fully supported:
- The BUID field in the RTAS parameter block selects the target PHB

    via spapr_pci_find_phb();

- For addr != 0 or mask != 0 the guest BAR address is translated to the corresponding host resource base address before calling the VFIO backend. Translation matches the guest BAR layout under the selected PHB, computes offset = guest_addr - guest_bar, reads the host sysfs resource file for the matching BAR, and yields host_addr = host_bar + offset.
- For addr == 0 and mask == 0 translation is skipped and zero addr/mask are forwarded directly (powerpc-utils errinjct -a 0 -m 0).

Non-IOA error types (corrupted-page, dcache, icache, tlb, recovered-special-event) are decoded and validated, then rejected with RTAS_OUT_NOT_SUPPORTED because their RTAS work buffers do not carry a BUID, making safe VFIO PHB/PE selection impossible.

The translation helpers added to spapr_pci_vfio.c:
- spapr_phb_vfio_translate_errinjct_addr() - public entry point
- spapr_vfio_errinjct_find_bar_cb() - per-device BAR scan
- spapr_vfio_errinjct_get_host_bar() - host sysfs BAR reader

config_addr is retained as a logging/debug parameter only; PHB selection relies on BUID.

---
 include/hw/pci-host/spapr.h |  11 ++
 include/hw/ppc/spapr.h      |   3 +
 hw/ppc/spapr_pci.c          | 135 ++++++++++++++++++++++++
 hw/ppc/spapr_pci_vfio.c     | 203 ++++++++++++++++++++++++++++++++++++
 4 files changed, 352 insertions(+)
include/hw/pci-host/spapr.h +11 -0
index 24109409f4..492f66e1ef 100644
@@ -127,6 +127,10 @@ int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb);
 void spapr_phb_vfio_reset(DeviceState *qdev);
 int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type,
                             uint32_t func, uint64_t addr, uint64_t mask);
+int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb,
+                                           uint32_t config_addr,
+                                           uint64_t guest_addr,
+                                           uint64_t *host_pci_bus_addr);
 #else
 static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb)
 {
@@ -159,6 +163,13 @@ static inline int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type,
 {
     return RTAS_OUT_NOT_SUPPORTED;
 }
+static inline int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb,
+                                                         uint32_t config_addr,
+                                                         uint64_t guest_addr,
+                                                         uint64_t *host_addr)
+{
+    return -ENOTSUP;
+}
 #endif
 
 void spapr_phb_dma_reset(SpaprPhbState *sphb);
include/hw/ppc/spapr.h +3 -0
index 253dc0e862..47791c71bd 100644
@@ -274,6 +274,9 @@ struct SpaprMachineState {
     bool fadump_registered;
     bool fadump_dump_active;
     FadumpMemStruct registered_fdm;
+
+    /* ibm,errinjct session token (0 = no session open) */
+    uint32_t errinjct_token;
 };
 
 #define H_SUCCESS         0
hw/ppc/spapr_pci.c +135 -0

147 lines not on this page · raw message

hw/ppc/spapr_pci_vfio.c +203 -0

213 lines not on this page · raw message

Signature · 1 line
2.51.1
#3 lore raw

PATCH v6 3/6 ppc/spapr: Add support for ibm, open-errinjct and ibm, close-errinjct

In reply to Narayana Murty N

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.

---
 include/hw/ppc/spapr.h |  8 +++++-
 hw/ppc/spapr_pci.c     | 57 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)
include/hw/ppc/spapr.h +7 -1
index 47791c71bd..bcb1da5fab 100644
@@ -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
hw/ppc/spapr_pci.c +57 -0

69 lines not on this page · raw message

Signature · 1 line
2.51.1
#4 lore raw

PATCH v6 4/6 ppc/spapr: Advertise RTAS error injection call support via FDT property

In reply to Narayana Murty N

Advertise the supported ibm,errinjct token types to the guest through the "ibm,errinjct-tokens" property under the RTAS node in the device tree.

The property blob is built directly from a QEMU-side static table. No host /proc/device-tree/rtas/ibm,errinjct-tokens probing is done QEMU presents the same token set regardless of the host platform, which avoids host-specific dependencies.

Each entry in the blob is a NUL-terminated token name string followed by a big-endian uint32 type value, matching the PAPR specification for ibm,errinjct-tokens.

---
 hw/ppc/spapr.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
hw/ppc/spapr.c +57 -0
index 6d99464486..22724d6afd 100644
@@ -116,6 +116,8 @@
 
 #define PHANDLE_INTC            0x00001111
 
+#define ERRINJCT_BLOB_MAX       512
+
 /* These two functions implement the VCPU id numbering: one to compute them
  * all and one to identify thread 0 of a VCORE. Any change to the first one
  * is likely to have an impact on the second one, so let's keep them close.
@@ -1081,6 +1083,61 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt)
      */
     _FDT(fdt_setprop(fdt, rtas, "ibm,extended-os-term", NULL, 0));
 
+    /*
+     * Advertise supported ibm,errinjct token types to the guest via the
+     * "ibm,errinjct-tokens" RTAS FDT property.  The blob is built locally
+     * from the QEMU-side token table; no /proc/device-tree probing is done.
+     * Each entry is: NUL-terminated name string || big-endian uint32 type.
+     */
+    {
+        static const struct {
+            const char *name;
+            uint32_t type;
+        } tok_table[] = {
+            { "recovered-special-event",
+              RTAS_ERR_TYPE_RECOVERED_SPECIAL_EVENT },
+            { "corrupted-page",     RTAS_ERR_TYPE_CORRUPTED_PAGE          },
+            { "ioa-bus-error",      RTAS_ERR_TYPE_IOA_BUS_ERROR           },
+            { "corrupted-dcache-start",
+              RTAS_ERR_TYPE_CORRUPTED_DCACHE_START  },
+            { "corrupted-dcache-end",
+              RTAS_ERR_TYPE_CORRUPTED_DCACHE_END    },
+            { "corrupted-icache-start",
+              RTAS_ERR_TYPE_CORRUPTED_ICACHE_START  },
+            { "corrupted-icache-end",
+              RTAS_ERR_TYPE_CORRUPTED_ICACHE_END    },
+            { "corrupted-tlb-start",
+              RTAS_ERR_TYPE_CORRUPTED_TLB_START     },
+            { "corrupted-tlb-end",  RTAS_ERR_TYPE_CORRUPTED_TLB_END       },
+            { "ioa-bus-error-64",   RTAS_ERR_TYPE_IOA_BUS_ERROR_64        },
+        };
+        g_autofree char *errinject_tokens = NULL;
+        uint8_t blob[ERRINJCT_BLOB_MAX];
+        size_t blen = 0;
+        bool ok = true;
+
+        for (int i = 0; i < G_N_ELEMENTS(tok_table) && ok; i++) {
+            size_t slen = strlen(tok_table[i].name) + 1;
+            uint32_t be_type;
+
+            if (blen + slen + sizeof(be_type) > ERRINJCT_BLOB_MAX) {
+                ok = false;
+                break;
+            }
+            memcpy(blob + blen, tok_table[i].name, slen);
+            blen += slen;
+            be_type = cpu_to_be32(tok_table[i].type);
+            memcpy(blob + blen, &be_type, sizeof(be_type));
+            blen += sizeof(be_type);
+        }
+
+        if (ok) {
+            errinject_tokens = g_memdup2(blob, blen);
+            _FDT(fdt_setprop(fdt, rtas, "ibm,errinjct-tokens",
+                             errinject_tokens, blen));
+        }
+    }
+
     _FDT(fdt_setprop(fdt, rtas, "ibm,lrdr-capacity",
                      lrdr_capacity, sizeof(lrdr_capacity)));
 
Signature · 1 line
2.51.1
#5 lore raw

PATCH v6 5/6 ppc/spapr: Split VFIO EEH support from general VFIO code

In reply to Narayana Murty N

Move all EEH and error-injection functions from spapr_pci_vfio.c into a dedicated hw/ppc/spapr_eeh.c. spapr_eeh.c is compiled only when CONFIG_VFIO_PCI is enabled.

spapr_pci_vfio.c is retained as a stub-only file compiled on Linux when CONFIG_VFIO_PCI is not available, providing the non-functional fallback implementations needed for Linux/pseries builds that do not include VFIO PCI.

meson.build: replace the single spapr_pci_vfio.c entry with an if_true/if_false pair keyed on CONFIG_VFIO_PCI:
CONFIG_VFIO_PCI=y -> spapr_eeh.c (real implementation)
CONFIG_VFIO_PCI=n -> stubs/spapr_pci_vfio-stubs.c (stubs)

No functional change to the EEH state machine.

---
 include/hw/pci-host/spapr.h  |  56 +---
 include/hw/ppc/spapr_vfio.h  |  31 ++
 hw/ppc/spapr_eeh.c           | 577 +++++++++++++++++++++++++++++++++
 hw/ppc/spapr_pci.c           |   1 +
 hw/ppc/spapr_pci_vfio.c      | 597 +----------------------------------
 stubs/spapr_phb_vfio-stubs.c |  62 ++++
 hw/ppc/Kconfig               |   2 +-
 hw/ppc/meson.build           |   1 +
 stubs/meson.build            |   1 +
 9 files changed, 676 insertions(+), 652 deletions(-)
 create mode 100644 include/hw/ppc/spapr_vfio.h
 create mode 100644 hw/ppc/spapr_eeh.c
 create mode 100644 stubs/spapr_phb_vfio-stubs.c
include/hw/pci-host/spapr.h +1 -55
index 492f66e1ef..d2bc90a3d2 100644
@@ -116,61 +116,7 @@ void spapr_phb_remove_pci_device_cb(DeviceState *dev);
 int spapr_pci_dt_populate(SpaprDrc *drc, SpaprMachineState *spapr,
                           void *fdt, int *fdt_start_offset, Error **errp);
 
-/* VFIO EEH hooks */
-#ifdef CONFIG_LINUX
-bool spapr_phb_eeh_available(SpaprPhbState *sphb);
-int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb,
-                                  unsigned int addr, int option);
-int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state);
-int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option);
-int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb);
-void spapr_phb_vfio_reset(DeviceState *qdev);
-int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type,
-                            uint32_t func, uint64_t addr, uint64_t mask);
-int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb,
-                                           uint32_t config_addr,
-                                           uint64_t guest_addr,
-                                           uint64_t *host_pci_bus_addr);
-#else
-static inline bool spapr_phb_eeh_available(SpaprPhbState *sphb)
-{
-    return false;
-}
-static inline int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb,
-                                                unsigned int addr, int option)
-{
-    return RTAS_OUT_HW_ERROR;
-}
-static inline int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb,
-                                               int *state)
-{
-    return RTAS_OUT_HW_ERROR;
-}
-static inline int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option)
-{
-    return RTAS_OUT_HW_ERROR;
-}
-static inline int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb)
-{
-    return RTAS_OUT_HW_ERROR;
-}
-static inline void spapr_phb_vfio_reset(DeviceState *qdev)
-{
-}
-static inline int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type,
-                                          uint32_t func, uint64_t addr,
-                                          uint64_t mask)
-{
-    return RTAS_OUT_NOT_SUPPORTED;
-}
-static inline int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb,
-                                                         uint32_t config_addr,
-                                                         uint64_t guest_addr,
-                                                         uint64_t *host_addr)
-{
-    return -ENOTSUP;
-}
-#endif
+/* VFIO EEH hooks - see hw/ppc/spapr_vfio.h for declarations */
 
 void spapr_phb_dma_reset(SpaprPhbState *sphb);
 
include/hw/ppc/spapr_vfio.h new file +31 -0
new file mode 100644
index 0000000000..5aabb262f2
@@ -0,0 +1,31 @@
+/*
+ * sPAPR VFIO EEH Header
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef HW_PPC_SPAPR_VFIO_H
+#define HW_PPC_SPAPR_VFIO_H
+
+/*
+ * Forward declarations to avoid pulling in full spapr headers
+ * This allows stubs and other files to compile without libfdt dependencies
+ */
+typedef struct SpaprPhbState SpaprPhbState;
+typedef struct DeviceState DeviceState;
+
+/* VFIO EEH function declarations */
+bool spapr_phb_eeh_available(SpaprPhbState *sphb);
+int spapr_phb_vfio_eeh_set_option(SpaprPhbState *sphb,
+                                  unsigned int addr, int option);
+int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state);
+int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option);
+int spapr_phb_vfio_eeh_configure(SpaprPhbState *sphb);
+void spapr_phb_vfio_reset(DeviceState *qdev);
+void spapr_phb_vfio_eeh_reenable(SpaprPhbState *sphb);
+int spapr_phb_vfio_errinjct(SpaprPhbState *sphb, uint32_t type,
+                            uint32_t func, uint64_t addr, uint64_t mask);
+int spapr_phb_vfio_translate_errinjct_addr(SpaprPhbState *sphb,
+                                           uint32_t config_addr,
+                                           uint64_t guest_addr,
+                                           uint64_t *host_pci_bus_addr);
+#endif /* HW_PPC_SPAPR_VFIO_H */
hw/ppc/spapr_eeh.c new file +577 -0

577 lines not on this page · raw message

hw/ppc/spapr_pci.c +1 -0
index ec9f6284c7..2c85d8595d 100644
@@ -33,6 +33,7 @@
 #include "hw/pci/msix.h"
 #include "hw/pci/pci_host.h"
 #include "hw/ppc/spapr.h"
+#include "hw/ppc/spapr_vfio.h"
 #include "hw/pci-host/spapr.h"
 #include <libfdt.h>
 #include "trace.h"
hw/ppc/spapr_pci_vfio.c +1 -596

611 lines not on this page · raw message

stubs/spapr_phb_vfio-stubs.c new file +62 -0

62 lines not on this page · raw message

hw/ppc/Kconfig +1 -1
index 347dcce690..3714d708d9 100644
@@ -6,7 +6,7 @@ config PSERIES
     imply PCI_DEVICES
     imply TEST_DEVICES
     imply VIRTIO_VGA
-    imply VFIO_PCI if LINUX   # needed by spapr_pci_vfio.c
+    imply VFIO_PCI if LINUX   # needed by spapr_pci_vfio.c and spapr_eeh.c
     select NVDIMM
     select DIMM
     select PCI
hw/ppc/meson.build +1 -0
index 37aa535db2..4e03973440 100644
@@ -36,6 +36,7 @@ ppc_ss.add(when: 'CONFIG_SPAPR_RNG', if_true: files('spapr_rng.c'))
 if host_os == 'linux'
   ppc_ss.add(when: 'CONFIG_PSERIES', if_true: files(
     'spapr_pci_vfio.c',
+    'spapr_eeh.c',
   ))
 endif
 
stubs/meson.build +1 -0
index dcb67ce529..122f1f85b3 100644
@@ -101,6 +101,7 @@ if have_system
     stub_ss.add(files('hmp-cmds-hw-s390x.c'))
     stub_ss.add(files('hmp-cmds-target-i386.c'))
   endif
+  stub_ss.add(files('spapr_phb_vfio-stubs.c'))
 endif
 
 if have_system or have_user
Signature · 1 line
2.51.1
#6 lore raw

PATCH v6 6/6 MAINTAINERS: Add self as sPAPR EEH reviewer under PPC RAS

In reply to Narayana Murty N

Adding self as reviewer for the sPAPR EEH under PPC RAS. Updating the EEH specific file name as got updated in previous patches.

---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index 33b4f7c259..337d402fa6 100644
@@ -1775,11 +1775,13 @@ M: Aditya Gupta <[email protected]>
 R: Sourabh Jain <[email protected]>
 R: Hari Bathini <[email protected]>
 R: Shivang Upadhyay <[email protected]>
+R: Narayana Murty N <[email protected]>
 L: [email protected]
 S: Maintained
 F: hw/ppc/spapr_events.c
 F: hw/ppc/spapr_fadump.c
 F: hw/ppc/spapr_pci_vfio.c
+F: hw/ppc/spapr_eeh.c
 F: hw/ppc/spapr_rtas.c
 F: hw/ppc/pnv_mpipl.c
 F: include/hw/ppc/spapr_fadump.h
Signature · 1 line
2.51.1