[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/35] virtio-bus: introduce iommu_enabled()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 13/35] virtio-bus: introduce iommu_enabled() |
Date: |
Sat, 4 Sep 2021 17:36:34 -0400 |
From: Jason Wang <jasowang@redhat.com>
This patch introduce a new method for the virtio-bus for the transport
to report whether or not the IOMMU is enabled for the device.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20210804034803.1644-2-jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio-bus.h | 4 +++-
hw/virtio/virtio-bus.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
index ef8abe49c5..7ab8c9dab0 100644
--- a/include/hw/virtio/virtio-bus.h
+++ b/include/hw/virtio/virtio-bus.h
@@ -93,6 +93,7 @@ struct VirtioBusClass {
*/
bool has_variable_vring_alignment;
AddressSpace *(*get_dma_as)(DeviceState *d);
+ bool (*iommu_enabled)(DeviceState *d);
};
struct VirtioBusState {
@@ -154,5 +155,6 @@ void virtio_bus_release_ioeventfd(VirtioBusState *bus);
int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign);
/* Tell the bus that the ioeventfd handler is no longer required. */
void virtio_bus_cleanup_host_notifier(VirtioBusState *bus, int n);
-
+/* Whether the IOMMU is enabled for this device */
+bool virtio_bus_device_iommu_enabled(VirtIODevice *vdev);
#endif /* VIRTIO_BUS_H */
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index 859978d248..d23db98c56 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -325,6 +325,20 @@ static char *virtio_bus_get_fw_dev_path(DeviceState *dev)
return NULL;
}
+bool virtio_bus_device_iommu_enabled(VirtIODevice *vdev)
+{
+ DeviceState *qdev = DEVICE(vdev);
+ BusState *qbus = BUS(qdev_get_parent_bus(qdev));
+ VirtioBusState *bus = VIRTIO_BUS(qbus);
+ VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
+
+ if (!klass->iommu_enabled) {
+ return false;
+ }
+
+ return klass->iommu_enabled(qbus->parent);
+}
+
static void virtio_bus_class_init(ObjectClass *klass, void *data)
{
BusClass *bus_class = BUS_CLASS(klass);
--
MST
- Re: [PULL 06/35] hw/acpi: refactor acpi hp modules so that targets can just use what they need, (continued)
- Re: [PULL 06/35] hw/acpi: refactor acpi hp modules so that targets can just use what they need, Ani Sinha, 2021/09/06
- Re: [PULL 06/35] hw/acpi: refactor acpi hp modules so that targets can just use what they need, Ani Sinha, 2021/09/07
- Re: [PULL 06/35] hw/acpi: refactor acpi hp modules so that targets can just use what they need, Philippe Mathieu-Daudé, 2021/09/07
- Re: [PULL 06/35] hw/acpi: refactor acpi hp modules so that targets can just use what they need, Ani Sinha, 2021/09/07
- Re: [PULL 06/35] hw/acpi: refactor acpi hp modules so that targets can just use what they need, Ani Sinha, 2021/09/07
[PULL 07/35] hw/virtio: move vhost_set_backend_type() to vhost.c, Michael S. Tsirkin, 2021/09/04
[PULL 09/35] acpi: Delete broken ACPI_GED_X86 macro, Michael S. Tsirkin, 2021/09/04
[PULL 10/35] Use PCI_HOST_BRIDGE macro, Michael S. Tsirkin, 2021/09/04
[PULL 11/35] virtio-balloon: don't start free page hinting if postcopy is possible, Michael S. Tsirkin, 2021/09/04
[PULL 12/35] virtio-balloon: free page hinting cleanups, Michael S. Tsirkin, 2021/09/04
[PULL 13/35] virtio-bus: introduce iommu_enabled(),
Michael S. Tsirkin <=
[PULL 14/35] virtio-pci: implement iommu_enabled(), Michael S. Tsirkin, 2021/09/04
[PULL 16/35] hw/i386/acpi-build: Get NUMA information from struct NumaState, Michael S. Tsirkin, 2021/09/04
[PULL 17/35] hw/pci: remove all references to find_i440fx function, Michael S. Tsirkin, 2021/09/04
[PULL 20/35] hw/virtio: Document virtio_queue_packed_empty_rcu is called within RCU, Michael S. Tsirkin, 2021/09/04
[PULL 21/35] hw/virtio: Remove NULL check in virtio_free_region_cache(), Michael S. Tsirkin, 2021/09/04
[PULL 19/35] MAINTAINERS: Added myself as a reviewer for acpi/smbios subsystem, Michael S. Tsirkin, 2021/09/04
[PULL 18/35] hw/acpi: use existing references to pci device struct within functions, Michael S. Tsirkin, 2021/09/04
[PULL 22/35] hw/virtio: Add flatview update in vhost_user_cleanup(), Michael S. Tsirkin, 2021/09/04
[PULL 23/35] tests/vhost-user-bridge.c: Sanity check socket path length, Michael S. Tsirkin, 2021/09/04
[PULL 24/35] tests/vhost-user-bridge.c: Fix typo in help message, Michael S. Tsirkin, 2021/09/04