AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/19 10:36 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series modifies PowerPC architecture code (in arch/powerpc/) and the sPAPR TCE VFIO IOMMU driver (drivers/vfio/vfio_iommu_spapr_tce.c, which depends on CONFIG_SPAPR_TCE_IOMMU, requiring CONFIG_PPC_POWERNV or CONFIG_PPC_PSERIES). None of this code can be compiled or executed on the target architecture (amd64), as all modified paths are strictly exclusive to PowerPC.",
  "WorthFuzzing": false
}

1/1 2026/10/19 10:36 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 39f17b64d7cfdde78f605ac371d7baebf3b94002\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Mon Oct 19 10:36:08 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h\nindex b7ebb4ac2c710..083ac58e7eb73 100644\n--- a/arch/powerpc/include/asm/eeh.h\n+++ b/arch/powerpc/include/asm/eeh.h\n@@ -310,8 +310,6 @@ int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed);\n int eeh_pe_configure(struct eeh_pe *pe);\n int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,\n \t\t      unsigned long addr, unsigned long mask);\n-int eeh_pe_inject_mmio_error(struct pci_dev *pdev);\n-\n /**\n  * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.\n  *\ndiff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c\nindex bb836f02101cf..369aad298f752 100644\n--- a/arch/powerpc/kernel/eeh.c\n+++ b/arch/powerpc/kernel/eeh.c\n@@ -1664,11 +1664,6 @@ static int eeh_break_device(struct pci_dev *pdev)\n \treturn 0;\n }\n \n-int eeh_pe_inject_mmio_error(struct pci_dev *pdev)\n-{\n-\treturn eeh_break_device(pdev);\n-}\n-\n #ifdef CONFIG_DEBUG_FS\n \n \ndiff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c\nindex 8d81c1e7a8db1..38f3d08d4228c 100644\n--- a/arch/powerpc/kernel/rtas.c\n+++ b/arch/powerpc/kernel/rtas.c\n@@ -1117,6 +1117,28 @@ static bool token_is_restricted_errinjct(s32 token)\n \t       token == rtas_function_token(RTAS_FN_IBM_ERRINJCT);\n }\n \n+/*\n+ * ibm,open-errinjct uses a non-standard return layout:\n+ *   rets[0] = session token  (output parameter)\n+ *   rets[1] = status code\n+ *\n+ * All other RTAS functions use the standard layout:\n+ *   rets[0] = status code\n+ *   rets[1..] = output parameters\n+ */\n+static inline bool rtas_token_is_open_errinjct(int token)\n+{\n+\treturn token == rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT);\n+}\n+\n+static int rtas_status_from_args(int token, struct rtas_args *args, int nret)\n+{\n+\tif (rtas_token_is_open_errinjct(token))\n+\t\treturn be32_to_cpu(args-\u003erets[1]);\n+\n+\treturn nret \u003e 0 ? be32_to_cpu(args-\u003erets[0]) : 0;\n+}\n+\n /**\n  * rtas_call() - Invoke an RTAS firmware function.\n  * @token: Identifies the function being invoked.\n@@ -1198,6 +1220,16 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)\n \t\t\treturn -1;\n \t}\n \n+\t/*\n+\t * ibm,open-errinjct returns rets[0]=session_token, rets[1]=status.\n+\t * We need nret \u003e= 2 to read status from rets[1].  Reject early if\n+\t * the caller forgot to account for the extra return cell.\n+\t */\n+\tif (rtas_token_is_open_errinjct(token) \u0026\u0026 nret \u003c 2) {\n+\t\tWARN_ON_ONCE(1);\n+\t\treturn -EINVAL;\n+\t}\n+\n \tif ((mfmsr() \u0026 (MSR_IR|MSR_DR)) != (MSR_IR|MSR_DR)) {\n \t\tWARN_ON_ONCE(1);\n \t\treturn -1;\n@@ -1213,15 +1245,33 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)\n \tva_rtas_call_unlocked(args, token, nargs, nret, list);\n \tva_end(list);\n \n+\tret = rtas_status_from_args(token, args, nret);\n+\n \t/* A -1 return code indicates that the last command couldn't\n-\t   be completed due to a hardware error. */\n-\tif (be32_to_cpu(args-\u003erets[0]) == -1)\n+\t * be completed due to a hardware error.\n+\t */\n+\tif (ret == -1)\n \t\tbuff_copy = __fetch_rtas_last_error(NULL);\n \n-\tif (nret \u003e 1 \u0026\u0026 outputs != NULL)\n-\t\tfor (i = 0; i \u003c nret-1; ++i)\n-\t\t\toutputs[i] = be32_to_cpu(args-\u003erets[i + 1]);\n-\tret = (nret \u003e 0) ? be32_to_cpu(args-\u003erets[0]) : 0;\n+\t/*\n+\t * Copy non-status outputs to the caller's buffer.\n+\t *\n+\t * For ibm,open-errinjct the layout is:\n+\t *   rets[0] = session token  -\u003e outputs[0]\n+\t *   rets[1] = status         (returned, not copied)\n+\t *\n+\t * For all other RTAS functions:\n+\t *   rets[0] = status         (returned, not copied)\n+\t *   rets[1..nret-1] -\u003e outputs[0..nret-2]\n+\t */\n+\tif (outputs) {\n+\t\tif (rtas_token_is_open_errinjct(token)) {\n+\t\t\toutputs[0] = be32_to_cpu(args-\u003erets[0]);\n+\t\t} else if (nret \u003e 1) {\n+\t\t\tfor (i = 0; i \u003c nret - 1; ++i)\n+\t\t\t\toutputs[i] = be32_to_cpu(args-\u003erets[i + 1]);\n+\t\t}\n+\t}\n \n \tlockdep_unpin_lock(\u0026rtas_lock, cookie);\n \traw_spin_unlock_irqrestore(\u0026rtas_lock, flags);\n@@ -1896,6 +1946,14 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)\n \tif (block_rtas_call(func, nargs, \u0026args))\n \t\treturn -EINVAL;\n \n+\t/*\n+\t * ibm,open-errinjct places status at rets[1]; reject calls with\n+\t * fewer than 2 return cells before entering RTAS, since reading\n+\t * rets[1] for the -1 sentinel would be out of bounds.\n+\t */\n+\tif (rtas_token_is_open_errinjct(token) \u0026\u0026 nret \u003c 2)\n+\t\treturn -EINVAL;\n+\n \tif (token_is_restricted_errinjct(token)) {\n \t\tint err;\n \n@@ -1942,9 +2000,11 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)\n \tdo_enter_rtas(\u0026rtas_args);\n \targs = rtas_args;\n \n-\t/* A -1 return code indicates that the last command couldn't\n-\t   be completed due to a hardware error. */\n-\tif (be32_to_cpu(args.rets[0]) == -1)\n+\t/*\n+\t * A -1 return code indicates that the last command couldn't\n+\t * be completed due to a hardware error.\n+\t */\n+\tif (rtas_status_from_args(token, \u0026args, nret) == -1)\n \t\terrbuf = __fetch_rtas_last_error(buff_copy);\n \n \tlockdep_unpin_lock(\u0026rtas_lock, cookie);\ndiff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c\nindex db3370d1673c3..01dae760cecb5 100644\n--- a/arch/powerpc/platforms/powernv/eeh-powernv.c\n+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c\n@@ -1167,12 +1167,24 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,\n {\n \tstruct pci_controller *hose = pe-\u003ephb;\n \tstruct pnv_phb *phb = hose-\u003eprivate_data;\n+\tint opal_err_type;\n \ts64 rc;\n \n-\tif (type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR \u0026\u0026\n-\t    type != OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64) {\n-\t\tpr_warn(\"%s: Invalid error type %d\\n\",\n-\t\t\t__func__, type);\n+\t/*\n+\t * eeh_pe_inject_err() receives generic EEH error types from the\n+\t * VFIO/EEH userspace ABI.  The PowerNV backend must not rely on\n+\t * these generic values being numerically identical to OPAL firmware\n+\t * values.  Translate to OPAL-specific types before calling firmware.\n+\t */\n+\tswitch (type) {\n+\tcase EEH_ERR_TYPE_32:\n+\t\topal_err_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR;\n+\t\tbreak;\n+\tcase EEH_ERR_TYPE_64:\n+\t\topal_err_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64;\n+\t\tbreak;\n+\tdefault:\n+\t\tpr_warn(\"%s: Invalid error type %d\\n\", __func__, type);\n \t\treturn -ERANGE;\n \t}\n \n@@ -1192,7 +1204,7 @@ static int pnv_eeh_err_inject(struct eeh_pe *pe, int type, int func,\n \n \t/* Do error injection */\n \trc = opal_pci_err_inject(phb-\u003eopal_id, pe-\u003eaddr,\n-\t\t\t\t type, func, addr, mask);\n+\t\t\t\t opal_err_type, func, addr, mask);\n \tif (rc != OPAL_SUCCESS) {\n \t\tpr_warn(\"%s: Failure %lld injecting error \"\n \t\t\t\"%d-%d to PHB#%x-PE#%x\\n\",\ndiff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c\nindex b12ef382fec70..52d0010426635 100644\n--- a/arch/powerpc/platforms/pseries/eeh_pseries.c\n+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c\n@@ -12,6 +12,8 @@\n  * Copyright Linas Vepstas 2005, 2006\n  */\n \n+#define pr_fmt(fmt) \"EEH: \" fmt\n+\n #include \u003clinux/atomic.h\u003e\n #include \u003clinux/delay.h\u003e\n #include \u003clinux/export.h\u003e\n@@ -22,7 +24,9 @@\n #include \u003clinux/proc_fs.h\u003e\n #include \u003clinux/rbtree.h\u003e\n #include \u003clinux/sched.h\u003e\n+#include \u003clinux/mutex.h\u003e\n #include \u003clinux/seq_file.h\u003e\n+#include \u003clinux/sizes.h\u003e\n #include \u003clinux/spinlock.h\u003e\n #include \u003clinux/crash_dump.h\u003e\n \n@@ -32,6 +36,7 @@\n #include \u003casm/machdep.h\u003e\n #include \u003casm/ppc-pci.h\u003e\n #include \u003casm/rtas.h\u003e\n+#include \u003casm/rtas-work-area.h\u003e\n \n /* RTAS tokens */\n static int ibm_set_eeh_option;\n@@ -786,43 +791,326 @@ static int pseries_notify_resume(struct eeh_dev *edev)\n }\n #endif\n \n+/*\n+ * RTAS firmware error-type encodings (PAPR).  These are pseries-private;\n+ * user-space sees only the generic EEH_ERR_TYPE_* values from eeh.h.\n+ * Only IOA bus-error types are supported; other PAPR encodings are not\n+ * reachable through the generic EEH_ERR_TYPE_* UAPI.\n+ */\n+#define RTAS_ERR_TYPE_IOA_BUS_ERROR\t\t0x07\n+#define RTAS_ERR_TYPE_IOA_BUS_ERROR_64\t\t0x0f\n+\n+/* Size of the ibm,errinjct work buffer as defined by PAPR */\n+#define RTAS_ERRINJCT_BUF_SIZE\t\t\tSZ_1K\n+\n /**\n- * pseries_eeh_err_inject - Inject specified error to the indicated PE\n- * @pe: the indicated PE\n- * @type: error type\n- * @func: specific error type\n- * @addr: address\n- * @mask: address mask\n- * The routine is called to inject specified error, which is\n- * determined by @type and @func, to the indicated PE\n+ * pseries_eeh_type_to_rtas - Map generic EEH error type to RTAS encoding\n+ * @type: generic EEH error type (EEH_ERR_TYPE_32, EEH_ERR_TYPE_64)\n+ *\n+ * Translates the generic VFIO/EEH error type passed from userspace into\n+ * the RTAS-specific ibm,errinjct error type encoding defined by PAPR.\n+ *\n+ * Return: RTAS error type on success, -EINVAL for unknown types.\n  */\n-static int pseries_eeh_err_inject(struct eeh_pe *pe, int type, int func,\n+static int pseries_eeh_type_to_rtas(int type)\n+{\n+\tswitch (type) {\n+\tcase EEH_ERR_TYPE_32:\n+\t\treturn RTAS_ERR_TYPE_IOA_BUS_ERROR;\n+\tcase EEH_ERR_TYPE_64:\n+\t\treturn RTAS_ERR_TYPE_IOA_BUS_ERROR_64;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+}\n+\n+/**\n+ * validate_addr_mask_in_pe - Validate addr against PCI bus BAR addresses in PE\n+ * @pe:   EEH PE containing one or more PCI devices\n+ * @addr: PCI bus address to validate\n+ * @mask: address mask (passed to firmware unchanged)\n+ *\n+ * RTAS IOA bus-error injection uses PCI bus addresses.  Linux PCI resources\n+ * are CPU/resource addresses and may differ on pseries due to PHB window\n+ * translation.  Convert each BAR resource to PCI bus address space before\n+ * validating @addr.\n+ *\n+ * Zero addr and mask are accepted without BAR lookup (no-address injection).\n+ *\n+ * Return: 0 if valid, -EINVAL on invalid input.\n+ */\n+static int validate_addr_mask_in_pe(struct eeh_pe *pe, unsigned long addr,\n+\t\t\t\t    unsigned long mask)\n+{\n+\tstruct pci_bus_region region;\n+\tstruct eeh_dev *edev, *tmp;\n+\tstruct pci_dev *pdev;\n+\tstruct resource *res;\n+\tresource_size_t bus_start;\n+\tresource_size_t bus_len;\n+\tbool found = false;\n+\tint bar;\n+\n+\tif (!addr \u0026\u0026 !mask)\n+\t\treturn 0;\n+\n+\tif (!pe)\n+\t\treturn -EINVAL;\n+\n+\t/*\n+\t * RTAS IOA bus-error injection uses PCI bus addresses. Linux PCI\n+\t * resources are CPU/resource addresses and may differ on pseries due\n+\t * to PHB window translation. Convert each BAR resource to PCI bus\n+\t * address space before validating @addr.\n+\t *\n+\t * Hold pci_rescan_remove_lock across the traversal to protect pdev\n+\t * lifetime: pci_stop_and_remove_bus_device() requires this lock.\n+\t */\n+\tpci_lock_rescan_remove();\n+\teeh_pe_for_each_dev(pe, edev, tmp) {\n+\t\tpdev = eeh_dev_to_pci_dev(edev);\n+\t\tif (!pdev)\n+\t\t\tcontinue;\n+\n+\t\t/*\n+\t\t * Validate against standard BARs (BAR0..BAR5) only.\n+\t\t * ROM and bridge resources are not IOA bus-error targets.\n+\t\t */\n+\t\tfor (bar = 0; bar \u003c PCI_STD_NUM_BARS; bar++) {\n+\t\t\tres = \u0026pdev-\u003eresource[bar];\n+\n+\t\t\tif (!resource_size(res))\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (!(res-\u003eflags \u0026 (IORESOURCE_MEM | IORESOURCE_IO)))\n+\t\t\t\tcontinue;\n+\n+\t\t\tpcibios_resource_to_bus(pdev-\u003ebus, \u0026region, res);\n+\n+\t\t\tbus_start = region.start;\n+\t\t\tbus_len = resource_size(res);\n+\n+\t\t\tif ((resource_size_t)addr \u003e= bus_start \u0026\u0026\n+\t\t\t    ((resource_size_t)addr - bus_start) \u003c bus_len) {\n+\t\t\t\tpr_debug(\"addr=0x%lx mask=0x%lx validated in PCI bus BAR[%d] of %s: bus range 0x%llx-0x%llx\\n\",\n+\t\t\t\t\t addr, mask, bar, pci_name(pdev),\n+\t\t\t\t\t (unsigned long long)region.start,\n+\t\t\t\t\t (unsigned long long)region.end);\n+\t\t\t\tfound = true;\n+\t\t\t\tgoto done;\n+\t\t\t}\n+\t\t}\n+\t}\n+done:\n+\tpci_unlock_rescan_remove();\n+\n+\tif (!found)\n+\t\tpr_err(\"addr=0x%lx mask=0x%lx not within any PCI bus BAR of any device in PE\\n\",\n+\t\t       addr, mask);\n+\treturn found ? 0 : -EINVAL;\n+}\n+\n+/**\n+ * validate_errinjct_args - Top-level validation for RTAS error injection arguments\n+ * @pe:   EEH PE for the target device\n+ * @type: generic EEH error type\n+ * @func: error function selector\n+ * @addr: address argument (type-dependent, may be zero)\n+ * @mask: mask argument (type-dependent, may be zero)\n+ *\n+ * Validates all parameters before opening an RTAS injection session.\n+ * Returns Linux errno values; does not return raw RTAS status codes.\n+ *\n+ * Return: 0 if all parameters are valid, negative errno otherwise.\n+ */\n+static int validate_errinjct_args(struct eeh_pe *pe, int type, int func,\n \t\t\t\t  unsigned long addr, unsigned long mask)\n {\n-\tstruct\teeh_dev\t*pdev;\n+\tif (!pe || !pe-\u003ephb)\n+\t\treturn -EINVAL;\n+\n+\tif (pseries_eeh_type_to_rtas(type) \u003c 0)\n+\t\treturn -EINVAL;\n \n-\t/* Check on PCI error type */\n-\tif (type != EEH_ERR_TYPE_32 \u0026\u0026 type != EEH_ERR_TYPE_64)\n+\tif (func \u003c EEH_ERR_FUNC_MIN || func \u003e EEH_ERR_FUNC_MAX)\n \t\treturn -EINVAL;\n \n-\tswitch (func) {\n-\tcase EEH_ERR_FUNC_LD_MEM_ADDR:\n-\tcase EEH_ERR_FUNC_LD_MEM_DATA:\n-\tcase EEH_ERR_FUNC_ST_MEM_ADDR:\n-\tcase EEH_ERR_FUNC_ST_MEM_DATA:\n-\t\t/* injects a MMIO error for all pdev's belonging to PE */\n-\t\tpci_lock_rescan_remove();\n-\t\tlist_for_each_entry(pdev, \u0026pe-\u003eedevs, entry)\n-\t\t\teeh_pe_inject_mmio_error(pdev-\u003epdev);\n-\t\tpci_unlock_rescan_remove();\n+\treturn 0;\n+}\n+\n+/**\n+ * prepare_errinjct_buffer() - Build ibm,errinjct work buffer\n+ * @buf: RTAS error-injection work buffer\n+ * @pe: EEH PE associated with the injection target\n+ * @rtas_err_type: RTAS firmware error-injection type\n+ * @func: Error function selector\n+ * @addr: Target PCI bus address\n+ * @mask: Address mask passed to firmware\n+ *\n+ * Zeroes @buf and populates it according to the PAPR layout for the\n+ * selected IOA bus-error injection type.\n+ *\n+ * The caller provides an exclusive per-call RTAS work-area buffer.\n+ * Firmware session serialization is handled by pseries_eeh_err_inject().\n+ *\n+ * Return: 0 on success or a negative errno on invalid input.\n+ */\n+static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe,\n+\t\t\t\t   int rtas_err_type, int func,\n+\t\t\t\t   unsigned long addr, unsigned long mask)\n+{\n+\t__be64 *buf64 = (__be64 *)buf;\n+\t__be32 *buf32 = (__be32 *)buf;\n+\tint rc;\n+\n+\tif (!buf || !pe || !pe-\u003ephb)\n+\t\treturn -EINVAL;\n+\n+\tmemset(buf, 0, RTAS_ERRINJCT_BUF_SIZE);\n+\n+\tswitch (rtas_err_type) {\n+\tcase RTAS_ERR_TYPE_IOA_BUS_ERROR:\n+\t\tif (upper_32_bits(addr) || upper_32_bits(mask))\n+\t\t\treturn -EINVAL;\n+\n+\t\trc = validate_addr_mask_in_pe(pe, addr, mask);\n+\t\tif (rc)\n+\t\t\treturn rc;\n+\n+\t\tbuf32[0] = cpu_to_be32((u32)addr);\n+\t\tbuf32[1] = cpu_to_be32((u32)mask);\n+\t\tbuf32[2] = cpu_to_be32(pe-\u003eaddr);\n+\t\tbuf32[3] = cpu_to_be32(BUID_HI(pe-\u003ephb-\u003ebuid));\n+\t\tbuf32[4] = cpu_to_be32(BUID_LO(pe-\u003ephb-\u003ebuid));\n+\t\tbuf32[5] = cpu_to_be32(func);\n \t\tbreak;\n+\n+\tcase RTAS_ERR_TYPE_IOA_BUS_ERROR_64:\n+\t\trc = validate_addr_mask_in_pe(pe, addr, mask);\n+\t\tif (rc)\n+\t\t\treturn rc;\n+\n+\t\tbuf64[0] = cpu_to_be64(addr);\n+\t\tbuf64[1] = cpu_to_be64(mask);\n+\t\tbuf32[4] = cpu_to_be32(pe-\u003eaddr);\n+\t\tbuf32[5] = cpu_to_be32(BUID_HI(pe-\u003ephb-\u003ebuid));\n+\t\tbuf32[6] = cpu_to_be32(BUID_LO(pe-\u003ephb-\u003ebuid));\n+\t\tbuf32[7] = cpu_to_be32(func);\n+\t\tbreak;\n+\n \tdefault:\n-\t\treturn -ERANGE;\n+\t\tpr_err(\"unsupported RTAS error injection type 0x%x\\n\", rtas_err_type);\n+\t\treturn -EINVAL;\n \t}\n \n+\tpr_debug(\"errinjct buffer ready: rtas_err_type=0x%x func=%d addr=0x%lx mask=0x%lx\\n\",\n+\t\t rtas_err_type, func, addr, mask);\n \treturn 0;\n }\n \n+/* Serializes the open/inject/close RTAS error injection session */\n+static DEFINE_MUTEX(errinjct_mutex);\n+\n+/**\n+ * pseries_eeh_err_inject - Inject specified error to the indicated PE\n+ * @pe: the indicated PE\n+ * @type: generic EEH error type (EEH_ERR_TYPE_32 or EEH_ERR_TYPE_64)\n+ * @func: specific error function\n+ * @addr: address argument (type-dependent, may be zero)\n+ * @mask: address mask (type-dependent, may be zero)\n+ *\n+ * Implements PAPR-compliant error injection using:\n+ *   ibm,open-errinjct -\u003e ibm,errinjct -\u003e ibm,close-errinjct\n+ *\n+ * errinjct_mutex serializes the open/inject/close session sequence\n+ * because RTAS maintains state between these calls.  A short-lived\n+ * RTAS work area is allocated after a successful open and freed before\n+ * close.\n+ *\n+ * Return: 0 on success, negative errno on failure.\n+ */\n+static int pseries_eeh_err_inject(struct eeh_pe *pe, int type, int func,\n+\t\t\t\t  unsigned long addr, unsigned long mask)\n+{\n+\tstruct rtas_work_area *area;\n+\tphys_addr_t area_phys;\n+\tvoid *buf;\n+\tint open_token, errinjct_token, close_token;\n+\tint session_token;\n+\tint rtas_err_type;\n+\tint close_rc;\n+\tint rc;\n+\n+\trc = validate_errinjct_args(pe, type, func, addr, mask);\n+\tif (rc)\n+\t\treturn rc;\n+\n+\trtas_err_type = pseries_eeh_type_to_rtas(type);\n+\tif (rtas_err_type \u003c 0)\n+\t\treturn -EINVAL;\n+\n+\topen_token = rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT);\n+\terrinjct_token = rtas_function_token(RTAS_FN_IBM_ERRINJCT);\n+\tclose_token = rtas_function_token(RTAS_FN_IBM_CLOSE_ERRINJCT);\n+\n+\tif (open_token == RTAS_UNKNOWN_SERVICE ||\n+\t    errinjct_token == RTAS_UNKNOWN_SERVICE ||\n+\t    close_token == RTAS_UNKNOWN_SERVICE)\n+\t\treturn -ENODEV;\n+\n+\tmutex_lock(\u0026errinjct_mutex);\n+\n+\tdo {\n+\t\trc = rtas_call(open_token, 0, 2, \u0026session_token);\n+\t} while (rtas_busy_delay(rc));\n+\n+\tif (rc) {\n+\t\tpr_err(\"ibm,open-errinjct failed: status=%d\\n\", rc);\n+\t\trc = rtas_error_rc(rc);\n+\t\tgoto out_unlock;\n+\t}\n+\n+\tarea = rtas_work_area_alloc(RTAS_ERRINJCT_BUF_SIZE);\n+\tbuf = rtas_work_area_raw_buf(area);\n+\tarea_phys = rtas_work_area_phys(area);\n+\n+\trc = prepare_errinjct_buffer(buf, pe, rtas_err_type, func, addr, mask);\n+\tif (rc)\n+\t\tgoto out_free_area;\n+\n+\t/*\n+\t * RTAS work areas are allocated below RTAS_INSTANTIATE_MAX, so\n+\t * area_phys fits in the 32-bit RTAS argument.\n+\t */\n+\tdo {\n+\t\trc = rtas_call(errinjct_token, 3, 1, NULL,\n+\t\t\t       rtas_err_type, session_token,\n+\t\t\t       (u32)area_phys);\n+\t} while (rtas_busy_delay(rc));\n+\n+\tif (rc) {\n+\t\tpr_err(\"ibm,errinjct failed: status=%d\\n\", rc);\n+\t\trc = rtas_error_rc(rc);\n+\t}\n+\n+out_free_area:\n+\trtas_work_area_free(area);\n+\n+\tdo {\n+\t\tclose_rc = rtas_call(close_token, 1, 1, NULL, session_token);\n+\t} while (rtas_busy_delay(close_rc));\n+\n+\tif (close_rc) {\n+\t\tpr_warn(\"ibm,close-errinjct failed: status=%d\\n\", close_rc);\n+\t\tif (!rc)\n+\t\t\trc = rtas_error_rc(close_rc);\n+\t}\n+\n+out_unlock:\n+\tmutex_unlock(\u0026errinjct_mutex);\n+\treturn rc;\n+}\n+\n static struct eeh_ops pseries_eeh_ops = {\n \t.name\t\t\t= \"pseries\",\n \t.probe\t\t\t= pseries_eeh_probe,\ndiff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c\nindex 1c0eec228cc6f..dad9ba54bae60 100644\n--- a/drivers/vfio/vfio_iommu_spapr_tce.c\n+++ b/drivers/vfio/vfio_iommu_spapr_tce.c\n@@ -774,6 +774,97 @@ static long tce_iommu_create_default_window(struct tce_container *container)\n \treturn ret;\n }\n \n+static int vfio_spapr_eeh_normalize_addr(struct eeh_pe *pe,\n+\t\t\t\t\t unsigned long addr,\n+\t\t\t\t\t unsigned long mask,\n+\t\t\t\t\t unsigned long *normalized)\n+{\n+\tstruct pci_bus_region region;\n+\tstruct eeh_dev *edev, *tmp;\n+\tstruct pci_dev *pdev;\n+\tstruct resource *res;\n+\tresource_size_t pci_start, pci_len;\n+\tresource_size_t res_start, res_len;\n+\tresource_size_t offset;\n+\tint bar, rc = -EINVAL;\n+\n+\tif (!pe || !normalized)\n+\t\treturn -EINVAL;\n+\n+\t/*\n+\t * addr == 0 and mask == 0 indicates a no-address injection (e.g.\n+\t * function-level error with no specific IOA target).  No BAR\n+\t * translation needed.\n+\t */\n+\tif (!addr \u0026\u0026 !mask) {\n+\t\t*normalized = addr;\n+\t\treturn 0;\n+\t}\n+\n+\t/*\n+\t * Walk standard BARs (BAR0..BAR5) of all devices in the PE.\n+\t * Hold pci_rescan_remove_lock to protect pdev lifetime during the\n+\t * traversal: pci_stop_and_remove_bus_device() requires this lock.\n+\t * ROM and bridge resources are not IOA bus-error targets, so the\n+\t * search is limited to PCI_STD_NUM_BARS.\n+\t */\n+\tpci_lock_rescan_remove();\n+\teeh_pe_for_each_dev(pe, edev, tmp) {\n+\t\tpdev = eeh_dev_to_pci_dev(edev);\n+\t\tif (!pdev)\n+\t\t\tcontinue;\n+\n+\t\tfor (bar = 0; bar \u003c PCI_STD_NUM_BARS; bar++) {\n+\t\t\tres = \u0026pdev-\u003eresource[bar];\n+\n+\t\t\tif (!resource_size(res))\n+\t\t\t\tcontinue;\n+\n+\t\t\tif (!(res-\u003eflags \u0026 (IORESOURCE_MEM | IORESOURCE_IO)))\n+\t\t\t\tcontinue;\n+\n+\t\t\tpcibios_resource_to_bus(pdev-\u003ebus, \u0026region, res);\n+\n+\t\t\tpci_start = region.start;\n+\t\t\tpci_len = resource_size(res);\n+\n+\t\t\t/*\n+\t\t\t * Case 1: userspace already supplied PCI/IOA\n+\t\t\t * bus address.\n+\t\t\t */\n+\t\t\tif ((resource_size_t)addr \u003e= pci_start \u0026\u0026\n+\t\t\t    ((resource_size_t)addr - pci_start) \u003c pci_len) {\n+\t\t\t\t*normalized = addr;\n+\t\t\t\trc = 0;\n+\t\t\t\tgoto done;\n+\t\t\t}\n+\n+\t\t\t/*\n+\t\t\t * Case 2: userspace supplied Linux resource/CPU\n+\t\t\t * address.  Convert it back to PCI/IOA bus address\n+\t\t\t * before calling the platform EEH backend.\n+\t\t\t */\n+\t\t\tres_start = res-\u003estart;\n+\t\t\tres_len = resource_size(res);\n+\n+\t\t\tif ((resource_size_t)addr \u003e= res_start \u0026\u0026\n+\t\t\t    ((resource_size_t)addr - res_start) \u003c res_len) {\n+\t\t\t\toffset = (resource_size_t)addr - res_start;\n+\t\t\t\t*normalized = region.start + offset;\n+\t\t\t\trc = 0;\n+\t\t\t\tgoto done;\n+\t\t\t}\n+\t\t}\n+\t}\n+done:\n+\tpci_unlock_rescan_remove();\n+\n+\tif (rc)\n+\t\tpr_debug(\"vfio EEH: addr=0x%lx not found in any PCI bus BAR of PE, injection may fail\\n\",\n+\t\t\t addr);\n+\treturn rc;\n+}\n+\n static long vfio_spapr_ioctl_eeh_pe_op(struct iommu_group *group,\n \t\t\t\t       unsigned long arg)\n {\n@@ -818,6 +909,20 @@ static long vfio_spapr_ioctl_eeh_pe_op(struct iommu_group *group,\n \t\tif (copy_from_user(\u0026op, (void __user *)arg, minsz))\n \t\t\treturn -EFAULT;\n \n+\t\tif (op.err.type == EEH_ERR_TYPE_32 ||\n+\t\t    op.err.type == EEH_ERR_TYPE_64) {\n+\t\t\tunsigned long normalized;\n+\t\t\tint ret;\n+\n+\t\t\tret = vfio_spapr_eeh_normalize_addr(pe, op.err.addr,\n+\t\t\t\t\t\t\t    op.err.mask,\n+\t\t\t\t\t\t\t    \u0026normalized);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\n+\t\t\top.err.addr = normalized;\n+\t\t}\n+\n \t\treturn eeh_pe_inject_err(pe, op.err.type, op.err.func,\n \t\t\t\t\t op.err.addr, op.err.mask);\n \tdefault:\n"
}

2/1 2026/10/19 10:36 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies PowerPC architecture code (in arch/powerpc/) and the sPAPR TCE VFIO IOMMU driver (drivers/vfio/vfio_iommu_spapr_tce.c, which depends on CONFIG_SPAPR_TCE_IOMMU, requiring CONFIG_PPC_POWERNV or CONFIG_PPC_PSERIES). None of this code can be compiled or executed on the target architecture (amd64), as all modified paths are strictly exclusive to PowerPC.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 39f17b64d7cfdde78f605ac371d7baebf3b94002
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Oct 19 10:36:08 2026 +0000

    syz-cluster: applied patch under review

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index b7ebb4ac2c710..083ac58e7eb73 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -310,8 +310,6 @@ int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed);
 int eeh_pe_configure(struct eeh_pe *pe);
 int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
 		      unsigned long addr, unsigned long mask);
