Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [RFC PATCH 0/1] vfio/pci: Disable sriov on PF device close
@ 2026-08-05  0:33 Samiullah Khawaja
  2026-08-05  0:33 ` [RFC PATCH 1/1] " Samiullah Khawaja
  0 siblings, 1 reply; 6+ messages in thread
From: Samiullah Khawaja @ 2026-08-05  0:33 UTC (permalink / raw)
  To: Alex Williamson, Jason Gunthorpe, bhelgaas
  Cc: Samiullah Khawaja, dmatlack, Kevin Tian, Leon Romanovsky, kvm,
	linux-kernel

When userspace closes a VFIO device file descriptor, the vfio driver
performs a hardware reset on the PCIe device to ensure it is returned to
a clean state. However, if the closed device is an SR-IOV Physical
Function (PF), it may have instantiated Virtual Functions (VFs) that are
actively bound to host kernel drivers (or other vfio instances).

When the PF is hardware-reset via VFIO, it implicitly disrupts SR-IOV
operations at the device level. Because this reset happens without
notifying the core PCI driver model, the kernel drivers bound to the VFs
remain loaded and operate under the assumption that the VF hardware is
still functional.

This creates a state mismatch between the kernel's view of the hardware
and the actual device state. Subsequent attempts by the host OS or bound
drivers to interact with the VFs will fail, leading to unexpected
errors.

Disabling SRIOV before resetting the device avoids this issue by tearing
down the VFs and removing the VF devices.

The fix in this patch only disables SRIOV on PF reset for devices bound
to vfio-pci drivers. But this probably needs a fix for kernel drivers
also, maybe return -EBUSY when SRIOV is enabled?

Looking forward to your feedback on this.

---

CC: bhelgaas@google.com
CC: dmatlack@google.com

Samiullah Khawaja (1):
  vfio/pci: Disable sriov on PF device close

 drivers/vfio/pci/vfio_pci_core.c | 7 +++++++
 1 file changed, 7 insertions(+)


base-commit: 0f6da28aab51b16762ed82e8fdeaa5042da45b08
-- 
2.55.0.629.g250fe7f194-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-06 19:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05  0:33 [RFC PATCH 0/1] vfio/pci: Disable sriov on PF device close Samiullah Khawaja
2026-08-05  0:33 ` [RFC PATCH 1/1] " Samiullah Khawaja
2026-08-05  1:03   ` sashiko-bot
2026-08-05  9:34   ` Tian, Kevin
2026-08-05 15:03   ` Alex Williamson
2026-08-06 19:47     ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox