|
|
383d26 |
From fd9f21135b1317ddfdf70d5d749e9c2ef51e4c22 Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Peter Xu <peterx@redhat.com>
|
|
|
383d26 |
Date: Mon, 3 Sep 2018 04:52:34 +0200
|
|
|
383d26 |
Subject: [PATCH 19/29] intel-iommu: remove IntelIOMMUNotifierNode
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Peter Xu <peterx@redhat.com>
|
|
|
383d26 |
Message-id: <20180903045241.6456-3-peterx@redhat.com>
|
|
|
383d26 |
Patchwork-id: 82023
|
|
|
383d26 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 2/9] intel-iommu: remove IntelIOMMUNotifierNode
|
|
|
383d26 |
Bugzilla: 1623859
|
|
|
383d26 |
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
That is not really necessary. Removing that node struct and put the
|
|
|
383d26 |
list entry directly into VTDAddressSpace. It simplfies the code a lot.
|
|
|
383d26 |
Since at it, rename the old notifiers_list into vtd_as_with_notifiers.
|
|
|
383d26 |
|
|
|
383d26 |
CC: QEMU Stable <qemu-stable@nongnu.org>
|
|
|
383d26 |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
383d26 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
383d26 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
383d26 |
(cherry picked from commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef)
|
|
|
383d26 |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
hw/i386/intel_iommu.c | 41 +++++++++++------------------------------
|
|
|
383d26 |
include/hw/i386/intel_iommu.h | 9 ++-------
|
|
|
383d26 |
2 files changed, 13 insertions(+), 37 deletions(-)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
|
|
|
383d26 |
index b359efd..3df9045 100644
|
|
|
383d26 |
--- a/hw/i386/intel_iommu.c
|
|
|
383d26 |
+++ b/hw/i386/intel_iommu.c
|
|
|
383d26 |
@@ -1248,10 +1248,10 @@ static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s)
|
|
|
383d26 |
|
|
|
383d26 |
static void vtd_iommu_replay_all(IntelIOMMUState *s)
|
|
|
383d26 |
{
|
|
|
383d26 |
- IntelIOMMUNotifierNode *node;
|
|
|
383d26 |
+ VTDAddressSpace *vtd_as;
|
|
|
383d26 |
|
|
|
383d26 |
- QLIST_FOREACH(node, &s->notifiers_list, next) {
|
|
|
383d26 |
- memory_region_iommu_replay_all(&node->vtd_as->iommu);
|
|
|
383d26 |
+ QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) {
|
|
|
383d26 |
+ memory_region_iommu_replay_all(&vtd_as->iommu);
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
@@ -1372,7 +1372,6 @@ static void vtd_iotlb_global_invalidate(IntelIOMMUState *s)
|
|
|
383d26 |
|
|
|
383d26 |
static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)
|
|
|
383d26 |
{
|
|
|
383d26 |
- IntelIOMMUNotifierNode *node;
|
|
|
383d26 |
VTDContextEntry ce;
|
|
|
383d26 |
VTDAddressSpace *vtd_as;
|
|
|
383d26 |
|
|
|
383d26 |
@@ -1381,8 +1380,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id)
|
|
|
383d26 |
g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_domain,
|
|
|
383d26 |
&domain_id);
|
|
|
383d26 |
|
|
|
383d26 |
- QLIST_FOREACH(node, &s->notifiers_list, next) {
|
|
|
383d26 |
- vtd_as = node->vtd_as;
|
|
|
383d26 |
+ QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) {
|
|
|
383d26 |
if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),
|
|
|
383d26 |
vtd_as->devfn, &ce) &&
|
|
|
383d26 |
domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) {
|
|
|
383d26 |
@@ -1402,12 +1400,11 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s,
|
|
|
383d26 |
uint16_t domain_id, hwaddr addr,
|
|
|
383d26 |
uint8_t am)
|
|
|
383d26 |
{
|
|
|
383d26 |
- IntelIOMMUNotifierNode *node;
|
|
|
383d26 |
+ VTDAddressSpace *vtd_as;
|
|
|
383d26 |
VTDContextEntry ce;
|
|
|
383d26 |
int ret;
|
|
|
383d26 |
|
|
|
383d26 |
- QLIST_FOREACH(node, &(s->notifiers_list), next) {
|
|
|
383d26 |
- VTDAddressSpace *vtd_as = node->vtd_as;
|
|
|
383d26 |
+ QLIST_FOREACH(vtd_as, &(s->vtd_as_with_notifiers), next) {
|
|
|
383d26 |
ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),
|
|
|
383d26 |
vtd_as->devfn, &ce);
|
|
|
383d26 |
if (!ret && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) {
|
|
|
383d26 |
@@ -2344,8 +2341,6 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
|
|
383d26 |
{
|
|
|
383d26 |
VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
|
|
|
383d26 |
IntelIOMMUState *s = vtd_as->iommu_state;
|
|
|
383d26 |
- IntelIOMMUNotifierNode *node = NULL;
|
|
|
383d26 |
- IntelIOMMUNotifierNode *next_node = NULL;
|
|
|
383d26 |
|
|
|
383d26 |
if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) {
|
|
|
383d26 |
error_report("We need to set caching-mode=1 for intel-iommu to enable "
|
|
|
383d26 |
@@ -2354,21 +2349,9 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
if (old == IOMMU_NOTIFIER_NONE) {
|
|
|
383d26 |
- node = g_malloc0(sizeof(*node));
|
|
|
383d26 |
- node->vtd_as = vtd_as;
|
|
|
383d26 |
- QLIST_INSERT_HEAD(&s->notifiers_list, node, next);
|
|
|
383d26 |
- return;
|
|
|
383d26 |
- }
|
|
|
383d26 |
-
|
|
|
383d26 |
- /* update notifier node with new flags */
|
|
|
383d26 |
- QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {
|
|
|
383d26 |
- if (node->vtd_as == vtd_as) {
|
|
|
383d26 |
- if (new == IOMMU_NOTIFIER_NONE) {
|
|
|
383d26 |
- QLIST_REMOVE(node, next);
|
|
|
383d26 |
- g_free(node);
|
|
|
383d26 |
- }
|
|
|
383d26 |
- return;
|
|
|
383d26 |
- }
|
|
|
383d26 |
+ QLIST_INSERT_HEAD(&s->vtd_as_with_notifiers, vtd_as, next);
|
|
|
383d26 |
+ } else if (new == IOMMU_NOTIFIER_NONE) {
|
|
|
383d26 |
+ QLIST_REMOVE(vtd_as, next);
|
|
|
383d26 |
}
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
@@ -2838,12 +2821,10 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
|
|
|
383d26 |
|
|
|
383d26 |
static void vtd_address_space_unmap_all(IntelIOMMUState *s)
|
|
|
383d26 |
{
|
|
|
383d26 |
- IntelIOMMUNotifierNode *node;
|
|
|
383d26 |
VTDAddressSpace *vtd_as;
|
|
|
383d26 |
IOMMUNotifier *n;
|
|
|
383d26 |
|
|
|
383d26 |
- QLIST_FOREACH(node, &s->notifiers_list, next) {
|
|
|
383d26 |
- vtd_as = node->vtd_as;
|
|
|
383d26 |
+ QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) {
|
|
|
383d26 |
IOMMU_NOTIFIER_FOREACH(n, &vtd_as->iommu) {
|
|
|
383d26 |
vtd_address_space_unmap(vtd_as, n);
|
|
|
383d26 |
}
|
|
|
383d26 |
@@ -3088,7 +3069,7 @@ static void vtd_realize(DeviceState *dev, Error **errp)
|
|
|
383d26 |
return;
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
- QLIST_INIT(&s->notifiers_list);
|
|
|
383d26 |
+ QLIST_INIT(&s->vtd_as_with_notifiers);
|
|
|
383d26 |
memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));
|
|
|
383d26 |
memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,
|
|
|
383d26 |
"intel_iommu", DMAR_REG_SIZE);
|
|
|
383d26 |
diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h
|
|
|
383d26 |
index 45ec891..032e33b 100644
|
|
|
383d26 |
--- a/include/hw/i386/intel_iommu.h
|
|
|
383d26 |
+++ b/include/hw/i386/intel_iommu.h
|
|
|
383d26 |
@@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry;
|
|
|
383d26 |
typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress;
|
|
|
383d26 |
typedef struct VTDIrq VTDIrq;
|
|
|
383d26 |
typedef struct VTD_MSIMessage VTD_MSIMessage;
|
|
|
383d26 |
-typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode;
|
|
|
383d26 |
|
|
|
383d26 |
/* Context-Entry */
|
|
|
383d26 |
struct VTDContextEntry {
|
|
|
383d26 |
@@ -93,6 +92,7 @@ struct VTDAddressSpace {
|
|
|
383d26 |
MemoryRegion iommu_ir; /* Interrupt region: 0xfeeXXXXX */
|
|
|
383d26 |
IntelIOMMUState *iommu_state;
|
|
|
383d26 |
VTDContextCacheEntry context_cache_entry;
|
|
|
383d26 |
+ QLIST_ENTRY(VTDAddressSpace) next;
|
|
|
383d26 |
};
|
|
|
383d26 |
|
|
|
383d26 |
struct VTDBus {
|
|
|
383d26 |
@@ -253,11 +253,6 @@ struct VTD_MSIMessage {
|
|
|
383d26 |
/* When IR is enabled, all MSI/MSI-X data bits should be zero */
|
|
|
383d26 |
#define VTD_IR_MSI_DATA (0)
|
|
|
383d26 |
|
|
|
383d26 |
-struct IntelIOMMUNotifierNode {
|
|
|
383d26 |
- VTDAddressSpace *vtd_as;
|
|
|
383d26 |
- QLIST_ENTRY(IntelIOMMUNotifierNode) next;
|
|
|
383d26 |
-};
|
|
|
383d26 |
-
|
|
|
383d26 |
/* The iommu (DMAR) device state struct */
|
|
|
383d26 |
struct IntelIOMMUState {
|
|
|
383d26 |
X86IOMMUState x86_iommu;
|
|
|
383d26 |
@@ -295,7 +290,7 @@ struct IntelIOMMUState {
|
|
|
383d26 |
GHashTable *vtd_as_by_busptr; /* VTDBus objects indexed by PCIBus* reference */
|
|
|
383d26 |
VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */
|
|
|
383d26 |
/* list of registered notifiers */
|
|
|
383d26 |
- QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list;
|
|
|
383d26 |
+ QLIST_HEAD(, VTDAddressSpace) vtd_as_with_notifiers;
|
|
|
383d26 |
|
|
|
383d26 |
/* interrupt remapping */
|
|
|
383d26 |
bool intr_enabled; /* Whether guest enabled IR */
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|