|
|
c687bc |
From f0fa537af2e1e5f827eeb74dc5b3e12776917a67 Mon Sep 17 00:00:00 2001
|
|
|
c687bc |
From: eperezma <eperezma@redhat.com>
|
|
|
c687bc |
Date: Tue, 12 Jan 2021 14:36:36 -0500
|
|
|
c687bc |
Subject: [PATCH 12/17] memory: Add IOMMU_NOTIFIER_DEVIOTLB_UNMAP
|
|
|
c687bc |
IOMMUTLBNotificationType
|
|
|
c687bc |
MIME-Version: 1.0
|
|
|
c687bc |
Content-Type: text/plain; charset=UTF-8
|
|
|
c687bc |
Content-Transfer-Encoding: 8bit
|
|
|
c687bc |
|
|
|
c687bc |
RH-Author: eperezma <eperezma@redhat.com>
|
|
|
c687bc |
Message-id: <20210112143638.374060-12-eperezma@redhat.com>
|
|
|
c687bc |
Patchwork-id: 100604
|
|
|
c687bc |
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 11/13] memory: Add IOMMU_NOTIFIER_DEVIOTLB_UNMAP IOMMUTLBNotificationType
|
|
|
c687bc |
Bugzilla: 1843852
|
|
|
c687bc |
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
|
|
c687bc |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
c687bc |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
c687bc |
|
|
|
c687bc |
This allows us to differentiate between regular IOMMU map/unmap events
|
|
|
c687bc |
and DEVIOTLB unmap. Doing so, notifiers that only need device IOTLB
|
|
|
c687bc |
invalidations will not receive regular IOMMU unmappings.
|
|
|
c687bc |
|
|
|
c687bc |
Adapt intel and vhost to use it.
|
|
|
c687bc |
|
|
|
c687bc |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
c687bc |
Reviewed-by: Peter Xu <peterx@redhat.com>
|
|
|
c687bc |
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
|
c687bc |
Acked-by: Jason Wang <jasowang@redhat.com>
|
|
|
c687bc |
Message-Id: <20201116165506.31315-4-eperezma@redhat.com>
|
|
|
c687bc |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
c687bc |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
c687bc |
(cherry picked from commit b68ba1ca57677acf870d5ab10579e6105c1f5338)
|
|
|
c687bc |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
c687bc |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
c687bc |
---
|
|
|
c687bc |
hw/i386/intel_iommu.c | 2 +-
|
|
|
c687bc |
hw/virtio/vhost.c | 2 +-
|
|
|
c687bc |
include/exec/memory.h | 7 ++++++-
|
|
|
c687bc |
3 files changed, 8 insertions(+), 3 deletions(-)
|
|
|
c687bc |
|
|
|
c687bc |
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
|
|
|
c687bc |
index 9fedbac82de..3640bc2ed15 100644
|
|
|
c687bc |
--- a/hw/i386/intel_iommu.c
|
|
|
c687bc |
+++ b/hw/i386/intel_iommu.c
|
|
|
c687bc |
@@ -2411,7 +2411,7 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s,
|
|
|
c687bc |
sz = VTD_PAGE_SIZE;
|
|
|
c687bc |
}
|
|
|
c687bc |
|
|
|
c687bc |
- event.type = IOMMU_NOTIFIER_UNMAP;
|
|
|
c687bc |
+ event.type = IOMMU_NOTIFIER_DEVIOTLB_UNMAP;
|
|
|
c687bc |
event.entry.target_as = &vtd_dev_as->as;
|
|
|
c687bc |
event.entry.addr_mask = sz - 1;
|
|
|
c687bc |
event.entry.iova = addr;
|
|
|
c687bc |
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
|
|
|
c687bc |
index 9182a00495e..78a5df3b379 100644
|
|
|
c687bc |
--- a/hw/virtio/vhost.c
|
|
|
c687bc |
+++ b/hw/virtio/vhost.c
|
|
|
c687bc |
@@ -704,7 +704,7 @@ static void vhost_iommu_region_add(MemoryListener *listener,
|
|
|
c687bc |
iommu_idx = memory_region_iommu_attrs_to_index(iommu_mr,
|
|
|
c687bc |
MEMTXATTRS_UNSPECIFIED);
|
|
|
c687bc |
iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify,
|
|
|
c687bc |
- IOMMU_NOTIFIER_UNMAP,
|
|
|
c687bc |
+ IOMMU_NOTIFIER_DEVIOTLB_UNMAP,
|
|
|
c687bc |
section->offset_within_region,
|
|
|
c687bc |
int128_get64(end),
|
|
|
c687bc |
iommu_idx);
|
|
|
c687bc |
diff --git a/include/exec/memory.h b/include/exec/memory.h
|
|
|
c687bc |
index 80e36077cdb..403dc0c0572 100644
|
|
|
c687bc |
--- a/include/exec/memory.h
|
|
|
c687bc |
+++ b/include/exec/memory.h
|
|
|
c687bc |
@@ -87,9 +87,14 @@ typedef enum {
|
|
|
c687bc |
IOMMU_NOTIFIER_UNMAP = 0x1,
|
|
|
c687bc |
/* Notify entry changes (newly created entries) */
|
|
|
c687bc |
IOMMU_NOTIFIER_MAP = 0x2,
|
|
|
c687bc |
+ /* Notify changes on device IOTLB entries */
|
|
|
c687bc |
+ IOMMU_NOTIFIER_DEVIOTLB_UNMAP = 0x04,
|
|
|
c687bc |
} IOMMUNotifierFlag;
|
|
|
c687bc |
|
|
|
c687bc |
-#define IOMMU_NOTIFIER_ALL (IOMMU_NOTIFIER_MAP | IOMMU_NOTIFIER_UNMAP)
|
|
|
c687bc |
+#define IOMMU_NOTIFIER_IOTLB_EVENTS (IOMMU_NOTIFIER_MAP | IOMMU_NOTIFIER_UNMAP)
|
|
|
c687bc |
+#define IOMMU_NOTIFIER_DEVIOTLB_EVENTS IOMMU_NOTIFIER_DEVIOTLB_UNMAP
|
|
|
c687bc |
+#define IOMMU_NOTIFIER_ALL (IOMMU_NOTIFIER_IOTLB_EVENTS | \
|
|
|
c687bc |
+ IOMMU_NOTIFIER_DEVIOTLB_EVENTS)
|
|
|
c687bc |
|
|
|
c687bc |
struct IOMMUNotifier;
|
|
|
c687bc |
typedef void (*IOMMUNotify)(struct IOMMUNotifier *notifier,
|
|
|
c687bc |
--
|
|
|
c687bc |
2.27.0
|
|
|
c687bc |
|