-int eeh_pe_inject_mmio_error(struct pci_dev *pdev);
-
 /**
  * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
  *
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index bb836f02101cf..369aad298f752 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1664,11 +1664,6 @@ static int eeh_break_device(struct pci_dev *pdev)
 	return 0;
 }
 
-int eeh_pe_inject_mmio_error(struct pci_dev *pdev)
-{
-	return eeh_break_device(pdev);
-}
-
 #ifdef CONFIG_DEBUG_FS
 
 
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 8d81c1e7a8db1..38f3d08d4228c 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -1117,6 +1117,28 @@ static bool token_is_restricted_errinjct(s32 token)
 	       token == rtas_function_token(RTAS_FN_IBM_ERRINJCT);
 }
 
+/*
+ * ibm,open-errinjct uses a non-standard return layout:
+ *   rets[0] = session token  (output parameter)
+ *   rets[1] = status code
+ *
+ * All other RTAS functions use the standard layout:
+ *   rets[0] = status code
+ *   rets[1..] = output parameters
+ */
+static inline bool rtas_token_is_open_errinjct(int token)
+{
+	return token == rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT);
+}
+
+static int rtas_status_from_args(int token, struct rtas_args *args, int nret)
+{
+	if (rtas_token_is_open_errinjct(token))
+		return be32_to_cpu(args->rets[1]);
+
+	return nret > 0 ? be32_to_cpu(args->rets[0]) : 0;
+}
+
 /**
  * rtas_call() - Invoke an RTAS firmware function.
  * @token: Identifies the function being invoked.
@@ -1198,6 +1220,16 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
 			return -1;
 	}
 
+	/*
+	 * ibm,open-errinjct returns rets[0]=session_token, rets[1]=status.
+	 * We need nret >= 2 to read status from rets[1].  Reject early if
+	 * the caller forgot to account for the extra return cell.
+	 */
+	if (rtas_token_is_open_errinjct(token) && nret < 2) {
+		WARN_ON_ONCE(1);
+		return -EINVAL;
+	}
+
 	if ((mfmsr() & (MSR_IR|MSR_DR)) != (MSR_IR|MSR_DR)) {
 		WARN_ON_ONCE(1);
 		return -1;
@@ -1213,15 +1245,33 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
 	va_rtas_call_unlocked(args, token, nargs, nret, list);
 	va_end(list);
 
+	ret = rtas_status_from_args(token, args, nret);
+
 	/* A -1 return code indicates that the last command couldn't
-	   be completed due to a hardware error. */
-	if (be32_to_cpu(args->rets[0]) == -1)
+	 * be completed due to a hardware error.
+	 */
+	if (ret == -1)
 		buff_copy = __fetch_rtas_last_error(NULL);
 
-	if (nret > 1 && outputs != NULL)
-		for (i = 0; i < nret-1; ++i)
-			outputs[i] = be32_to_cpu(args->rets[i + 1]);
-	ret = (nret > 0) ? be32_to_cpu(args->rets[0]) : 0;
+	/*
+	 * Copy non-status outputs to the caller's buffer.
+	 *
+	 * For ibm,open-errinjct the layout is:
+	 *   rets[0] = session token  -> outputs[0]
+	 *   rets[1] = status         (returned, not copied)
+	 *
+	 * For all other RTAS functions:
+	 *   rets[0] = status         (returned, not copied)
+	 *   rets[1..nret-1] -> outputs[0..nret-2]
+	 */
+	if (outputs) {
+		if (rtas_token_is_open_errinjct(token)) {
+			outputs[0] = be32_to_cpu(args->rets[0]);
+		} else if (nret > 1) {
+			for (i = 0; i < nret - 1; ++i)
+				outputs[i] = be32_to_cpu(args->rets[i + 1]);
+		}
+	}
 
 	lockdep_unpin_lock(&rtas_lock, cookie);
 	raw_spin_unlock_irqrestore(&rtas_lock, flags);
@@ -1896,6 +1946,14 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
 	if (block_rtas_call(func, nargs, &args))
 		return -EINVAL;
 
+	/*
+	 * ibm,open-errinjct places status at rets[1]; reject calls with
+	 * fewer than 2 return cells before entering RTAS, since reading
+	 * rets[1] for the -1 sentinel would be out of bounds.
+	 */
+	if (rtas_token_is_open_errinjct(token) && nret < 2)
+		return -EINVAL;
+
 	if (token_is_restricted_errinjct(token)) {
 		int err;
 
@@ -1942,9 +2000,11 @@ SYSCALL_DEFINE1(rtas, struct rtas_args __user *, uargs)
 	do_enter_rtas(&rtas_args);
 	args = rtas_args;
 
-	/* A -1 return code indicates that the last command couldn't
-	   be completed due to a hardware error. */
-	if (be32_to_cpu(args.rets[0]) == -1)
+	/*
+	 * A -1 return code indicates that the last command couldn't
+	 * be completed due to a hardware error.
+	 */
+	if (rtas_status_from_args(token, &args, nret) == -1)
 		errbuf = __fetch_rtas_last_error(buff_copy);
 
 	lockdep_unpin_lock(&rtas_lock, cookie);
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index db3370d1673c3..01dae760cecb5 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -1167,12 +1167,24 @@ 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_err_type;
 	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);
+	/*
+	 * eeh_pe_inject_err() receives generic EEH error types from the
+	 * VFIO/EEH userspace ABI.  The PowerNV backend must not rely on
+	 * these generic values being numerically identical to OPAL firmware
+	 * values.  Translate to OPAL-specific types before calling firmware.
+	 */
+	switch (type) {
+	case EEH_ERR_TYPE_32:
+		opal_err_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR;
+		break;
+	case EEH_ERR_TYPE_64:
+		opal_err_type = OPAL_ERR_INJECT_TYPE_IOA_BUS_ERR64;
+		break;
+	default:
+		pr_warn("%s: Invalid error type %d\n", __func__, type);
 		return -ERANGE;
 	}
 
@@ -1192,7 +1204,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_err_type, func, addr, mask);
 	if (rc != OPAL_SUCCESS) {
 		pr_warn("%s: Failure %lld injecting error "
 			"%d-%d to PHB#%x-PE#%x\n",
diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
index b12ef382fec70..52d0010426635 100644
--- a/arch/powerpc/platforms/pseries/eeh_pseries.c
+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
@@ -12,6 +12,8 @@
  * Copyright Linas Vepstas 2005, 2006
  */
 
+#define pr_fmt(fmt) "EEH: " fmt
+
 #include <linux/atomic.h>
 #include <linux/delay.h>
 #include <linux/export.h>
@@ -22,7 +24,9 @@
 #include <linux/proc_fs.h>
 #include <linux/rbtree.h>
 #include <linux/sched.h>
+#include <linux/mutex.h>
 #include <linux/seq_file.h>
+#include <linux/sizes.h>
 #include <linux/spinlock.h>
 #include <linux/crash_dump.h>
 
@@ -32,6 +36,7 @@
 #include <asm/machdep.h>
 #include <asm/ppc-pci.h>
 #include <asm/rtas.h>
+#include <asm/rtas-work-area.h>
 
 /* RTAS tokens */
 static int ibm_set_eeh_option;
@@ -786,43 +791,326 @@ static int pseries_notify_resume(struct eeh_dev *edev)
 }
 #endif
 
+/*
+ * RTAS firmware error-type encodings (PAPR).  These are pseries-private;
+ * user-space sees only the generic EEH_ERR_TYPE_* values from eeh.h.
+ * Only IOA bus-error types are supported; other PAPR encodings are not
+ * reachable through the generic EEH_ERR_TYPE_* UAPI.
+ */
+#define RTAS_ERR_TYPE_IOA_BUS_ERROR		0x07
+#define RTAS_ERR_TYPE_IOA_BUS_ERROR_64		0x0f
+
+/* Size of the ibm,errinjct work buffer as defined by PAPR */
+#define RTAS_ERRINJCT_BUF_SIZE			SZ_1K
+
 /**
- * pseries_eeh_err_inject - Inject specified error to the indicated PE
- * @pe: the indicated PE
- * @type: error type
- * @func: specific error type
- * @addr: address
- * @mask: address mask
- * The routine is called to inject specified error, which is
- * determined by @type and @func, to the indicated PE
+ * pseries_eeh_type_to_rtas - Map generic EEH error type to RTAS encoding
+ * @type: generic EEH error type (EEH_ERR_TYPE_32, EEH_ERR_TYPE_64)
+ *
+ * Translates the generic VFIO/EEH error type passed from userspace into
+ * the RTAS-specific ibm,errinjct error type encoding defined by PAPR.
+ *
+ * Return: RTAS error type on success, -EINVAL for unknown types.
  */
-static int pseries_eeh_err_inject(struct eeh_pe *pe, int type, int func,
+static int pseries_eeh_type_to_rtas(int type)
+{
+	switch (type) {
+	case EEH_ERR_TYPE_32:
+		return RTAS_ERR_TYPE_IOA_BUS_ERROR;
+	case EEH_ERR_TYPE_64:
+		return RTAS_ERR_TYPE_IOA_BUS_ERROR_64;
+	default:
+		return -EINVAL;
+	}
+}
+
+/**
+ * validate_addr_mask_in_pe - Validate addr against PCI bus BAR addresses in PE
+ * @pe:   EEH PE containing one or more PCI devices
+ * @addr: PCI bus address to validate
+ * @mask: address mask (passed to firmware unchanged)
+ *
+ * RTAS IOA bus-error injection uses PCI bus addresses.  Linux PCI resources
+ * are CPU/resource addresses and may differ on pseries due to PHB window
+ * translation.  Convert each BAR resource to PCI bus address space before
+ * validating @addr.
+ *
+ * Zero addr and mask are accepted without BAR lookup (no-address injection).
+ *
+ * Return: 0 if valid, -EINVAL on invalid input.
+ */
+static int validate_addr_mask_in_pe(struct eeh_pe *pe, unsigned long addr,
+				    unsigned long mask)
+{
+	struct pci_bus_region region;
+	struct eeh_dev *edev, *tmp;
+	struct pci_dev *pdev;
+	struct resource *res;
+	resource_size_t bus_start;
+	resource_size_t bus_len;
+	bool found = false;
+	int bar;
+
+	if (!addr && !mask)
+		return 0;
+
+	if (!pe)
+		return -EINVAL;
+
+	/*
+	 * RTAS IOA bus-error injection uses PCI bus addresses. Linux PCI
+	 * resources are CPU/resource addresses and may differ on pseries due
+	 * to PHB window translation. Convert each BAR resource to PCI bus
+	 * address space before validating @addr.
+	 *
+	 * Hold pci_rescan_remove_lock across the traversal to protect pdev
+	 * lifetime: pci_stop_and_remove_bus_device() requires this lock.
+	 */
+	pci_lock_rescan_remove();
+	eeh_pe_for_each_dev(pe, edev, tmp) {
+		pdev = eeh_dev_to_pci_dev(edev);
+		if (!pdev)
+			continue;
+
+		/*
+		 * Validate against standard BARs (BAR0..BAR5) only.
+		 * ROM and bridge resources are not IOA bus-error targets.
+		 */
+		for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
+			res = &pdev->resource[bar];
+
+			if (!resource_size(res))
+				continue;
+
+			if (!(res->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
+				continue;
+
+			pcibios_resource_to_bus(pdev->bus, &region, res);
+
+			bus_start = region.start;
+			bus_len = resource_size(res);
+
+			if ((resource_size_t)addr >= bus_start &&
+			    ((resource_size_t)addr - bus_start) < bus_len) {
+				pr_debug("addr=0x%lx mask=0x%lx validated in PCI bus BAR[%d] of %s: bus range 0x%llx-0x%llx\n",
+					 addr, mask, bar, pci_name(pdev),
+					 (unsigned long long)region.start,
+					 (unsigned long long)region.end);
+				found = true;
+				goto done;
+			}
+		}
+	}
+done:
+	pci_unlock_rescan_remove();
+
+	if (!found)
+		pr_err("addr=0x%lx mask=0x%lx not within any PCI bus BAR of any device in PE\n",
+		       addr, mask);
+	return found ? 0 : -EINVAL;
+}
+
+/**
+ * validate_errinjct_args - Top-level validation for RTAS error injection arguments
+ * @pe:   EEH PE for the target device
+ * @type: generic EEH error type
+ * @func: error function selector
+ * @addr: address argument (type-dependent, may be zero)
+ * @mask: mask argument (type-dependent, may be zero)
+ *
+ * Validates all parameters before opening an RTAS injection session.
+ * Returns Linux errno values; does not return raw RTAS status codes.
+ *
+ * Return: 0 if all parameters are valid, negative errno otherwise.
+ */
+static int validate_errinjct_args(struct eeh_pe *pe, int type, int func,
 				  unsigned long addr, unsigned long mask)
 {
-	struct	eeh_dev	*pdev;
+	if (!pe || !pe->phb)
+		return -EINVAL;
+
+	if (pseries_eeh_type_to_rtas(type) < 0)
+		return -EINVAL;
 
-	/* Check on PCI error type */
-	if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64)
+	if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX)
 		return -EINVAL;
 
-	switch (func) {
-	case EEH_ERR_FUNC_LD_MEM_ADDR:
-	case EEH_ERR_FUNC_LD_MEM_DATA:
-	case EEH_ERR_FUNC_ST_MEM_ADDR:
-	case EEH_ERR_FUNC_ST_MEM_DATA:
-		/* injects a MMIO error for all pdev's belonging to PE */
-		pci_lock_rescan_remove();
-		list_for_each_entry(pdev, &pe->edevs, entry)
-			eeh_pe_inject_mmio_error(pdev->pdev);
-		pci_unlock_rescan_remove();
+	return 0;
+}
+
+/**
+ * prepare_errinjct_buffer() - Build ibm,errinjct work buffer
+ * @buf: RTAS error-injection work buffer
+ * @pe: EEH PE associated with the injection target
+ * @rtas_err_type: RTAS firmware error-injection type
+ * @func: Error function selector
+ * @addr: Target PCI bus address
+ * @mask: Address mask passed to firmware
+ *
+ * Zeroes @buf and populates it according to the PAPR layout for the
+ * selected IOA bus-error injection type.
+ *
+ * The caller provides an exclusive per-call RTAS work-area buffer.
+ * Firmware session serialization is handled by pseries_eeh_err_inject().
+ *
+ * Return: 0 on success or a negative errno on invalid input.
+ */
+static int prepare_errinjct_buffer(void *buf, struct eeh_pe *pe,
+				   int rtas_err_type, int func,
+				   unsigned long addr, unsigned long mask)
+{
+	__be64 *buf64 = (__be64 *)buf;
+	__be32 *buf32 = (__be32 *)buf;
+	int rc;
+
+	if (!buf || !pe || !pe->phb)
+		return -EINVAL;
+
+	memset(buf, 0, RTAS_ERRINJCT_BUF_SIZE);
+
+	switch (rtas_err_type) {
+	case RTAS_ERR_TYPE_IOA_BUS_ERROR:
+		if (upper_32_bits(addr) || upper_32_bits(mask))
+			return -EINVAL;
+
+		rc = validate_addr_mask_in_pe(pe, addr, mask);
+		if (rc)
+			return rc;
+
+		buf32[0] = cpu_to_be32((u32)addr);
+		buf32[1] = cpu_to_be32((u32)mask);
+		buf32[2] = cpu_to_be32(pe->addr);
+		buf32[3] = cpu_to_be32(BUID_HI(pe->phb->buid));
+		buf32[4] = cpu_to_be32(BUID_LO(pe->phb->buid));
+		buf32[5] = cpu_to_be32(func);
 		break;
+
+	case RTAS_ERR_TYPE_IOA_BUS_ERROR_64:
+		rc = validate_addr_mask_in_pe(pe, addr, mask);
+		if (rc)
+			return rc;
+
+		buf64[0] = cpu_to_be64(addr);
+		buf64[1] = cpu_to_be64(mask);
+		buf32[4] = cpu_to_be32(pe->addr);
+		buf32[5] = cpu_to_be32(BUID_HI(pe->phb->buid));
+		buf32[6] = cpu_to_be32(BUID_LO(pe->phb->buid));
+		buf32[7] = cpu_to_be32(func);
+		break;
+
 	default:
-		return -ERANGE;
+		pr_err("unsupported RTAS error injection type 0x%x\n", rtas_err_type);
+		return -EINVAL;
 	}
 
+	pr_debug("errinjct buffer ready: rtas_err_type=0x%x func=%d addr=0x%lx mask=0x%lx\n",
+		 rtas_err_type, func, addr, mask);
 	return 0;
 }
 
+/* Serializes the open/inject/close RTAS error injection session */
+static DEFINE_MUTEX(errinjct_mutex);
+
+/**
+ * pseries_eeh_err_inject - Inject specified error to the indicated PE
+ * @pe: the indicated PE
+ * @type: generic EEH error type (EEH_ERR_TYPE_32 or EEH_ERR_TYPE_64)
+ * @func: specific error function
+ * @addr: address argument (type-dependent, may be zero)
+ * @mask: address mask (type-dependent, may be zero)
+ *
+ * Implements PAPR-compliant error injection using:
+ *   ibm,open-errinjct -> ibm,errinjct -> ibm,close-errinjct
+ *
+ * errinjct_mutex serializes the open/inject/close session sequence
+ * because RTAS maintains state between these calls.  A short-lived
+ * RTAS work area is allocated after a successful open and freed before
+ * close.
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+static int pseries_eeh_err_inject(struct eeh_pe *pe, int type, int func,
+				  unsigned long addr, unsigned long mask)
+{
+	struct rtas_work_area *area;
+	phys_addr_t area_phys;
+	void *buf;
+	int open_token, errinjct_token, close_token;
+	int session_token;
+	int rtas_err_type;
+	int close_rc;
+	int rc;
+
+	rc = validate_errinjct_args(pe, type, func, addr, mask);
+	if (rc)
+		return rc;
+
+	rtas_err_type = pseries_eeh_type_to_rtas(type);
+	if (rtas_err_type < 0)
+		return -EINVAL;
+
+	open_token = rtas_function_token(RTAS_FN_IBM_OPEN_ERRINJCT);
+	errinjct_token = rtas_function_token(RTAS_FN_IBM_ERRINJCT);
+	close_token = rtas_function_token(RTAS_FN_IBM_CLOSE_ERRINJCT);
+
+	if (open_token == RTAS_UNKNOWN_SERVICE ||
+	    errinjct_token == RTAS_UNKNOWN_SERVICE ||
+	    close_token == RTAS_UNKNOWN_SERVICE)
+		return -ENODEV;
+
+	mutex_lock(&errinjct_mutex);
+
+	do {
+		rc = rtas_call(open_token, 0, 2, &session_token);
+	} while (rtas_busy_delay(rc));
+
+	if (rc) {
+		pr_err("ibm,open-errinjct failed: status=%d\n", rc);
+		rc = rtas_error_rc(rc);
+		goto out_unlock;
+	}
+
+	area = rtas_work_area_alloc(RTAS_ERRINJCT_BUF_SIZE);
+	buf = rtas_work_area_raw_buf(area);
+	area_phys = rtas_work_area_phys(area);
+
+	rc = prepare_errinjct_buffer(buf, pe, rtas_err_type, func, addr, mask);
+	if (rc)
+		goto out_free_area;
+
+	/*
+	 * RTAS work areas are allocated below RTAS_INSTANTIATE_MAX, so
+	 * area_phys fits in the 32-bit RTAS argument.
+	 */
+	do {
+		rc = rtas_call(errinjct_token, 3, 1, NULL,
+			       rtas_err_type, session_token,
+			       (u32)area_phys);
+	} while (rtas_busy_delay(rc));
+
+	if (rc) {
+		pr_err("ibm,errinjct failed: status=%d\n", rc);
+		rc = rtas_error_rc(rc);
+	}
+
+out_free_area:
+	rtas_work_area_free(area);
+
+	do {
+		close_rc = rtas_call(close_token, 1, 1, NULL, session_token);
+	} while (rtas_busy_delay(close_rc));
+
+	if (close_rc) {
+		pr_warn("ibm,close-errinjct failed: status=%d\n", close_rc);
+		if (!rc)
+			rc = rtas_error_rc(close_rc);
+	}
+
+out_unlock:
+	mutex_unlock(&errinjct_mutex);
+	return rc;
+}
+
 static struct eeh_ops pseries_eeh_ops = {
 	.name			= "pseries",
 	.probe			= pseries_eeh_probe,
diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index 1c0eec228cc6f..dad9ba54bae60 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -774,6 +774,97 @@ static long tce_iommu_create_default_window(struct tce_container *container)
 	return ret;
 }
 
+static int vfio_spapr_eeh_normalize_addr(struct eeh_pe *pe,
+					 unsigned long addr,
+					 unsigned long mask,
+					 unsigned long *normalized)
+{
+	struct pci_bus_region region;
+	struct eeh_dev *edev, *tmp;
+	struct pci_dev *pdev;
+	struct resource *res;
+	resource_size_t pci_start, pci_len;
+	resource_size_t res_start, res_len;
+	resource_size_t offset;
+	int bar, rc = -EINVAL;
+
+	if (!pe || !normalized)
+		return -EINVAL;
+
+	/*
+	 * addr == 0 and mask == 0 indicates a no-address injection (e.g.
+	 * function-level error with no specific IOA target).  No BAR
+	 * translation needed.
+	 */
+	if (!addr && !mask) {
+		*normalized = addr;
+		return 0;
+	}
+
+	/*
+	 * Walk standard BARs (BAR0..BAR5) of all devices in the PE.
+	 * Hold pci_rescan_remove_lock to protect pdev lifetime during the
+	 * traversal: pci_stop_and_remove_bus_device() requires this lock.
+	 * ROM and bridge resources are not IOA bus-error targets, so the
+	 * search is limited to PCI_STD_NUM_BARS.
+	 */
+	pci_lock_rescan_remove();
+	eeh_pe_for_each_dev(pe, edev, tmp) {
+		pdev = eeh_dev_to_pci_dev(edev);
+		if (!pdev)
+			continue;
+
+		for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
+			res = &pdev->resource[bar];
+
+			if (!resource_size(res))
+				continue;
+
+			if (!(res->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
+				continue;
+
+			pcibios_resource_to_bus(pdev->bus, &region, res);
+
+			pci_start = region.start;
+			pci_len = resource_size(res);
+
+			/*
+			 * Case 1: userspace already supplied PCI/IOA
+			 * bus address.
+			 */
+			if ((resource_size_t)addr >= pci_start &&
+			    ((resource_size_t)addr - pci_start) < pci_len) {
+				*normalized = addr;
+				rc = 0;
+				goto done;
+			}
+
+			/*
+			 * Case 2: userspace supplied Linux resource/CPU
+			 * address.  Convert it back to PCI/IOA bus address
+			 * before calling the platform EEH backend.
+			 */
+			res_start = res->start;
+			res_len = resource_size(res);
+
+			if ((resource_size_t)addr >= res_start &&
+			    ((resource_size_t)addr - res_start) < res_len) {
+				offset = (resource_size_t)addr - res_start;
+				*normalized = region.start + offset;
+				rc = 0;
+				goto done;
+			}
+		}
+	}
+done:
+	pci_unlock_rescan_remove();
+
+	if (rc)
+		pr_debug("vfio EEH: addr=0x%lx not found in any PCI bus BAR of PE, injection may fail\n",
+			 addr);
+	return rc;
+}
+
 static long vfio_spapr_ioctl_eeh_pe_op(struct iommu_group *group,
 				       unsigned long arg)
 {
@@ -818,6 +909,20 @@ static long vfio_spapr_ioctl_eeh_pe_op(struct iommu_group *group,
 		if (copy_from_user(&op, (void __user *)arg, minsz))
 			return -EFAULT;
 
+		if (op.err.type == EEH_ERR_TYPE_32 ||
+		    op.err.type == EEH_ERR_TYPE_64) {
+			unsigned long normalized;
+			int ret;
+
+			ret = vfio_spapr_eeh_normalize_addr(pe, op.err.addr,
+							    op.err.mask,
+							    &normalized);
+			if (ret)
+				return ret;
+
+			op.err.addr = normalized;
+		}
+
 		return eeh_pe_inject_err(pe, op.err.type, op.err.func,
 					 op.err.addr, op.err.mask);
 	default:

3/2 2026/10/19 10:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 11594
							output: 47
							thoughts: 287
						

Thoughts:
**Analyzing the Patch for Compatibility**

Okay, let's break this down. First, the target architecture is listed as amd64, which is important to keep in mind. Now, the diff tells the story of modified files: `arch/powerpc/include/asm/eeh.h`, `arch/powerpc/kernel/eeh.c`, `arch/powerpc/kernel/rtas.c`, `arch/powerpc/platforms/powernv/eeh-powernv.c`, `arch/powerpc/platforms/pseries/eeh_pseries.c`, and finally, `drivers/vfio/vfio_iommu_spapr_tce.c`.

The initial bunch, under `arch/powerpc/`, clearly points to PowerPC-specific architecture code, which is expected. However, the last file, `drivers/vfio/vfio_iommu_spapr_tce.c` gives me pause. This warrants further investigation. I need to determine if this file is conditionally compiled based on the architecture.

The critical question now is whether the `vfio_iommu_spapr_tce.c` code is even relevant or able to be compiled and run on an amd64 system or if it's strictly PowerPC. Time to consult the Kconfig. I'll need to use my tools – `grepper` or possibly just `read-file` – to quickly check the Kconfig configuration options in that directory to get the answer. This will determine if the patch is truly applicable to the target architecture.



4/2 2026/10/19 10:36 tool grepper
0m Args:
{
  "Expression": "vfio_iommu_spapr_tce|SPAPR_TCE_IOMMU",
  "PathPrefixes": [
    "drivers/vfio"
  ]
}

Results:
{
  "Output": "drivers/vfio/Kconfig=2=menuconfig VFIO\n--\ndrivers/vfio/Kconfig-6-\tselect INTERVAL_TREE\ndrivers/vfio/Kconfig:7:\tselect VFIO_GROUP if SPAPR_TCE_IOMMU || IOMMUFD=n\ndrivers/vfio/Kconfig-8-\tselect VFIO_DEVICE_CDEV if !VFIO_GROUP\n--\ndrivers/vfio/Kconfig=17=config VFIO_DEVICE_CDEV\ndrivers/vfio/Kconfig-18-\tbool \"Support for the VFIO cdev /dev/vfio/devices/vfioX\"\ndrivers/vfio/Kconfig:19:\tdepends on IOMMUFD \u0026\u0026 !SPAPR_TCE_IOMMU\ndrivers/vfio/Kconfig-20-\tdefault !VFIO_GROUP\n--\ndrivers/vfio/Kconfig=56=config VFIO_IOMMU_SPAPR_TCE\ndrivers/vfio/Kconfig-57-\ttristate\ndrivers/vfio/Kconfig:58:\tdepends on SPAPR_TCE_IOMMU\ndrivers/vfio/Kconfig-59-\tdefault VFIO\n--\ndrivers/vfio/Makefile=12=obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o\ndrivers/vfio/Makefile:13:obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o\ndrivers/vfio/Makefile-14-obj-$(CONFIG_VFIO_PCI_CORE) += pci/\n--\ndrivers/vfio/group.c=809=struct iommu_group *vfio_file_iommu_group(struct file *file)\n--\ndrivers/vfio/group.c-813-\ndrivers/vfio/group.c:814:\tif (!IS_ENABLED(CONFIG_SPAPR_TCE_IOMMU))\ndrivers/vfio/group.c-815-\t\treturn NULL;\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c=316=static void *tce_iommu_open(unsigned long arg)\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-319-\ndrivers/vfio/vfio_iommu_spapr_tce.c:320:\tif ((arg != VFIO_SPAPR_TCE_IOMMU) \u0026\u0026 (arg != VFIO_SPAPR_TCE_v2_IOMMU)) {\ndrivers/vfio/vfio_iommu_spapr_tce.c-321-\t\tpr_err(\"tce_vfio: Wrong IOMMU type\\n\");\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c=933=static long tce_iommu_ioctl(void *iommu_data,\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-942-\t\tswitch (arg) {\ndrivers/vfio/vfio_iommu_spapr_tce.c:943:\t\tcase VFIO_SPAPR_TCE_IOMMU:\ndrivers/vfio/vfio_iommu_spapr_tce.c-944-\t\tcase VFIO_SPAPR_TCE_v2_IOMMU:\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-962-\tcase VFIO_IOMMU_SPAPR_TCE_GET_INFO: {\ndrivers/vfio/vfio_iommu_spapr_tce.c:963:\t\tstruct vfio_iommu_spapr_tce_info info;\ndrivers/vfio/vfio_iommu_spapr_tce.c-964-\t\tstruct tce_iommu_group *tcegrp;\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-976-\ndrivers/vfio/vfio_iommu_spapr_tce.c:977:\t\tminsz = offsetofend(struct vfio_iommu_spapr_tce_info,\ndrivers/vfio/vfio_iommu_spapr_tce.c-978-\t\t\t\tdma32_window_size);\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-999-\ndrivers/vfio/vfio_iommu_spapr_tce.c:1000:\t\tddwsz = offsetofend(struct vfio_iommu_spapr_tce_info, ddw);\ndrivers/vfio/vfio_iommu_spapr_tce.c-1001-\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-1211-\tcase VFIO_IOMMU_SPAPR_TCE_CREATE: {\ndrivers/vfio/vfio_iommu_spapr_tce.c:1212:\t\tstruct vfio_iommu_spapr_tce_create create;\ndrivers/vfio/vfio_iommu_spapr_tce.c-1213-\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-1223-\ndrivers/vfio/vfio_iommu_spapr_tce.c:1224:\t\tminsz = offsetofend(struct vfio_iommu_spapr_tce_create,\ndrivers/vfio/vfio_iommu_spapr_tce.c-1225-\t\t\t\tstart_addr);\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-1252-\tcase VFIO_IOMMU_SPAPR_TCE_REMOVE: {\ndrivers/vfio/vfio_iommu_spapr_tce.c:1253:\t\tstruct vfio_iommu_spapr_tce_remove remove;\ndrivers/vfio/vfio_iommu_spapr_tce.c-1254-\n--\ndrivers/vfio/vfio_iommu_spapr_tce.c-1264-\ndrivers/vfio/vfio_iommu_spapr_tce.c:1265:\t\tminsz = offsetofend(struct vfio_iommu_spapr_tce_remove,\ndrivers/vfio/vfio_iommu_spapr_tce.c-1266-\t\t\t\tstart_addr);\n--\ndrivers/vfio/vfio_main.c=1886=MODULE_DESCRIPTION(DRIVER_DESC);\ndrivers/vfio/vfio_main.c:1887:MODULE_SOFTDEP(\"post: vfio_iommu_type1 vfio_iommu_spapr_tce\");\n"
}

5/2 2026/10/19 10:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 13990
							output: 24
							thoughts: 24
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating `SPAPR_TCE_IOMMU` in the Kconfig Landscape**

Alright, time to get my hands dirty. My initial thought is to dive into the Kconfig files across the entire tree and thoroughly check the definition of `SPAPR_TCE_IOMMU`. This isn't just a casual glance; I'm talking a full-on audit. I need to understand exactly where this option is used, what dependencies it has, and perhaps most importantly, *why* it's defined the way it is. Are there any inconsistencies in how it's treated across different architectures or sub-systems? Are there any potential conflicts I can foresee based on existing configuration options? This is about getting a solid, comprehensive picture of its implications throughout the kernel configuration space. I'm looking for edge cases, potential gotchas, and opportunities for optimization or clarification in the documentation or code comments related to this. Let's see what secrets the Kconfig files are hiding!



6/2 2026/10/19 10:36 tool grepper
0m Args:
{
  "Expression": "config SPAPR_TCE_IOMMU"
}

Results:
{
  "Output": "drivers/iommu/Kconfig=282=config IPMMU_VMSA\n--\ndrivers/iommu/Kconfig-295-\ndrivers/iommu/Kconfig:296:config SPAPR_TCE_IOMMU\ndrivers/iommu/Kconfig-297-\tbool \"sPAPR TCE IOMMU Support\"\n"
}

7/2 2026/10/19 10:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 14361
							output: 36
							thoughts: 21
						

Thoughts:
Okay, let's dive into this. Here's my take on those instructions, as if they're my internal thought process:

**Diving into the IOMMU Kconfig**

Alright, time to get to the heart of this IOMMU configuration. My focus is going to be on the `drivers/iommu/Kconfig` file, specifically around line 296. I want to understand how a particular feature, or potential option, is being defined and how it's controlled. Is it conditional on a specific architecture? Does it depend on other kernel configurations? What are the implications of enabling or disabling it? I'm going to quickly parse the relevant code to get a clear picture of its behavior. I expect to see the usual suspects - `bool`, `tristate`, `select`, `depends on`, perhaps some `help` text. I’m hoping this is a relatively straightforward section, as I am trying to build a new feature. Let's see what we've got!



8/2 2026/10/19 10:36 tool read-file
0m Args:
{
  "File": "drivers/iommu/Kconfig",
  "FirstLine": 290,
  "LineCount": 25
}

Results:
{
  "Contents": " 290:\t\thelp\n 291:\t\t  Support for the Renesas VMSA-compatible IPMMU found in the R-Mobile\n 292:\t\t  APE6, R-Car Gen{2,3} and RZ/G{1,2} SoCs.\n 293:\t\n 294:\t\t  If unsure, say N.\n 295:\t\n 296:\tconfig SPAPR_TCE_IOMMU\n 297:\t\tbool \"sPAPR TCE IOMMU Support\"\n 298:\t\tdepends on PPC_POWERNV || PPC_PSERIES\n 299:\t\tselect IOMMU_API\n 300:\t\thelp\n 301:\t\t  Enables bits of IOMMU API required by VFIO. The iommu_ops\n 302:\t\t  is not implemented as it is not necessary for VFIO.\n 303:\t\n 304:\tconfig APPLE_DART\n 305:\t\ttristate \"Apple DART IOMMU Support\"\n 306:\t\tdepends on ARCH_APPLE || COMPILE_TEST\n 307:\t\tdepends on !GENERIC_ATOMIC64\t# for IOMMU_IO_PGTABLE_DART\n 308:\t\tselect IOMMU_API\n 309:\t\tselect IOMMU_IO_PGTABLE_DART\n 310:\t\thelp\n 311:\t\t  Support for Apple DART (Device Address Resolution Table) IOMMUs\n 312:\t\t  found in Apple ARM SoCs like the M1.\n 313:\t\t  This IOMMU is required for most peripherals using DMA to access\n 314:\t\t  the main memory.\n"
}

9/2 2026/10/19 10:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 15065
							output: 26
							thoughts: 120
						

Thoughts:
Okay, let's break this down.

**sPAPR TCE IOMMU Support - Kconfig Analysis**

Alright, so I'm looking at this Kconfig snippet and immediately, my attention is drawn to `depends on PPC_POWERNV || PPC_PSERIES`. This is key. It's essentially saying that the `SPAPR_TCE_IOMMU` option is *only* available if either `PPC_POWERNV` *or* `PPC_PSERIES` are defined.  Pretty standard Kconfig logic so far.

Now, the next thing I'm thinking is, "Let's make sure I'm clear on the dependencies of `PPC_POWERNV` and `PPC_PSERIES`." Because, naturally, those are probably tied to more fundamental architecture choices, and I know from experience that dependencies can form interesting, and sometimes tangled, webs. I need to be sure where `SPAPR_TCE_IOMMU` fits in the bigger picture of the PowerPC architecture support. So, I have to go double-check those. It's almost guaranteed they depend on something like `PPC` or `PPC64`. I should verify that, it's just good practice.



10/2 2026/10/19 10:36 tool grepper
0m Args:
{
  "Expression": "config PPC_P(SERIES|OWERNV)"
}

Results:
{
  "Output": "arch/powerpc/platforms/powernv/Kconfig-1-# SPDX-License-Identifier: GPL-2.0\narch/powerpc/platforms/powernv/Kconfig:2:config PPC_POWERNV\narch/powerpc/platforms/powernv/Kconfig-3-\tdepends on PPC64 \u0026\u0026 PPC_BOOK3S\n--\narch/powerpc/platforms/pseries/Kconfig-1-# SPDX-License-Identifier: GPL-2.0\narch/powerpc/platforms/pseries/Kconfig:2:config PPC_PSERIES\narch/powerpc/platforms/pseries/Kconfig-3-\tdepends on PPC64 \u0026\u0026 PPC_BOOK3S\n--\narch/powerpc/platforms/pseries/Kconfig=92=config LPARCFG\n--\narch/powerpc/platforms/pseries/Kconfig-98-\narch/powerpc/platforms/pseries/Kconfig:99:config PPC_PSERIES_DEBUG\narch/powerpc/platforms/pseries/Kconfig-100-\tdepends on PPC_PSERIES \u0026\u0026 PPC_EARLY_DEBUG\n"
}

11/2 2026/10/19 10:36 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 15754
							output: 143
							thoughts: 1108
						

Thoughts:
**Analysis of WorthFuzzing for Patch Series**

Okay, let's break this down. My goal is to determine if this patch series is "WorthFuzzing" on amd64. First, I need to understand what's being modified. I see changes in `arch/powerpc/...` and `drivers/vfio/vfio_iommu_spapr_tce.c`. The vfio driver relies on `SPAPR_TCE_IOMMU`, which in turn depends on either `PPC_POWERNV` or `PPC_PSERIES`. These dependencies scream "PowerPC only"!

Now, the instructions are clear: if all modified code falls into certain negative criteria, then `WorthFuzzing` must be false. One of those criteria is "Unreachable execution paths: Code paths exclusive to architectures other than the target architecture." I need to verify if the patch applies to amd64 architecture.

Let me confirm that `vfio_iommu_spapr_tce.c` can *never* be compiled on amd64, even with some conditional `COMPILE_TEST`. Looking at the Kconfig files, I see that while `VFIO_IOMMU_SPAPR_TCE` has a default, it can only be enabled if `SPAPR_TCE_IOMMU` is enabled, which forces the PowerPC dependencies via the `PPC_POWERNV || PPC_PSERIES` condition. So, no `COMPILE_TEST` tricks here, and even if there were, it's specific to sPAPR hardware/hypervisor (IBM POWER). It's all strictly PowerPC.

Therefore, since all the changes are within `arch/powerpc/` or are guarded by PowerPC-specific configurations, none of this code can be compiled or executed on amd64. This directly hits the negative criteria: "Unreachable execution paths."

My conclusion is clear: `WorthFuzzing` must be false. I'll construct the `set-results` reply with the following:

-   `WorthFuzzing`: `false`
-   `Reasoning`: "All modifications in this patch series are located in `arch/powerpc/` and `drivers/vfio/vfio_iommu_spapr_tce.c` (which depends on `CONFIG_SPAPR_TCE_IOMMU`, which in turn requires `CONFIG_PPC_POWERNV || CONFIG_PPC_PSERIES`). These code paths are strictly exclusive to the PowerPC architecture (ppc64) and cannot be compiled or executed on the target architecture (amd64)."
-   `EnableConfigs`: `[]` (empty array)
-   `FocusSymbols`: `[]` (empty array)

I'm ready to call `set-results`.



12/2 2026/10/19 10:36 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies PowerPC architecture code (in arch/powerpc/) and the sPAPR TCE VFIO IOMMU driver (drivers/vfio/vfio_iommu_spapr_tce.c, which depends on CONFIG_SPAPR_TCE_IOMMU, requiring CONFIG_PPC_POWERNV or CONFIG_PPC_PSERIES). None of this code can be compiled or executed on the target architecture (amd64), as all modified paths are strictly exclusive to PowerPC.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch series modifies PowerPC architecture code (in arch/powerpc/) and the sPAPR TCE VFIO IOMMU driver (drivers/vfio/vfio_iommu_spapr_tce.c, which depends on CONFIG_SPAPR_TCE_IOMMU, requiring CONFIG_PPC_POWERNV or CONFIG_PPC_PSERIES). None of this code can be compiled or executed on the target architecture (amd64), as all modified paths are strictly exclusive to PowerPC.",
  "WorthFuzzing": false
}

13/1 2026/10/19 10:36 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)