[PATCH v2 0/5] pci/iommu: Fail early if vfio-pci detected before vIOMMU

Peter Xu posted 5 patches 2 years, 6 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20211028043129.38871-1-peterx@redhat.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Shannon Zhao <shannon.zhaosl@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Matthew Rosato <mjrosato@linux.ibm.com>, David Hildenbrand <david@redhat.com>, Anthony Perard <anthony.perard@citrix.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Ani Sinha <ani@anisinha.ca>, Paul Durrant <paul@xen.org>, Igor Mammedov <imammedo@redhat.com>, Greg Kurz <groug@kaod.org>, "Michael S. Tsirkin" <mst@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Eduardo Habkost <ehabkost@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Christian Borntraeger <borntraeger@de.ibm.com>, Thomas Huth <thuth@redhat.com>, Eric Farman <farman@linux.ibm.com>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, "Daniel P. Berrangé" <berrange@redhat.com>
hw/arm/virt-acpi-build.c    | 31 ++++++++--------------
hw/i386/acpi-build.c        | 39 +++++++---------------------
hw/i386/pc.c                |  4 +++
hw/i386/x86-iommu.c         | 14 ++++++++++
hw/pci/pci.c                | 52 +++++++++++++++++++++++++------------
hw/pci/pcie.c               |  4 +--
hw/ppc/spapr_pci.c          | 12 ++++-----
hw/ppc/spapr_pci_nvlink2.c  |  7 +++--
hw/ppc/spapr_pci_vfio.c     |  4 +--
hw/s390x/s390-pci-bus.c     |  5 ++--
hw/xen/xen_pt.c             |  4 +--
include/hw/i386/x86-iommu.h |  8 ++++++
include/hw/pci/pci.h        | 26 ++++++++++++-------
include/qom/object.h        | 20 ++++++++++++++
qom/object.c                | 27 +++++++++++++++++++
15 files changed, 160 insertions(+), 97 deletions(-)
[PATCH v2 0/5] pci/iommu: Fail early if vfio-pci detected before vIOMMU
Posted by Peter Xu 2 years, 6 months ago
Note that patch 1-4 are cleanups for pci subsystem, and patch 5 is a fix to
fail early for mis-ordered qemu cmdline on vfio and vIOMMU.  Logically they
should be posted separately and they're not directly related, however to make
it still correlated to v1 I kept them in the same patchset.

In this version I used pre_plug() hook for q35 to detect the ordering issue as
Igor suggested, meanwhile it's done via object_resolve_path_type() rather than
scanning the pci bus as Michael suggested.

Please review, thanks.

v2 changelog:
- Picked up r-b where I can
- Merged patch 1 & 4, 2 & 3, 5 & 6
- s/pci_root_bus_args/PCIRootBusArgs/ [David, Michael]
- Replace "void* " with "void *" in pci.h [Phil]
- Dropped "pci: Add pci_for_each_device_all()"
- Dropped "x86-iommu: Fail early if vIOMMU specified after vfio-pci"
- Added "qom: object_child_foreach_recursive_type()"
- Added "pc/q35: Add pre-plug hook for x86-iommu"

v1: https://lore.kernel.org/qemu-devel/20211021104259.57754-1-peterx@redhat.com/

Peter Xu (5):
  pci: Define pci_bus_dev_fn/pci_bus_fn/pci_bus_ret_fn
  pci: Export pci_for_each_device_under_bus*()
  qom: object_child_foreach_recursive_type()
  pci: Add pci_for_each_root_bus()
  pc/q35: Add pre-plug hook for x86-iommu

 hw/arm/virt-acpi-build.c    | 31 ++++++++--------------
 hw/i386/acpi-build.c        | 39 +++++++---------------------
 hw/i386/pc.c                |  4 +++
 hw/i386/x86-iommu.c         | 14 ++++++++++
 hw/pci/pci.c                | 52 +++++++++++++++++++++++++------------
 hw/pci/pcie.c               |  4 +--
 hw/ppc/spapr_pci.c          | 12 ++++-----
 hw/ppc/spapr_pci_nvlink2.c  |  7 +++--
 hw/ppc/spapr_pci_vfio.c     |  4 +--
 hw/s390x/s390-pci-bus.c     |  5 ++--
 hw/xen/xen_pt.c             |  4 +--
 include/hw/i386/x86-iommu.h |  8 ++++++
 include/hw/pci/pci.h        | 26 ++++++++++++-------
 include/qom/object.h        | 20 ++++++++++++++
 qom/object.c                | 27 +++++++++++++++++++
 15 files changed, 160 insertions(+), 97 deletions(-)

-- 
2.32.0


Re: [PATCH v2 0/5] pci/iommu: Fail early if vfio-pci detected before vIOMMU
Posted by Peter Xu 2 years, 6 months ago
On Thu, Oct 28, 2021 at 12:31:24PM +0800, Peter Xu wrote:
> Note that patch 1-4 are cleanups for pci subsystem, and patch 5 is a fix to
> fail early for mis-ordered qemu cmdline on vfio and vIOMMU.  Logically they
> should be posted separately and they're not directly related, however to make
> it still correlated to v1 I kept them in the same patchset.
> 
> In this version I used pre_plug() hook for q35 to detect the ordering issue as
> Igor suggested, meanwhile it's done via object_resolve_path_type() rather than
> scanning the pci bus as Michael suggested.
> 
> Please review, thanks.

Michael,

Would you consider review/pick patches 1-4 first?  The last patch needs further
discussion, and I would like to address it separately in the future.

Thanks,

-- 
Peter Xu


Re: [PATCH v2 0/5] pci/iommu: Fail early if vfio-pci detected before vIOMMU
Posted by Michael S. Tsirkin 2 years, 6 months ago
On Tue, Nov 02, 2021 at 09:15:59AM +0800, Peter Xu wrote:
> On Thu, Oct 28, 2021 at 12:31:24PM +0800, Peter Xu wrote:
> > Note that patch 1-4 are cleanups for pci subsystem, and patch 5 is a fix to
> > fail early for mis-ordered qemu cmdline on vfio and vIOMMU.  Logically they
> > should be posted separately and they're not directly related, however to make
> > it still correlated to v1 I kept them in the same patchset.
> > 
> > In this version I used pre_plug() hook for q35 to detect the ordering issue as
> > Igor suggested, meanwhile it's done via object_resolve_path_type() rather than
> > scanning the pci bus as Michael suggested.
> > 
> > Please review, thanks.
> 
> Michael,
> 
> Would you consider review/pick patches 1-4 first?  The last patch needs further
> discussion, and I would like to address it separately in the future.
> 
> Thanks,

I did just that yesterday.

> -- 
> Peter Xu