qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/16] pci: Abort if pci_add_capability fails
@ 2022-10-26 20:15 Akihiko Odaki
  2022-10-26 20:15 ` [PATCH v3 01/16] pci: Allow to omit errp for pci_add_capability Akihiko Odaki
                   ` (15 more replies)
  0 siblings, 16 replies; 19+ messages in thread
From: Akihiko Odaki @ 2022-10-26 20:15 UTC (permalink / raw)
  Cc: Alex Williamson, qemu-devel, qemu-block, qemu-arm,
	Michael S . Tsirkin, Marcel Apfelbaum, Gerd Hoffmann,
	Paolo Bonzini, Richard Henderson, Eduardo Habkost, John Snow,
	Dmitry Fleytman, Jason Wang, Stefan Weil, Keith Busch,
	Klaus Jensen, Peter Maydell, Andrey Smirnov, Paul Burton,
	Aleksandar Rikalo, Yan Vugenfirer, Yuri Benditovich,
	Akihiko Odaki

pci_add_capability appears most PCI devices. Its error handling required
lots of code, and led to inconsistent behaviors such as:
- passing error_abort
- passing error_fatal
- asserting the returned value
- propagating the error to the caller
- skipping the rest of the function
- just ignoring

The code generating errors in pci_add_capability had a comment which
says:
> Verify that capabilities don't overlap.  Note: device assignment
> depends on this check to verify that the device is not broken.
> Should never trigger for emulated devices, but it's helpful for
> debugging these.

Indeed vfio has some code that passes capability offsets and sizes from
a physical device, but it explicitly pays attention so that the
capabilities never overlap. Therefore, we can always assert that
capabilities never overlap when pci_add_capability is called, resolving
these inconsistencies.

v3:
- Correct patch split between virtio-pci and pci (Markus Armbruster)
- Add messages for individual patches (Markus Armbruster)
- Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

v2: Split the patch (Markus Armbruster)

Akihiko Odaki (16):
  pci: Allow to omit errp for pci_add_capability
  hw/i386/amd_iommu: Omit errp for pci_add_capability
  ahci: Omit errp for pci_add_capability
  e1000e: Omit errp for pci_add_capability
  eepro100: Omit errp for pci_add_capability
  hw/nvme: Omit errp for pci_add_capability
  msi: Omit errp for pci_add_capability
  hw/pci/pci_bridge: Omit errp for pci_add_capability
  pcie: Omit errp for pci_add_capability
  pci/shpc: Omit errp for pci_add_capability
  msix: Omit errp for pci_add_capability
  pci/slotid: Omit errp for pci_add_capability
  hw/pci-bridge/pcie_pci_bridge: Omit errp for pci_add_capability
  hw/vfio/pci: Omit errp for pci_add_capability
  virtio-pci: Omit errp for pci_add_capability
  pci: Remove legacy errp from pci_add_capability

 docs/pcie_sriov.txt                |  4 +--
 hw/display/bochs-display.c         |  4 +--
 hw/i386/amd_iommu.c                | 21 +++---------
 hw/ide/ich.c                       |  8 ++---
 hw/net/e1000e.c                    | 22 +++----------
 hw/net/eepro100.c                  |  7 +---
 hw/nvme/ctrl.c                     | 14 ++------
 hw/pci-bridge/cxl_downstream.c     |  9 ++----
 hw/pci-bridge/cxl_upstream.c       |  8 ++---
 hw/pci-bridge/i82801b11.c          | 14 ++------
 hw/pci-bridge/pci_bridge_dev.c     |  2 +-
 hw/pci-bridge/pcie_pci_bridge.c    | 19 +++--------
 hw/pci-bridge/pcie_root_port.c     | 16 ++-------
 hw/pci-bridge/xio3130_downstream.c | 15 ++-------
 hw/pci-bridge/xio3130_upstream.c   | 15 ++-------
 hw/pci-host/designware.c           |  3 +-
 hw/pci-host/xilinx-pcie.c          |  4 +--
 hw/pci/msi.c                       |  9 +-----
 hw/pci/msix.c                      |  8 ++---
 hw/pci/pci.c                       | 29 ++++-------------
 hw/pci/pci_bridge.c                | 21 ++++--------
 hw/pci/pcie.c                      | 52 ++++++++----------------------
 hw/pci/shpc.c                      | 23 ++++---------
 hw/pci/slotid_cap.c                |  8 ++---
 hw/usb/hcd-xhci-pci.c              |  3 +-
 hw/vfio/pci-quirks.c               | 15 ++-------
 hw/vfio/pci.c                      | 14 +++-----
 hw/virtio/virtio-pci.c             | 12 ++-----
 include/hw/pci/pci.h               |  5 ++-
 include/hw/pci/pci_bridge.h        |  5 ++-
 include/hw/pci/pcie.h              | 11 +++----
 include/hw/pci/shpc.h              |  3 +-
 include/hw/virtio/virtio-pci.h     |  2 +-
 33 files changed, 99 insertions(+), 306 deletions(-)

-- 
2.37.3



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

end of thread, other threads:[~2022-10-27  5:53 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-26 20:15 [PATCH v3 00/16] pci: Abort if pci_add_capability fails Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 01/16] pci: Allow to omit errp for pci_add_capability Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 02/16] hw/i386/amd_iommu: Omit " Akihiko Odaki
2022-10-27  5:43   ` Markus Armbruster
2022-10-26 20:15 ` [PATCH v3 03/16] ahci: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 04/16] e1000e: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 05/16] eepro100: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 06/16] hw/nvme: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 07/16] msi: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 08/16] hw/pci/pci_bridge: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 09/16] pcie: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 10/16] pci/shpc: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 11/16] msix: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 12/16] pci/slotid: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 13/16] hw/pci-bridge/pcie_pci_bridge: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 14/16] hw/vfio/pci: " Akihiko Odaki
2022-10-26 22:10   ` Alex Williamson
2022-10-26 20:15 ` [PATCH v3 15/16] virtio-pci: " Akihiko Odaki
2022-10-26 20:15 ` [PATCH v3 16/16] pci: Remove legacy errp from pci_add_capability Akihiko Odaki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).