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 multiple error types including: - IOA bus errors (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 parsed and validated, 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 device tree properties Patch 5: Refactors EEH specific code/stubs to new files. Patch 6: Updates MAINTAINERS file Changelog: v5: - added the missing files on patch 0005. - move 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. 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. 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, 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 | 61 ++++ hw/ppc/spapr_eeh.c | 571 +++++++++++++++++++++++++++++++++++ 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, 994 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 -- 2.51.1
