[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v4 26/83] hw/virtio/virtio-iommu-pci: Enforce the device is plugge
From: |
Michael S. Tsirkin |
Subject: |
[PULL v4 26/83] hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus |
Date: |
Mon, 7 Nov 2022 17:49:43 -0500 |
From: Eric Auger <eric.auger@redhat.com>
In theory the virtio-iommu-pci could be plugged anywhere in the PCIe
topology and as long as the dt/acpi info are properly built this should
work. However at the moment we fail to do that because the
virtio-iommu-pci BDF is not computed at plug time and in that case
vms->virtio_iommu_bdf gets an incorrect value.
For instance if the virtio-iommu-pci is plugged onto a pcie root port
and the virtio-iommu protects a virtio-block-pci device the guest does
not boot.
So let's do not pretend we do support this case and fail the initialize()
if we detect the virtio-iommu-pci is plugged anywhere else than on the
root bus. Anyway this ability is not needed.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Message-Id: <20221012163448.121368-1-eric.auger@redhat.com>
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio-iommu-pci.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
index 79ea8334f0..7ef2f9dcdb 100644
--- a/hw/virtio/virtio-iommu-pci.c
+++ b/hw/virtio/virtio-iommu-pci.c
@@ -17,6 +17,7 @@
#include "hw/qdev-properties-system.h"
#include "qapi/error.h"
#include "hw/boards.h"
+#include "hw/pci/pci_bus.h"
#include "qom/object.h"
typedef struct VirtIOIOMMUPCI VirtIOIOMMUPCI;
@@ -44,6 +45,7 @@ static Property virtio_iommu_pci_properties[] = {
static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
{
VirtIOIOMMUPCI *dev = VIRTIO_IOMMU_PCI(vpci_dev);
+ PCIBus *pbus = pci_get_bus(&vpci_dev->pci_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
VirtIOIOMMU *s = VIRTIO_IOMMU(vdev);
@@ -57,11 +59,17 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy
*vpci_dev, Error **errp)
s->reserved_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_MSI) {
error_setg(errp, "reserved region %d has an invalid type", i);
error_append_hint(errp, "Valid values are 0 and 1\n");
+ return;
}
}
+ if (!pci_bus_is_root(pbus)) {
+ error_setg(errp, "virtio-iommu-pci must be plugged on the root bus");
+ return;
+ }
+
object_property_set_link(OBJECT(dev), "primary-bus",
- OBJECT(pci_get_bus(&vpci_dev->pci_dev)),
- &error_abort);
+ OBJECT(pbus), &error_abort);
+
virtio_pci_force_virtio_1(vpci_dev);
qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
}
--
MST
- [PULL v4 15/83] acpi/tests/avocado/bits/doc: add a doc file to describe the acpi bits test, (continued)
- [PULL v4 15/83] acpi/tests/avocado/bits/doc: add a doc file to describe the acpi bits test, Michael S. Tsirkin, 2022/11/07
- [PULL v4 17/83] tests/acpi: virt: allow acpi MADT and FADT changes, Michael S. Tsirkin, 2022/11/07
- [PULL v4 18/83] acpi: fadt: support revision 6.0 of the ACPI specification, Michael S. Tsirkin, 2022/11/07
- [PULL v4 19/83] acpi: arm/virt: madt: bump to revision 4 accordingly to ACPI 6.0 Errata A, Michael S. Tsirkin, 2022/11/07
- [PULL v4 20/83] tests/acpi: virt: update ACPI MADT and FADT binaries, Michael S. Tsirkin, 2022/11/07
- [PULL v4 21/83] hw/pci: PCIe Data Object Exchange emulation, Michael S. Tsirkin, 2022/11/07
- [PULL v4 22/83] hw/mem/cxl-type3: Add MSIX support, Michael S. Tsirkin, 2022/11/07
- [PULL v4 23/83] hw/cxl/cdat: CXL CDAT Data Object Exchange implementation, Michael S. Tsirkin, 2022/11/07
- [PULL v4 24/83] hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange, Michael S. Tsirkin, 2022/11/07
- [PULL v4 25/83] hw/pci-bridge/cxl-upstream: Add a CDAT table access DOE, Michael S. Tsirkin, 2022/11/07
- [PULL v4 26/83] hw/virtio/virtio-iommu-pci: Enforce the device is plugged on the root bus,
Michael S. Tsirkin <=
- [PULL v4 27/83] virtio: introduce __virtio_queue_reset(), Michael S. Tsirkin, 2022/11/07
- [PULL v4 28/83] virtio: introduce virtio_queue_reset(), Michael S. Tsirkin, 2022/11/07
- [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Michael S. Tsirkin, 2022/11/07
- Re: [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Stefan Hajnoczi, 2022/11/08
- Re: [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Jason Wang, 2022/11/08
- Re: [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Michael S. Tsirkin, 2022/11/09
- Re: [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Xuan Zhuo, 2022/11/09
- Re: [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Michael S. Tsirkin, 2022/11/09
- Re: [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Xuan Zhuo, 2022/11/09
- Re: [PULL v4 29/83] virtio: introduce virtio_queue_enable(), Michael S. Tsirkin, 2022/11/09