* [PATCH v3 1/2] vfio/pci: Add persistent BAR mmap blocking helper
2026-11-23 8:15 [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset Narayana Murty N
@ 2026-11-23 8:15 ` Narayana Murty N
2026-11-23 8:15 ` [PATCH v3 2/2] ppc/spapr: Preserve VFIO MSI-X shadow and block BAR mmap on EEH reset Narayana Murty N
2026-12-01 17:57 ` [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset Cédric Le Goater
2 siblings, 0 replies; 7+ messages in thread
From: Narayana Murty N @ 2026-11-23 8:15 UTC (permalink / raw)
To: qemu-devel, qemu-ppc, sbhat, mahesh, sourabhjain, adityag,
npiggin, harshpb, alex, clg
Cc: amachhiw, hbathini, shivangu, anushree.mathur
Some platform recovery flows need to stop using direct mmap-backed BAR
subregions after a device reset. Disabling the subregions once is not
sufficient because the VFIO INTx mmap timer and interrupt-mode
transitions can later call vfio_mmap_set_enabled() with enabled=true.
Add a generic per-device mmap_blocked state and
vfio_pci_mmap_block(). Once a device is blocked, attempts to re-enable
its direct BAR mmap subregions are ignored. The helper also cancels a
pending INTx mmap re-enable timer and disables all currently active BAR
mmap subregions.
The parent VFIO MemoryRegion remains enabled, so BAR accesses continue
through vfio_region_read()/vfio_region_write() using the VFIO device fd.
The helper contains no platform or EEH policy; callers decide when a
recovery flow requires direct mmap to remain blocked.
The block is intentionally persistent for the lifetime of the VFIO
device object. No unblock operation is added until there is a proven
safe point at which an existing direct BAR mmap can be reused after such
a reset. The state is not migrated because it controls a local access
path optimization rather than guest-visible device state.
Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
---
hw/vfio/pci.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
hw/vfio/pci.h | 7 ++++++
2 files changed, 66 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 0da2e143b8..49d6b7d3f4 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1949,11 +1949,70 @@ static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled)
{
int i;
+ /*
+ * Some recovery flows require direct BAR mmap to remain disabled
+ * after a device reset. Honour mmap_blocked so that INTx timer
+ * callbacks and interrupt-mode transitions cannot re-enable
+ * the direct mmap subregions once the device has been blocked.
+ */
+ if (enabled && vdev->mmap_blocked) {
+ return;
+ }
+
for (i = 0; i < PCI_ROM_SLOT; i++) {
vfio_region_mmaps_set_enabled(&vdev->bars[i].region, enabled);
}
}
+/**
+ * vfio_pci_mmap_block - Persistently block direct BAR mmap access
+ * @vdev: the VFIO PCI device
+ *
+ * Some recovery flows cannot safely resume direct BAR mmap access using
+ * mappings that were established before the device was reset. Once the
+ * device is blocked, keep accesses on the VFIO region read/write path
+ * rather than allowing later interrupt-mode or timer activity to restore
+ * the direct mmap subregions.
+ *
+ * This helper:
+ * 1. Sets mmap_blocked so that no subsequent interrupt-mode
+ * transition or INTx mmap timer callback can re-enable direct
+ * BAR mmap access.
+ * 2. Cancels any pending INTx mmap re-enable timer.
+ * 3. Disables all currently active BAR mmap subregions.
+ *
+ * The parent slow-path VFIO MemoryRegion remains enabled, so BAR
+ * accesses continue via vfio_region_read()/vfio_region_write() which
+ * use pread()/pwrite() on the VFIO device fd. This is slower than
+ * the direct mmap path but remains available while mmap is blocked.
+ *
+ * The flag is intentionally not cleared by this helper. Blocking is
+ * persistent for the lifetime of the VFIO device object unless a future
+ * change introduces an explicit, proven-safe unblock operation.
+ *
+ * The function is idempotent.
+ */
+void vfio_pci_mmap_block(VFIOPCIDevice *vdev)
+{
+ if (vdev->mmap_blocked) {
+ return;
+ }
+
+ vdev->mmap_blocked = true;
+
+ /*
+ * Cancel any pending INTx mmap re-enable timer. Without this the
+ * timer could still fire and call vfio_mmap_set_enabled() with
+ * enabled=true. That would be blocked by the flag above, but
+ * cancelling it avoids the unnecessary wakeup.
+ */
+ if (vdev->intx.mmap_timer) {
+ timer_del(vdev->intx.mmap_timer);
+ }
+
+ vfio_mmap_set_enabled(vdev, false);
+}
+
static void vfio_bar_prepare(VFIOPCIDevice *vdev, int nr)
{
VFIOBAR *bar = &vdev->bars[nr];
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 7ff52e9a52..d4c3c9eeae 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -187,6 +187,12 @@ struct VFIOPCIDevice {
bool defer_kvm_irq_routing;
bool clear_parent_atomics_on_exit;
bool skip_vsc_check;
+ /*
+ * Block direct BAR mmap subregions for the lifetime of this
+ * VFIO device. Calls that would re-enable mmap are ignored
+ * while this flag is set.
+ */
+ bool mmap_blocked;
uint16_t vpasid_cap_offset;
OnOffAuto ats;
VFIODisplay *dpy;
@@ -243,6 +249,7 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **errp);
/* BARs */
void vfio_pci_bars_exit(VFIOPCIDevice *vdev);
void vfio_sub_page_bar_update_mappings(VFIOPCIDevice *vdev);
+void vfio_pci_mmap_block(VFIOPCIDevice *vdev);
/* Capabilities */
bool vfio_pci_add_capabilities(VFIOPCIDevice *vdev, Error **errp);
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v3 2/2] ppc/spapr: Preserve VFIO MSI-X shadow and block BAR mmap on EEH reset
2026-11-23 8:15 [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset Narayana Murty N
2026-11-23 8:15 ` [PATCH v3 1/2] vfio/pci: Add persistent BAR mmap blocking helper Narayana Murty N
@ 2026-11-23 8:15 ` Narayana Murty N
2026-12-01 17:57 ` [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset Cédric Le Goater
2 siblings, 0 replies; 7+ messages in thread
From: Narayana Murty N @ 2026-11-23 8:15 UTC (permalink / raw)
To: qemu-devel, qemu-ppc, sbhat, mahesh, sourabhjain, adityag,
npiggin, harshpb, alex, clg
Cc: amachhiw, hbathini, shivangu, anushree.mathur
Prepare VFIO PCI devices before a pSeries EEH hot or fundamental PE
reset without destroying the MSI-X state that the guest needs to
recover interrupts.
The existing path clears MSI-X Enable and then calls msix_reset(). On
pSeries with vfio-no-msix-emulation=true, QEMU keeps the MSI-X messages
used by ibm,change-msi in its software shadow. The Linux EEH recovery
sequence does not necessarily issue ibm,change-msi again. Clearing the
shadow with msix_reset() therefore loses the message address/data needed
when MSI-X is enabled again.
Preserve the shadow by removing msix_reset(). Read the MSI-X Message
Control value from QEMU's cached PCI config space, clear only MSI-X
Enable, and write it through pci_host_config_write_common(). This keeps
the normal VFIO MSI-X disable/enable transition while avoiding a config
read from a PE that may still be frozen.
Also block direct BAR mmap access before changing MSI-X state by calling
vfio_pci_mmap_block(). Testing with a VFIO-passed-through BCM5719
showed that restoring direct mmap after VFIO_EEH_PE_CONFIGURE can leave
the device inaccessible again during guest resume, while keeping BAR
access on the VFIO region read/write path allows the Guest-2 EEH
recovery to complete and the device to remain functional. Blocking
mmap first also prevents a subsequent MSI-X-to-INTx transition from
re-enabling the mmap path through the normal INTx policy.
The generic VFIO helper provides only the persistent mmap-block
mechanism; the decision to use it for EEH remains local to the sPAPR
recovery code. No post-configure mmap restore is added because the
current testing does not establish a safe point for reusing the direct
BAR mmap after the PE reset.
No guest-visible ABI is changed.
Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
---
hw/ppc/spapr_pci_vfio.c | 75 ++++++++++++++++++++++++++++-------------
1 file changed, 51 insertions(+), 24 deletions(-)
diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
index a748a0bf4c..c164a7a6ce 100644
--- a/hw/ppc/spapr_pci_vfio.c
+++ b/hw/ppc/spapr_pci_vfio.c
@@ -32,6 +32,8 @@
* Interfaces for IBM EEH (Enhanced Error Handling)
*/
#ifdef CONFIG_VFIO_PCI
+#include "hw/vfio/pci.h"
+
static bool vfio_eeh_container_ok(VFIOLegacyContainer *container)
{
/*
@@ -233,47 +235,72 @@ int spapr_phb_vfio_eeh_get_state(SpaprPhbState *sphb, int *state)
return RTAS_OUT_SUCCESS;
}
-static void spapr_phb_vfio_eeh_clear_dev_msix(PCIBus *bus,
- PCIDevice *pdev,
- void *opaque)
+static void spapr_phb_vfio_eeh_prepare_dev(PCIBus *bus,
+ PCIDevice *pdev,
+ void *opaque)
{
- /* Check if the device is VFIO PCI device */
+ VFIOPCIDevice *vdev;
+ uint16_t flags;
+
if (!object_dynamic_cast(OBJECT(pdev), "vfio-pci")) {
return;
}
+ vdev = VFIO_PCI_DEVICE(pdev);
+
/*
- * The MSIx table will be cleaned out by reset. We need
- * disable it so that it can be reenabled properly. Also,
- * the cached MSIx table should be cleared as it's not
- * reflecting the contents in hardware.
+ * Direct BAR mmap access may not be reliable after an EEH PE reset.
+ * Block mmap before changing MSI-X state so any resulting interrupt
+ * mode transition cannot re-enable it, and keep BAR accesses on the
+ * VFIO pread()/pwrite() path after the reset. This avoids restoring
+ * the direct mmap path at an unproven point in EEH recovery.
*/
- if (msix_enabled(pdev)) {
- uint16_t flags;
-
- flags = pci_host_config_read_common(pdev,
- pdev->msix_cap + PCI_MSIX_FLAGS,
- pci_config_size(pdev), 2);
- flags &= ~PCI_MSIX_FLAGS_ENABLE;
- pci_host_config_write_common(pdev,
- pdev->msix_cap + PCI_MSIX_FLAGS,
- pci_config_size(pdev), flags, 2);
+ vfio_pci_mmap_block(vdev);
+
+ if (!msix_enabled(pdev)) {
+ return;
}
- msix_reset(pdev);
+ /*
+ * Disable MSI-X by clearing the Enable bit in the MSI-X Message
+ * Control register. We use the cached config value to avoid a
+ * config-space read while the PE may still be frozen.
+ *
+ * Writing through pci_host_config_write_common() causes VFIO to:
+ * - release the active MSI-X vector eventfds,
+ * - remove the KVM irqchip routes,
+ * - disable the VFIO MSIX_IRQ_INDEX,
+ * so that the subsequent MSI-X Enable write from the guest driver
+ * is seen as a clean disabled-to-enabled transition and all
+ * vectors are re-armed through vfio_msix_vector_do_use().
+ *
+ * Do NOT call msix_reset() here. On pSeries, QEMU's MSI-X table
+ * is a software shadow populated by the ibm,change-msi RTAS call.
+ * The EEH recovery sequence does not necessarily re-issue
+ * ibm,change-msi, so the shadow contains the only copy of the
+ * message addresses and data that Linux EEH will restore.
+ * msix_reset() would zero those shadow entries, leaving
+ * vfio_msix_enable() with no vectors to pass to
+ * vfio_msix_vector_do_use() and the device would never recover
+ * interrupts.
+ */
+ flags = pci_get_word(pdev->config + pdev->msix_cap + PCI_MSIX_FLAGS);
+ flags &= ~PCI_MSIX_FLAGS_ENABLE;
+ pci_host_config_write_common(pdev,
+ pdev->msix_cap + PCI_MSIX_FLAGS,
+ pci_config_size(pdev), flags, 2);
}
-static void spapr_phb_vfio_eeh_clear_bus_msix(PCIBus *bus, void *opaque)
+static void spapr_phb_vfio_eeh_prepare_bus(PCIBus *bus, void *opaque)
{
- pci_for_each_device_under_bus(bus, spapr_phb_vfio_eeh_clear_dev_msix,
- NULL);
+ pci_for_each_device_under_bus(bus, spapr_phb_vfio_eeh_prepare_dev, NULL);
}
static void spapr_phb_vfio_eeh_pre_reset(SpaprPhbState *sphb)
{
- PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
+ PCIHostState *phb = PCI_HOST_BRIDGE(sphb);
- pci_for_each_bus(phb->bus, spapr_phb_vfio_eeh_clear_bus_msix, NULL);
+ pci_for_each_bus(phb->bus, spapr_phb_vfio_eeh_prepare_bus, NULL);
}
int spapr_phb_vfio_eeh_reset(SpaprPhbState *sphb, int option)
--
2.54.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset
2026-11-23 8:15 [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset Narayana Murty N
2026-11-23 8:15 ` [PATCH v3 1/2] vfio/pci: Add persistent BAR mmap blocking helper Narayana Murty N
2026-11-23 8:15 ` [PATCH v3 2/2] ppc/spapr: Preserve VFIO MSI-X shadow and block BAR mmap on EEH reset Narayana Murty N
@ 2026-12-01 17:57 ` Cédric Le Goater
2026-12-03 5:00 ` Narayana Murty N
2 siblings, 1 reply; 7+ messages in thread
From: Cédric Le Goater @ 2026-12-01 17:57 UTC (permalink / raw)
To: Narayana Murty N, qemu-devel, qemu-ppc, sbhat, mahesh,
sourabhjain, adityag, npiggin, harshpb, alex
Cc: amachhiw, hbathini, shivangu, anushree.mathur
Hello Narayana,
On 11/23/26 09:15, Narayana Murty N wrote:
> This series fixes two independent but related problems in the sPAPR EEH
> PE reset path for VFIO pass-through devices.
>
> Patch 1 fixes MSI-X interrupt delivery after EEH recovery. The existing
> pre-reset path calls msix_reset(), which clears QEMU's MSI-X table shadow.
> On pSeries, this shadow is populated through:
>
> ibm,change-msi
> -> spapr_msi_setmsg()
> -> msix_set_message()
>
> and is not necessarily rebuilt before the guest restores MSI-X after an
> EEH reset.
>
> Instead of resetting the MSI-X state, disable MSI-X by clearing only the
> Enable bit using QEMU's cached PCI configuration value and dispatch the
> write through pci_host_config_write_common(). This lets VFIO tear down
> the active vectors and KVM irqfd routes through vfio_msix_disable() while
> preserving the MSI-X shadow needed when the guest later re-enables MSI-X.
>
> Patch 2 handles BAR mmap access while the PE is undergoing an EEH reset.
> BAR mmap access is disabled before issuing the hot or fundamental PE
> reset and restored only after VFIO_EEH_PE_CONFIGURE completes
> successfully. During this interval BAR accesses fall back to the VFIO
> region read/write path.
>
> Following review feedback, the BAR mmap and INTx mmap timer handling are
> now encapsulated in VFIO PCI helpers instead of accessing
> VFIOPCIDevice internals directly from the pSeries code. The pre-reset
> helper cancels a pending INTx mmap re-enable timer and disables the BAR
> mmap path after interrupt teardown. The post-configure helper restores
> the normal mmap/INTx timer policy after successful PE configuration.
>
> Without the fixes, EEH recovery itself reports success for the
> passed-through BCM5719/tg3 device, but the interface does not recover its
> link:
> <snip>
> EEH: Beginning: 'resume'
> PCI 0001:00:01.0#0001: EEH: Invoking tg3->resume()
> PCI 0001:00:01.0#0001: EEH: tg3 driver reports: 'none'
> EEH: Finished:'resume'
> EEH: Recovery successful.
> </snip>
> <snip>
> # ethtool enP1p0s1 | grep Link
> Link detected: no
> </snip>
>
> With the series applied, EEH recovery completes and the link subsequently
> comes back:
>
> <snip>
> EEH: Beginning: 'resume'
> PCI 0001:00:01.0#0001: EEH: Invoking tg3->resume()
> PCI 0001:00:01.0#0001: EEH: tg3 driver reports: 'none'
> EEH: Finished:'resume'
> EEH: Recovery successful.
> tg3 0001:00:01.0 enP1p0s1: Link is up at 1000 Mbps, full duplex
> tg3 0001:00:01.0 enP1p0s1: Flow control is on for TX and on for RX
> </snip>
> <snip>
> # ethtool enP1p0s1 | grep Link
> Link detected: yes
> </snip>
>
> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
> ---
> Change log:
> v2:
> - Reworked the BAR mmap handling based on review feedback so that generic
> VFIO provides only the mmap mechanism and the pSeries code retains the
> EEH policy.
> - Replaced the EEH-specific generic VFIO helpers
> `vfio_pci_eeh_pre_reset()` and `vfio_pci_eeh_post_configure()` with a
> neutral `vfio_pci_mmap_block()` helper.
> - Added per-device `mmap_blocked` state in vfio-pci. Once BAR mmap is
> blocked, later attempts to re-enable the mmap subregions, including
> those from INTx timer or interrupt-mode transitions, are ignored.
> - Changed the BAR mmap handling from temporary disable/restore to a
> persistent block after an EEH PE reset. In particular, BAR mmap is no
> longer restored after `VFIO_EEH_PE_CONFIGURE`.
> - Removed the pSeries post-configure device/bus walkers that were added
> in v2 solely to restore BAR mmap.
> - Moved the generic mmap-block implementation into patch 1/2 and kept
> the pSeries EEH use of that mechanism in patch 2/2.
> - Block BAR mmap before changing MSI-X state during EEH reset
> preparation, so subsequent VFIO interrupt-mode activity cannot restore
> the direct mmap path.
> - Retained the v2 MSI-X shadow preservation behavior: clear only
> `PCI_MSIX_FLAGS_ENABLE` through the normal PCI config-write path and
> do not call `msix_reset()`.
> - Updated the BAR mmap recovery policy based on BCM5719 passthrough
> testing: restoring direct BAR mmap after PE configure could result in
> the device becoming inaccessible again during guest resume, while
> keeping BAR accesses on the VFIO region read/write path allowed the
> Guest-2 EEH recovery to complete and the device to remain functional.
>
> v1:
> - Move BAR mmap and INTx mmap timer handling into VFIO PCI helpers,
> as suggested by Mahesh.
> - Avoid direct access to VFIOPCIDevice BAR and INTx internals from
> spapr_pci_vfio.c.
> - Restore normal INTx mmap handling after successful PE configuration.
> - Keep BAR mmap disabled when VFIO_EEH_PE_CONFIGURE fails.
> - Keep the MSI-X shadow preservation behavior from patch 1 unchanged.
> v1: https://lore.kernel.org/qemu-devel/20260902114758.85160-1-nnmlinux@linux.ibm.com
>
> Narayana Murty N (2):
> vfio/pci: Add persistent BAR mmap blocking helper
> ppc/spapr: Preserve VFIO MSI-X shadow and block BAR mmap on EEH reset
>
> hw/ppc/spapr_pci_vfio.c | 75 ++++++++++++++++++++++++++++-------------
> hw/vfio/pci.c | 59 ++++++++++++++++++++++++++++++++
> hw/vfio/pci.h | 7 ++++
> 3 files changed, 117 insertions(+), 24 deletions(-)
This series needs a background section. As posted, the cover letter
assumes the reader already knows EEH, PEs and the pSeries VFIO
error-recovery path, and the majority of qemu-devel does not. Please
rewrite it to start with a problem background that answers:
- What is EEH ?
- How does it differ from PCIe AER ? be explicit about the differences.
- How does this relate to the ongoing proposals to report PCIe errors
to userspace and drive recovery from it [1] ?
- Which platform, which processors ? PowerNV bare metal ? pSeries
guests under PowerVM/KVM ?
- What is a PE ?
- How does recovery work on the host?
- How does it reach the guest ?
- What is RTAS ?
And then state the problems, not just the symptoms.
Please also fix the cover letter. It seems to still describe the v1
disable/restore design, and has no v3. changelog section is confusing.
Thanks,
C.
[1] [RFC PATCH v2 00/16] vfio/pci: Handle PCI error recovery and report state to userspace
https://lore.kernel.org/all/20260929173305.204856-1-skolothumtho@nvidia.com/
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset
2026-12-01 17:57 ` [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset Cédric Le Goater
@ 2026-12-03 5:00 ` Narayana Murty N
2026-12-03 7:49 ` Cédric Le Goater
0 siblings, 1 reply; 7+ messages in thread
From: Narayana Murty N @ 2026-12-03 5:00 UTC (permalink / raw)
To: Cédric Le Goater, qemu-devel, qemu-ppc, sbhat, mahesh,
sourabhjain, adityag, npiggin, harshpb, alex
Cc: amachhiw, hbathini, shivangu, anushree.mathur
Hi Cédric,
On 01/12/26 11:27 PM, Cédric Le Goater wrote:
> Hello Narayana,
>
> On 11/23/26 09:15, Narayana Murty N wrote:
>> This series fixes two independent but related problems in the sPAPR EEH
>> PE reset path for VFIO pass-through devices.
>>
>> Patch 1 fixes MSI-X interrupt delivery after EEH recovery. The existing
>> pre-reset path calls msix_reset(), which clears QEMU's MSI-X table
>> shadow.
>> On pSeries, this shadow is populated through:
>>
>> ibm,change-msi
>> -> spapr_msi_setmsg()
>> -> msix_set_message()
>>
>> and is not necessarily rebuilt before the guest restores MSI-X after an
>> EEH reset.
>>
>> Instead of resetting the MSI-X state, disable MSI-X by clearing only the
>> Enable bit using QEMU's cached PCI configuration value and dispatch the
>> write through pci_host_config_write_common(). This lets VFIO tear down
>> the active vectors and KVM irqfd routes through vfio_msix_disable() while
>> preserving the MSI-X shadow needed when the guest later re-enables MSI-X.
>>
>> Patch 2 handles BAR mmap access while the PE is undergoing an EEH reset.
>> BAR mmap access is disabled before issuing the hot or fundamental PE
>> reset and restored only after VFIO_EEH_PE_CONFIGURE completes
>> successfully. During this interval BAR accesses fall back to the VFIO
>> region read/write path.
>>
>> Following review feedback, the BAR mmap and INTx mmap timer handling are
>> now encapsulated in VFIO PCI helpers instead of accessing
>> VFIOPCIDevice internals directly from the pSeries code. The pre-reset
>> helper cancels a pending INTx mmap re-enable timer and disables the BAR
>> mmap path after interrupt teardown. The post-configure helper restores
>> the normal mmap/INTx timer policy after successful PE configuration.
>>
>> Without the fixes, EEH recovery itself reports success for the
>> passed-through BCM5719/tg3 device, but the interface does not recover its
>> link:
>> <snip>
>> EEH: Beginning: 'resume'
>> PCI 0001:00:01.0#0001: EEH: Invoking tg3->resume()
>> PCI 0001:00:01.0#0001: EEH: tg3 driver reports: 'none'
>> EEH: Finished:'resume'
>> EEH: Recovery successful.
>> </snip>
>> <snip>
>> # ethtool enP1p0s1 | grep Link
>> Link detected: no
>> </snip>
>>
>> With the series applied, EEH recovery completes and the link subsequently
>> comes back:
>>
>> <snip>
>> EEH: Beginning: 'resume'
>> PCI 0001:00:01.0#0001: EEH: Invoking tg3->resume()
>> PCI 0001:00:01.0#0001: EEH: tg3 driver reports: 'none'
>> EEH: Finished:'resume'
>> EEH: Recovery successful.
>> tg3 0001:00:01.0 enP1p0s1: Link is up at 1000 Mbps, full duplex
>> tg3 0001:00:01.0 enP1p0s1: Flow control is on for TX and on for RX
>> </snip>
>> <snip>
>> # ethtool enP1p0s1 | grep Link
>> Link detected: yes
>> </snip>
>>
>> Signed-off-by: Narayana Murty N <nnmlinux@linux.ibm.com>
>> ---
>> Change log:
>> v2:
>> - Reworked the BAR mmap handling based on review feedback so that generic
>> VFIO provides only the mmap mechanism and the pSeries code retains the
>> EEH policy.
>> - Replaced the EEH-specific generic VFIO helpers
>> `vfio_pci_eeh_pre_reset()` and `vfio_pci_eeh_post_configure()` with a
>> neutral `vfio_pci_mmap_block()` helper.
>> - Added per-device `mmap_blocked` state in vfio-pci. Once BAR mmap is
>> blocked, later attempts to re-enable the mmap subregions, including
>> those from INTx timer or interrupt-mode transitions, are ignored.
>> - Changed the BAR mmap handling from temporary disable/restore to a
>> persistent block after an EEH PE reset. In particular, BAR mmap is no
>> longer restored after `VFIO_EEH_PE_CONFIGURE`.
>> - Removed the pSeries post-configure device/bus walkers that were added
>> in v2 solely to restore BAR mmap.
>> - Moved the generic mmap-block implementation into patch 1/2 and kept
>> the pSeries EEH use of that mechanism in patch 2/2.
>> - Block BAR mmap before changing MSI-X state during EEH reset
>> preparation, so subsequent VFIO interrupt-mode activity cannot restore
>> the direct mmap path.
>> - Retained the v2 MSI-X shadow preservation behavior: clear only
>> `PCI_MSIX_FLAGS_ENABLE` through the normal PCI config-write path and
>> do not call `msix_reset()`.
>> - Updated the BAR mmap recovery policy based on BCM5719 passthrough
>> testing: restoring direct BAR mmap after PE configure could result in
>> the device becoming inaccessible again during guest resume, while
>> keeping BAR accesses on the VFIO region read/write path allowed the
>> Guest-2 EEH recovery to complete and the device to remain functional.
>>
>> v1:
>> - Move BAR mmap and INTx mmap timer handling into VFIO PCI helpers,
>> as suggested by Mahesh.
>> - Avoid direct access to VFIOPCIDevice BAR and INTx internals from
>> spapr_pci_vfio.c.
>> - Restore normal INTx mmap handling after successful PE configuration.
>> - Keep BAR mmap disabled when VFIO_EEH_PE_CONFIGURE fails.
>> - Keep the MSI-X shadow preservation behavior from patch 1 unchanged.
>> v1: https://lore.kernel.org/qemu-devel/20260902114758.85160-1-
>> nnmlinux@linux.ibm.com
>>
>> Narayana Murty N (2):
>> vfio/pci: Add persistent BAR mmap blocking helper
>> ppc/spapr: Preserve VFIO MSI-X shadow and block BAR mmap on EEH reset
>>
>> hw/ppc/spapr_pci_vfio.c | 75 ++++++++++++++++++++++++++++-------------
>> hw/vfio/pci.c | 59 ++++++++++++++++++++++++++++++++
>> hw/vfio/pci.h | 7 ++++
>> 3 files changed, 117 insertions(+), 24 deletions(-)
>
>
>
> This series needs a background section. As posted, the cover letter
> assumes the reader already knows EEH, PEs and the pSeries VFIO
> error-recovery path, and the majority of qemu-devel does not. Please
> rewrite it to start with a problem background that answers:
>
> - What is EEH ?
> - How does it differ from PCIe AER ? be explicit about the differences.
> - How does this relate to the ongoing proposals to report PCIe errors
> to userspace and drive recovery from it [1] ?
> - Which platform, which processors ? PowerNV bare metal ? pSeries
> guests under PowerVM/KVM ?
> - What is a PE ?
> - How does recovery work on the host?
> - How does it reach the guest ?
> - What is RTAS ?
>
> And then state the problems, not just the symptoms.
>
> Please also fix the cover letter. It seems to still describe the v1
> disable/restore design, and has no v3. changelog section is confusing.
>
Sure, will address these review comments in V4.
Thanks,
Narayana.
> Thanks,
>
> C.
>
>
> [1] [RFC PATCH v2 00/16] vfio/pci: Handle PCI error recovery and report
> state to userspace
> https://lore.kernel.org/all/20260929173305.204856-1-
> skolothumtho@nvidia.com/
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset
2026-12-03 5:00 ` Narayana Murty N
@ 2026-12-03 7:49 ` Cédric Le Goater
2026-12-03 14:35 ` Narayana Murty N
0 siblings, 1 reply; 7+ messages in thread
From: Cédric Le Goater @ 2026-12-03 7:49 UTC (permalink / raw)
To: Narayana Murty N, qemu-devel, qemu-ppc, sbhat, mahesh,
sourabhjain, adityag, npiggin, harshpb, alex
Cc: amachhiw, hbathini, shivangu, anushree.mathur
Hello,
>> assumes the reader already knows EEH, PEs and the pSeries VFIO>> error-recovery path, and the majority of qemu-devel does not. Please
>> rewrite it to start with a problem background that answers:
>>
>> - What is EEH ?
>> - How does it differ from PCIe AER ? be explicit about the differences.
>> - How does this relate to the ongoing proposals to report PCIe errors
>> to userspace and drive recovery from it [1] ?
>> - Which platform, which processors ? PowerNV bare metal ? pSeries
>> guests under PowerVM/KVM ?
>> - What is a PE ?
>> - How does recovery work on the host?
>> - How does it reach the guest ?
>> - What is RTAS ?
>>
>> And then state the problems, not just the symptoms.
>>
>> Please also fix the cover letter. It seems to still describe the v1
>> disable/restore design, and has no v3. changelog section is confusing.
>>
> Sure, will address these review comments in V4.
You should mention :
https://lore.kernel.org/all/20261123102237.95860-6-nnmlinux@linux.ibm.com/
https://lore.kernel.org/all/20260901174110.45356-1-nnmlinux@linux.ibm.com/
Please go through this design from Shameer :
https://lore.kernel.org/all/20260929173305.204856-1-skolothumtho@nvidia.com/
https://github.com/shamiali2008/qemu-master/commits/private-master-vfio-aer-test-v2/
and check that it does not fit your needs.
Keeping the BAR mappings alive but disabled after a reset, that should
have invalidated them, seems wrong.
Thanks,
C.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/2] ppc/spapr: Fix MSI-X shadow and BAR mmap handling during EEH PE reset
2026-12-03 7:49 ` Cédric Le Goater
@ 2026-12-03 14:35 ` Narayana Murty N
0 siblings, 0 replies; 7+ messages in thread
From: Narayana Murty N @ 2026-12-03 14:35 UTC (permalink / raw)
To: Cédric Le Goater, qemu-devel, qemu-ppc, sbhat, mahesh,
sourabhjain, adityag, npiggin, harshpb, alex
Cc: amachhiw, hbathini, shivangu, anushree.mathur
Hi Cédric,
On 03/12/26 1:19 PM, Cédric Le Goater wrote:
> Hello,
>
>>> assumes the reader already knows EEH, PEs and the pSeries VFIO>>
>>> error-recovery path, and the majority of qemu-devel does not. Please
>>> rewrite it to start with a problem background that answers:
>>>
>>> - What is EEH ?
>>> - How does it differ from PCIe AER ? be explicit about the differences.
>>> - How does this relate to the ongoing proposals to report PCIe errors
>>> to userspace and drive recovery from it [1] ?
>>> - Which platform, which processors ? PowerNV bare metal ? pSeries
>>> guests under PowerVM/KVM ?
>>> - What is a PE ?
>>> - How does recovery work on the host?
>>> - How does it reach the guest ?
>>> - What is RTAS ?
>>>
>>> And then state the problems, not just the symptoms.
>>>
>>> Please also fix the cover letter. It seems to still describe the v1
>>> disable/restore design, and has no v3. changelog section is confusing.
>>>
>> Sure, will address these review comments in V4.
>
>
> You should mention :
>
> https://lore.kernel.org/all/20261123102237.95860-6-
> nnmlinux@linux.ibm.com/
> https://lore.kernel.org/all/20260901174110.45356-1-
> nnmlinux@linux.ibm.com/
>
> Please go through this design from Shameer :
>
> https://lore.kernel.org/all/20260929173305.204856-1-
> skolothumtho@nvidia.com/
> https://github.com/shamiali2008/qemu-master/commits/private-master-
> vfio-aer-test-v2/
>
> and check that it does not fit your needs.
The POWER platform already has an EEH error detection, isolation and
recovery mechanism for VFIO passthrough devices through the existing
VFIO EEH PE operations and sPAPR RTAS interfaces. Unlike the proposed
host-driven PCI error recovery mechanism, the existing sPAPR EEH
recovery is driven by the guest through RTAS calls.
This series is not intended to introduce a new error recovery mechanism,
but to fix two issues in the existing sPAPR EEH recovery path.
>
> Keeping the BAR mappings alive but disabled after a reset, that should
> have invalidated them, seems wrong.
>
The first is specific to the MSI-X handling on sPAPR, where the MSI-X
message information is maintained in QEMU's software shadow and
populated through ibm,change-msi. Clearing this shadow during a PE reset
causes interrupt restoration to fail when the guest does not reissue
ibm,change-msi during recovery.
The second concerns BAR access across the PE reset, particularly in
configurations where the MSI-X table is excluded from direct mmap and
the BAR is split into multiple mmap subregions.
I also noticed that Shameer's RFC v3 explicitly excludes EEH-enabled
configurations from the proposed recovery feature due to differences in
the locking requirements of the recovery paths.
However, there is overlap in the handling of BAR mappings across a
device reset. I agree that we should investigate whether the mapping
invalidation and restoration mechanisms from Shameer's design can be
reused or adapted for the existing EEH recovery path, rather than
retaining the original mappings in a permanently disabled state.
I will revisit the BAR mmap handling with this in mind.
Thanks,
Narayana Murty.
> Thanks,
>
> C.
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread