diff options
author | Eugenio Pérez <eperezma@redhat.com> | 2020-11-16 17:55:03 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2020-12-08 13:48:57 -0500 |
commit | 5039caf3c449c49e625d34e134463260cf8e00e0 (patch) | |
tree | 54734bddbe00a28bd9582228ff0ab9e893267d9a /hw/virtio | |
parent | 3b5ebf8532afdc1518bd8b0961ed802bc3f5f07c (diff) |
memory: Add IOMMUTLBEvent
This way we can tell between regular IOMMUTLBEntry (entry of IOMMU
hardware) and notifications.
In the notifications, we set explicitly if it is a MAPs or an UNMAP,
instead of trusting in entry permissions to differentiate them.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20201116165506.31315-3-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/virtio')
-rw-r--r-- | hw/virtio/virtio-iommu.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index fc5c75d693..cea8811295 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -129,7 +129,7 @@ static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start, hwaddr virt_end, hwaddr paddr, uint32_t flags) { - IOMMUTLBEntry entry; + IOMMUTLBEvent event; IOMMUAccessFlags perm = IOMMU_ACCESS_FLAG(flags & VIRTIO_IOMMU_MAP_F_READ, flags & VIRTIO_IOMMU_MAP_F_WRITE); @@ -141,19 +141,20 @@ static void virtio_iommu_notify_map(IOMMUMemoryRegion *mr, hwaddr virt_start, trace_virtio_iommu_notify_map(mr->parent_obj.name, virt_start, virt_end, paddr, perm); - entry.target_as = &address_space_memory; - entry.addr_mask = virt_end - virt_start; - entry.iova = virt_start; - entry.perm = perm; - entry.translated_addr = paddr; + event.type = IOMMU_NOTIFIER_MAP; + event.entry.target_as = &address_space_memory; + event.entry.addr_mask = virt_end - virt_start; + event.entry.iova = virt_start; + event.entry.perm = perm; + event.entry.translated_addr = paddr; - memory_region_notify_iommu(mr, 0, entry); + memory_region_notify_iommu(mr, 0, event); } static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, hwaddr virt_end) { - IOMMUTLBEntry entry; + IOMMUTLBEvent event; if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) { return; @@ -161,13 +162,14 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, trace_virtio_iommu_notify_unmap(mr->parent_obj.name, virt_start, virt_end); - entry.target_as = &address_space_memory; - entry.addr_mask = virt_end - virt_start; - entry.iova = virt_start; - entry.perm = IOMMU_NONE; - entry.translated_addr = 0; + event.type = IOMMU_NOTIFIER_UNMAP; + event.entry.target_as = &address_space_memory; + event.entry.addr_mask = virt_end - virt_start; + event.entry.iova = virt_start; + event.entry.perm = IOMMU_NONE; + event.entry.translated_addr = 0; - memory_region_notify_iommu(mr, 0, entry); + memory_region_notify_iommu(mr, 0, event); } static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value, |