[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [RFC v2 20/28] hw/vfio/common: Register MAP notifier for MSI
From: |
Eric Auger |
Subject: |
[Qemu-arm] [RFC v2 20/28] hw/vfio/common: Register MAP notifier for MSI binding |
Date: |
Fri, 21 Sep 2018 10:18:11 +0200 |
Register a MAP notifier to propage MSI stage 1 bindings to
the host. When the notifier gets called, we pass the guest
stage 1 MSI binding to the host. The host can then build
a S2 binding whose entry is the guest MSI doorbell GPA.
Signed-off-by: Eric Auger <address@hidden>
---
hw/vfio/common.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 77bdb76ade..172ddd396f 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -408,6 +408,26 @@ static void vfio_iommu_unmap_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
}
}
+static void vfio_iommu_msi_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
+{
+ VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
+ VFIOContainer *container = giommu->container;
+ struct vfio_iommu_type1_bind_guest_msi ustruct;
+ int ret;
+
+ ustruct.argsz = sizeof(struct vfio_iommu_type1_bind_guest_msi);
+ ustruct.flags = 0;
+ ustruct.binding.iova = iotlb->iova;
+ ustruct.binding.gpa = iotlb->translated_addr;
+ ustruct.binding.granule = ctz64(~iotlb->addr_mask);
+
+ ret = ioctl(container->fd, VFIO_IOMMU_BIND_MSI , &ustruct);
+ if (ret) {
+ error_report("%s: failed to pass MSI binding (%d)",
+ __func__, ret);
+ }
+}
+
static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
{
VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n);
@@ -743,6 +763,15 @@ static void vfio_listener_region_add(MemoryListener
*listener,
iommu_idx);
QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
memory_region_register_iommu_notifier(section->mr, &giommu->n);
+
+ giommu = vfio_alloc_guest_iommu(container, iommu_mr, offset);
+ iommu_iotlb_notifier_init(&giommu->n, vfio_iommu_msi_map_notify,
+ IOMMU_NOTIFIER_MAP,
+ section->offset_within_region,
+ int128_get64(llend),
+ iommu_idx);
+ QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
+ memory_region_register_iommu_notifier(section->mr, &giommu->n);
} else {
/* MAP/UNMAP IOTLB notifier */
giommu = vfio_alloc_guest_iommu(container, iommu_mr, offset);
--
2.17.1
- [Qemu-arm] [RFC v2 13/28] hw/arm/smmuv3: Store s1ctrptr in translation config data, (continued)
- [Qemu-arm] [RFC v2 13/28] hw/arm/smmuv3: Store s1ctrptr in translation config data, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 12/28] memory: Add arch_id in IOTLBEntry, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 14/28] hw/arm/smmuv3: Implement dummy replay, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 16/28] hw/arm/smmuv3: Fill the IOTLBEntry arch_id on NH_VA invalidation, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 15/28] hw/arm/smmuv3: Notify on config changes, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 17/28] hw/vfio/common: Introduce vfio_alloc_guest_iommu helper, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 18/28] hw/vfio/common: Introduce vfio_dma_(un)map_ram_section helpers, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 19/28] hw/vfio/common: Register specific nested mode notifiers and memory_listener, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 22/28] vfio/pci: Always set up MSI route before enabling vectors, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 21/28] target/arm/kvm: Notifies IOMMU on MSI stage 1 binding, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 20/28] hw/vfio/common: Register MAP notifier for MSI binding,
Eric Auger <=
- [Qemu-arm] [RFC v2 24/28] memory: Introduce IOMMU_NOTIFIER_INIT_CFG IOMMU Config Notifier, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 23/28] hw/arm/smmuv3: Remove warning about unsupported MAP notifiers, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 25/28] memory: Introduce IOMMU Memory Region inject_faults API, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 26/28] hw/vfio/common: Handle fault_handler, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 27/28] hw/arm/smmuv3: Init fault handling, Eric Auger, 2018/09/21
- [Qemu-arm] [RFC v2 28/28] hw/arm/smmuv3: Implement fault injection, Eric Auger, 2018/09/21