Re: [PATCH v4 01/10] PCI: Avoid saving error values for config space
From: Farhan Ali
Date: Thu Oct 09 2025 - 13:02:40 EST
On 10/8/2025 9:52 PM, Lukas Wunner wrote:
On Wed, Oct 08, 2025 at 02:55:56PM -0700, Farhan Ali wrote:
The ask is for the host to notify the VM of the ->error_detected() eventThe reset is not performed by the VM, reset is still done by the host. MyOn 10/8/2025 6:34 AM, Lukas Wunner wrote:
I also don't quite understand why the VM needs to perform a reset.
Why can't you just let the VM tell the host that a reset is needed
(PCI_ERS_RESULT_NEED_RESET) and then the host resets the device on
behalf of the VM?
approach for a VM to let the host know that reset was needed, was to
intercept any reset instructions for the PCI device in QEMU. QEMU would then
drive a reset via VFIO_DEVICE_RESET. Maybe I am missing something, but based
on what we have today in vfio driver, we don't have a mechanism for
userspace to reset a device other than VFIO_DEVICE_RESET and
VFIO_PCI_DEVICE_HOT_RESET ioctls.
and the VM then responding with one of the "enum pci_ers_result" values.
Maybe there is some confusion here. Could you clarify what do you mean by VM responding with "enum pci_ers_result" values? Is it a device driver (for example an NVMe driver) running in the VM that should do that? Or is it something else you are suggesting?
Let me try to clarify what I am trying to do with this patch series. For passthrough devices to a VM, the driver bound to the device on the host is vfio-pci. vfio-pci driver does support the error_detected() callback (vfio_pci_core_aer_err_detected()), and on an PCI error s390x recovery code on the host will call the vfio-pci error_detected() callback. The vfio-pci error_detected() callback will notify userspace/QEMU via an eventfd, and return PCI_ERS_RESULT_CAN_RECOVER. At this point the s390x error recovery on the host will skip any further action(see patch 7) and let userspace drive the error recovery.
Once userspace/QEMU is notified, it then inject this error into the VM so device drivers in the VM can take recovery actions. For example for a passthrough NVMe device, the VM's OS NVMe driver will access the device. At this point the VM's NVMe driver's error_detected() will drive the recovery by returning PCI_ERS_RESULT_NEED_RESET, and the s390x error recovery in the VM's OS will try to do a reset. Resets are privileged operations and so the VM will need intervention from QEMU to perform the reset. QEMU will invoke the ioctls to now notify the host that the VM is requesting a reset of the device. The vfio-pci driver on the host will then perform the reset on the device.
Thanks Farhan