Re: [PATCH v4 5/5] powerpc/powernv/eeh: Map VFIO EEH error injection to OPAL

From: Narayana Murty N

Date: Mon Oct 19 2026 - 06:01:50 EST


Hi Sourabh,

On 24/09/26 10:05 AM, Sourabh Jain wrote:
Can you update the commit message to explain why and how this
change is needed?

Sure. I expanded the v5 commit message to explain that eeh_pe_inject_err() receives generic EEH userspace ABI values, while the PowerNV firmware interface uses OPAL-specific error types.

The backend now explicitly maps the generic EEH type to the corresponding OPAL error type rather than relying on the two sets of constants having identical numeric values.


On 31/08/26 12:24, Narayana Murty N wrote:
VFIO EEH error injection exposes a generic userspace ABI.  pSeries maps
the generic EEH error types to RTAS ibm,errinjct encodings, while
PowerNV maps the same generic ABI values to OPAL-specific encodings.

Keep EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 unchanged.  The mapping is
internal to the platform backend.

Add a switch in pnv_eeh_err_inject() that translates:
   EEH_ERR_TYPE_32 -> OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR
   EEH_ERR_TYPE_64 -> OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64

Return -EINVAL for unsupported error types rather than comparing
directly against OPAL constants.  This decouples the VFIO/EEH
interface from OPAL implementation details, paralleling the approach
used on the pSeries RTAS path.

Signed-off-by: Narayana Murty N <nnmlinux@xxxxxxxxxxxxx>
---
  arch/powerpc/platforms/powernv/eeh-powernv.c | 27 +++++++++++++++-----
  1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/ powerpc/platforms/powernv/eeh-powernv.c
index db3370d1673c..53c4c05aaef2 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -1167,13 +1167,28 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,
  {
      struct pci_controller *hose = pe->phb;
      struct pnv_phb *phb = hose->private_data;
+    int opal_type;

opal_type is confusing... How about opal_err_type or just err_type?

Agreed. Renamed it to opal_err_type in v5.

Thanks,
Narayana
      s64 rc;
-    if (type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR &&
-        type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64) {
-        pr_warn("%s: Invalid error type %d\n",
-            __func__, type);
-        return -ERANGE;
+    /*
+     * VFIO EEH error injection exposes a generic userspace ABI.
+     * pSeries maps the generic EEH error types to RTAS ibm,errinjct
+     * encodings, while PowerNV maps the same generic ABI values to
+     * OPAL-specific encodings.
+     *
+     * Keep EEH_ERR_TYPE_32 and EEH_ERR_TYPE_64 unchanged.  The
+     * mapping is internal to the platform backend.
+     */
+    switch (type) {
+    case EEH_ERR_TYPE_32:
+        opal_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR;
+        break;
+    case EEH_ERR_TYPE_64:
+        opal_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64;
+        break;
+    default:
+        pr_warn("%s: Invalid error type %d\n", __func__, type);
+        return -EINVAL;
      }
      if (func < OPAL_ERR_INJECT_FUNC_IOA_LD_MEM_ADDR ||
@@ -1192,7 +1207,7 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,
      /* Do error injection */
      rc = opal_pci_err_inject(phb->opal_id, pe->addr,
-                 type, func, addr, mask);
+                 opal_type, func, addr, mask);
      if (rc != OPAL_SUCCESS) {
          pr_warn("%s: Failure %lld injecting error "
              "%d-%d to PHB#%x-PE#%x\n",