Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] PCI/vfio-pci: Guard resets against active SR-IOV VFs
@ 2026-08-12  4:53 Alex Williamson
  2026-08-12  4:53 ` [RFC PATCH 1/5] PCI: Refuse function reset of an SR-IOV PF with enabled VFs Alex Williamson
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Alex Williamson @ 2026-08-12  4:53 UTC (permalink / raw)
  To: kvm, Alex Williamson
  Cc: Alex Williamson, skhawaja, Jason Gunthorpe, Bjorn Helgaas,
	Kevin Tian, linux-kernel, linux-pci

It's recently been found[1] that vfio-pci doesn't restrict resets on PFs
while SR-IOV is enabled.  This can not only result in an uncoordinated
disruption of the use of the associated VFs, but the ongoing use of and
access to the VF has the potential to result in machine checks.

This series proposes that this gap is largely an oversight of
pci_reset_function() to recognize that a PF reset affecting SR-IOV VFs
violates the scope boundary of the pci_reset_function() API.

Patch 1 introduces guards in the common wrappers where we can hold
device_lock to prevent .sriov_configure races.  This covers locking
conformant use cases.  __pci_reset_function_locked() can't be gated in
PCI-core; it runs after the potentially destructive .reset_prepare.
Therefore its callers must provide the gating, along with the locking
and state manipulation the interface already demands.  The vfio-pci
change is included as an example and known use case here.

Patch 2 introduces a callback to pci_reset_bus() which allows a lock
dependent callback to be evaluated after locking the physical hierarchy
and before initiating the actual reset.  This allows use cases such as
in the following patch to evaluate the SR-IOV PF configuration without
racing.

Patch 3 implements exactly that test in vfio-pci-core, such that the
hot-reset ioctl can be blocked when SR-IOV VFs are present on a bus/slot
affected PF.  This completes the lockdown of resets induced on behalf of
the vfio-pci in-kernel or userspace drivers.

Patch 4 exports pci_reset_supported, which allows patch 5 to remove the
latched reset_works flag, which already had the potential to become
stale due to reset_method manipulation through sysfs, but now may also
become stale due to the SR-IOV state of the PF.

This is RFC to capture the discussion of [1] while it's active but
requires testing before formal proposal.  This effectively side-steps
the feasibility and security question of the operating model in use by
the referenced thread by generically gating resets affecting PFs with
active SR-IOV.  Please review and comment.  Thanks,

Alex


[1]https://lore.kernel.org/all/20260805003355.728299-1-skhawaja@google.com/

Alex Williamson (5):
  PCI: Refuse function reset of an SR-IOV PF with enabled VFs
  PCI: Add pci_reset_bus_cond() for a caller-gated slot or bus reset
  vfio/pci: Refuse to reset an SR-IOV PF with enabled VFs
  PCI: Export pci_reset_supported()
  vfio/pci: Use pci_reset_supported() in place of reset_works

 drivers/pci/pci.c                | 117 +++++++++++++++++++++++++++----
 drivers/pci/pci.h                |   1 -
 drivers/vfio/pci/vfio_pci_core.c |  28 +++++---
 include/linux/pci.h              |   4 ++
 include/linux/vfio_pci_core.h    |   1 -
 include/uapi/linux/vfio.h        |   3 +
 6 files changed, 129 insertions(+), 25 deletions(-)

-- 
2.53.0


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

end of thread, other threads:[~2026-08-12  5:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12  4:53 [RFC PATCH 0/5] PCI/vfio-pci: Guard resets against active SR-IOV VFs Alex Williamson
2026-08-12  4:53 ` [RFC PATCH 1/5] PCI: Refuse function reset of an SR-IOV PF with enabled VFs Alex Williamson
2026-08-12  5:01   ` sashiko-bot
2026-08-12  4:53 ` [RFC PATCH 2/5] PCI: Add pci_reset_bus_cond() for a caller-gated slot or bus reset Alex Williamson
2026-08-12  5:00   ` sashiko-bot
2026-08-12  4:53 ` [RFC PATCH 3/5] vfio/pci: Refuse to reset an SR-IOV PF with enabled VFs Alex Williamson
2026-08-12  5:02   ` sashiko-bot
2026-08-12  4:53 ` [RFC PATCH 4/5] PCI: Export pci_reset_supported() Alex Williamson
2026-08-12  4:59   ` sashiko-bot
2026-08-12  4:53 ` [RFC PATCH 5/5] vfio/pci: Use pci_reset_supported() in place of reset_works Alex Williamson
2026-08-12  4:59   ` sashiko-bot

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