|
|
26ba25 |
From 4084168a694381238dadf1f5c0cc4af756ac883f Mon Sep 17 00:00:00 2001
|
|
|
26ba25 |
From: Peter Xu <peterx@redhat.com>
|
|
|
26ba25 |
Date: Thu, 8 Nov 2018 06:29:37 +0000
|
|
|
26ba25 |
Subject: [PATCH 09/35] intel_iommu: move ce fetching out when sync shadow
|
|
|
26ba25 |
|
|
|
26ba25 |
RH-Author: Peter Xu <peterx@redhat.com>
|
|
|
26ba25 |
Message-id: <20181108062938.21143-7-peterx@redhat.com>
|
|
|
26ba25 |
Patchwork-id: 82965
|
|
|
26ba25 |
O-Subject: [RHEL-8 qemu-kvm PATCH 6/7] intel_iommu: move ce fetching out when sync shadow
|
|
|
26ba25 |
Bugzilla: 1625173
|
|
|
26ba25 |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
Bugzilla: 1629616
|
|
|
26ba25 |
|
|
|
26ba25 |
There are two callers for vtd_sync_shadow_page_table_range(): one
|
|
|
26ba25 |
provided a valid context entry and one not. Move that fetching
|
|
|
26ba25 |
operation into the caller vtd_sync_shadow_page_table() where we need to
|
|
|
26ba25 |
fetch the context entry.
|
|
|
26ba25 |
|
|
|
26ba25 |
Meanwhile, remove the error_report_once() directly since we're already
|
|
|
26ba25 |
tracing all the error cases in the previous call. Instead, return error
|
|
|
26ba25 |
number back to caller. This will not change anything functional since
|
|
|
26ba25 |
callers are dropping it after all.
|
|
|
26ba25 |
|
|
|
26ba25 |
We do this move majorly because we want to do something more later in
|
|
|
26ba25 |
vtd_sync_shadow_page_table().
|
|
|
26ba25 |
|
|
|
26ba25 |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
26ba25 |
Reviewed-by: Eric Auger <eric.auger@redhat.com>
|
|
|
26ba25 |
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
|
|
|
26ba25 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
26ba25 |
(cherry picked from commit 95ecd3df7815b4bc4f9a0f47e1c64d81434715aa)
|
|
|
26ba25 |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
26ba25 |
---
|
|
|
26ba25 |
hw/i386/intel_iommu.c | 41 +++++++++++++----------------------------
|
|
|
26ba25 |
1 file changed, 13 insertions(+), 28 deletions(-)
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
|
|
|
26ba25 |
index a6e87a9..c95128d 100644
|
|
|
26ba25 |
--- a/hw/i386/intel_iommu.c
|
|
|
26ba25 |
+++ b/hw/i386/intel_iommu.c
|
|
|
26ba25 |
@@ -1045,7 +1045,6 @@ static int vtd_sync_shadow_page_hook(IOMMUTLBEntry *entry,
|
|
|
26ba25 |
return 0;
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
-/* If context entry is NULL, we'll try to fetch it on our own. */
|
|
|
26ba25 |
static int vtd_sync_shadow_page_table_range(VTDAddressSpace *vtd_as,
|
|
|
26ba25 |
VTDContextEntry *ce,
|
|
|
26ba25 |
hwaddr addr, hwaddr size)
|
|
|
26ba25 |
@@ -1057,39 +1056,25 @@ static int vtd_sync_shadow_page_table_range(VTDAddressSpace *vtd_as,
|
|
|
26ba25 |
.notify_unmap = true,
|
|
|
26ba25 |
.aw = s->aw_bits,
|
|
|
26ba25 |
.as = vtd_as,
|
|
|
26ba25 |
+ .domain_id = VTD_CONTEXT_ENTRY_DID(ce->hi),
|
|
|
26ba25 |
};
|
|
|
26ba25 |
- VTDContextEntry ce_cache;
|
|
|
26ba25 |
- int ret;
|
|
|
26ba25 |
-
|
|
|
26ba25 |
- if (ce) {
|
|
|
26ba25 |
- /* If the caller provided context entry, use it */
|
|
|
26ba25 |
- ce_cache = *ce;
|
|
|
26ba25 |
- } else {
|
|
|
26ba25 |
- /* If the caller didn't provide ce, try to fetch */
|
|
|
26ba25 |
- ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),
|
|
|
26ba25 |
- vtd_as->devfn, &ce_cache);
|
|
|
26ba25 |
- if (ret) {
|
|
|
26ba25 |
- /*
|
|
|
26ba25 |
- * This should not really happen, but in case it happens,
|
|
|
26ba25 |
- * we just skip the sync for this time. After all we even
|
|
|
26ba25 |
- * don't have the root table pointer!
|
|
|
26ba25 |
- */
|
|
|
26ba25 |
- error_report_once("%s: invalid context entry for bus 0x%x"
|
|
|
26ba25 |
- " devfn 0x%x",
|
|
|
26ba25 |
- __func__, pci_bus_num(vtd_as->bus),
|
|
|
26ba25 |
- vtd_as->devfn);
|
|
|
26ba25 |
- return 0;
|
|
|
26ba25 |
- }
|
|
|
26ba25 |
- }
|
|
|
26ba25 |
|
|
|
26ba25 |
- info.domain_id = VTD_CONTEXT_ENTRY_DID(ce_cache.hi);
|
|
|
26ba25 |
-
|
|
|
26ba25 |
- return vtd_page_walk(&ce_cache, addr, addr + size, &info;;
|
|
|
26ba25 |
+ return vtd_page_walk(ce, addr, addr + size, &info;;
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
static int vtd_sync_shadow_page_table(VTDAddressSpace *vtd_as)
|
|
|
26ba25 |
{
|
|
|
26ba25 |
- return vtd_sync_shadow_page_table_range(vtd_as, NULL, 0, UINT64_MAX);
|
|
|
26ba25 |
+ int ret;
|
|
|
26ba25 |
+ VTDContextEntry ce;
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ ret = vtd_dev_to_context_entry(vtd_as->iommu_state,
|
|
|
26ba25 |
+ pci_bus_num(vtd_as->bus),
|
|
|
26ba25 |
+ vtd_as->devfn, &ce);
|
|
|
26ba25 |
+ if (ret) {
|
|
|
26ba25 |
+ return ret;
|
|
|
26ba25 |
+ }
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ return vtd_sync_shadow_page_table_range(vtd_as, &ce, 0, UINT64_MAX);
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
/*
|
|
|
26ba25 |
--
|
|
|
26ba25 |
1.8.3.1
|
|
|
26ba25 |
|